mirror of
https://github.com/hrydgard/ppsspp.git
synced 2024-11-26 23:10:38 +00:00
Fix stickiness of NV Shield d-pad (and other digital pads that are mapped to axises)
This commit is contained in:
parent
90d6c0cd5e
commit
8972bf0d12
@ -81,6 +81,32 @@ struct DefaultKeyMap {
|
||||
return m;
|
||||
}
|
||||
|
||||
// Not used yet, will autodetect later
|
||||
static KeyMapping defaultShieldMap()
|
||||
{
|
||||
KeyMapping m;
|
||||
m[KeyDef(DEVICE_ID_X360_0, KEYCODE_BUTTON_A)] = CTRL_CROSS;
|
||||
m[KeyDef(DEVICE_ID_X360_0, KEYCODE_BUTTON_B)] = CTRL_CIRCLE;
|
||||
m[KeyDef(DEVICE_ID_X360_0, KEYCODE_BUTTON_X)] = CTRL_SQUARE;
|
||||
m[KeyDef(DEVICE_ID_X360_0, KEYCODE_BUTTON_Y)] = CTRL_TRIANGLE;
|
||||
m[KeyDef(DEVICE_ID_X360_0, KEYCODE_BUTTON_START)] = CTRL_START;
|
||||
m[KeyDef(DEVICE_ID_X360_0, KEYCODE_BUTTON_SELECT)] = CTRL_SELECT;
|
||||
m[KeyDef(DEVICE_ID_X360_0, KEYCODE_BUTTON_L1)] = CTRL_LTRIGGER;
|
||||
m[KeyDef(DEVICE_ID_X360_0, KEYCODE_BUTTON_R1)] = CTRL_RTRIGGER;
|
||||
m[KeyDef(DEVICE_ID_X360_0, KEYCODE_BUTTON_R2)] = VIRTKEY_UNTHROTTLE;
|
||||
m[KeyDef(DEVICE_ID_X360_0, KEYCODE_BUTTON_THUMBR)] = VIRTKEY_PAUSE;
|
||||
m[KeyDef(DEVICE_ID_X360_0, KEYCODE_BUTTON_L2)] = VIRTKEY_SPEED_TOGGLE;
|
||||
m[AxisDef(DEVICE_ID_X360_0, JOYSTICK_AXIS_X, -1)] = VIRTKEY_AXIS_X_MIN;
|
||||
m[AxisDef(DEVICE_ID_X360_0, JOYSTICK_AXIS_X, +1)] = VIRTKEY_AXIS_X_MAX;
|
||||
m[AxisDef(DEVICE_ID_X360_0, JOYSTICK_AXIS_Y, -1)] = VIRTKEY_AXIS_Y_MIN;
|
||||
m[AxisDef(DEVICE_ID_X360_0, JOYSTICK_AXIS_Y, +1)] = VIRTKEY_AXIS_Y_MAX;
|
||||
m[AxisDef(DEVICE_ID_X360_0, JOYSTICK_AXIS_HAT_X, -1)] = CTRL_LEFT;
|
||||
m[AxisDef(DEVICE_ID_X360_0, JOYSTICK_AXIS_HAT_X, +1)] = CTRL_RIGHT;
|
||||
m[AxisDef(DEVICE_ID_X360_0, JOYSTICK_AXIS_HAT_Y, -1)] = CTRL_UP;
|
||||
m[AxisDef(DEVICE_ID_X360_0, JOYSTICK_AXIS_HAT_Y, +1)] = CTRL_DOWN;
|
||||
return m;
|
||||
}
|
||||
|
||||
static KeyMapping defaultPadMap()
|
||||
{
|
||||
KeyMapping m;
|
||||
|
@ -323,6 +323,7 @@ void EmuScreen::pspKey(int pspKeyCode, int flags) {
|
||||
onVKeyUp(pspKeyCode);
|
||||
}
|
||||
} else {
|
||||
ILOG("pspKey %i %i", pspKeyCode, flags);
|
||||
if (flags & KEY_DOWN)
|
||||
__CtrlButtonDown(pspKeyCode);
|
||||
if (flags & KEY_UP)
|
||||
@ -331,7 +332,21 @@ void EmuScreen::pspKey(int pspKeyCode, int flags) {
|
||||
}
|
||||
|
||||
void EmuScreen::axis(const AxisInput &axis) {
|
||||
int result = KeyMap::AxisToPspButton(axis.deviceId, axis.axisId, axis.value >= 0 ? 1 : -1);
|
||||
if (axis.value > 0) {
|
||||
processAxis(axis, 1);
|
||||
} else if (axis.value < 0) {
|
||||
processAxis(axis, -1);
|
||||
} else if (axis.value == 0) {
|
||||
// Both directions! Prevents sticking for digital input devices that are axises (like HAT)
|
||||
processAxis(axis, 1);
|
||||
processAxis(axis, -1);
|
||||
}
|
||||
}
|
||||
|
||||
void EmuScreen::processAxis(const AxisInput &axis, int direction) {
|
||||
// ILOG("axis: %i %i %f", axis.deviceId, axis.axisId, axis.value);
|
||||
|
||||
int result = KeyMap::AxisToPspButton(axis.deviceId, axis.axisId, direction);
|
||||
if (result == KEYMAP_ERROR_UNKNOWN_KEY)
|
||||
return;
|
||||
|
||||
|
@ -24,6 +24,8 @@
|
||||
#include "ui/ui_screen.h"
|
||||
#include "Common/KeyMap.h"
|
||||
|
||||
struct AxisInput;
|
||||
|
||||
class EmuScreen : public UIScreen
|
||||
{
|
||||
public:
|
||||
@ -45,6 +47,7 @@ protected:
|
||||
|
||||
private:
|
||||
void bootGame(const std::string &filename);
|
||||
void processAxis(const AxisInput &axis, int direction);
|
||||
|
||||
void pspKey(int pspKeyCode, int flags);
|
||||
void onVKeyDown(int virtualKeyCode);
|
||||
|
Loading…
Reference in New Issue
Block a user