summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorMichaelFiber <[email protected]>2023-10-11 04:30:51 -0400
committerGitHub <[email protected]>2023-10-11 10:30:51 +0200
commitdaba1a27945d6be914e71f71fe8e7cfaef1eca5e (patch)
treee1c3a18295927181b2233a0dfabdb8dc8754fd2b /src
parent101a9b04458a38413a29a11f22e6c8e0a472a75b (diff)
downloadraylib-daba1a27945d6be914e71f71fe8e7cfaef1eca5e.tar.gz
raylib-daba1a27945d6be914e71f71fe8e7cfaef1eca5e.zip
Split drm update input (#3397)
* Update `PLATFORM_DRM` implementation of `GetGamepadAxisCount` * Update * Update `PLATFORM_DRM` implementation of `GetGamepadName` * Add example to test gamepad info functions Fix typo * Update new gamepad info example * Move axis count update out of GamepadThread - race condition * Remove pointless if statement
Diffstat (limited to 'src')
-rw-r--r--src/rcore_drm.c18
1 files changed, 4 insertions, 14 deletions
diff --git a/src/rcore_drm.c b/src/rcore_drm.c
index ccf44feb..3b688b8a 100644
--- a/src/rcore_drm.c
+++ b/src/rcore_drm.c
@@ -742,25 +742,12 @@ void OpenURL(const char *url)
// Get gamepad internal name id
const char *GetGamepadName(int gamepad)
{
- const char *name = NULL;
-
- if (CORE.Input.Gamepad.ready[gamepad])
- {
- ioctl(platform.gamepadStreamFd[gamepad], JSIOCGNAME(64), &CORE.Input.Gamepad.name[gamepad]);
- name = CORE.Input.Gamepad.name[gamepad];
- }
-
- return name;
+ return CORE.Input.Gamepad.name[gamepad];
}
// Get gamepad axis count
int GetGamepadAxisCount(int gamepad)
{
- int axisCount = 0;
-
- if (CORE.Input.Gamepad.ready[gamepad]) ioctl(platform.gamepadStreamFd[gamepad], JSIOCGAXES, &axisCount);
- CORE.Input.Gamepad.axisCount = axisCount;
-
return CORE.Input.Gamepad.axisCount;
}
@@ -1959,6 +1946,9 @@ static void InitGamepad(void)
if (error != 0) TRACELOG(LOG_WARNING, "RPI: Failed to create gamepad input event thread");
else TRACELOG(LOG_INFO, "RPI: Gamepad device initialized successfully");
}
+
+ ioctl(platform.gamepadStreamFd[i], JSIOCGNAME(64), &CORE.Input.Gamepad.name[i]);
+ ioctl(platform.gamepadStreamFd[i], JSIOCGAXES, &CORE.Input.Gamepad.axisCount);
}
}
}