3 * (c) 2002, Carlos Hasan, for OpenBeOS.
4 * Compile: gcc -Wall -Wno-multichar -O2 -o iroster iroster.cpp -lbe
9 #include <interface/Input.h>
10 #include <support/List.h>
12 static int list_devices()
19 printf(" name type state \n");
20 printf("--------------------------------------------------\n");
22 if ((err
= get_input_devices(&list
))!=B_OK
) {
23 fprintf(stderr
, "error while get_input_devices: %s\n", strerror(err
));
27 n
= list
.CountItems();
29 printf("...no input devices found...\n");
32 for (i
= 0; i
< n
; i
++) {
33 device
= (BInputDevice
*) list
.ItemAt(i
);
35 printf("%23s %18s %7s\n",
37 device
->Type() == B_POINTING_DEVICE
? "B_POINTING_DEVICE" :
38 device
->Type() == B_KEYBOARD_DEVICE
? "B_KEYBOARD_DEVICE" : "B_UNDEFINED_DEVICE",
39 device
->IsRunning() ? "running" : "stopped");
45 static void start_device(const char *name
)
50 device
= find_input_device(name
);
52 printf("Error finding device \"%s\"\n", name
);
54 else if ((status
= device
->Start()) != B_OK
) {
55 printf("Error starting device \"%s\" (%" B_PRId32
")\n", name
, status
);
58 printf("Started device \"%s\"\n", name
);
64 static void stop_device(const char *name
)
69 device
= find_input_device(name
);
71 printf("Error finding device \"%s\"\n", name
);
73 else if ((status
= device
->Stop()) != B_OK
) {
74 printf("Error stopping device \"%s\" (%" B_PRId32
")\n", name
, status
);
77 printf("Stopped device \"%s\"\n", name
);
83 int main(int argc
, char *argv
[])
89 return list_devices();
92 for (i
= 1; i
< argc
; i
++) {
95 start_device(name
+ 1);
97 else if (name
[0] == '-') {
98 stop_device(name
+ 1);
101 printf("USAGE: %s [+|-]input_device_name\n", argv
[0]);