From daba1a27945d6be914e71f71fe8e7cfaef1eca5e Mon Sep 17 00:00:00 2001 From: MichaelFiber <42419558+michaelfiber@users.noreply.github.com> Date: Wed, 11 Oct 2023 04:30:51 -0400 Subject: 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 --- src/rcore_drm.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) (limited to 'src') 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); } } } -- cgit v1.2.3