(360) Use input LUTs in code

This commit is contained in:
TwinAphex51224 2012-03-06 13:35:20 +01:00
parent 3239edccb9
commit 4ff4957a45
4 changed files with 67 additions and 40 deletions

View File

@ -25,6 +25,7 @@
#include "xdk360_input.h"
#include "xdk360_video.h"
#include "../input/input_luts.h"
#include "../console/rom_ext.h"
#include "../console/main_wrap.h"
#include "../conf/config_file.h"
@ -135,46 +136,29 @@ static void set_default_settings (void)
g_settings.video.vsync = true;
g_settings.video.smooth = true;
ssnes_default_keybind_lut[SNES_DEVICE_ID_JOYPAD_B] = ssnes_platform_keybind_lut[XDK360_DEVICE_ID_JOYPAD_A];
ssnes_default_keybind_lut[SNES_DEVICE_ID_JOYPAD_Y] = ssnes_platform_keybind_lut[XDK360_DEVICE_ID_JOYPAD_X];
ssnes_default_keybind_lut[SNES_DEVICE_ID_JOYPAD_SELECT] = ssnes_platform_keybind_lut[XDK360_DEVICE_ID_JOYPAD_BACK];
ssnes_default_keybind_lut[SNES_DEVICE_ID_JOYPAD_START] = ssnes_platform_keybind_lut[XDK360_DEVICE_ID_JOYPAD_START];
ssnes_default_keybind_lut[SNES_DEVICE_ID_JOYPAD_UP] = ssnes_platform_keybind_lut[XDK360_DEVICE_ID_JOYPAD_UP];
ssnes_default_keybind_lut[SNES_DEVICE_ID_JOYPAD_DOWN] = ssnes_platform_keybind_lut[XDK360_DEVICE_ID_JOYPAD_DOWN];
ssnes_default_keybind_lut[SNES_DEVICE_ID_JOYPAD_LEFT] = ssnes_platform_keybind_lut[XDK360_DEVICE_ID_JOYPAD_LEFT];
ssnes_default_keybind_lut[SNES_DEVICE_ID_JOYPAD_RIGHT] = ssnes_platform_keybind_lut[XDK360_DEVICE_ID_JOYPAD_RIGHT];
ssnes_default_keybind_lut[SNES_DEVICE_ID_JOYPAD_A] = ssnes_platform_keybind_lut[XDK360_DEVICE_ID_JOYPAD_B];
ssnes_default_keybind_lut[SNES_DEVICE_ID_JOYPAD_X] = ssnes_platform_keybind_lut[XDK360_DEVICE_ID_JOYPAD_Y];
ssnes_default_keybind_lut[SNES_DEVICE_ID_JOYPAD_L] = ssnes_platform_keybind_lut[XDK360_DEVICE_ID_JOYPAD_LB];
ssnes_default_keybind_lut[SNES_DEVICE_ID_JOYPAD_R] = ssnes_platform_keybind_lut[XDK360_DEVICE_ID_JOYPAD_RB];
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 = XINPUT_GAMEPAD_A;
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 = XINPUT_GAMEPAD_X;
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 = XINPUT_GAMEPAD_BACK;
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 = XINPUT_GAMEPAD_START;
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 = XINPUT_GAMEPAD_DPAD_UP | XINPUT_GAMEPAD_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 = XINPUT_GAMEPAD_DPAD_DOWN | XINPUT_GAMEPAD_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 = XINPUT_GAMEPAD_DPAD_LEFT | XINPUT_GAMEPAD_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 = XINPUT_GAMEPAD_DPAD_RIGHT | XINPUT_GAMEPAD_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 = XINPUT_GAMEPAD_B;
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 = XINPUT_GAMEPAD_Y;
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 = XINPUT_GAMEPAD_LEFT_SHOULDER;
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 = XINPUT_GAMEPAD_RIGHT_SHOULDER;
for(uint32_t y = 0; y < SSNES_FIRST_META_KEY; y++)
{
g_settings.input.binds[x][y].id = y;
g_settings.input.binds[x][y].joykey = ssnes_default_keybind_lut[y];
}
g_settings.input.dpad_emulation[x] = DPAD_EMULATION_LSTICK;
}
//g_console
g_console.block_config_read = true;
g_console.throttle_enable = true;
@ -518,6 +502,7 @@ int main(int argc, char *argv[])
init_settings(load_libsnes_path);
xdk360_video_init();
xdk360_input_init();
menu_init();
begin_loop:

View File

