static long get_usage_page(IOHIDDeviceRef device) { long res; res = get_long_property(device, CFSTR(kIOHIDDeviceUsagePageKey)); if (!res) res = get_long_property(device, CFSTR(kIOHIDPrimaryUsagePageKey)); return res; }
int main (int argc, char **argv) { int ret = EXIT_SUCCESS; Display *disp; Window root; char *newName; long pos = -1; int insert = 0; char *oldList; size_t oldLen; char *newList; size_t newLen; consume_arguments(argc, argv, &pos, &insert, &newName); disp = XOpenDisplay(NULL); if (disp == NULL) { fputs("Can't open display.\n", stderr); exit(EXIT_FAILURE); } root = DefaultRootWindow(disp); if (pos < 0) { pos = get_long_property(disp, root, "_NET_CURRENT_DESKTOP"); if (pos < 0) { fprintf(stderr, "Can't get _NET_CURRENT_DESKTOP.\n"); exit(EXIT_FAILURE); } } oldList = get_string_property(disp, root, "_NET_DESKTOP_NAMES", &oldLen); if (oldList == NULL) { fprintf(stderr, "Can't get _NET_DESKTOP_NAMES.\n"); exit(EXIT_FAILURE); } newList = add_name_to_list(oldList, oldLen, newName, pos, insert, &newLen); if (newList == NULL) { ret = EXIT_FAILURE; goto F1; } set_string_property(disp, root, "_NET_DESKTOP_NAMES", newList, newLen); XCloseDisplay(disp); free(newList); F1: free(oldList); exit(ret); }
static long get_max_report_length(IOHIDDeviceRef device) { return get_long_property(device, CFSTR(kIOHIDMaxInputReportSizeKey)); }
static unsigned short get_product_id(IOHIDDeviceRef device) { return get_long_property(device, CFSTR(kIOHIDProductIDKey)); }
static unsigned short get_vendor_id(IOHIDDeviceRef device) { return get_long_property(device, CFSTR(kIOHIDVendorIDKey)); }
static long get_location_id(IOHIDDeviceRef device) { return get_long_property(device, CFSTR(kIOHIDLocationIDKey)); }
static uint16_t get_vendor_id(IOHIDDeviceRef device) { return get_long_property(device, CFSTR(kIOHIDVendorIDKey)); }
static uint16_t get_product_id(IOHIDDeviceRef device) { return get_long_property(device, CFSTR(kIOHIDProductIDKey)); }