(OSX) More settings menu work (now supports all input bindings for player 1)
This commit is contained in:
parent
29b8a6f8e4
commit
253bb88bfc
|
@ -49,6 +49,40 @@ static uint32_t key_id_for_name(const char* name)
|
|||
#define key_name_for_rk(X) key_name_for_id(input_translate_rk_to_keysym(X))
|
||||
#define key_rk_for_name(X) input_translate_keysym_to_rk(key_id_for_name(X))
|
||||
|
||||
static const char* get_input_config_key(const rarch_setting_t* setting, const char* type)
|
||||
{
|
||||
static char buffer[32];
|
||||
snprintf(buffer, 32, "input_player%d_%s%c%s", setting->input_player, setting->name, type ? '_' : '\0', type);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
static const char* get_button_name(const rarch_setting_t* setting)
|
||||
{
|
||||
static char buffer[32];
|
||||
|
||||
if (BINDFOR(*setting).joykey == NO_BTN)
|
||||
return "nul";
|
||||
|
||||
snprintf(buffer, 32, "%lld", BINDFOR(*setting).joykey);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
static const char* get_axis_name(const rarch_setting_t* setting)
|
||||
{
|
||||
static char buffer[32];
|
||||
|
||||
uint32_t joyaxis = BINDFOR(*setting).joyaxis;
|
||||
|
||||
if (AXIS_NEG_GET(joyaxis) != AXIS_DIR_NONE)
|
||||
snprintf(buffer, 8, "-%d", AXIS_NEG_GET(joyaxis));
|
||||
else if (AXIS_POS_GET(joyaxis) != AXIS_DIR_NONE)
|
||||
snprintf(buffer, 8, "+%d", AXIS_POS_GET(joyaxis));
|
||||
else
|
||||
return "nul";
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
@interface RAInputBinder : NSWindow
|
||||
@end
|
||||
|
||||
|
@ -134,8 +168,9 @@ static uint32_t key_id_for_name(const char* name)
|
|||
// Input Binding
|
||||
- (void)updateInputString
|
||||
{
|
||||
self.stringValue = [NSString stringWithFormat:@"[KB:%s] [JS:%lld] [AX:nul]", key_name_for_rk(BINDFOR(*_setting).key),
|
||||
BINDFOR(*_setting).joykey];
|
||||
self.stringValue = [NSString stringWithFormat:@"[KB:%s] [JS:%s] [AX:%s]", key_name_for_rk(BINDFOR(*_setting).key),
|
||||
get_button_name(_setting),
|
||||
get_axis_name(_setting)];
|
||||
}
|
||||
|
||||
- (void)dismissBinder
|
||||
|
@ -174,6 +209,19 @@ static uint32_t key_id_for_name(const char* name)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Pad Axis
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
int16_t value = g_current_input_data.pad_axis[0][i];
|
||||
|
||||
if (abs(value) > 0x4000)
|
||||
{
|
||||
BINDFOR(*_setting).joyaxis = (value > 0x1000) ? AXIS_POS(i) : AXIS_NEG(i);
|
||||
[self dismissBinder];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (IBAction)doGetBind:(id)sender
|
||||
|
@ -214,10 +262,10 @@ static uint32_t key_id_for_name(const char* name)
|
|||
NSMutableArray* thisGroup = nil;
|
||||
NSMutableArray* thisSubGroup = nil;
|
||||
_settings = [NSMutableArray array];
|
||||
|
||||
|
||||
memcpy(&fake_settings, &g_settings, sizeof(struct settings));
|
||||
memcpy(&fake_extern, &g_extern, sizeof(struct global));
|
||||
|
||||
|
||||
for (int i = 0; setting_data[i].type; i ++)
|
||||
{
|
||||
switch (setting_data[i].type)
|
||||
|
@ -264,20 +312,24 @@ static uint32_t key_id_for_name(const char* name)
|
|||
- (void)load
|
||||
{
|
||||
config_file_t* conf = config_file_new([RetroArch_OSX get].configPath.UTF8String);
|
||||
|
||||
for (int i = 0; setting_data[i].type; i ++)
|
||||
{
|
||||
switch (setting_data[i].type)
|
||||
{
|
||||
case ST_BOOL: config_set_bool (conf, setting_data[i].name, * (bool*)setting_data[i].value); break;
|
||||
case ST_INT: config_set_int (conf, setting_data[i].name, * (int*)setting_data[i].value); break;
|
||||
case ST_FLOAT: config_set_float (conf, setting_data[i].name, *(float*)setting_data[i].value); break;
|
||||
case ST_PATH: config_set_string(conf, setting_data[i].name, (char*)setting_data[i].value); break;
|
||||
case ST_STRING: config_set_string(conf, setting_data[i].name, (char*)setting_data[i].value); break;
|
||||
case ST_BOOL: config_get_bool (conf, setting_data[i].name, (bool*)setting_data[i].value); break;
|
||||
case ST_INT: config_get_int (conf, setting_data[i].name, (int*)setting_data[i].value); break;
|
||||
case ST_FLOAT: config_get_float (conf, setting_data[i].name, (float*)setting_data[i].value); break;
|
||||
case ST_PATH: config_get_array (conf, setting_data[i].name, (char*)setting_data[i].value, setting_data[i].size); break;
|
||||
case ST_STRING: config_get_array (conf, setting_data[i].name, (char*)setting_data[i].value, setting_data[i].size); break;
|
||||
|
||||
case ST_BIND: input_config_parse_key(conf, "input_player1", input_config_bind_map[0].base, setting_data[i].value);
|
||||
input_config_parse_joy_button(conf, "input_player1", input_config_bind_map[0].base, setting_data[i].value);
|
||||
input_config_parse_joy_axis(conf, "input_player1", input_config_bind_map[0].base, setting_data[i].value);
|
||||
break;
|
||||
case ST_BIND:
|
||||
{
|
||||
input_config_parse_key (conf, "input_player1", setting_data[i].name, setting_data[i].value);
|
||||
input_config_parse_joy_button(conf, "input_player1", setting_data[i].name, setting_data[i].value);
|
||||
input_config_parse_joy_axis (conf, "input_player1", setting_data[i].name, setting_data[i].value);
|
||||
break;
|
||||
}
|
||||
|
||||
case ST_HEX: break;
|
||||
default: break;
|
||||
|
@ -288,7 +340,9 @@ static uint32_t key_id_for_name(const char* name)
|
|||
|
||||
- (void)windowWillClose:(NSNotification *)notification
|
||||
{
|
||||
config_file_t* conf = config_file_new(0);
|
||||
config_file_t* conf = config_file_new([RetroArch_OSX get].configPath.UTF8String);
|
||||
conf = conf ? conf : config_file_new(0);
|
||||
|
||||
for (int i = 0; setting_data[i].type; i ++)
|
||||
{
|
||||
switch (setting_data[i].type)
|
||||
|
@ -301,7 +355,9 @@ static uint32_t key_id_for_name(const char* name)
|
|||
|
||||
case ST_BIND:
|
||||
{
|
||||
config_set_string(conf, setting_data[i].name, key_name_for_rk(BINDFOR(setting_data[i]).key));
|
||||
config_set_string(conf, get_input_config_key(&setting_data[i], 0 ), key_name_for_rk(BINDFOR(setting_data[i]).key));
|
||||
config_set_string(conf, get_input_config_key(&setting_data[i], "btn" ), get_button_name(&setting_data[i]));
|
||||
config_set_string(conf, get_input_config_key(&setting_data[i], "axis"), get_axis_name(&setting_data[i]));
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -31,11 +31,9 @@ typedef struct
|
|||
uint32_t size;
|
||||
|
||||
const char* short_description;
|
||||
const char* long_description;
|
||||
|
||||
const char** values;
|
||||
|
||||
uint32_t input_player;
|
||||
|
||||
double min;
|
||||
double max;
|
||||
bool allow_blank;
|
||||
|
@ -52,13 +50,14 @@ extern struct global fake_extern;
|
|||
#define END_GROUP() { ST_END_GROUP },
|
||||
#define START_SUB_GROUP(NAME) { ST_SUB_GROUP, NAME },
|
||||
#define END_SUB_GROUP() { ST_END_SUB_GROUP },
|
||||
#define CONFIG_BOOL(TARGET, NAME, SHORT) { ST_BOOL, NAME, &TARGET, sizeof(TARGET), SHORT, 0, 0, 0, 0.0, 0.0, false },
|
||||
#define CONFIG_INT(TARGET, NAME, SHORT) { ST_INT, NAME, &TARGET, sizeof(TARGET), SHORT, 0, 0, 0, 0.0, 0.0, false },
|
||||
#define CONFIG_FLOAT(TARGET, NAME, SHORT) { ST_FLOAT, NAME, &TARGET, sizeof(TARGET), SHORT, 0, 0, 0, 0.0, 0.0, false },
|
||||
#define CONFIG_PATH(TARGET, NAME, SHORT) { ST_PATH, NAME, &TARGET, sizeof(TARGET), SHORT, 0, 0, 0, 0.0, 0.0, false },
|
||||
#define CONFIG_STRING(TARGET, NAME, SHORT) { ST_STRING, NAME, &TARGET, sizeof(TARGET), SHORT, 0, 0, 0, 0.0, 0.0, false },
|
||||
#define CONFIG_HEX(TARGET, NAME, SHORT) { ST_HEX, NAME, &TARGET, sizeof(TARGET), SHORT, 0, 0, 0, 0.0, 0.0, false },
|
||||
#define CONFIG_BIND(TARGET, NAME, SHORT) { ST_BIND, NAME, &TARGET, sizeof(TARGET), SHORT },
|
||||
#define CONFIG_BOOL(TARGET, NAME, SHORT) { ST_BOOL, NAME, &TARGET, sizeof(TARGET), SHORT },
|
||||
#define CONFIG_INT(TARGET, NAME, SHORT) { ST_INT, NAME, &TARGET, sizeof(TARGET), SHORT },
|
||||
#define CONFIG_FLOAT(TARGET, NAME, SHORT) { ST_FLOAT, NAME, &TARGET, sizeof(TARGET), SHORT },
|
||||
#define CONFIG_PATH(TARGET, NAME, SHORT) { ST_PATH, NAME, &TARGET, sizeof(TARGET), SHORT },
|
||||
#define CONFIG_STRING(TARGET, NAME, SHORT) { ST_STRING, NAME, &TARGET, sizeof(TARGET), SHORT },
|
||||
#define CONFIG_HEX(TARGET, NAME, SHORT) { ST_HEX, NAME, &TARGET, sizeof(TARGET), SHORT },
|
||||
|
||||
#define CONFIG_BIND(TARGET, PLAYER, NAME, SHORT) { ST_BIND, NAME, &TARGET, sizeof(TARGET), SHORT, PLAYER },
|
||||
|
||||
const rarch_setting_t setting_data[] =
|
||||
{
|
||||
|
@ -183,22 +182,31 @@ const rarch_setting_t setting_data[] =
|
|||
END_SUB_GROUP()
|
||||
|
||||
START_SUB_GROUP("Player 1")
|
||||
CONFIG_BIND(g_settings.input.binds[0][ 0], "input_player1_b", "B button (down)")
|
||||
CONFIG_BIND(g_settings.input.binds[0][ 1], "input_player1_y", "Y button (left)")
|
||||
CONFIG_BIND(g_settings.input.binds[0][ 2], "input_player1_select", "Select button")
|
||||
CONFIG_BIND(g_settings.input.binds[0][ 3], "input_player1_start", "Start button")
|
||||
CONFIG_BIND(g_settings.input.binds[0][ 4], "input_player1_up", "Up D-pad")
|
||||
CONFIG_BIND(g_settings.input.binds[0][ 5], "input_player1_down", "Down D-pad")
|
||||
CONFIG_BIND(g_settings.input.binds[0][ 6], "input_player1_left", "Left D-pad")
|
||||
CONFIG_BIND(g_settings.input.binds[0][ 7], "input_player1_right", "Right D-pad")
|
||||
CONFIG_BIND(g_settings.input.binds[0][ 8], "input_player1_a", "A button (right)")
|
||||
CONFIG_BIND(g_settings.input.binds[0][ 9], "input_player1_x", "X button (top)")
|
||||
CONFIG_BIND(g_settings.input.binds[0][10], "input_player1_l", "L button (left shoulder)")
|
||||
CONFIG_BIND(g_settings.input.binds[0][11], "input_player1_r", "R button (right shoulder)")
|
||||
CONFIG_BIND(g_settings.input.binds[0][12], "input_player1_l2", "L2 button (left shoulder #2)")
|
||||
CONFIG_BIND(g_settings.input.binds[0][13], "input_player1_r2", "R2 button (right shoulder #2)")
|
||||
CONFIG_BIND(g_settings.input.binds[0][14], "input_player1_l3", "L3 button (left analog button)")
|
||||
CONFIG_BIND(g_settings.input.binds[0][15], "input_player1_r3", "R3 button (right analog button)")
|
||||
CONFIG_BIND(g_settings.input.binds[0][ 0], 1, "b", "B button (down)")
|
||||
CONFIG_BIND(g_settings.input.binds[0][ 1], 1, "y", "Y button (left)")
|
||||
CONFIG_BIND(g_settings.input.binds[0][ 2], 1, "select", "Select button")
|
||||
CONFIG_BIND(g_settings.input.binds[0][ 3], 1, "start", "Start button")
|
||||
CONFIG_BIND(g_settings.input.binds[0][ 4], 1, "up", "Up D-pad")
|
||||
CONFIG_BIND(g_settings.input.binds[0][ 5], 1, "down", "Down D-pad")
|
||||
CONFIG_BIND(g_settings.input.binds[0][ 6], 1, "left", "Left D-pad")
|
||||
CONFIG_BIND(g_settings.input.binds[0][ 7], 1, "right", "Right D-pad")
|
||||
CONFIG_BIND(g_settings.input.binds[0][ 8], 1, "a", "A button (right)")
|
||||
CONFIG_BIND(g_settings.input.binds[0][ 9], 1, "x", "X button (top)")
|
||||
CONFIG_BIND(g_settings.input.binds[0][10], 1, "l", "L button (left shoulder)")
|
||||
CONFIG_BIND(g_settings.input.binds[0][11], 1, "r", "R button (right shoulder)")
|
||||
CONFIG_BIND(g_settings.input.binds[0][12], 1, "l2", "L2 button (left shoulder #2)")
|
||||
CONFIG_BIND(g_settings.input.binds[0][13], 1, "r2", "R2 button (right shoulder #2)")
|
||||
CONFIG_BIND(g_settings.input.binds[0][14], 1, "l3", "L3 button (left analog button)")
|
||||
CONFIG_BIND(g_settings.input.binds[0][15], 1, "r3", "R3 button (right analog button)")
|
||||
CONFIG_BIND(g_settings.input.binds[0][16], 1, "turbo", "Turbo enable")
|
||||
CONFIG_BIND(g_settings.input.binds[0][17], 1, "l_x_plus", "Left analog X+ (right)")
|
||||
CONFIG_BIND(g_settings.input.binds[0][18], 1, "l_x_minus", "Left analog X- (left)")
|
||||
CONFIG_BIND(g_settings.input.binds[0][19], 1, "l_y_plus", "Left analog Y+ (down)")
|
||||
CONFIG_BIND(g_settings.input.binds[0][20], 1, "l_y_minus", "Left analog Y- (up)")
|
||||
CONFIG_BIND(g_settings.input.binds[0][21], 1, "r_x_plus", "Right analog X+ (right)")
|
||||
CONFIG_BIND(g_settings.input.binds[0][22], 1, "r_x_minus", "Right analog X- (left)")
|
||||
CONFIG_BIND(g_settings.input.binds[0][23], 1, "r_y_plus", "Right analog Y+ (down)")
|
||||
CONFIG_BIND(g_settings.input.binds[0][24], 1, "r_y_minus", "Right analog Y- (up)")
|
||||
END_SUB_GROUP()
|
||||
END_GROUP()
|
||||
|
||||
|
|
Loading…
Reference in New Issue