From cd0833905140a0fea649af6dc9a56a13e94dc53b Mon Sep 17 00:00:00 2001 From: TwinAphex51224 Date: Sat, 3 Mar 2012 14:57:28 +0100 Subject: [PATCH] (PS3) D-pad analog stick left mapping - make this configurable later on --- driver.h | 4 ++++ general.h | 4 ++++ ps3/main.c | 22 ++++++++++++++++++---- ps3/ps3_input.c | 27 +++++++++++++++++++++++++++ ps3/ps3_input.h | 1 + ps3/shared.h | 7 +++++++ 6 files changed, 61 insertions(+), 4 deletions(-) diff --git a/driver.h b/driver.h index 35069c5341..a2372a6d88 100644 --- a/driver.h +++ b/driver.h @@ -72,7 +72,11 @@ struct snes_keybind bool valid; int id; enum ssnes_key key; +#ifdef __CELLOS_LV2__ + uint64_t joykey; +#else uint16_t joykey; +#endif uint32_t joyaxis; }; diff --git a/general.h b/general.h index e9cbd29606..1ecffa124d 100644 --- a/general.h +++ b/general.h @@ -151,6 +151,9 @@ struct settings struct snes_keybind binds[MAX_PLAYERS][SSNES_BIND_LIST_END]; float axis_threshold; int joypad_map[MAX_PLAYERS]; +#ifdef SSNES_CONSOLE + unsigned dpad_emulation[MAX_PLAYERS]; +#endif bool netplay_client_swap_input; } input; @@ -200,6 +203,7 @@ struct console_settings uint32_t current_resolution_id; uint32_t ingame_menu_item; uint32_t initial_resolution_id; + uint32_t map_dpad_to_stick; uint32_t mode_switch; uint32_t sound_mode; uint32_t *supported_resolutions; diff --git a/ps3/main.c b/ps3/main.c index 57f8cc018f..417b0c463b 100644 --- a/ps3/main.c +++ b/ps3/main.c @@ -112,19 +112,15 @@ static void set_default_settings(void) g_settings.input.binds[x][SNES_DEVICE_ID_JOYPAD_UP].id = SNES_DEVICE_ID_JOYPAD_UP; g_settings.input.binds[x][SNES_DEVICE_ID_JOYPAD_UP].joykey = CTRL_UP_MASK; - g_settings.input.binds[x][SNES_DEVICE_ID_JOYPAD_UP].joyaxis = CTRL_LSTICK_UP_MASK; g_settings.input.binds[x][SNES_DEVICE_ID_JOYPAD_DOWN].id = SNES_DEVICE_ID_JOYPAD_DOWN; g_settings.input.binds[x][SNES_DEVICE_ID_JOYPAD_DOWN].joykey = CTRL_DOWN_MASK; - g_settings.input.binds[x][SNES_DEVICE_ID_JOYPAD_DOWN].joyaxis = CTRL_LSTICK_DOWN_MASK; g_settings.input.binds[x][SNES_DEVICE_ID_JOYPAD_LEFT].id = SNES_DEVICE_ID_JOYPAD_LEFT; g_settings.input.binds[x][SNES_DEVICE_ID_JOYPAD_LEFT].joykey = CTRL_LEFT_MASK; - g_settings.input.binds[x][SNES_DEVICE_ID_JOYPAD_LEFT].joyaxis = CTRL_LSTICK_LEFT_MASK; g_settings.input.binds[x][SNES_DEVICE_ID_JOYPAD_RIGHT].id = SNES_DEVICE_ID_JOYPAD_RIGHT; g_settings.input.binds[x][SNES_DEVICE_ID_JOYPAD_RIGHT].joykey = CTRL_RIGHT_MASK; - g_settings.input.binds[x][SNES_DEVICE_ID_JOYPAD_RIGHT].joyaxis = CTRL_LSTICK_RIGHT_MASK; g_settings.input.binds[x][SNES_DEVICE_ID_JOYPAD_A].id = SNES_DEVICE_ID_JOYPAD_A; g_settings.input.binds[x][SNES_DEVICE_ID_JOYPAD_A].joykey = CTRL_CIRCLE_MASK; @@ -137,6 +133,8 @@ static void set_default_settings(void) g_settings.input.binds[x][SNES_DEVICE_ID_JOYPAD_R].id = SNES_DEVICE_ID_JOYPAD_R; g_settings.input.binds[x][SNES_DEVICE_ID_JOYPAD_R].joykey = CTRL_R1_MASK; + + g_settings.input.dpad_emulation[x] = DPAD_EMULATION_LSTICK; } // g_console @@ -232,6 +230,14 @@ static void init_settings(bool load_libsnes_path) CONFIG_GET_BOOL(video.vsync, "video_vsync"); CONFIG_GET_FLOAT(video.aspect_ratio, "video_aspect_ratio"); + CONFIG_GET_INT(input.dpad_emulation[0], "dpad_emulation_p1"); + CONFIG_GET_INT(input.dpad_emulation[1], "dpad_emulation_p2"); + CONFIG_GET_INT(input.dpad_emulation[2], "dpad_emulation_p3"); + CONFIG_GET_INT(input.dpad_emulation[3], "dpad_emulation_p4"); + CONFIG_GET_INT(input.dpad_emulation[4], "dpad_emulation_p5"); + CONFIG_GET_INT(input.dpad_emulation[5], "dpad_emulation_p6"); + CONFIG_GET_INT(input.dpad_emulation[6], "dpad_emulation_p7"); + // g_console CONFIG_GET_BOOL_CONSOLE(overscan_enable, "overscan_enable"); @@ -288,6 +294,14 @@ static void save_settings(void) config_set_bool(conf, "video_smooth", g_settings.video.smooth); config_set_bool(conf, "video_vsync", g_settings.video.vsync); + config_set_int(conf, "dpad_emulation_p1", g_settings.input.dpad_emulation[0]); + config_set_int(conf, "dpad_emulation_p2", g_settings.input.dpad_emulation[1]); + config_set_int(conf, "dpad_emulation_p3", g_settings.input.dpad_emulation[2]); + config_set_int(conf, "dpad_emulation_p4", g_settings.input.dpad_emulation[3]); + config_set_int(conf, "dpad_emulation_p5", g_settings.input.dpad_emulation[4]); + config_set_int(conf, "dpad_emulation_p6", g_settings.input.dpad_emulation[5]); + config_set_int(conf, "dpad_emulation_p7", g_settings.input.dpad_emulation[6]); + // g_console config_set_bool(conf, "overscan_enable", g_console.overscan_enable); config_set_bool(conf, "screenshots_enable", g_console.screenshots_enable); diff --git a/ps3/ps3_input.c b/ps3/ps3_input.c index 06b3a570b9..433ef85f5a 100644 --- a/ps3/ps3_input.c +++ b/ps3/ps3_input.c @@ -78,6 +78,33 @@ static void* ps3_input_initialize(void) void ps3_input_init(void) { cell_pad_input_init(); + for(unsigned i = 0; i < MAX_PADS; i++) + ps3_input_map_dpad_to_stick(g_settings.input.dpad_emulation[i], i); +} + +void ps3_input_map_dpad_to_stick(uint32_t map_dpad_enum, uint32_t controller_id) +{ + switch(map_dpad_enum) + { + case DPAD_EMULATION_NONE: + g_settings.input.binds[controller_id][SNES_DEVICE_ID_JOYPAD_UP].joykey = CTRL_UP_MASK; + g_settings.input.binds[controller_id][SNES_DEVICE_ID_JOYPAD_DOWN].joykey = CTRL_DOWN_MASK; + g_settings.input.binds[controller_id][SNES_DEVICE_ID_JOYPAD_LEFT].joykey = CTRL_LEFT_MASK; + g_settings.input.binds[controller_id][SNES_DEVICE_ID_JOYPAD_RIGHT].joykey = CTRL_RIGHT_MASK; + break; + case DPAD_EMULATION_LSTICK: + g_settings.input.binds[controller_id][SNES_DEVICE_ID_JOYPAD_UP].joykey = CTRL_UP_MASK | CTRL_LSTICK_UP_MASK; + g_settings.input.binds[controller_id][SNES_DEVICE_ID_JOYPAD_DOWN].joykey = CTRL_DOWN_MASK | CTRL_LSTICK_DOWN_MASK; + g_settings.input.binds[controller_id][SNES_DEVICE_ID_JOYPAD_LEFT].joykey = CTRL_LEFT_MASK | CTRL_LSTICK_LEFT_MASK; + g_settings.input.binds[controller_id][SNES_DEVICE_ID_JOYPAD_RIGHT].joykey = CTRL_RIGHT_MASK | CTRL_LSTICK_RIGHT_MASK; + break; + case DPAD_EMULATION_RSTICK: + g_settings.input.binds[controller_id][SNES_DEVICE_ID_JOYPAD_UP].joykey = CTRL_UP_MASK | CTRL_RSTICK_UP_MASK; + g_settings.input.binds[controller_id][SNES_DEVICE_ID_JOYPAD_DOWN].joykey = CTRL_DOWN_MASK | CTRL_RSTICK_DOWN_MASK; + g_settings.input.binds[controller_id][SNES_DEVICE_ID_JOYPAD_LEFT].joykey = CTRL_LEFT_MASK | CTRL_RSTICK_LEFT_MASK; + g_settings.input.binds[controller_id][SNES_DEVICE_ID_JOYPAD_RIGHT].joykey = CTRL_RIGHT_MASK | CTRL_RSTICK_RIGHT_MASK; + break; + } } static bool ps3_key_pressed(void *data, int key) diff --git a/ps3/ps3_input.h b/ps3/ps3_input.h index a23476b4e5..437a5ed45f 100644 --- a/ps3/ps3_input.h +++ b/ps3/ps3_input.h @@ -22,5 +22,6 @@ #include "cellframework2/input/pad_input.h" void ps3_input_init(void); +void ps3_input_map_dpad_to_stick(uint32_t map_dpad_enum, uint32_t controller_id); #endif diff --git a/ps3/shared.h b/ps3/shared.h index d2a2688a66..c1b54e77ef 100644 --- a/ps3/shared.h +++ b/ps3/shared.h @@ -32,6 +32,13 @@ #define LIGHTBLUE 0xFFFFE0E0U #define LIGHTORANGE 0xFFE0EEFFu +enum +{ + DPAD_EMULATION_NONE, + DPAD_EMULATION_LSTICK, + DPAD_EMULATION_RSTICK +}; + enum { EXTERN_LAUNCHER_SALAMANDER,