diff --git a/src/binding.c b/src/binding.c index 3bbc58c..a4238d6 100644 --- a/src/binding.c +++ b/src/binding.c @@ -22,7 +22,7 @@ int input_file_descriptor = -1; // The output device char output_device_name[32] = "Virtual TouchCursor Keyboard"; char output_sys_path[256] = { '\0' }; -int output_device_keystate[MAX_KEYBIT]; +int output_device_keystate[KEY_MAX]; int output_file_descriptor = -1; /** @@ -179,7 +179,7 @@ int bind_output() return EXIT_FAILURE; } // Enable the set of KEY events - for (int i = 0; i <= MAX_KEYBIT; i++) + for (int i = 0; i <= KEY_MAX; i++) { int result = ioctl(output_file_descriptor, UI_SET_KEYBIT, i); if (result < 0) @@ -218,7 +218,7 @@ int bind_output() * */ void release_output_keys() { - for (int i = 0; i < MAX_KEYBIT; i++) + for (int i = 0; i < KEY_MAX; i++) { if (output_device_keystate[i] > 0) { diff --git a/src/binding.h b/src/binding.h index 4438ee9..3717873 100644 --- a/src/binding.h +++ b/src/binding.h @@ -1,17 +1,7 @@ #ifndef binding_h #define binding_h -/** - * @brief The upper limit for enabling key events. - * - * There used to be KEY_MAX here, but that seems to be causing issues: - * At one point there was an issue where the virtual device could not be created - * if keys up to KEY_MAX (767) were included. 572 came from iterating down - * from KEY_MAX until things started working again. Not sure what the underlying - * cause is. For further reference, see - * https://github.com/donniebreve/touchcursor-linux/pull/39#issuecomment-1000901050. - */ -#define MAX_KEYBIT 572 +#include /** * The name of the input device. @@ -55,7 +45,7 @@ extern char output_sys_path[256]; /** * The output device key state. * */ -extern int output_device_keystate[MAX_KEYBIT]; +extern int output_device_keystate[KEY_MAX]; /** * The file descriptor for the output device. * */ diff --git a/src/keys.c b/src/keys.c index 4b88e4e..415f66d 100644 --- a/src/keys.c +++ b/src/keys.c @@ -922,6 +922,10 @@ int convertKeyStringToCode(char* keyString) else if (strcmp(keyString, "ALS_TOGGLE") == 0) return KEY_ALS_TOGGLE; else if (strcmp(keyString, "KEY_ROTATE_LOCK_TOGGLE") == 0) return KEY_ROTATE_LOCK_TOGGLE; else if (strcmp(keyString, "ROTATE_LOCK_TOGGLE") == 0) return KEY_ROTATE_LOCK_TOGGLE; + else if (strcmp(keyString, "KEY_RIGHT_UP") == 0) return KEY_RIGHT_UP; + else if (strcmp(keyString, "KEY_RIGHT_DOWN") == 0) return KEY_RIGHT_DOWN; + else if (strcmp(keyString, "KEY_LEFT_UP") == 0) return KEY_LEFT_UP; + else if (strcmp(keyString, "KEY_LEFT_DOWN") == 0) return KEY_LEFT_DOWN; else return 0; }