Disable stdin input by default and add ability to disable EVDEV input

This commit is contained in:
Tera << 8 2025-06-10 21:19:02 -04:00
parent 15afe89aff
commit 21a377707f
Signed by: imterah
GPG key ID: 8FA7DD57BA6CEA37
4 changed files with 53 additions and 37 deletions

View file

@ -1639,46 +1639,52 @@ static void ProcessKeyboard(void)
// this means mouse, keyboard or gamepad devices
static void InitEvdevInput(void)
{
char path[MAX_FILEPATH_LENGTH] = { 0 };
DIR *directory = NULL;
struct dirent *entity = NULL;
#if !defined(DISABLE_EVDEV_INPUT)
char path[MAX_FILEPATH_LENGTH] = { 0 };
DIR *directory = NULL;
struct dirent *entity = NULL;
// Initialise keyboard file descriptor
platform.keyboardFd = -1;
platform.mouseFd = -1;
// Initialise keyboard file descriptor
platform.keyboardFd = -1;
platform.mouseFd = -1;
// Reset variables
for (int i = 0; i < MAX_TOUCH_POINTS; ++i)
{
CORE.Input.Touch.position[i].x = -1;
CORE.Input.Touch.position[i].y = -1;
}
// Reset keyboard key state
for (int i = 0; i < MAX_KEYBOARD_KEYS; i++)
{
CORE.Input.Keyboard.currentKeyState[i] = 0;
CORE.Input.Keyboard.keyRepeatInFrame[i] = 0;
}
// Open the linux directory of "/dev/input"
directory = opendir(DEFAULT_EVDEV_PATH);
if (directory)
{
while ((entity = readdir(directory)) != NULL)
// Reset variables
for (int i = 0; i < MAX_TOUCH_POINTS; ++i)
{
if ((strncmp("event", entity->d_name, strlen("event")) == 0) || // Search for devices named "event*"
(strncmp("mouse", entity->d_name, strlen("mouse")) == 0)) // Search for devices named "mouse*"
{
sprintf(path, "%s%s", DEFAULT_EVDEV_PATH, entity->d_name);
ConfigureEvdevDevice(path); // Configure the device if appropriate
}
CORE.Input.Touch.position[i].x = -1;
CORE.Input.Touch.position[i].y = -1;
}
closedir(directory);
}
else TRACELOG(LOG_WARNING, "INPUT: Failed to open linux event directory: %s", DEFAULT_EVDEV_PATH);
// Reset keyboard key state
for (int i = 0; i < MAX_KEYBOARD_KEYS; i++)
{
CORE.Input.Keyboard.currentKeyState[i] = 0;
CORE.Input.Keyboard.keyRepeatInFrame[i] = 0;
}
// Open the linux directory of "/dev/input"
directory = opendir(DEFAULT_EVDEV_PATH);
if (directory)
{
while ((entity = readdir(directory)) != NULL)
{
if ((strncmp("event", entity->d_name, strlen("event")) == 0) || // Search for devices named "event*"
(strncmp("mouse", entity->d_name, strlen("mouse")) == 0)) // Search for devices named "mouse*"
{
sprintf(path, "%s%s", DEFAULT_EVDEV_PATH, entity->d_name);
ConfigureEvdevDevice(path); // Configure the device if appropriate
}
}
closedir(directory);
}
else TRACELOG(LOG_WARNING, "INPUT: Failed to open linux event directory: %s", DEFAULT_EVDEV_PATH);
#else
TRACELOG(LOG_INFO, "INPUT: Not doing evdev input configuration as it's disabled");
platform.keyboardFd = -1;
platform.mouseFd = -1;
#endif
}
// Identifies a input device and configures it for use if appropriate