2021-08-28 13:12:10 +00:00
|
|
|
#include "ppsspp_config.h"
|
|
|
|
|
|
|
|
#include "Common/CommonFuncs.h"
|
|
|
|
#include "Common/Input/KeyCodes.h"
|
|
|
|
#include "Common/Input/InputState.h"
|
2022-01-10 00:11:08 +00:00
|
|
|
#include "Common/System/System.h"
|
2021-08-28 13:12:10 +00:00
|
|
|
#include "Core/KeyMapDefaults.h"
|
|
|
|
#include "Core/KeyMap.h"
|
|
|
|
|
|
|
|
#include "Core/HLE/sceCtrl.h"
|
|
|
|
|
|
|
|
namespace KeyMap {
|
|
|
|
|
|
|
|
struct DefMappingStruct {
|
|
|
|
int pspKey;
|
2023-03-29 09:59:31 +00:00
|
|
|
int keyOrAxis;
|
|
|
|
int direction; // if 0, it's a key, otherwise an axis.
|
2021-08-28 13:12:10 +00:00
|
|
|
};
|
|
|
|
|
2021-08-28 13:38:03 +00:00
|
|
|
static const DefMappingStruct defaultQwertyKeyboardKeyMap[] = {
|
2021-08-28 13:12:10 +00:00
|
|
|
{CTRL_SQUARE, NKCODE_A},
|
|
|
|
{CTRL_TRIANGLE, NKCODE_S},
|
|
|
|
{CTRL_CIRCLE, NKCODE_X},
|
|
|
|
{CTRL_CROSS, NKCODE_Z},
|
|
|
|
{CTRL_LTRIGGER, NKCODE_Q},
|
|
|
|
{CTRL_RTRIGGER, NKCODE_W},
|
|
|
|
|
|
|
|
{CTRL_START, NKCODE_SPACE},
|
|
|
|
#ifdef _WIN32
|
|
|
|
{CTRL_SELECT, NKCODE_V},
|
|
|
|
#else
|
|
|
|
{CTRL_SELECT, NKCODE_ENTER},
|
|
|
|
#endif
|
|
|
|
{CTRL_UP , NKCODE_DPAD_UP},
|
|
|
|
{CTRL_DOWN , NKCODE_DPAD_DOWN},
|
|
|
|
{CTRL_LEFT , NKCODE_DPAD_LEFT},
|
|
|
|
{CTRL_RIGHT, NKCODE_DPAD_RIGHT},
|
|
|
|
{VIRTKEY_AXIS_Y_MAX, NKCODE_I},
|
|
|
|
{VIRTKEY_AXIS_Y_MIN, NKCODE_K},
|
|
|
|
{VIRTKEY_AXIS_X_MIN, NKCODE_J},
|
|
|
|
{VIRTKEY_AXIS_X_MAX, NKCODE_L},
|
|
|
|
{VIRTKEY_RAPID_FIRE, NKCODE_SHIFT_LEFT},
|
|
|
|
{VIRTKEY_FASTFORWARD, NKCODE_TAB},
|
|
|
|
{VIRTKEY_SPEED_TOGGLE, NKCODE_GRAVE},
|
|
|
|
{VIRTKEY_PAUSE , NKCODE_ESCAPE},
|
|
|
|
{VIRTKEY_REWIND , NKCODE_DEL},
|
|
|
|
{VIRTKEY_ANALOG_LIGHTLY, NKCODE_SHIFT_RIGHT},
|
2024-11-04 22:33:03 +00:00
|
|
|
{VIRTKEY_TOGGLE_DEBUGGER, NKCODE_F12},
|
2021-08-28 13:12:10 +00:00
|
|
|
};
|
|
|
|
|
2021-08-28 13:38:03 +00:00
|
|
|
static const DefMappingStruct defaultAzertyKeyboardKeyMap[] = {
|
2021-08-28 13:12:10 +00:00
|
|
|
{CTRL_SQUARE, NKCODE_Q},
|
|
|
|
{CTRL_TRIANGLE, NKCODE_S},
|
|
|
|
{CTRL_CIRCLE, NKCODE_X},
|
|
|
|
{CTRL_CROSS, NKCODE_W},
|
|
|
|
{CTRL_LTRIGGER, NKCODE_A},
|
|
|
|
{CTRL_RTRIGGER, NKCODE_Z},
|
|
|
|
|
|
|
|
{CTRL_START, NKCODE_SPACE},
|
|
|
|
#ifdef _WIN32
|
|
|
|
{CTRL_SELECT, NKCODE_V},
|
|
|
|
#else
|
|
|
|
{CTRL_SELECT, NKCODE_ENTER},
|
|
|
|
#endif
|
|
|
|
{CTRL_UP , NKCODE_DPAD_UP},
|
|
|
|
{CTRL_DOWN , NKCODE_DPAD_DOWN},
|
|
|
|
{CTRL_LEFT , NKCODE_DPAD_LEFT},
|
|
|
|
{CTRL_RIGHT, NKCODE_DPAD_RIGHT},
|
|
|
|
{VIRTKEY_AXIS_Y_MAX, NKCODE_I},
|
|
|
|
{VIRTKEY_AXIS_Y_MIN, NKCODE_K},
|
|
|
|
{VIRTKEY_AXIS_X_MIN, NKCODE_J},
|
|
|
|
{VIRTKEY_AXIS_X_MAX, NKCODE_L},
|
|
|
|
{VIRTKEY_RAPID_FIRE, NKCODE_SHIFT_LEFT},
|
|
|
|
{VIRTKEY_FASTFORWARD, NKCODE_TAB},
|
|
|
|
{VIRTKEY_SPEED_TOGGLE, NKCODE_GRAVE},
|
|
|
|
{VIRTKEY_PAUSE , NKCODE_ESCAPE},
|
|
|
|
{VIRTKEY_REWIND , NKCODE_DEL},
|
|
|
|
{VIRTKEY_ANALOG_LIGHTLY, NKCODE_SHIFT_RIGHT},
|
|
|
|
};
|
|
|
|
|
2021-08-28 13:38:03 +00:00
|
|
|
static const DefMappingStruct defaultQwertzKeyboardKeyMap[] = {
|
2021-08-28 13:12:10 +00:00
|
|
|
{CTRL_SQUARE, NKCODE_A},
|
|
|
|
{CTRL_TRIANGLE, NKCODE_S},
|
|
|
|
{CTRL_CIRCLE, NKCODE_X},
|
|
|
|
{CTRL_CROSS, NKCODE_Y},
|
|
|
|
{CTRL_LTRIGGER, NKCODE_Q},
|
|
|
|
{CTRL_RTRIGGER, NKCODE_W},
|
|
|
|
|
|
|
|
{CTRL_START, NKCODE_SPACE},
|
|
|
|
#ifdef _WIN32
|
|
|
|
{CTRL_SELECT, NKCODE_V},
|
|
|
|
#else
|
|
|
|
{CTRL_SELECT, NKCODE_ENTER},
|
|
|
|
#endif
|
|
|
|
{CTRL_UP , NKCODE_DPAD_UP},
|
|
|
|
{CTRL_DOWN , NKCODE_DPAD_DOWN},
|
|
|
|
{CTRL_LEFT , NKCODE_DPAD_LEFT},
|
|
|
|
{CTRL_RIGHT, NKCODE_DPAD_RIGHT},
|
|
|
|
{VIRTKEY_AXIS_Y_MAX, NKCODE_I},
|
|
|
|
{VIRTKEY_AXIS_Y_MIN, NKCODE_K},
|
|
|
|
{VIRTKEY_AXIS_X_MIN, NKCODE_J},
|
|
|
|
{VIRTKEY_AXIS_X_MAX, NKCODE_L},
|
|
|
|
{VIRTKEY_RAPID_FIRE, NKCODE_SHIFT_LEFT},
|
|
|
|
{VIRTKEY_FASTFORWARD, NKCODE_TAB},
|
|
|
|
{VIRTKEY_SPEED_TOGGLE, NKCODE_GRAVE},
|
|
|
|
{VIRTKEY_PAUSE , NKCODE_ESCAPE},
|
|
|
|
{VIRTKEY_REWIND , NKCODE_DEL},
|
|
|
|
{VIRTKEY_ANALOG_LIGHTLY, NKCODE_SHIFT_RIGHT},
|
|
|
|
};
|
|
|
|
|
2021-08-28 13:38:03 +00:00
|
|
|
static const DefMappingStruct defaultXInputKeyMap[] = {
|
2021-08-28 13:12:10 +00:00
|
|
|
{VIRTKEY_AXIS_X_MIN, JOYSTICK_AXIS_X, -1},
|
|
|
|
{VIRTKEY_AXIS_X_MAX, JOYSTICK_AXIS_X, +1},
|
|
|
|
{VIRTKEY_AXIS_Y_MIN, JOYSTICK_AXIS_Y, -1},
|
|
|
|
{VIRTKEY_AXIS_Y_MAX, JOYSTICK_AXIS_Y, +1},
|
|
|
|
{CTRL_CROSS , NKCODE_BUTTON_A},
|
|
|
|
{CTRL_CIRCLE , NKCODE_BUTTON_B},
|
|
|
|
{CTRL_SQUARE , NKCODE_BUTTON_X},
|
|
|
|
{CTRL_TRIANGLE , NKCODE_BUTTON_Y},
|
|
|
|
{CTRL_UP , NKCODE_DPAD_UP},
|
|
|
|
{CTRL_RIGHT , NKCODE_DPAD_RIGHT},
|
|
|
|
{CTRL_DOWN , NKCODE_DPAD_DOWN},
|
|
|
|
{CTRL_LEFT , NKCODE_DPAD_LEFT},
|
|
|
|
{CTRL_START , NKCODE_BUTTON_START},
|
|
|
|
{CTRL_SELECT , NKCODE_BUTTON_SELECT},
|
|
|
|
{CTRL_LTRIGGER , NKCODE_BUTTON_L1},
|
|
|
|
{CTRL_RTRIGGER , NKCODE_BUTTON_R1},
|
|
|
|
{VIRTKEY_FASTFORWARD , JOYSTICK_AXIS_RTRIGGER, +1},
|
|
|
|
{VIRTKEY_SPEED_TOGGLE, NKCODE_BUTTON_THUMBR},
|
|
|
|
{VIRTKEY_PAUSE , JOYSTICK_AXIS_LTRIGGER, +1},
|
|
|
|
{VIRTKEY_PAUSE, NKCODE_HOME},
|
2022-11-23 11:42:44 +00:00
|
|
|
{VIRTKEY_FASTFORWARD , JOYSTICK_AXIS_GAS, +1},
|
|
|
|
{VIRTKEY_PAUSE , JOYSTICK_AXIS_BRAKE, +1},
|
2021-08-28 13:12:10 +00:00
|
|
|
};
|
|
|
|
|
2021-08-28 13:38:03 +00:00
|
|
|
static const DefMappingStruct defaultShieldKeyMap[] = {
|
2021-08-28 13:12:10 +00:00
|
|
|
{CTRL_CROSS, NKCODE_BUTTON_A},
|
|
|
|
{CTRL_CIRCLE ,NKCODE_BUTTON_B},
|
|
|
|
{CTRL_SQUARE ,NKCODE_BUTTON_X},
|
|
|
|
{CTRL_TRIANGLE ,NKCODE_BUTTON_Y},
|
|
|
|
{CTRL_START, NKCODE_BUTTON_START},
|
|
|
|
{CTRL_SELECT, JOYSTICK_AXIS_LTRIGGER, +1},
|
|
|
|
{CTRL_LTRIGGER, NKCODE_BUTTON_L1},
|
|
|
|
{CTRL_RTRIGGER, NKCODE_BUTTON_R1},
|
|
|
|
{VIRTKEY_AXIS_X_MIN, JOYSTICK_AXIS_X, -1},
|
|
|
|
{VIRTKEY_AXIS_X_MAX, JOYSTICK_AXIS_X, +1},
|
|
|
|
{VIRTKEY_AXIS_Y_MIN, JOYSTICK_AXIS_Y, +1},
|
|
|
|
{VIRTKEY_AXIS_Y_MAX, JOYSTICK_AXIS_Y, -1},
|
|
|
|
{CTRL_LEFT, JOYSTICK_AXIS_HAT_X, -1},
|
|
|
|
{CTRL_RIGHT, JOYSTICK_AXIS_HAT_X, +1},
|
|
|
|
{CTRL_UP, JOYSTICK_AXIS_HAT_Y, -1},
|
|
|
|
{CTRL_DOWN, JOYSTICK_AXIS_HAT_Y, +1},
|
|
|
|
{VIRTKEY_FASTFORWARD, JOYSTICK_AXIS_RTRIGGER, +1 },
|
|
|
|
{VIRTKEY_PAUSE, NKCODE_BACK },
|
|
|
|
};
|
|
|
|
|
2021-08-28 13:38:03 +00:00
|
|
|
static const DefMappingStruct defaultMOQI7SKeyMap[] = {
|
2021-08-28 13:12:10 +00:00
|
|
|
{CTRL_CROSS, NKCODE_BUTTON_A},
|
|
|
|
{CTRL_CIRCLE, NKCODE_BUTTON_B},
|
|
|
|
{CTRL_SQUARE, NKCODE_BUTTON_X},
|
|
|
|
{CTRL_TRIANGLE, NKCODE_BUTTON_Y},
|
|
|
|
{CTRL_START, JOYSTICK_AXIS_Z, +1},
|
|
|
|
{CTRL_SELECT, JOYSTICK_AXIS_Z, -1},
|
|
|
|
{CTRL_LTRIGGER, NKCODE_BUTTON_L1},
|
|
|
|
{CTRL_RTRIGGER, NKCODE_BUTTON_R1},
|
|
|
|
{VIRTKEY_AXIS_X_MIN, JOYSTICK_AXIS_X, -1},
|
|
|
|
{VIRTKEY_AXIS_X_MAX, JOYSTICK_AXIS_X, +1},
|
|
|
|
{VIRTKEY_AXIS_Y_MIN, JOYSTICK_AXIS_Y, +1},
|
|
|
|
{VIRTKEY_AXIS_Y_MAX, JOYSTICK_AXIS_Y, -1},
|
|
|
|
{CTRL_LEFT, JOYSTICK_AXIS_HAT_X, -1},
|
|
|
|
{CTRL_RIGHT, JOYSTICK_AXIS_HAT_X, +1},
|
|
|
|
{CTRL_UP, JOYSTICK_AXIS_HAT_Y, -1},
|
|
|
|
{CTRL_DOWN, JOYSTICK_AXIS_HAT_Y, +1},
|
|
|
|
{VIRTKEY_FASTFORWARD, JOYSTICK_AXIS_RZ, +1 },
|
|
|
|
{VIRTKEY_PAUSE, NKCODE_BACK },
|
|
|
|
};
|
|
|
|
|
2021-08-28 13:38:03 +00:00
|
|
|
static const DefMappingStruct defaultAndroidXboxControllerMap[] = {
|
2021-08-28 13:12:10 +00:00
|
|
|
{CTRL_CROSS , NKCODE_BUTTON_A},
|
|
|
|
{CTRL_CIRCLE , NKCODE_BUTTON_B},
|
|
|
|
{CTRL_SQUARE , NKCODE_BUTTON_X},
|
|
|
|
{CTRL_TRIANGLE , NKCODE_BUTTON_Y},
|
|
|
|
// The hat for DPAD is standard for bluetooth pads, which is the most likely pads on Android I think.
|
|
|
|
{CTRL_LEFT , NKCODE_DPAD_LEFT},
|
|
|
|
{CTRL_RIGHT , NKCODE_DPAD_RIGHT},
|
|
|
|
{CTRL_UP , NKCODE_DPAD_UP},
|
|
|
|
{CTRL_DOWN , NKCODE_DPAD_DOWN},
|
|
|
|
{CTRL_START , NKCODE_BUTTON_START},
|
|
|
|
{CTRL_SELECT , NKCODE_BACK},
|
|
|
|
{CTRL_LTRIGGER , NKCODE_BUTTON_L1},
|
|
|
|
{CTRL_RTRIGGER , NKCODE_BUTTON_R1},
|
2021-08-28 18:06:05 +00:00
|
|
|
{VIRTKEY_FASTFORWARD , JOYSTICK_AXIS_RTRIGGER, +1},
|
2021-08-28 13:12:10 +00:00
|
|
|
{VIRTKEY_PAUSE , JOYSTICK_AXIS_LTRIGGER, +1},
|
2022-11-23 11:42:44 +00:00
|
|
|
{VIRTKEY_FASTFORWARD , JOYSTICK_AXIS_GAS, +1},
|
|
|
|
{VIRTKEY_PAUSE , JOYSTICK_AXIS_BRAKE, +1},
|
2021-08-28 13:12:10 +00:00
|
|
|
{VIRTKEY_AXIS_X_MIN, JOYSTICK_AXIS_X, -1},
|
|
|
|
{VIRTKEY_AXIS_X_MAX, JOYSTICK_AXIS_X, +1},
|
|
|
|
{VIRTKEY_AXIS_Y_MIN, JOYSTICK_AXIS_Y, +1},
|
|
|
|
{VIRTKEY_AXIS_Y_MAX, JOYSTICK_AXIS_Y, -1},
|
2021-08-28 13:38:03 +00:00
|
|
|
};
|
|
|
|
|
2022-04-30 17:23:12 +00:00
|
|
|
// Retroid reports its controller as "Retro Station Controller".
|
|
|
|
// It's very similar to the Android Xbox mapping, just with main buttons swapped around.
|
2024-10-23 11:21:41 +00:00
|
|
|
static const DefMappingStruct defaultRetroidControllerMap[] = {
|
2022-04-30 17:23:12 +00:00
|
|
|
{CTRL_CROSS , NKCODE_BUTTON_B},
|
|
|
|
{CTRL_CIRCLE , NKCODE_BUTTON_A},
|
|
|
|
{CTRL_SQUARE , NKCODE_BUTTON_Y},
|
|
|
|
{CTRL_TRIANGLE , NKCODE_BUTTON_X},
|
2024-10-23 11:21:41 +00:00
|
|
|
{CTRL_LEFT , JOYSTICK_AXIS_HAT_X, -1},
|
2022-04-30 17:23:12 +00:00
|
|
|
{CTRL_LEFT , NKCODE_DPAD_LEFT},
|
2024-10-23 11:21:41 +00:00
|
|
|
{CTRL_RIGHT , JOYSTICK_AXIS_HAT_X, +1},
|
2022-04-30 17:23:12 +00:00
|
|
|
{CTRL_RIGHT , NKCODE_DPAD_RIGHT},
|
2024-10-23 11:21:41 +00:00
|
|
|
{CTRL_UP , JOYSTICK_AXIS_HAT_Y, -1},
|
2022-04-30 17:23:12 +00:00
|
|
|
{CTRL_UP , NKCODE_DPAD_UP},
|
2024-10-23 11:21:41 +00:00
|
|
|
{CTRL_DOWN , JOYSTICK_AXIS_HAT_Y, +1},
|
2022-04-30 17:23:12 +00:00
|
|
|
{CTRL_DOWN , NKCODE_DPAD_DOWN},
|
|
|
|
{CTRL_START , NKCODE_BUTTON_START},
|
2024-10-23 11:21:41 +00:00
|
|
|
{CTRL_SELECT , NKCODE_BUTTON_SELECT},
|
2022-04-30 17:23:12 +00:00
|
|
|
{CTRL_LTRIGGER , NKCODE_BUTTON_L1},
|
|
|
|
{CTRL_RTRIGGER , NKCODE_BUTTON_R1},
|
2024-10-23 11:21:41 +00:00
|
|
|
{VIRTKEY_FASTFORWARD , NKCODE_BUTTON_R2},
|
2022-04-30 17:23:12 +00:00
|
|
|
{VIRTKEY_FASTFORWARD , JOYSTICK_AXIS_RTRIGGER, +1},
|
2024-10-23 11:21:41 +00:00
|
|
|
{VIRTKEY_PAUSE , NKCODE_BUTTON_L2},
|
2022-04-30 17:23:12 +00:00
|
|
|
{VIRTKEY_PAUSE , JOYSTICK_AXIS_LTRIGGER, +1},
|
|
|
|
{VIRTKEY_AXIS_X_MIN, JOYSTICK_AXIS_X, -1},
|
|
|
|
{VIRTKEY_AXIS_X_MAX, JOYSTICK_AXIS_X, +1},
|
|
|
|
{VIRTKEY_AXIS_Y_MIN, JOYSTICK_AXIS_Y, +1},
|
|
|
|
{VIRTKEY_AXIS_Y_MAX, JOYSTICK_AXIS_Y, -1},
|
|
|
|
};
|
|
|
|
|
2021-08-28 13:38:03 +00:00
|
|
|
static const DefMappingStruct defaultPadMapAndroid[] = {
|
|
|
|
{CTRL_CROSS , NKCODE_BUTTON_A},
|
|
|
|
{CTRL_CIRCLE , NKCODE_BUTTON_B},
|
|
|
|
{CTRL_SQUARE , NKCODE_BUTTON_X},
|
|
|
|
{CTRL_TRIANGLE , NKCODE_BUTTON_Y},
|
|
|
|
// The hat for DPAD is standard for bluetooth pads, which is the most likely pads on Android I think.
|
|
|
|
{CTRL_LEFT , JOYSTICK_AXIS_HAT_X, -1},
|
|
|
|
{CTRL_LEFT , NKCODE_DPAD_LEFT},
|
|
|
|
{CTRL_RIGHT , JOYSTICK_AXIS_HAT_X, +1},
|
|
|
|
{CTRL_RIGHT , NKCODE_DPAD_RIGHT},
|
|
|
|
{CTRL_UP , JOYSTICK_AXIS_HAT_Y, -1},
|
|
|
|
{CTRL_UP , NKCODE_DPAD_UP},
|
|
|
|
{CTRL_DOWN , JOYSTICK_AXIS_HAT_Y, +1},
|
|
|
|
{CTRL_DOWN , NKCODE_DPAD_DOWN},
|
2021-08-28 18:06:05 +00:00
|
|
|
|
2021-08-28 13:38:03 +00:00
|
|
|
{CTRL_START , NKCODE_BUTTON_START},
|
|
|
|
{CTRL_SELECT , NKCODE_BUTTON_SELECT},
|
|
|
|
{CTRL_LTRIGGER , NKCODE_BUTTON_L1},
|
|
|
|
{CTRL_RTRIGGER , NKCODE_BUTTON_R1},
|
2021-08-28 18:06:05 +00:00
|
|
|
{VIRTKEY_FASTFORWARD , JOYSTICK_AXIS_RTRIGGER, +1},
|
2021-08-28 13:38:03 +00:00
|
|
|
{VIRTKEY_FASTFORWARD , NKCODE_BUTTON_R2},
|
|
|
|
{VIRTKEY_PAUSE , JOYSTICK_AXIS_LTRIGGER, +1},
|
2021-08-28 18:06:05 +00:00
|
|
|
{VIRTKEY_PAUSE , NKCODE_BUTTON_L2 },
|
2022-11-23 11:42:44 +00:00
|
|
|
{VIRTKEY_FASTFORWARD , JOYSTICK_AXIS_GAS, +1},
|
|
|
|
{VIRTKEY_PAUSE , JOYSTICK_AXIS_BRAKE, +1},
|
2021-08-28 13:38:03 +00:00
|
|
|
{VIRTKEY_AXIS_X_MIN, JOYSTICK_AXIS_X, -1},
|
|
|
|
{VIRTKEY_AXIS_X_MAX, JOYSTICK_AXIS_X, +1},
|
|
|
|
{VIRTKEY_AXIS_Y_MIN, JOYSTICK_AXIS_Y, +1},
|
|
|
|
{VIRTKEY_AXIS_Y_MAX, JOYSTICK_AXIS_Y, -1},
|
|
|
|
};
|
|
|
|
|
|
|
|
static const DefMappingStruct defaultPadMap[] = {
|
2021-08-28 13:12:10 +00:00
|
|
|
{CTRL_CROSS , NKCODE_BUTTON_2},
|
|
|
|
{CTRL_CIRCLE , NKCODE_BUTTON_3},
|
|
|
|
{CTRL_SQUARE , NKCODE_BUTTON_4},
|
|
|
|
{CTRL_TRIANGLE , NKCODE_BUTTON_1},
|
|
|
|
{CTRL_UP , NKCODE_DPAD_UP},
|
|
|
|
{CTRL_RIGHT , NKCODE_DPAD_RIGHT},
|
|
|
|
{CTRL_DOWN , NKCODE_DPAD_DOWN},
|
|
|
|
{CTRL_LEFT , NKCODE_DPAD_LEFT},
|
|
|
|
{CTRL_START , NKCODE_BUTTON_10},
|
|
|
|
{CTRL_SELECT , NKCODE_BUTTON_9},
|
|
|
|
{CTRL_LTRIGGER , NKCODE_BUTTON_7},
|
|
|
|
{CTRL_RTRIGGER , NKCODE_BUTTON_8},
|
|
|
|
{VIRTKEY_AXIS_X_MIN, JOYSTICK_AXIS_X, -1},
|
|
|
|
{VIRTKEY_AXIS_X_MAX, JOYSTICK_AXIS_X, +1},
|
|
|
|
{VIRTKEY_AXIS_Y_MIN, JOYSTICK_AXIS_Y, +1},
|
|
|
|
{VIRTKEY_AXIS_Y_MAX, JOYSTICK_AXIS_Y, -1},
|
2021-08-28 18:17:58 +00:00
|
|
|
{VIRTKEY_PAUSE , NKCODE_BUTTON_SELECT },
|
2021-08-28 18:06:05 +00:00
|
|
|
{VIRTKEY_PAUSE , NKCODE_BUTTON_L2 },
|
2021-08-28 13:12:10 +00:00
|
|
|
};
|
|
|
|
|
2024-05-26 09:11:45 +00:00
|
|
|
static const DefMappingStruct defaultPadMapIOS[] = {
|
|
|
|
{CTRL_CROSS , NKCODE_BUTTON_2},
|
|
|
|
{CTRL_CIRCLE , NKCODE_BUTTON_3},
|
|
|
|
{CTRL_SQUARE , NKCODE_BUTTON_4},
|
|
|
|
{CTRL_TRIANGLE , NKCODE_BUTTON_1},
|
|
|
|
{CTRL_UP , NKCODE_DPAD_UP},
|
|
|
|
{CTRL_RIGHT , NKCODE_DPAD_RIGHT},
|
|
|
|
{CTRL_DOWN , NKCODE_DPAD_DOWN},
|
|
|
|
{CTRL_LEFT , NKCODE_DPAD_LEFT},
|
|
|
|
{CTRL_START , NKCODE_BUTTON_START},
|
|
|
|
{CTRL_SELECT , NKCODE_BUTTON_SELECT},
|
|
|
|
{CTRL_LTRIGGER , NKCODE_BUTTON_L1},
|
|
|
|
{CTRL_RTRIGGER , NKCODE_BUTTON_R1},
|
|
|
|
{VIRTKEY_AXIS_X_MIN, JOYSTICK_AXIS_X, -1},
|
|
|
|
{VIRTKEY_AXIS_X_MAX, JOYSTICK_AXIS_X, +1},
|
|
|
|
{VIRTKEY_AXIS_Y_MIN, JOYSTICK_AXIS_Y, +1},
|
|
|
|
{VIRTKEY_AXIS_Y_MAX, JOYSTICK_AXIS_Y, -1},
|
|
|
|
{VIRTKEY_PAUSE , NKCODE_BUTTON_THUMBL },
|
|
|
|
{VIRTKEY_FASTFORWARD , JOYSTICK_AXIS_RTRIGGER, +1},
|
|
|
|
};
|
|
|
|
|
2021-08-28 13:38:03 +00:00
|
|
|
static const DefMappingStruct defaultOuyaMap[] = {
|
2021-08-28 13:12:10 +00:00
|
|
|
{CTRL_CROSS , NKCODE_BUTTON_A},
|
|
|
|
{CTRL_CIRCLE , NKCODE_BUTTON_B},
|
|
|
|
{CTRL_SQUARE , NKCODE_BUTTON_X},
|
|
|
|
{CTRL_TRIANGLE , NKCODE_BUTTON_Y},
|
|
|
|
{CTRL_UP , NKCODE_DPAD_UP},
|
|
|
|
{CTRL_RIGHT , NKCODE_DPAD_RIGHT},
|
|
|
|
{CTRL_DOWN , NKCODE_DPAD_DOWN},
|
|
|
|
{CTRL_LEFT , NKCODE_DPAD_LEFT},
|
|
|
|
{CTRL_START , NKCODE_BUTTON_R2},
|
|
|
|
{CTRL_SELECT , NKCODE_BUTTON_L2},
|
|
|
|
{CTRL_LTRIGGER , NKCODE_BUTTON_L1},
|
|
|
|
{CTRL_RTRIGGER , NKCODE_BUTTON_R1},
|
|
|
|
{VIRTKEY_FASTFORWARD , NKCODE_BUTTON_THUMBL},
|
|
|
|
{VIRTKEY_PAUSE , NKCODE_BUTTON_THUMBR},
|
|
|
|
{VIRTKEY_AXIS_X_MIN, JOYSTICK_AXIS_X, -1},
|
|
|
|
{VIRTKEY_AXIS_X_MAX, JOYSTICK_AXIS_X, +1},
|
|
|
|
{VIRTKEY_AXIS_Y_MIN, JOYSTICK_AXIS_Y, +1},
|
|
|
|
{VIRTKEY_AXIS_Y_MAX, JOYSTICK_AXIS_Y, -1},
|
|
|
|
};
|
|
|
|
|
2021-08-28 13:38:03 +00:00
|
|
|
static const DefMappingStruct defaultXperiaPlay[] = {
|
2021-08-28 13:12:10 +00:00
|
|
|
{CTRL_CROSS , NKCODE_BUTTON_CROSS},
|
|
|
|
{CTRL_CIRCLE , NKCODE_BUTTON_CIRCLE},
|
|
|
|
{CTRL_SQUARE , NKCODE_BUTTON_X},
|
|
|
|
{CTRL_TRIANGLE , NKCODE_BUTTON_Y},
|
|
|
|
{CTRL_UP , NKCODE_DPAD_UP},
|
|
|
|
{CTRL_RIGHT , NKCODE_DPAD_RIGHT},
|
|
|
|
{CTRL_DOWN , NKCODE_DPAD_DOWN},
|
|
|
|
{CTRL_LEFT , NKCODE_DPAD_LEFT},
|
|
|
|
{CTRL_START , NKCODE_BUTTON_START},
|
|
|
|
{CTRL_SELECT , NKCODE_BUTTON_SELECT},
|
|
|
|
{CTRL_LTRIGGER , NKCODE_BUTTON_L1},
|
|
|
|
{CTRL_RTRIGGER , NKCODE_BUTTON_R1},
|
|
|
|
{VIRTKEY_AXIS_X_MIN, JOYSTICK_AXIS_X, -1},
|
|
|
|
{VIRTKEY_AXIS_X_MAX, JOYSTICK_AXIS_X, +1},
|
|
|
|
{VIRTKEY_AXIS_Y_MIN, JOYSTICK_AXIS_Y, -1},
|
|
|
|
{VIRTKEY_AXIS_Y_MAX, JOYSTICK_AXIS_Y, +1},
|
|
|
|
};
|
|
|
|
|
2022-07-24 13:38:30 +00:00
|
|
|
static const DefMappingStruct defaultVRLeftController[] = {
|
|
|
|
{CTRL_UP , NKCODE_DPAD_UP},
|
|
|
|
{CTRL_DOWN , NKCODE_DPAD_DOWN},
|
|
|
|
{CTRL_LEFT , NKCODE_DPAD_LEFT},
|
|
|
|
{CTRL_RIGHT , NKCODE_DPAD_RIGHT},
|
|
|
|
{CTRL_SELECT , NKCODE_BUTTON_THUMBL},
|
|
|
|
{CTRL_LTRIGGER , NKCODE_BUTTON_X},
|
|
|
|
{CTRL_RTRIGGER , NKCODE_BUTTON_Y},
|
2022-08-15 14:53:00 +00:00
|
|
|
{CTRL_SCREEN , NKCODE_ALT_LEFT},
|
2022-07-24 13:38:30 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static const DefMappingStruct defaultVRRightController[] = {
|
|
|
|
{CTRL_CIRCLE , NKCODE_ALT_RIGHT},
|
|
|
|
{CTRL_CROSS , NKCODE_ENTER},
|
|
|
|
{CTRL_SQUARE , NKCODE_BUTTON_B},
|
|
|
|
{CTRL_TRIANGLE , NKCODE_BUTTON_A},
|
|
|
|
{CTRL_START , NKCODE_BUTTON_THUMBR},
|
|
|
|
{VIRTKEY_AXIS_Y_MAX, NKCODE_DPAD_UP},
|
|
|
|
{VIRTKEY_AXIS_Y_MIN, NKCODE_DPAD_DOWN},
|
|
|
|
{VIRTKEY_AXIS_X_MIN, NKCODE_DPAD_LEFT},
|
|
|
|
{VIRTKEY_AXIS_X_MAX, NKCODE_DPAD_RIGHT},
|
|
|
|
};
|
|
|
|
|
2023-05-26 16:40:13 +00:00
|
|
|
static void SetDefaultKeyMap(InputDeviceID deviceId, const DefMappingStruct *array, size_t count, bool replace) {
|
2021-08-28 13:12:10 +00:00
|
|
|
for (size_t i = 0; i < count; i++) {
|
|
|
|
if (array[i].direction == 0)
|
2023-03-31 22:12:14 +00:00
|
|
|
SetInputMapping(array[i].pspKey, MultiInputMapping(InputMapping(deviceId, array[i].keyOrAxis)), replace);
|
2021-08-28 13:12:10 +00:00
|
|
|
else
|
2023-03-31 22:12:14 +00:00
|
|
|
SetInputMapping(array[i].pspKey, MultiInputMapping(InputMapping(deviceId, array[i].keyOrAxis, array[i].direction)), replace);
|
2021-08-28 13:12:10 +00:00
|
|
|
}
|
|
|
|
g_seenDeviceIds.insert(deviceId);
|
|
|
|
}
|
|
|
|
|
|
|
|
void SetDefaultKeyMap(DefaultMaps dmap, bool replace) {
|
|
|
|
switch (dmap) {
|
|
|
|
case DEFAULT_MAPPING_KEYBOARD:
|
|
|
|
{
|
2024-05-03 15:54:57 +00:00
|
|
|
int keyboardLayout = (int)System_GetPropertyInt(SYSPROP_KEYBOARD_LAYOUT);
|
2022-01-10 00:11:08 +00:00
|
|
|
switch (keyboardLayout) {
|
|
|
|
case KEYBOARD_LAYOUT_QWERTZ:
|
|
|
|
SetDefaultKeyMap(DEVICE_ID_KEYBOARD, defaultQwertzKeyboardKeyMap, ARRAY_SIZE(defaultQwertzKeyboardKeyMap), replace);
|
2021-08-28 13:12:10 +00:00
|
|
|
break;
|
2022-01-10 00:11:08 +00:00
|
|
|
case KEYBOARD_LAYOUT_AZERTY:
|
|
|
|
SetDefaultKeyMap(DEVICE_ID_KEYBOARD, defaultAzertyKeyboardKeyMap, ARRAY_SIZE(defaultAzertyKeyboardKeyMap), replace);
|
2021-08-28 13:12:10 +00:00
|
|
|
break;
|
2022-01-10 00:11:08 +00:00
|
|
|
case KEYBOARD_LAYOUT_QWERTY:
|
2021-08-28 13:12:10 +00:00
|
|
|
default:
|
|
|
|
SetDefaultKeyMap(DEVICE_ID_KEYBOARD, defaultQwertyKeyboardKeyMap, ARRAY_SIZE(defaultQwertyKeyboardKeyMap), replace);
|
2022-01-10 00:11:08 +00:00
|
|
|
break;
|
2021-08-28 13:12:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2021-08-28 13:38:03 +00:00
|
|
|
case DEFAULT_MAPPING_XINPUT:
|
|
|
|
SetDefaultKeyMap(DEVICE_ID_XINPUT_0, defaultXInputKeyMap, ARRAY_SIZE(defaultXInputKeyMap), replace);
|
2021-08-28 13:12:10 +00:00
|
|
|
break;
|
|
|
|
case DEFAULT_MAPPING_SHIELD:
|
|
|
|
SetDefaultKeyMap(DEVICE_ID_PAD_0, defaultShieldKeyMap, ARRAY_SIZE(defaultShieldKeyMap), replace);
|
|
|
|
break;
|
|
|
|
case DEFAULT_MAPPING_MOQI_I7S:
|
|
|
|
SetDefaultKeyMap(DEVICE_ID_PAD_0, defaultMOQI7SKeyMap, ARRAY_SIZE(defaultMOQI7SKeyMap), replace);
|
|
|
|
break;
|
|
|
|
case DEFAULT_MAPPING_PAD:
|
|
|
|
SetDefaultKeyMap(DEVICE_ID_PAD_0, defaultPadMap, ARRAY_SIZE(defaultPadMap), replace);
|
|
|
|
break;
|
2021-08-28 13:38:03 +00:00
|
|
|
case DEFAULT_MAPPING_ANDROID_PAD:
|
|
|
|
SetDefaultKeyMap(DEVICE_ID_PAD_0, defaultPadMapAndroid, ARRAY_SIZE(defaultPadMapAndroid), replace);
|
|
|
|
break;
|
2024-05-26 09:11:45 +00:00
|
|
|
case DEFAULT_MAPPING_IOS_PAD:
|
|
|
|
SetDefaultKeyMap(DEVICE_ID_PAD_0, defaultPadMapIOS, ARRAY_SIZE(defaultPadMapIOS), replace);
|
|
|
|
break;
|
2021-08-28 13:12:10 +00:00
|
|
|
case DEFAULT_MAPPING_OUYA:
|
|
|
|
SetDefaultKeyMap(DEVICE_ID_PAD_0, defaultOuyaMap, ARRAY_SIZE(defaultOuyaMap), replace);
|
|
|
|
break;
|
|
|
|
case DEFAULT_MAPPING_XPERIA_PLAY:
|
|
|
|
SetDefaultKeyMap(DEVICE_ID_DEFAULT, defaultXperiaPlay, ARRAY_SIZE(defaultXperiaPlay), replace);
|
|
|
|
break;
|
2021-08-28 13:38:03 +00:00
|
|
|
case DEFAULT_MAPPING_ANDROID_XBOX:
|
|
|
|
SetDefaultKeyMap(DEVICE_ID_PAD_0, defaultAndroidXboxControllerMap, ARRAY_SIZE(defaultAndroidXboxControllerMap), replace);
|
|
|
|
break;
|
2024-10-23 11:21:41 +00:00
|
|
|
case DEFAULT_MAPPING_RETROID_CONTROLLER:
|
|
|
|
SetDefaultKeyMap(DEVICE_ID_PAD_0, defaultRetroidControllerMap, ARRAY_SIZE(defaultRetroidControllerMap), replace);
|
2022-04-30 17:23:12 +00:00
|
|
|
break;
|
2022-07-24 13:38:30 +00:00
|
|
|
case DEFAULT_MAPPING_VR_HEADSET:
|
|
|
|
SetDefaultKeyMap(DEVICE_ID_XR_CONTROLLER_LEFT, defaultVRLeftController, ARRAY_SIZE(defaultVRLeftController), replace);
|
|
|
|
SetDefaultKeyMap(DEVICE_ID_XR_CONTROLLER_RIGHT, defaultVRRightController, ARRAY_SIZE(defaultVRRightController), replace);
|
|
|
|
break;
|
2021-08-28 13:12:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
UpdateNativeMenuKeys();
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace KeyMap
|