Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/binding.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
{
Expand Down
14 changes: 2 additions & 12 deletions src/binding.h
Original file line number Diff line number Diff line change
@@ -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 <linux/input-event-codes.h>

/**
* The name of the input device.
Expand Down Expand Up @@ -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.
* */
Expand Down
4 changes: 4 additions & 0 deletions src/keys.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down