diff options
author | Jan Arne Petersen <jpetersen@openismus.com> | 2012-09-17 15:28:07 +0200 |
---|---|---|
committer | Kristian Høgsberg <krh@bitplanet.net> | 2012-09-25 11:24:49 -0400 |
commit | 8aba11d057213da485532e9ab3a870d9b04ae5c5 (patch) | |
tree | 4adba7ca8eb561d4e01de8117d5732dee66da763 /clients/keyboard.c | |
parent | d7f282b84e1729f4692488a8af7e696e4d6b69d7 (diff) | |
download | weston-8aba11d057213da485532e9ab3a870d9b04ae5c5.tar.gz |
editor, keyboard: Add support for arrow keys
Add support for arrow keys on the virtual keyboard and make it possible
to move around the cursor in the editor example.
Diffstat (limited to 'clients/keyboard.c')
-rw-r--r-- | clients/keyboard.c | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/clients/keyboard.c b/clients/keyboard.c index c90c5b2d..bf0e9f03 100644 --- a/clients/keyboard.c +++ b/clients/keyboard.c @@ -47,7 +47,11 @@ enum key_type { keytype_space, keytype_switch, keytype_symbols, - keytype_tab + keytype_tab, + keytype_arrow_up, + keytype_arrow_left, + keytype_arrow_right, + keytype_arrow_down }; struct key { @@ -96,9 +100,13 @@ static const struct key keys[] = { { keytype_default, ".", ".", 1}, { keytype_switch, "ABC", "abc", 1}, - { keytype_symbols, "?123", "?123", 2}, - { keytype_space, "", "", 8}, - { keytype_symbols, "?123", "?123", 2} + { keytype_symbols, "?123", "?123", 1}, + { keytype_space, "", "", 6}, + { keytype_arrow_up, "/\\", "/\\", 1}, + { keytype_arrow_left, "<", "<", 1}, + { keytype_arrow_right, ">", ">", 1}, + { keytype_arrow_down, "\\/", "\\/", 1}, + { keytype_symbols, "?123", "?123", 1} }; static const unsigned int columns = 12; @@ -255,6 +263,22 @@ keyboard_handle_key(struct keyboard *keyboard, const struct key *key) input_method_context_key(keyboard->keyboard->context, XKB_KEY_Tab, WL_KEYBOARD_KEY_STATE_PRESSED); break; + case keytype_arrow_up: + input_method_context_key(keyboard->keyboard->context, + XKB_KEY_Up, WL_KEYBOARD_KEY_STATE_PRESSED); + break; + case keytype_arrow_left: + input_method_context_key(keyboard->keyboard->context, + XKB_KEY_Left, WL_KEYBOARD_KEY_STATE_PRESSED); + break; + case keytype_arrow_right: + input_method_context_key(keyboard->keyboard->context, + XKB_KEY_Right, WL_KEYBOARD_KEY_STATE_PRESSED); + break; + case keytype_arrow_down: + input_method_context_key(keyboard->keyboard->context, + XKB_KEY_Down, WL_KEYBOARD_KEY_STATE_PRESSED); + break; } } |