From 40ce42c87c200235de46230c31858b2345564efb Mon Sep 17 00:00:00 2001 From: TwinAphex51224 Date: Thu, 2 Feb 2012 15:46:27 +0100 Subject: [PATCH] (PS3) Initial keybind implementation --- ps3/main.c | 39 +++++++++++++++++++++++++++++++++++++++ ps3/ps3_input.c | 12 +++++++----- 2 files changed, 46 insertions(+), 5 deletions(-) diff --git a/ps3/main.c b/ps3/main.c index bf96ab0772..9fb837b519 100644 --- a/ps3/main.c +++ b/ps3/main.c @@ -113,6 +113,45 @@ static void set_default_settings(void) g_settings.video.msg_pos_y = 0.90f; g_settings.video.aspect_ratio = -1.0f; + for(uint32_t x = 0; x < MAX_PLAYERS; x++) + { + g_settings.input.binds[x][SNES_DEVICE_ID_JOYPAD_B].id = SNES_DEVICE_ID_JOYPAD_B; + g_settings.input.binds[x][SNES_DEVICE_ID_JOYPAD_B].joykey = CTRL_CROSS_MASK; + + g_settings.input.binds[x][SNES_DEVICE_ID_JOYPAD_Y].id = SNES_DEVICE_ID_JOYPAD_Y; + g_settings.input.binds[x][SNES_DEVICE_ID_JOYPAD_Y].joykey = CTRL_SQUARE_MASK; + + g_settings.input.binds[x][SNES_DEVICE_ID_JOYPAD_SELECT].id = SNES_DEVICE_ID_JOYPAD_SELECT; + g_settings.input.binds[x][SNES_DEVICE_ID_JOYPAD_SELECT].joykey = CTRL_SELECT_MASK; + + g_settings.input.binds[x][SNES_DEVICE_ID_JOYPAD_START].id = SNES_DEVICE_ID_JOYPAD_START; + g_settings.input.binds[x][SNES_DEVICE_ID_JOYPAD_START].joykey = CTRL_START_MASK; + + 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_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_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_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_A].id = SNES_DEVICE_ID_JOYPAD_A; + g_settings.input.binds[x][SNES_DEVICE_ID_JOYPAD_A].joykey = CTRL_CIRCLE_MASK; + + g_settings.input.binds[x][SNES_DEVICE_ID_JOYPAD_X].id = SNES_DEVICE_ID_JOYPAD_X; + g_settings.input.binds[x][SNES_DEVICE_ID_JOYPAD_X].joykey = CTRL_TRIANGLE_MASK; + + g_settings.input.binds[x][SNES_DEVICE_ID_JOYPAD_L].id = SNES_DEVICE_ID_JOYPAD_L; + g_settings.input.binds[x][SNES_DEVICE_ID_JOYPAD_L].joykey = CTRL_L1_MASK; + + 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_console g_console.block_config_read = true; g_console.screenshots_enable = false; diff --git a/ps3/ps3_input.c b/ps3/ps3_input.c index 4f7c13a9f7..f92c3d1bc0 100644 --- a/ps3/ps3_input.c +++ b/ps3/ps3_input.c @@ -37,7 +37,6 @@ static int16_t ps3_input_state(void *data, const struct snes_keybind **binds, unsigned index, unsigned id) { (void)data; - (void)binds; (void)index; unsigned pads_connected, player; @@ -54,13 +53,15 @@ static int16_t ps3_input_state(void *data, const struct snes_keybind **binds, if(pads_connected < 2) return 0; - if(device != SNES_DEVICE_MULTITAP) - player = 1; - else - player = index + 1; + player = 1; + + if(device == SNES_DEVICE_MULTITAP) + player += index; } // Hardcoded binds. + button = binds[player][id].joykey; + #if 0 switch (id) { case SNES_DEVICE_ID_JOYPAD_A: @@ -103,6 +104,7 @@ static int16_t ps3_input_state(void *data, const struct snes_keybind **binds, button = 0; break; } + #endif return CTRL_MASK(state[player], button) ? 1 : 0; }