(PS3) D-pad analog stick left mapping - make this configurable later

on
This commit is contained in:
TwinAphex51224 2012-03-03 14:57:28 +01:00
parent 85ee49b2cd
commit cd08339051
6 changed files with 61 additions and 4 deletions

View File

@ -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;
};

View File

@ -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;

View File

@ -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);

View File

@ -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)

View File

@ -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

View File

@ -32,6 +32,13 @@
#define LIGHTBLUE 0xFFFFE0E0U
#define LIGHTORANGE 0xFFE0EEFFu
enum
{
DPAD_EMULATION_NONE,
DPAD_EMULATION_LSTICK,
DPAD_EMULATION_RSTICK
};
enum
{
EXTERN_LAUNCHER_SALAMANDER,