home · contact · privacy
Finished applying new code formatting and documentation rules on main module.
[plomrogue] / src / keybindings.h
1 /* keybindings.h
2  *
3  * Retrieval and storage of keybindings.
4  */
5
6 #ifndef KEYBINDINGS_H
7 #define KEYBINDINGS_H
8
9
10
11 #include <stdint.h> /* for uint16_t */
12 struct World;
13 struct WinMeta;
14
15
16
17 /* Individual keybinding. */
18 struct KeyBinding
19 {
20   char * name;  /* name of functionality bound to keycode */
21   uint16_t key; /* keycode */
22 };
23
24
25
26 /* Metadata used by the keybinding editing window. */
27 struct KeysWinData
28 {
29   uint16_t max;    /* index of last keybinding (= n of keybindings - 1) */
30   char edit;       /* 1 if currently editing a keybinding, else 0 */
31   uint16_t select; /* index of keybinding selected for editing */
32 };
33
34
35
36 /* Read keybindings data from / write them to the file "keybindings". */
37 extern void init_keybindings(struct World * world);
38 extern void save_keybindings(struct World * world);
39
40
41
42 /* Return keycode matching a key (functionality) name. */
43 extern uint16_t get_action_key(struct KeyBinding * keybindings, char * name);
44
45
46
47 /* Translate keycode to readable names of max 9 chars where possible. */
48 extern char * get_keyname(uint16_t keycode);
49
50
51
52 /* Mark selection in keybindings window modifiable, get user input to modify
53  * key. Ensure there are max. three digits in the keycode ASCII representation.
54  */
55 extern void keyswin_mod_key(struct World * world, struct WinMeta * win_meta);
56
57
58
59 /* Move selection in keybinding window upwards ("dir" = "u") or downwards ("dir"
60  * = "d") within the limits of the keybindings list length.
61  */
62 extern void keyswin_move_selection(struct World * world, char dir);
63
64
65
66 #endif