about summary refs log tree commit diff
path: root/keyboard.h
diff options
context:
space:
mode:
authorStacy Harper <contact@stacyharper.net>2021-08-22 19:42:16 +0200
committerJohn Sullivan <jsullivan@csumb.edu>2021-10-19 23:12:01 -0700
commita7c28e647ece4944dc5cf92cf5dbfddb078919e4 (patch)
tree2abc527cdd85acaad2527f63e7f9924b68c90c2d /keyboard.h
parent75362e21e56727643a9cf48d5a5beba7a3cd09fb (diff)
downloadsuggpicker-a7c28e647ece4944dc5cf92cf5dbfddb078919e4.tar.gz
Add a CodeMod type of key
Diffstat (limited to 'keyboard.h')
-rw-r--r--keyboard.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/keyboard.h b/keyboard.h
index 02c1829..ea3bddc 100644
--- a/keyboard.h
+++ b/keyboard.h
@@ -12,6 +12,7 @@ enum key_type {
 	Layout,
 	EndRow,
 	Last,
+	CodeMod,
 };
 
 /* Modifiers passed to the virtual_keyboard protocol. They are based on
@@ -41,6 +42,7 @@ struct key {
 
 	const uint32_t code;
 	struct layout *layout;
+	const uint32_t code_mod;
 
 	//actual coordinates on the surface
 	uint32_t x, y, w, h;
@@ -154,7 +156,21 @@ kbd_unpress_key(struct kbd *kb, uint32_t time) {
 
 void
 kbd_press_key(struct kbd *kb, struct key *k, uint32_t time) {
+	uint8_t mods_before;
 	switch (k->type) {
+	case CodeMod:
+		mods_before = kb->mods;
+
+		kb->mods = k->code_mod;
+		kb->last_press = k;
+		kbd_draw_key(kb, k, true);
+		zwp_virtual_keyboard_v1_modifiers(kb->vkbd, kb->mods, 0, 0, 0);
+		zwp_virtual_keyboard_v1_key(kb->vkbd, time, kb->last_press->code,
+		                            WL_KEYBOARD_KEY_STATE_PRESSED);
+
+		kb->mods = mods_before;
+		zwp_virtual_keyboard_v1_modifiers(kb->vkbd, kb->mods, 0, 0, 0);
+		break;
 	case Code:
 		kb->last_press = k;
 		kbd_draw_key(kb, k, true);