Created
December 29, 2017 06:59
-
-
Save Abdillah/f1e7ba9e0876543f6d608a0c4cb66e06 to your computer and use it in GitHub Desktop.
Patch of syndaemon (ftp://www.x.org/pub/X11R7.5/doc/man/man1/syndaemon.1.html) to ignore arrow keys
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| From a7189b6da6fc320eaf9ccac4511081a5a6977750 Mon Sep 17 00:00:00 2001 | |
| From: Hernawan Fa'iz Abdillah <[email protected]> | |
| Date: Sat, 27 Dec 2014 22:43:24 +0700 | |
| Subject: [PATCH] Add a capability for ignoring arrow keys. Cause, in some | |
| case, using arrow keys are not considered typing. | |
| --- | |
| tools/syndaemon.c | 21 ++++++++++++++++++--- | |
| 1 file changed, 18 insertions(+), 3 deletions(-) | |
| diff --git a/tools/syndaemon.c b/tools/syndaemon.c | |
| index 29e75f5..1f7c8ae 100644 | |
| --- a/tools/syndaemon.c | |
| +++ b/tools/syndaemon.c | |
| @@ -57,6 +57,7 @@ static Bool pad_disabled | |
| /* internal flag, this does not correspond to device state */ ; | |
| static int ignore_modifier_combos; | |
| static int ignore_modifier_keys; | |
| +static int ignore_arrow_keys; | |
| static int background; | |
| static const char *pid_file; | |
| static Display *display; | |
| @@ -86,6 +87,8 @@ usage(void) | |
| fprintf(stderr, | |
| " -k Ignore modifier keys when monitoring keyboard activity.\n"); | |
| fprintf(stderr, " -K Like -k but also ignore Modifier+Key combos.\n"); | |
| + fprintf(stderr, | |
| + " -a Ignore arrow keys when monitoring keyboard activity.\n"); | |
| fprintf(stderr, " -R Use the XRecord extension.\n"); | |
| fprintf(stderr, " -v Print diagnostic messages.\n"); | |
| fprintf(stderr, " -? Show this help message.\n"); | |
| @@ -210,6 +213,7 @@ keyboard_activity(Display * display) | |
| } | |
| for (i = 0; i < KEYMAP_SIZE; i++) | |
| old_key_state[i] = key_state[i]; | |
| + | |
| return ret; | |
| } | |
| @@ -261,7 +265,8 @@ clear_bit(unsigned char *ptr, int bit) | |
| } | |
| static void | |
| -setup_keyboard_mask(Display * display, int ignore_modifier_keys) | |
| +setup_keyboard_mask(Display * display, int ignore_modifier_keys, | |
| + int ignore_arrow_keys) | |
| { | |
| XModifierKeymap *modifiers; | |
| int i; | |
| @@ -279,6 +284,13 @@ setup_keyboard_mask(Display * display, int ignore_modifier_keys) | |
| } | |
| XFreeModifiermap(modifiers); | |
| } | |
| + | |
| + if (ignore_arrow_keys) { | |
| + // Up(128) | |
| + keyboard_mask[13] &= ~0b10000000; | |
| + // Left(16) - Down(4) - Right(2) | |
| + keyboard_mask[14] &= ~(0b00010000 | 0b00000100 | 0b00000010); | |
| + } | |
| } | |
| /* ---- the following code is for using the xrecord extension ----- */ | |
| @@ -547,8 +559,11 @@ main(int argc, char *argv[]) | |
| int use_xrecord = 0; | |
| /* Parse command line parameters */ | |
| - while ((c = getopt(argc, argv, "i:m:dtp:kKR?v")) != EOF) { | |
| + while ((c = getopt(argc, argv, "ai:m:dtp:kKR?v")) != EOF) { | |
| switch (c) { | |
| + case 'a': | |
| + ignore_arrow_keys = 1; | |
| + break; | |
| case 'i': | |
| idle_time = atof(optarg); | |
| break; | |
| @@ -641,7 +656,7 @@ main(int argc, char *argv[]) | |
| else | |
| #endif /* HAVE_X11_EXTENSIONS_RECORD_H */ | |
| { | |
| - setup_keyboard_mask(display, ignore_modifier_keys); | |
| + setup_keyboard_mask(display, ignore_modifier_keys, ignore_arrow_keys); | |
| /* Run the main loop */ | |
| main_loop(display, idle_time, poll_delay); | |
| -- | |
| 2.4.0 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment