From 5ebf984e9a68f13cadd85ddafee1c9eeda09d351 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Revol?= Date: Sat, 15 Feb 2025 16:22:23 +0100 Subject: [PATCH] Keyboard (Haiku): add support --- CMakeLists.txt | 2 +- src/detection/keyboard/keyboard_haiku.cpp | 36 +++++++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 src/detection/keyboard/keyboard_haiku.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index f6313cc5..5a7d37f3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1149,7 +1149,7 @@ elseif(Haiku) src/detection/host/host_windows.c src/detection/icons/icons_nosupport.c src/detection/initsystem/initsystem_haiku.cpp - src/detection/keyboard/keyboard_nosupport.c + src/detection/keyboard/keyboard_haiku.cpp src/detection/libc/libc_nosupport.c src/detection/lm/lm_nosupport.c src/detection/loadavg/loadavg_nosupport.c diff --git a/src/detection/keyboard/keyboard_haiku.cpp b/src/detection/keyboard/keyboard_haiku.cpp new file mode 100644 index 00000000..77712511 --- /dev/null +++ b/src/detection/keyboard/keyboard_haiku.cpp @@ -0,0 +1,36 @@ +extern "C" { +#include "keyboard.h" +#include "common/io/io.h" +} + +#include +#include + +const char* ffDetectKeyboard(FFlist* devices /* List of FFKeyboardDevice */) +{ + BList list; + BInputDevice *device; + + if (get_input_devices(&list) != B_OK) + { + return "get_input_devices() failed"; + } + + int32 i, n = list.CountItems(); + for (i = 0; i < n; i++) + { + device = (BInputDevice *) list.ItemAt(i); + if (device->Type() != B_KEYBOARD_DEVICE) + continue; + + FF_STRBUF_AUTO_DESTROY name = ffStrbufCreateS(device->Name()); + if (!device->IsRunning()) + ffStrbufAppendS(&name, " (stopped)"); + + FFKeyboardDevice* device = (FFKeyboardDevice*) ffListAdd(devices); + ffStrbufInit(&device->serial); + ffStrbufInitMove(&device->name, &name); + } + + return NULL; +}