Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linux: fix joystick initialization #1573

Merged
merged 2 commits into from
Aug 11, 2024
Merged
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
13 changes: 11 additions & 2 deletions src/linux/ljoynu.c
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,7 @@ static void ljoy_scan(bool configure)
{
int num;
ALLEGRO_USTR *device_name;
const ALLEGRO_FS_INTERFACE *fs_interface;
unsigned i;
int t;

Expand All @@ -522,6 +523,10 @@ static void ljoy_scan(bool configure)
(*joypp)->marked = false;
}

/* Make sure we're using stdio. */
fs_interface = al_get_fs_interface();
al_set_standard_fs_interface();

device_name = al_ustr_new("");

/* First try to read devices from allegro.cfg. */
Expand Down Expand Up @@ -552,8 +557,9 @@ static void ljoy_scan(bool configure)
continue;
}
char const *path = al_get_fs_entry_name(dev);
/* In the second pass in /dev/input we don't filter anymore. */
if (t ==1 || strcmp(suffix, path + strlen(path) - strlen(suffix)) == 0) {
/* In the second pass in /dev/input we don't filter anymore.
In the first pass, in /dev/input/by-path, strlen(path) > strlen(suffix). */
if (t == 1 || strcmp(suffix, path + strlen(path) - strlen(suffix)) == 0) {
found = true;
al_ustr_assign_cstr(device_name, path);
ljoy_device(device_name);
Expand All @@ -574,6 +580,9 @@ static void ljoy_scan(bool configure)

al_ustr_free(device_name);

/* Restore the fs interface. */
al_set_fs_interface(fs_interface);

/* Schedule unmarked structures to be inactivated. */
for (i = 0; i < _al_vector_size(&joysticks); i++) {
ALLEGRO_JOYSTICK_LINUX **joypp = _al_vector_ref(&joysticks, i);
Expand Down
Loading