mirror of
https://github.com/glfw/glfw.git
synced 2024-11-26 12:02:00 +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)
|
static void handleKeyEvent(_GLFWjoystick* js, int code, int value)
|
||||||
{
|
{
|
||||||
if (code < BTN_MISC || code >= KEY_CNT - BTN_MISC) return;
|
|
||||||
_glfwInputJoystickButton(js,
|
_glfwInputJoystickButton(js,
|
||||||
js->linjs.keyMap[code - BTN_MISC],
|
js->linjs.keyMap[code],
|
||||||
value ? GLFW_PRESS : GLFW_RELEASE);
|
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)
|
static void handleAbsEvent(_GLFWjoystick* js, int code, int value)
|
||||||
{
|
{
|
||||||
if (code >= ABS_CNT) return;
|
|
||||||
const int index = js->linjs.absMap[code];
|
const int index = js->linjs.absMap[code];
|
||||||
|
|
||||||
if (code >= ABS_HAT0X && code <= ABS_HAT3Y)
|
if (code >= ABS_HAT0X && code <= ABS_HAT3Y)
|
||||||
@ -197,7 +195,16 @@ static GLFWbool openJoystickDevice(const char* path)
|
|||||||
if (!isBitSet(code, keyBits))
|
if (!isBitSet(code, keyBits))
|
||||||
continue;
|
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++;
|
buttonCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ typedef struct _GLFWjoystickLinux
|
|||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
char path[PATH_MAX];
|
char path[PATH_MAX];
|
||||||
int keyMap[KEY_CNT - BTN_MISC];
|
int keyMap[KEY_CNT];
|
||||||
int absMap[ABS_CNT];
|
int absMap[ABS_CNT];
|
||||||
struct input_absinfo absInfo[ABS_CNT];
|
struct input_absinfo absInfo[ABS_CNT];
|
||||||
int hats[4][2];
|
int hats[4][2];
|
||||||
|
Loading…
Reference in New Issue
Block a user