mirror of
https://github.com/glfw/glfw.git
synced 2025-06-07 16:24:57 +00:00
Merge 9ae058b208
into e7ea71be03
This commit is contained in:
commit
24cf0811b6
@ -50,7 +50,7 @@
|
|||||||
static void handleKeyEvent(_GLFWjoystick* js, int code, int value)
|
static void handleKeyEvent(_GLFWjoystick* js, int code, int value)
|
||||||
{
|
{
|
||||||
_glfwInputJoystickButton(js,
|
_glfwInputJoystickButton(js,
|
||||||
js->linjs.keyMap[code - BTN_MISC],
|
js->linjs.keyMap[code],
|
||||||
value ? GLFW_PRESS : GLFW_RELEASE);
|
value ? GLFW_PRESS : GLFW_RELEASE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -190,12 +190,28 @@ static GLFWbool openJoystickDevice(const char* path)
|
|||||||
|
|
||||||
int axisCount = 0, buttonCount = 0, hatCount = 0;
|
int axisCount = 0, buttonCount = 0, hatCount = 0;
|
||||||
|
|
||||||
for (int code = BTN_MISC; code < KEY_CNT; code++)
|
// This loop should stop at KEY_CNT instead of KEY_MAX. However, we are
|
||||||
|
// terminating the loop one iteration early to maintain compatibility with
|
||||||
|
// the SDL gamepad mappings.
|
||||||
|
for (int code = BTN_JOYSTICK; code < KEY_MAX; code++)
|
||||||
{
|
{
|
||||||
if (!isBitSet(code, keyBits))
|
if (!isBitSet(code, keyBits))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
linjs.keyMap[code - BTN_MISC] = buttonCount;
|
linjs.keyMap[code] = buttonCount;
|
||||||
|
buttonCount++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Originally, this range was not mapped, but some controllers now output
|
||||||
|
// these values. Appending them to the end of the list maintains both
|
||||||
|
// backwards compatibility with older versions of GLFW, and with the SDL
|
||||||
|
// gamepad mappings.
|
||||||
|
for (int code = 0; code < BTN_JOYSTICK; 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