aboutsummaryrefslogtreecommitdiff
path: root/maps
diff options
context:
space:
mode:
Diffstat (limited to 'maps')
-rw-r--r--maps/map_en.h8
-rw-r--r--maps/map_es.h8
-rw-r--r--maps/maps.h30
3 files changed, 26 insertions, 20 deletions
diff --git a/maps/map_en.h b/maps/map_en.h
index f6e835a..58a379e 100644
--- a/maps/map_en.h
+++ b/maps/map_en.h
@@ -3,12 +3,12 @@
*
*/
-#ifndef __MAP_EN
-#define __MAP_EN
+#ifndef __EVS_MAP_EN
+#define __EVS_MAP_EN
static void init_shiftmap(void)
{
- init_shiftmap_global();
+ shm = khm_create();
EVS_SHIFT(KEY_1, "!");
EVS_SHIFT(KEY_2, "@");
EVS_SHIFT(KEY_3, "#");
@@ -57,4 +57,4 @@ static char map[] = {
};
-#endif // __MAP_EN
+#endif // __EVS_MAP_EN
diff --git a/maps/map_es.h b/maps/map_es.h
index 30752e7..763e7cc 100644
--- a/maps/map_es.h
+++ b/maps/map_es.h
@@ -3,12 +3,12 @@
*
*/
-#ifndef __MAP_ES
-#define __MAP_ES
+#ifndef __EVS_MAP_ES
+#define __EVS_MAP_ES
static void init_shiftmap(void)
{
- init_shiftmap_global();
+ shm = khm_create();
EVS_SHIFT(KEY_1, "!");
EVS_SHIFT(KEY_2, "\"");
EVS_SHIFT(KEY_4, "$");
@@ -54,4 +54,4 @@ static char map[] = {
};
-#endif // __MAP_ES
+#endif // __EVS_MAP_ES
diff --git a/maps/maps.h b/maps/maps.h
index 399d3df..f4fc856 100644
--- a/maps/maps.h
+++ b/maps/maps.h
@@ -3,36 +3,42 @@
*
* Each map is an array where the content of each position is the key value
* associated with the event code (index). An special/unknown key is represented
- * as a dot ('.'). The dot key itself has its own macro (KEY_DOT).
+ * as a dot ('.'). The dot key itself is registered with its own macro (KEY_DOT).
+ *
+ * Maps are imported from files named map_XX.h, where XX is the layout code.
+ *
+ * Each file declares a char array called map, where the content of each
+ * position is the key value associated with the event code (index). It also
+ * defines a function called init_shiftmap that can register any number of shift
+ * keys to be parsed when shift or capslock has been pressed.
+ *
+ * For example,
+ * EVS_SHIFT(KEY_7, "/");
+ * associates the key of number 7 to the slash character when shift is pressed.
+ * Yeah, the character associated is a string: this is because of the hashmap
+ * implementation, that maps an integer to a (void *).
*
* By the moment, evspy does not support non-ascii characters.
*
- * Select your map with EVS_MAP macro in evspy-core.h
+ * Select your map with EVS_KLAY macro in evspy-core.h
*/
#ifndef __EVS_MAPS
#define __EVS_MAPS
#include <linux/input.h>
-#include "../khashmap/khashmap.h"
+#include "../khm/khm.h"
#define EVS_SHIFT(KEY, VALUE) khm_insert(shm, (KEY), (VALUE))
+// Shift map
static struct khashmap *shm;
-static inline void exit_map(void)
+static inline void exit_shiftmap(void)
{
khm_destroy(shm);
}
-static inline void init_shiftmap_global(void)
-{
- shm = khm_create();
-}
-
-#define EVS_KLAY_EN 0
-#define EVS_KLAY_ES 1
-
// Load the map associated with the given keyboard layout
#ifndef EVS_KLAY
#include "map_es.h" // default layout