summaryrefslogtreecommitdiff
path: root/evspy/evspy.h
diff options
context:
space:
mode:
Diffstat (limited to 'evspy/evspy.h')
-rw-r--r--evspy/evspy.h106
1 files changed, 51 insertions, 55 deletions
diff --git a/evspy/evspy.h b/evspy/evspy.h
index f140638..1575b71 100644
--- a/evspy/evspy.h
+++ b/evspy/evspy.h
@@ -1,75 +1,71 @@
+#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_PROCNAME "driver/evspy" // virtual file within /proc
+#define EVS_BUFSIZE PAGE_SIZE // size of the circular buffer
+
//#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
-#define PROCNAME "driver/evspy2"
-#define BUFSIZE PAGE_SIZE
#define MIN(x, y) (x) < (y) ? (x) : (y)
-#define incp(p) \
+/*
+ * 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[BUFSIZE-1]) \
+ if (p == &buffer[EVS_BUFSIZE-1]) \
p = buffer; \
else \
p++; \
p; \
})
-#define ins(c) \
+/*
+ * Insert a character where wrp is pointing and move it to the next char.
+ * If rdp == wrp, increase rdp too.
+ */
+#define evs_insrt(c) \
({ \
*wrp = c; \
- if (incp(wrp) == rdp) \
- incp(rdp); \
+ if (evs_incp(wrp) == rdp) \
+ evs_incp(rdp); \
})
+/*
+ * Is the c event code associated to any of the FX buttons?
+ * NOTE: F1-F10 events are consecutive numbers, but F11 & F12 are not. (?)
+ */
#define isfX(c) \
({ \
- (c >= F1 && c <= F10) || (c == F11 || c == F12); \
+ (c >= EVS_COD_F1 && c <= EVS_COD_F10) || \
+ (c == EVS_COD_F11 || c == EVS_COD_F12); \
})
-#define EV_BLKMAYUS 17
-
-#define FREE 0
-#define PRESS 1
-#define HOLD 2
+// Bloq mayus has its own type
+#define EVS_TYPE_BLKMAYUS 17
-#define ESC 1
-#define TAB 15
-#define LCTRL 29
-#define LMAYUS 42
-#define DOT 52
-#define RMAYUS 54
-#define ALT 56
-#define BLKMAYUS 58
-#define F1 59
-#define F10 68
-#define F11 87
-#define F12 88
-#define RCTRL 97
-#define ALTGR 100
-#define UP_AR 103
-#define DOWN_AR 108
-#define LEFT_AR 105
-#define RIGHT_AR 106
+// Event values
+#define EVS_VAL_FREE 0
+#define EVS_VAL_PRESS 1
+#define EVS_VAL_HOLD 2
-static char map_es[] = {
- '.', '.', '1', '2', '3', //0 // 1:ESC
- '4', '5', '6', '7', '8', //5
- '9', '0', '\'', '!', '\b', //10 // 13:¡ (NOASCII)
- '.', 'q', 'w', 'e', 'r', //15 // 15:TAB
- 't', 'y', 'u', 'i', 'o', //20
- 'p', '`', '+', '\n', '.', //25 // 29:LCTRL
- 'a', 's', 'd', 'f', 'g', //30
- 'h', 'j', 'k', 'l', 'n', //35 // 39:ñ (NOASCII)
- '\'', '.', '.', 'c', 'z', //40 // 42:LMAYUS 43:ç (NOASCII)
- 'x', 'c', 'v', 'b', 'n', //45
- 'm', ',', '.', '-', '.', //50 // 52:. 54:RMAYUS
- '*', '.', ' ', '.', '.', //55 // 56:ALT 58:BLKMAYUS 59-68:F1-F10
- '.', '.', '.', '.', '.', //60
- '.', '.', '.', '.', '.', //65
- '.', '7', '8', '9', '-', //70
- '4', '5', '6', '+', '1', //75
- '2', '3', '.', '.', '.', //80
- '.', '<', '.', '.', '.', //85
- '.', '.', '.', '.', '.', //90
- '.', '\n', '.', '/', '.', //95 // 97:RCTRL
- '.', '.', '.', '.', '.', //100 // 100:ALTGR 103:up_arrow
- '.', '.', '.', '.', '.', //105 // 105:lft_arrow 106:rgt_arrow 108:down_arrow
-};
+// 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