From 8e5c2adda3a8628bb8f7d53181d64b6e9e4d18c3 Mon Sep 17 00:00:00 2001 From: Carter Li Date: Sun, 16 Feb 2025 11:05:58 +0800 Subject: [PATCH] Gamepad (Haiku): add support --- src/detection/gamepad/gamepad_haiku.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 src/detection/gamepad/gamepad_haiku.cpp diff --git a/src/detection/gamepad/gamepad_haiku.cpp b/src/detection/gamepad/gamepad_haiku.cpp new file mode 100644 index 000000000..820836f07 --- /dev/null +++ b/src/detection/gamepad/gamepad_haiku.cpp @@ -0,0 +1,21 @@ +extern "C" { +#include "gamepad.h" +} +#include + +const char* ffDetectGamepad(FFlist* devices /* List of FFGamepadDevice */) +{ + BJoystick js; + for (int32 i = 0, n = js.CountDevices(); i < n; ++i) + { + char name[B_OS_NAME_LENGTH]; + if (js.GetDeviceName(i, name) == B_OK) + { + FFGamepadDevice* device = (FFGamepadDevice*) ffListAdd(devices); + ffStrbufInit(&device->serial); + ffStrbufInitS(&device->name, name); + device->battery = 0; + } + } + return NULL; +}