mirror of https://github.com/libsdl-org/SDL
Removed acquire/release of keymaps, which isn't needed internally.
This commit is contained in:
parent
a13c993e40
commit
ac7df9d01f
|
@ -229,8 +229,6 @@ SDL_Keymap *SDL_GetCurrentKeymap(void)
|
|||
{
|
||||
SDL_Keyboard *keyboard = &SDL_keyboard;
|
||||
|
||||
SDL_AcquireKeymap(keyboard->keymap);
|
||||
|
||||
return keyboard->keymap;
|
||||
}
|
||||
|
||||
|
@ -239,7 +237,7 @@ void SDL_SetKeymap(SDL_Keymap *keymap, SDL_bool send_event)
|
|||
SDL_Keyboard *keyboard = &SDL_keyboard;
|
||||
|
||||
if (keyboard->keymap) {
|
||||
SDL_ReleaseKeymap(keyboard->keymap);
|
||||
SDL_DestroyKeymap(keyboard->keymap);
|
||||
}
|
||||
|
||||
keyboard->keymap = keymap;
|
||||
|
@ -851,7 +849,7 @@ void SDL_QuitKeyboard(void)
|
|||
SDL_keyboards = NULL;
|
||||
|
||||
if (SDL_keyboard.keymap) {
|
||||
SDL_ReleaseKeymap(SDL_keyboard.keymap);
|
||||
SDL_DestroyKeymap(SDL_keyboard.keymap);
|
||||
SDL_keyboard.keymap = NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
|
||||
struct SDL_Keymap
|
||||
{
|
||||
int refcount;
|
||||
SDL_HashTable *scancode_to_keycode;
|
||||
SDL_HashTable *keycode_to_scancode;
|
||||
};
|
||||
|
@ -41,23 +40,15 @@ SDL_Keymap *SDL_CreateKeymap(void)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
keymap->refcount = 1;
|
||||
keymap->scancode_to_keycode = SDL_CreateHashTable(NULL, 64, SDL_HashID, SDL_KeyMatchID, NULL, SDL_FALSE);
|
||||
keymap->keycode_to_scancode = SDL_CreateHashTable(NULL, 64, SDL_HashID, SDL_KeyMatchID, NULL, SDL_FALSE);
|
||||
if (!keymap->scancode_to_keycode || !keymap->keycode_to_scancode) {
|
||||
SDL_ReleaseKeymap(keymap);
|
||||
SDL_DestroyKeymap(keymap);
|
||||
return NULL;
|
||||
}
|
||||
return keymap;
|
||||
}
|
||||
|
||||
void SDL_AcquireKeymap(SDL_Keymap *keymap)
|
||||
{
|
||||
if (keymap) {
|
||||
++keymap->refcount;
|
||||
}
|
||||
}
|
||||
|
||||
static SDL_Keymod NormalizeModifierStateForKeymap(SDL_Keymod modstate)
|
||||
{
|
||||
// The modifiers that affect the keymap are: SHIFT, CAPS, ALT, and MODE
|
||||
|
@ -128,17 +119,12 @@ SDL_Scancode SDL_GetKeymapScancode(SDL_Keymap *keymap, SDL_Keycode keycode, SDL_
|
|||
return scancode;
|
||||
}
|
||||
|
||||
void SDL_ReleaseKeymap(SDL_Keymap *keymap)
|
||||
void SDL_DestroyKeymap(SDL_Keymap *keymap)
|
||||
{
|
||||
if (!keymap) {
|
||||
return;
|
||||
}
|
||||
|
||||
--keymap->refcount;
|
||||
if (keymap->refcount != 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
SDL_DestroyHashTable(keymap->scancode_to_keycode);
|
||||
SDL_DestroyHashTable(keymap->keycode_to_scancode);
|
||||
SDL_free(keymap);
|
||||
|
@ -1030,7 +1016,6 @@ const char *SDL_GetKeyName(SDL_Keycode key, SDL_bool uppercase)
|
|||
if (scancode != SDL_SCANCODE_UNKNOWN) {
|
||||
if (key >= 0x0E00 && key <= 0x0E7F) {
|
||||
// Thai keyboards are QWERTY plus Thai characters, so let's use the ASCII key names
|
||||
SDL_ReleaseKeymap(keymap);
|
||||
return SDL_GetScancodeName(scancode);
|
||||
}
|
||||
|
||||
|
@ -1039,7 +1024,6 @@ const char *SDL_GetKeyName(SDL_Keycode key, SDL_bool uppercase)
|
|||
key = capital;
|
||||
}
|
||||
}
|
||||
SDL_ReleaseKeymap(keymap);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1108,7 +1092,6 @@ SDL_Keycode SDL_GetKeyFromName(const char *name, SDL_bool uppercase)
|
|||
if (scancode != SDL_SCANCODE_UNKNOWN && (modstate & SDL_KMOD_SHIFT)) {
|
||||
key = SDL_GetKeymapKeycode(keymap, scancode, SDL_KMOD_NONE);
|
||||
}
|
||||
SDL_ReleaseKeymap(keymap);
|
||||
}
|
||||
}
|
||||
return key;
|
||||
|
|
|
@ -27,10 +27,9 @@ typedef struct SDL_Keymap SDL_Keymap;
|
|||
|
||||
SDL_Keymap *SDL_GetCurrentKeymap(void);
|
||||
SDL_Keymap *SDL_CreateKeymap(void);
|
||||
void SDL_AcquireKeymap(SDL_Keymap *keymap);
|
||||
void SDL_SetKeymapEntry(SDL_Keymap *keymap, SDL_Scancode scancode, SDL_Keymod modstate, SDL_Keycode keycode);
|
||||
SDL_Keycode SDL_GetKeymapKeycode(SDL_Keymap *keymap, SDL_Scancode scancode, SDL_Keymod modstate);
|
||||
SDL_Scancode SDL_GetKeymapScancode(SDL_Keymap *keymap, SDL_Keycode keycode, SDL_Keymod *modstate);
|
||||
void SDL_ReleaseKeymap(SDL_Keymap *keymap);
|
||||
void SDL_DestroyKeymap(SDL_Keymap *keymap);
|
||||
|
||||
#endif /* SDL_keymap_c_h_ */
|
||||
|
|
|
@ -1185,7 +1185,7 @@ static void Wayland_UpdateKeymap(struct SDL_WaylandInput *input)
|
|||
keymap.state = WAYLAND_xkb_state_new(input->xkb.keymap);
|
||||
if (!keymap.state) {
|
||||
SDL_SetError("failed to create XKB state");
|
||||
SDL_ReleaseKeymap(keymap.keymap);
|
||||
SDL_DestroyKeymap(keymap.keymap);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue