|
| 1 | +#include <stdbool.h> |
| 2 | +#define MAX_LAYERS 25 |
| 3 | + |
| 4 | +enum key_type; |
| 5 | +enum key_modifier_type; |
| 6 | +struct key; |
| 7 | +struct layout; |
| 8 | +struct kbd; |
| 9 | + |
| 10 | +enum key_type { |
| 11 | + Pad = 0, // Padding, not a pressable key |
| 12 | + Code, // A normal key emitting a keycode |
| 13 | + Mod, // A modifier key |
| 14 | + Copy, // Copy key, copies the unicode value specified in code (creates and |
| 15 | + // activates temporary keymap) |
| 16 | + // used for keys that are not part of the keymap |
| 17 | + Layout, // Layout switch to a specific layout |
| 18 | + BackLayer, // Layout switch to the layout that was previously active |
| 19 | + NextLayer, // Layout switch to the next layout in the layers sequence |
| 20 | + Compose, // Compose modifier key, switches to a specific associated layout |
| 21 | + // upon next keypress |
| 22 | + EndRow, // Incidates the end of a key row |
| 23 | + Last, // Indicated the end of a layout |
| 24 | +}; |
| 25 | + |
| 26 | +/* Modifiers passed to the virtual_keyboard protocol. They are based on |
| 27 | + * wayland's wl_keyboard, which doesn't document them. |
| 28 | + */ |
| 29 | +enum key_modifier_type { |
| 30 | + NoMod = 0, |
| 31 | + Shift = 1, |
| 32 | + CapsLock = 2, |
| 33 | + Ctrl = 4, |
| 34 | + Alt = 8, |
| 35 | + Super = 64, |
| 36 | + AltGr = 128, |
| 37 | +}; |
| 38 | + |
| 39 | +struct key { |
| 40 | + const char *label; // primary label |
| 41 | + const char *shift_label; // secondary label |
| 42 | + const double width; // relative width (1.0) |
| 43 | + const enum key_type type; |
| 44 | + |
| 45 | + const uint32_t |
| 46 | + code; /* code: key scancode or modifier name (see |
| 47 | + * `/usr/include/linux/input-event-codes.h` for scancode names, and |
| 48 | + * `keyboard.h` for modifiers) |
| 49 | + * XKB keycodes are +8 */ |
| 50 | + struct layout *layout; // pointer back to the parent layout that holds this |
| 51 | + // key |
| 52 | + const uint32_t code_mod; /* modifier to force when this key is pressed */ |
| 53 | + uint8_t scheme; // index of the scheme to use |
| 54 | + bool reset_mod; /* reset modifiers when clicked */ |
| 55 | + |
| 56 | + // actual coordinates on the surface (pixels), will be computed automatically |
| 57 | + // for all keys |
| 58 | + uint32_t x, y, w, h; |
| 59 | +}; |
| 60 | + |
| 61 | +struct layout { |
| 62 | + struct key *keys; |
| 63 | + const char *keymap_name; |
| 64 | + const char *name; |
| 65 | + bool abc; //is this an alphabetical/abjad layout or not? (i.e. something that is a primary input layout) |
| 66 | + uint32_t keyheight; // absolute height (pixels) |
| 67 | +}; |
0 commit comments