Files
fastfetch/src/detection/gamepad/gamepad_haiku.cpp
T

19 lines
535 B
C++
Raw Normal View History

2025-02-16 11:05:58 +08:00
extern "C" {
#include "gamepad.h"
}
#include <Joystick.h>
2026-03-29 09:28:49 +08:00
const char* ffDetectGamepad(FFlist* devices /* List of FFGamepadDevice */) {
2025-02-16 11:05:58 +08:00
BJoystick js;
2026-03-29 09:28:49 +08:00
for (int32 i = 0, n = js.CountDevices(); i < n; ++i) {
2025-02-16 11:05:58 +08:00
char name[B_OS_NAME_LENGTH];
2026-03-29 09:28:49 +08:00
if (js.GetDeviceName(i, name) == B_OK) {
2025-02-16 11:05:58 +08:00
FFGamepadDevice* device = (FFGamepadDevice*) ffListAdd(devices);
ffStrbufInit(&device->serial);
ffStrbufInitS(&device->name, name);
device->battery = 0;
}
}
return NULL;
}