mirror of
https://github.com/fltk/fltk.git
synced 2026-05-28 11:25:22 +08:00
Wayland: Fix Fl::event_key() when using non-latin keyboard layouts (#1427)
This commit is contained in:
@@ -589,6 +589,17 @@ static void remove_int_vector(std::vector<int>& v, int val) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static char keycode_to_ascii(int keycode) {
|
||||||
|
static const char row_AD[] = "qwertyuiop";
|
||||||
|
static const char row_AC[] = "asdfghjkl";
|
||||||
|
static const char row_AB[] = "zxcvbnm";
|
||||||
|
if (keycode >= 24 && keycode <= 33) return row_AD[keycode - 24];
|
||||||
|
else if (keycode >= 38 && keycode <= 46) return row_AC[keycode - 38];
|
||||||
|
else if (keycode >= 52 && keycode <= 58) return row_AB[keycode - 52];
|
||||||
|
else return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static int process_wld_key(struct xkb_state *xkb_state, uint32_t key,
|
static int process_wld_key(struct xkb_state *xkb_state, uint32_t key,
|
||||||
uint32_t *p_keycode, xkb_keysym_t *p_sym) {
|
uint32_t *p_keycode, xkb_keysym_t *p_sym) {
|
||||||
uint32_t keycode = key + 8;
|
uint32_t keycode = key + 8;
|
||||||
@@ -604,6 +615,13 @@ static int process_wld_key(struct xkb_state *xkb_state, uint32_t key,
|
|||||||
} else if (keycode == 19) {
|
} else if (keycode == 19) {
|
||||||
for_key_vector = '0';
|
for_key_vector = '0';
|
||||||
}
|
}
|
||||||
|
// Check for non-Latin keyboard layout
|
||||||
|
if (xkb_state_key_get_one_sym(xkb_state, 38 /* 'A' key on US keyboard */) > 'z') {
|
||||||
|
int asciiSym = keycode_to_ascii(keycode);
|
||||||
|
if (asciiSym != 0) {
|
||||||
|
for_key_vector = asciiSym;
|
||||||
|
}
|
||||||
|
}
|
||||||
if (p_keycode) *p_keycode = keycode;
|
if (p_keycode) *p_keycode = keycode;
|
||||||
if (p_sym) *p_sym = sym;
|
if (p_sym) *p_sym = sym;
|
||||||
return for_key_vector;
|
return for_key_vector;
|
||||||
|
|||||||
Reference in New Issue
Block a user