1 /* 2 ** Copyright 2004, Jérôme Duval. All rights reserved. 3 ** 4 ** Distributed under the terms of the MIT License. 5 */ 6 7 #include <Input.h> 8 #include <List.h> 9 10 #include <string.h> 11 #include <stdio.h> 12 13 int 14 main(int argc, char *argv[]) 15 { 16 BList list; 17 status_t err; 18 if ((err = get_input_devices(&list))!=B_OK) 19 printf("get_input_devices returned %s\n", strerror(err)); 20 21 for (uint32 i=0; i<(unsigned)list.CountItems(); i++) { 22 BInputDevice *device = (BInputDevice*)list.ItemAt(i); 23 if (device == NULL) { 24 printf("device %ld is NULL\n", i); 25 continue; 26 } 27 28 printf("device %ld %s ", i, device->Name()); 29 if (device->Type() == B_POINTING_DEVICE) 30 printf("B_POINTING_DEVICE\n"); 31 if (device->Type() == B_KEYBOARD_DEVICE) 32 printf("B_KEYBOARD_DEVICE\n"); 33 if (device->Type() == B_UNDEFINED_DEVICE) 34 printf("B_UNDEFINED_DEVICE\n"); 35 36 37 device = find_input_device(device->Name()); 38 if (device == NULL) { 39 printf("device %ld with find_input_device is NULL\n", i); 40 continue; 41 } 42 43 printf("device %ld with find_input_device %s ", i, device->Name()); 44 if (device->Type() == B_POINTING_DEVICE) 45 printf("B_POINTING_DEVICE"); 46 if (device->Type() == B_KEYBOARD_DEVICE) 47 printf("B_KEYBOARD_DEVICE"); 48 if (device->Type() == B_UNDEFINED_DEVICE) 49 printf("B_UNDEFINED_DEVICE"); 50 51 printf("\n"); 52 printf(" %s", device->IsRunning() ? "true" : "false"); 53 device->Stop(); 54 printf(" %s", device->IsRunning() ? "true" : "false"); 55 device->Start(); 56 printf(" %s", device->IsRunning() ? "true" : "false"); 57 device->Stop(); 58 printf(" %s", device->IsRunning() ? "true" : "false"); 59 device->Start(); 60 printf(" %s", device->IsRunning() ? "true" : "false"); 61 62 printf("\n"); 63 64 } 65 66 if (find_input_device("blahha") != NULL ) 67 printf("find_input_device(\"blahha\") not returned NULL\n"); 68 else 69 printf("find_input_device(\"blahha\") returned NULL\n"); 70 71 printf("\n"); 72 BInputDevice::Start(B_POINTING_DEVICE); 73 for (uint32 i=0; i<(unsigned)list.CountItems(); i++) { 74 BInputDevice *device = (BInputDevice*)list.ItemAt(i); 75 printf(" %s", device->IsRunning() ? "true" : "false"); 76 } 77 BInputDevice::Stop(B_POINTING_DEVICE); 78 for (uint32 i=0; i<(unsigned)list.CountItems(); i++) { 79 BInputDevice *device = (BInputDevice*)list.ItemAt(i); 80 printf(" %s", device->IsRunning() ? "true" : "false"); 81 } 82 BInputDevice::Start(B_POINTING_DEVICE); 83 for (uint32 i=0; i<(unsigned)list.CountItems(); i++) { 84 BInputDevice *device = (BInputDevice*)list.ItemAt(i); 85 printf(" %s", device->IsRunning() ? "true" : "false"); 86 } 87 BInputDevice::Stop(B_POINTING_DEVICE); 88 for (uint32 i=0; i<(unsigned)list.CountItems(); i++) { 89 BInputDevice *device = (BInputDevice*)list.ItemAt(i); 90 printf(" %s", device->IsRunning() ? "true" : "false"); 91 } 92 BInputDevice::Start(B_POINTING_DEVICE); 93 for (uint32 i=0; i<(unsigned)list.CountItems(); i++) { 94 BInputDevice *device = (BInputDevice*)list.ItemAt(i); 95 printf(" %s", device->IsRunning() ? "true" : "false"); 96 } 97 printf("\n"); 98 return 0; 99 } 100 101