Skip to content

Commit f5dbbb7

Browse files
committed
Mouse / Keyboard (Haiku): code cleanup; ignore disabled devices
1 parent fc3f477 commit f5dbbb7

File tree

2 files changed

+12
-30
lines changed

2 files changed

+12
-30
lines changed

src/detection/keyboard/keyboard_haiku.cpp

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
extern "C" {
22
#include "keyboard.h"
3-
#include "common/io/io.h"
43
}
54

65
#include <interface/Input.h>
@@ -9,27 +8,19 @@ extern "C" {
98
const char* ffDetectKeyboard(FFlist* devices /* List of FFKeyboardDevice */)
109
{
1110
BList list;
12-
BInputDevice *device;
1311

1412
if (get_input_devices(&list) != B_OK)
15-
{
1613
return "get_input_devices() failed";
17-
}
1814

19-
int32 i, n = list.CountItems();
20-
for (i = 0; i < n; i++)
15+
for (int32 i = 0, n = list.CountItems(); i < n; i++)
2116
{
22-
device = (BInputDevice *) list.ItemAt(i);
23-
if (device->Type() != B_KEYBOARD_DEVICE)
17+
BInputDevice *device = (BInputDevice *) list.ItemAt(i);
18+
if (device->Type() != B_KEYBOARD_DEVICE || !device->IsRunning())
2419
continue;
2520

26-
FF_STRBUF_AUTO_DESTROY name = ffStrbufCreateS(device->Name());
27-
if (!device->IsRunning())
28-
ffStrbufAppendS(&name, " (stopped)");
29-
30-
FFKeyboardDevice* device = (FFKeyboardDevice*) ffListAdd(devices);
31-
ffStrbufInit(&device->serial);
32-
ffStrbufInitMove(&device->name, &name);
21+
FFKeyboardDevice* item = (FFKeyboardDevice*) ffListAdd(devices);
22+
ffStrbufInit(&item->serial);
23+
ffStrbufInitS(&item->name, device->Name());
3324
}
3425

3526
return NULL;

src/detection/mouse/mouse_haiku.cpp

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
extern "C" {
22
#include "mouse.h"
3-
#include "common/io/io.h"
43
}
54

65
#include <interface/Input.h>
@@ -9,27 +8,19 @@ extern "C" {
98
const char* ffDetectMouse(FFlist* devices /* List of FFMouseDevice */)
109
{
1110
BList list;
12-
BInputDevice *device;
1311

1412
if (get_input_devices(&list) != B_OK)
15-
{
1613
return "get_input_devices() failed";
17-
}
1814

19-
int32 i, n = list.CountItems();
20-
for (i = 0; i < n; i++)
15+
for (int32 i = 0, n = list.CountItems(); i < n; i++)
2116
{
22-
device = (BInputDevice *) list.ItemAt(i);
23-
if (device->Type() != B_POINTING_DEVICE)
17+
BInputDevice *device = (BInputDevice *) list.ItemAt(i);
18+
if (device->Type() != B_POINTING_DEVICE || !device->IsRunning())
2419
continue;
2520

26-
FF_STRBUF_AUTO_DESTROY name = ffStrbufCreateS(device->Name());
27-
if (!device->IsRunning())
28-
ffStrbufAppendS(&name, " (stopped)");
29-
30-
FFMouseDevice* device = (FFMouseDevice*) ffListAdd(devices);
31-
ffStrbufInit(&device->serial);
32-
ffStrbufInitMove(&device->name, &name);
21+
FFMouseDevice* item = (FFMouseDevice*) ffListAdd(devices);
22+
ffStrbufInit(&item->serial);
23+
ffStrbufInitS(&item->name, device->Name());
3324
}
3425

3526
return NULL;

0 commit comments

Comments
 (0)