aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillermo Ramos2011-09-18 17:08:35 +0200
committerGuillermo Ramos2011-09-18 17:08:35 +0200
commit974a8595ed3c09ccef62df7e3748baddb9038d8e (patch)
tree2bb7757e9a1e7a159b671cbcd95f035038afd008
parent68859128f0a0b8a17a1f0c37e154845eaa5fbb74 (diff)
downloadevspy-974a8595ed3c09ccef62df7e3748baddb9038d8e.tar.gz
Fixed backspace bug
-rw-r--r--TODO4
-rw-r--r--evspy-core.c14
-rw-r--r--evspy-core.h22
3 files changed, 29 insertions, 11 deletions
diff --git a/TODO b/TODO
index e2b5880..93ae3bb 100644
--- a/TODO
+++ b/TODO
@@ -1,4 +1,4 @@
-* Fix backspace key (do not erase special key events) - Prio:Medium
-* Implement 2nd mapping (shift) - Prio:Medium FIXED
+* Differenciate between capslock and shift (they do not behave the same with
+ non-alphanumeric keys) - Prio:Low
* Take a look at kernel's circular buffer API - Prio:Low
* Which FX key has been pressed? - Prio:None
diff --git a/evspy-core.c b/evspy-core.c
index 55b097c..1bfa578 100644
--- a/evspy-core.c
+++ b/evspy-core.c
@@ -128,6 +128,9 @@ static void special_char(unsigned int code, unsigned int value)
case KEY_TAB:
sp_tag = "[TAB]";
break;
+ case KEY_BACKSPACE:
+ sp_tag = "[<<]";
+ break;
case KEY_ESC:
sp_tag = "[ESC]";
break;
@@ -164,15 +167,18 @@ static void special_char(unsigned int code, unsigned int value)
static void evspy_event(struct input_handle *handle, unsigned int type,
unsigned int code, int value)
{
- // Ignore hold-key events
- if (unlikely(value == EVS_VAL_HOLD))
+ // Ignore non-key and hold events
+ if (type != EV_KEY || unlikely(value == EVS_VAL_HOLD)) {
return;
// If caps lock is pressed, handle it the same way as left shift
- if (code == KEY_CAPSLOCK && value == EVS_VAL_PRESS) {
+ } else if (code == KEY_CAPSLOCK && value == EVS_VAL_PRESS) {
special_char(KEY_LEFTSHIFT, capslock_state);
return;
- } else if (type != EV_KEY) {
+
+ // Backspace
+ } else if (code == KEY_BACKSPACE && value == EVS_VAL_PRESS) {
+ evs_backspace();
return;
}
diff --git a/evspy-core.h b/evspy-core.h
index 0613b9f..97e9660 100644
--- a/evspy-core.h
+++ b/evspy-core.h
@@ -18,6 +18,11 @@
#include "maps/maps.h"
+// Event values
+#define EVS_VAL_FREE 0
+#define EVS_VAL_PRESS 1
+#define EVS_VAL_HOLD 2
+
#define MIN(x, y) (x) < (y) ? (x) : (y)
/*
@@ -66,6 +71,18 @@
})
/*
+ * Try to delete the last char inserted. If it is a special key ("[KEY]"),
+ * insert "[<<]" instead
+ */
+#define evs_backspace() \
+({ \
+ if (*(wrp-1) != ']') \
+ evs_delete(); \
+ else \
+ special_char(KEY_BACKSPACE, EVS_VAL_PRESS); \
+})
+
+/*
* Is the c event code associated to any of the FX buttons?
*/
#define evs_isfX(c) \
@@ -91,8 +108,3 @@
} \
__c; \
})
-
-// Event values
-#define EVS_VAL_FREE 0
-#define EVS_VAL_PRESS 1
-#define EVS_VAL_HOLD 2