mirror of https://github.com/encounter/SDL.git
wayland: Enforce text capitalization manually, for remapped keymods
This commit is contained in:
parent
a75c6150e0
commit
6d9ca92626
|
@ -910,6 +910,8 @@ keyboard_input_get_text(char text[8], const struct SDL_WaylandInput *input, uint
|
||||||
SDL_WindowData *window = input->keyboard_focus;
|
SDL_WindowData *window = input->keyboard_focus;
|
||||||
const xkb_keysym_t *syms;
|
const xkb_keysym_t *syms;
|
||||||
xkb_keysym_t sym;
|
xkb_keysym_t sym;
|
||||||
|
SDL_Keymod mod;
|
||||||
|
SDL_bool caps;
|
||||||
|
|
||||||
if (!window || window->keyboard_device != input || !input->xkb.state) {
|
if (!window || window->keyboard_device != input || !input->xkb.state) {
|
||||||
return SDL_FALSE;
|
return SDL_FALSE;
|
||||||
|
@ -921,6 +923,24 @@ keyboard_input_get_text(char text[8], const struct SDL_WaylandInput *input, uint
|
||||||
}
|
}
|
||||||
sym = syms[0];
|
sym = syms[0];
|
||||||
|
|
||||||
|
/* Wayland is actually pretty cool and sends key codes based on presumed
|
||||||
|
* caps lock state, problem is that it isn't totally accurate if the key
|
||||||
|
* has been remapped, so we have to force caps for our purposes.
|
||||||
|
* -flibit
|
||||||
|
*/
|
||||||
|
mod = SDL_GetModState();
|
||||||
|
caps = (
|
||||||
|
/* Caps lock without shift... */
|
||||||
|
((mod & KMOD_CAPS) && !(mod & KMOD_SHIFT)) ||
|
||||||
|
/* No caps lock with shift... */
|
||||||
|
(!(mod & KMOD_CAPS) && (mod & KMOD_SHIFT))
|
||||||
|
);
|
||||||
|
if (caps) {
|
||||||
|
sym = toupper(sym);
|
||||||
|
} else {
|
||||||
|
sym = tolower(sym);
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef SDL_USE_IME
|
#ifdef SDL_USE_IME
|
||||||
if (SDL_IME_ProcessKeyEvent(sym, key + 8)) {
|
if (SDL_IME_ProcessKeyEvent(sym, key + 8)) {
|
||||||
*handled_by_ime = SDL_TRUE;
|
*handled_by_ime = SDL_TRUE;
|
||||||
|
|
Loading…
Reference in New Issue