about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--keyboard.c37
-rw-r--r--keyboard.h22
2 files changed, 10 insertions, 49 deletions
diff --git a/keyboard.c b/keyboard.c
index a964c34..a2c40f3 100644
--- a/keyboard.c
+++ b/keyboard.c
@@ -39,17 +39,11 @@ kbd_init_layout(struct layout *l, uint32_t width, uint32_t height) {
 
 	struct key *k = l->keys;
 	double rowlength = kbd_get_row_length(k);
-	while (k->type != Last) {
-		if (k->type == EndRow) {
-			y += l->keyheight;
-			x = 0;
-			rowlength = kbd_get_row_length(k + 1);
-		} else if (k->type == Code) {
-			k->x = x;
-			k->y = y;
-			k->w = width / rowlength;
-			x += k->w;
-		}
+	while (k->label != NULL) {
+		k->x = x;
+		k->y = y;
+		k->w = width / rowlength;
+		x += k->w;
 		k->h = l->keyheight;
 		k++;
 	}
@@ -58,7 +52,7 @@ kbd_init_layout(struct layout *l, uint32_t width, uint32_t height) {
 double
 kbd_get_row_length(struct key *k) {
 	double l = 0.0;
-	while ((k->type != Last) && (k->type != EndRow)) {
+	while (k->label != NULL) {
 		l += 1.0;
 		k++;
 	}
@@ -71,9 +65,8 @@ kbd_get_key(struct kbd *kb, uint32_t x, uint32_t y) {
 	struct key *k = l->keys;
 	if (kb->debug)
 		fprintf(stderr, "get key: +%d+%d\n", x, y);
-	while (k->type != Last) {
-		if ((k->type != EndRow) && (k->type != Pad) && (k->type != Pad) &&
-		    (x >= k->x) && (y >= k->y) && (x < k->x + k->w) && (y < k->y + k->h)) {
+	while (k->label != NULL) {
+		if ((x >= k->x) && (y >= k->y) && (x < k->x + k->w) && (y < k->y + k->h)) {
 			return k;
 		}
 		k++;
@@ -105,16 +98,10 @@ kbd_motion_key(struct kbd *kb, uint32_t time, uint32_t x, uint32_t y) {
 
 void
 kbd_press_key(struct kbd *kb, struct key *k, uint32_t time) {
-
-
-	switch (k->type) {
-	case Code:
+	if (k->label) {
 		kb->last_press = k;
 		kbd_draw_key(kb, k, Press);
 		kbd_print_key_stdout(kb, k);
-		break;
-	default:
-		break;
 	}
 }
 
@@ -156,11 +143,7 @@ kbd_draw_layout(struct kbd *kb) {
 
 	drw_fill_rectangle(d, kb->scheme.bg, 0, 0, kb->w, kb->h);
 
-	while (next_key->type != Last) {
-		if ((next_key->type == Pad) || (next_key->type == EndRow)) {
-			next_key++;
-			continue;
-		}
+	while (next_key->label != NULL) {
 		kbd_draw_key(kb, next_key, Unpress);
 		next_key++;
 	}
diff --git a/keyboard.h b/keyboard.h
index 520ca05..84e6b8c 100644
--- a/keyboard.h
+++ b/keyboard.h
@@ -12,26 +12,6 @@ struct key;
 struct layout;
 struct kbd;
 
-enum key_type {
-	Pad = 0, // Padding, not a pressable key
-	Code,    // A normal key emitting a keycode
-	EndRow,    // Incidates the end of a key row
-	Last,      // Indicated the end of a layout
-};
-
-/* Modifiers passed to the virtual_keyboard protocol. They are based on
- * wayland's wl_keyboard, which doesn't document them.
- */
-enum key_modifier_type {
-	NoMod = 0,
-	Shift = 1,
-	CapsLock = 2,
-	Ctrl = 4,
-	Alt = 8,
-	Super = 64,
-	AltGr = 128,
-};
-
 enum key_draw_type {
 	Unpress = 0,
 	Press,
@@ -49,10 +29,8 @@ struct clr_scheme {
 struct key {
 	const char *label;       // primary label
 
-	const enum key_type type;
 	struct layout *layout;   // pointer back to the parent layout that holds this
 	                         // key
-	bool reset_mod;          /* reset modifiers when clicked */
 
 	// actual coordinates on the surface (pixels), will be computed automatically
 	// for all keys