@ -18,6 +18,13 @@
#define MAX_PATH_LENGTH 1024
enum
{
DPAD_EMULATION_NONE,
DPAD_EMULATION_LSTICK,
DPAD_EMULATION_RSTICK
};
enum
{
MODE_EMULATION,

View File

@ -22,6 +22,7 @@
#include "../driver.h"
#include "../general.h"
#include "../libsnes.hpp"
#include "../input/input_luts.h"
#include "xdk360_input.h"
#include "xdk360_video.h"
#include "shared.h"
@ -88,11 +89,42 @@ static void xdk360_free_input(void *data)
(void)data;
}
static void* xdk360_input_init(void)
static void* xdk360_input_initialize(void)
{
return (void*)-1;
}
void xdk360_input_init(void)
{
for(unsigned i = 0; i < 4; i++)
xdk360_input_map_dpad_to_stick(g_settings.input.dpad_emulation[i], i);
}
void xdk360_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 = ssnes_platform_keybind_lut[XDK360_DEVICE_ID_JOYPAD_UP];
g_settings.input.binds[controller_id][SNES_DEVICE_ID_JOYPAD_DOWN].joykey = ssnes_platform_keybind_lut[XDK360_DEVICE_ID_JOYPAD_DOWN];
g_settings.input.binds[controller_id][SNES_DEVICE_ID_JOYPAD_LEFT].joykey = ssnes_platform_keybind_lut[XDK360_DEVICE_ID_JOYPAD_LEFT];
g_settings.input.binds[controller_id][SNES_DEVICE_ID_JOYPAD_RIGHT].joykey = ssnes_platform_keybind_lut[XDK360_DEVICE_ID_JOYPAD_RIGHT];
break;
case DPAD_EMULATION_LSTICK:
g_settings.input.binds[controller_id][SNES_DEVICE_ID_JOYPAD_UP].joykey = ssnes_platform_keybind_lut[XDK360_DEVICE_ID_LSTICK_UP_DPAD];
g_settings.input.binds[controller_id][SNES_DEVICE_ID_JOYPAD_DOWN].joykey = ssnes_platform_keybind_lut[XDK360_DEVICE_ID_LSTICK_DOWN_DPAD];
g_settings.input.binds[controller_id][SNES_DEVICE_ID_JOYPAD_LEFT].joykey = ssnes_platform_keybind_lut[XDK360_DEVICE_ID_LSTICK_LEFT_DPAD];
g_settings.input.binds[controller_id][SNES_DEVICE_ID_JOYPAD_RIGHT].joykey = ssnes_platform_keybind_lut[XDK360_DEVICE_ID_LSTICK_RIGHT_DPAD];
break;
case DPAD_EMULATION_RSTICK:
g_settings.input.binds[controller_id][SNES_DEVICE_ID_JOYPAD_UP].joykey = ssnes_platform_keybind_lut[XDK360_DEVICE_ID_RSTICK_UP_DPAD];
g_settings.input.binds[controller_id][SNES_DEVICE_ID_JOYPAD_DOWN].joykey = ssnes_platform_keybind_lut[XDK360_DEVICE_ID_RSTICK_DOWN_DPAD];
g_settings.input.binds[controller_id][SNES_DEVICE_ID_JOYPAD_LEFT].joykey = ssnes_platform_keybind_lut[XDK360_DEVICE_ID_RSTICK_LEFT_DPAD];
g_settings.input.binds[controller_id][SNES_DEVICE_ID_JOYPAD_RIGHT].joykey = ssnes_platform_keybind_lut[XDK360_DEVICE_ID_RSTICK_RIGHT_DPAD];
break;
}
}
static bool xdk360_key_pressed(void *data, int key)
{
(void)data;
@ -149,7 +181,7 @@ static bool xdk360_key_pressed(void *data, int key)
}
const input_driver_t input_xdk360 = {
xdk360_input_init,
xdk360_input_initialize,
xdk360_input_poll,
xdk360_input_state,
xdk360_key_pressed,

View File

@ -27,8 +27,11 @@
#define XINPUT_GAMEPAD_RSTICK_RIGHT_MASK (2097152)
#define XINPUT_GAMEPAD_RSTICK_UP_MASK (4194304)
#define XINPUT_GAMEPAD_RSTICK_DOWN_MASK (8388608)
#define XINPUT_GAMEPAD_LEFT_TRIGGER (16777216)
#define XINPUT_GAMEPAD_LEFT_TRIGGER (16777216)
#define XINPUT_GAMEPAD_RIGHT_TRIGGER (33554432)
#define DEADZONE (16000)
#define DEADZONE (16000)
extern void xdk360_input_init(void);
extern void xdk360_input_map_dpad_to_stick(uint32_t map_dpad_enum, uint32_t controller_id);
#endif