mirror of
https://github.com/glfw/glfw
synced 2026-09-26 16:18:21 +03:00
Add support for right alt or altgr modifiers
This commit is contained in:
parent
80847e0e36
commit
0ec8e46e20
7 changed files with 20 additions and 2 deletions
|
|
@ -560,6 +560,11 @@ extern "C" {
|
|||
* GLFW_LOCK_KEY_MODS input mode is set.
|
||||
*/
|
||||
#define GLFW_MOD_NUM_LOCK 0x0020
|
||||
/*! @brief If this bit is set the Alt-Gr or right alt key were held down.
|
||||
*
|
||||
* If this bit is set the Alt-Gr or right alt key were held down.
|
||||
*/
|
||||
#define GLFW_MOD_ALT_GR 0x0040
|
||||
|
||||
/*! @} */
|
||||
|
||||
|
|
|
|||
|
|
@ -47,7 +47,8 @@
|
|||
GLFW_MOD_ALT | \
|
||||
GLFW_MOD_SUPER | \
|
||||
GLFW_MOD_CAPS_LOCK | \
|
||||
GLFW_MOD_NUM_LOCK)
|
||||
GLFW_MOD_NUM_LOCK | \
|
||||
GLFW_MOD_ALT_GR)
|
||||
|
||||
// Initializes the platform joystick API if it has not been already
|
||||
//
|
||||
|
|
|
|||
|
|
@ -525,6 +525,7 @@ void _glfwUpdateKeyNamesWin32(void)
|
|||
state[(int) VK_CONTROL] = (mods & GLFW_MOD_CONTROL)? 0xff : 0x00;
|
||||
state[(int) VK_MENU] = (mods & GLFW_MOD_ALT)? 0xff : 0x00;
|
||||
state[(int) VK_CAPITAL] = (mods & GLFW_MOD_CAPS_LOCK)? 0xff : 0x00;
|
||||
state[(int) VK_RMENU] = (mods & GLFW_MOD_ALT_GR)? 0xff : 0x00;
|
||||
|
||||
length = ToUnicode(vk, scancode, state,
|
||||
chars, sizeof(chars) / sizeof(WCHAR),
|
||||
|
|
|
|||
|
|
@ -419,6 +419,8 @@ static int getKeyMods(void)
|
|||
mods |= GLFW_MOD_CAPS_LOCK;
|
||||
if (GetKeyState(VK_NUMLOCK) & 1)
|
||||
mods |= GLFW_MOD_NUM_LOCK;
|
||||
if (GetKeyState(VK_RMENU) & 1)
|
||||
mods |= GLFW_MOD_ALT_GR;
|
||||
|
||||
return mods;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -523,6 +523,7 @@ typedef struct _GLFWlibraryWayland
|
|||
xkb_mod_index_t superIndex;
|
||||
xkb_mod_index_t capsLockIndex;
|
||||
xkb_mod_index_t numLockIndex;
|
||||
xkb_mod_index_t altGrIndex;
|
||||
unsigned int modifiers;
|
||||
|
||||
PFN_xkb_context_new context_new;
|
||||
|
|
|
|||
|
|
@ -1909,6 +1909,7 @@ static void keyboardHandleKeymap(void* userData,
|
|||
_glfw.wl.xkb.superIndex = xkb_keymap_mod_get_index(_glfw.wl.xkb.keymap, "Mod4");
|
||||
_glfw.wl.xkb.capsLockIndex = xkb_keymap_mod_get_index(_glfw.wl.xkb.keymap, "Lock");
|
||||
_glfw.wl.xkb.numLockIndex = xkb_keymap_mod_get_index(_glfw.wl.xkb.keymap, "Mod2");
|
||||
_glfw.wl.xkb.altGrIndex = xkb_keymap_mod_get_index(_glfw.wl.xkb.keymap, "Mod3");
|
||||
}
|
||||
|
||||
static void keyboardHandleEnter(void* userData,
|
||||
|
|
@ -2033,7 +2034,8 @@ static void keyboardHandleModifiers(void* userData,
|
|||
{ _glfw.wl.xkb.shiftIndex, GLFW_MOD_SHIFT },
|
||||
{ _glfw.wl.xkb.superIndex, GLFW_MOD_SUPER },
|
||||
{ _glfw.wl.xkb.capsLockIndex, GLFW_MOD_CAPS_LOCK },
|
||||
{ _glfw.wl.xkb.numLockIndex, GLFW_MOD_NUM_LOCK }
|
||||
{ _glfw.wl.xkb.numLockIndex, GLFW_MOD_NUM_LOCK },
|
||||
{ _glfw.wl.xkb.altGrIndex, GLFW_MOD_ALT_GR }
|
||||
};
|
||||
|
||||
for (size_t i = 0; i < sizeof(modifiers) / sizeof(modifiers[0]); i++)
|
||||
|
|
@ -2996,6 +2998,8 @@ static xkb_mod_mask_t translateStateInverse(int mods)
|
|||
mask |= xkb_keymap_mod_get_mask2(_glfw.wl.xkb.keymap, _glfw.wl.xkb.capsLockIndex);
|
||||
if (mods & GLFW_MOD_NUM_LOCK)
|
||||
mask |= xkb_keymap_mod_get_mask2(_glfw.wl.xkb.keymap, _glfw.wl.xkb.numLockIndex);
|
||||
if (mods & GLFW_MOD_ALT_GR)
|
||||
mask |= xkb_keymap_mod_get_mask2(_glfw.wl.xkb.keymap, _glfw.wl.xkb.altGrIndex);
|
||||
|
||||
return mask;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -229,6 +229,8 @@ static int translateState(int state)
|
|||
mods |= GLFW_MOD_CAPS_LOCK;
|
||||
if (state & Mod2Mask)
|
||||
mods |= GLFW_MOD_NUM_LOCK;
|
||||
if (state & Mod3Mask)
|
||||
mods |= GLFW_MOD_ALT_GR;
|
||||
|
||||
return mods;
|
||||
}
|
||||
|
|
@ -251,6 +253,8 @@ static int translateStateInverse(int mods)
|
|||
state |= LockMask;
|
||||
if (mods & GLFW_MOD_NUM_LOCK)
|
||||
state |= Mod2Mask;
|
||||
if (mods & GLFW_MOD_ALT_GR)
|
||||
state |= Mod3Mask;
|
||||
|
||||
return state;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue