mirror of
https://github.com/glfw/glfw.git
synced 2024-11-11 04:53:50 +00:00
Remaps indices of buttons below the previous minimum
This prevents us from missing their inputs, while also maintaining backwards compatibility with previous indices
This commit is contained in:
parent
5e1ec2444f
commit
6836e650bc
@ -49,9 +49,8 @@
|
||||
//
|
||||
static void handleKeyEvent(_GLFWjoystick* js, int code, int value)
|
||||
{
|
||||
if (code < BTN_MISC || code >= KEY_CNT - BTN_MISC) return;
|
||||
_glfwInputJoystickButton(js,
|
||||
js->linjs.keyMap[code - BTN_MISC],
|
||||
js->linjs.keyMap[code],
|
||||
value ? GLFW_PRESS : GLFW_RELEASE);
|
||||
}
|
||||
|
||||
@ -59,7 +58,6 @@ static void handleKeyEvent(_GLFWjoystick* js, int code, int value)
|
||||
//
|
||||
static void handleAbsEvent(_GLFWjoystick* js, int code, int value)
|
||||
{
|
||||
if (code >= ABS_CNT) return;
|
||||
const int index = js->linjs.absMap[code];
|
||||
|
||||
if (code >= ABS_HAT0X && code <= ABS_HAT3Y)
|
||||
@ -197,7 +195,16 @@ static GLFWbool openJoystickDevice(const char* path)
|
||||
if (!isBitSet(code, keyBits))
|
||||
continue;
|
||||
|
||||
linjs.keyMap[code - BTN_MISC] = buttonCount;
|
||||
linjs.keyMap[code] = buttonCount;
|
||||
buttonCount++;
|
||||
}
|
||||
|
||||
for (int code = 0; code < BTN_MISC; code++)
|
||||
{
|
||||
if (!isBitSet(code, keyBits))
|
||||
continue;
|
||||
|
||||
linjs.keyMap[code] = buttonCount;
|
||||
buttonCount++;
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,7 @@ typedef struct _GLFWjoystickLinux
|
||||
{
|
||||
int fd;
|
||||
char path[PATH_MAX];
|
||||
int keyMap[KEY_CNT - BTN_MISC];
|
||||
int keyMap[KEY_CNT];
|
||||
int absMap[ABS_CNT];
|
||||
struct input_absinfo absInfo[ABS_CNT];
|
||||
int hats[4][2];
|
||||
|
Loading…
Reference in New Issue
Block a user