#include #include #include "hid-simple.h" #define DRIVER_DESC "HID simple device example #1" #define DRIVER_VERSION "0.1.0" /* For BETOP BTP-C033 joystick (A popluar product in China market) */ #define SAMPLE_ID_VENDOR 0x0e8f #define SAMPLE_ID_PRODUCT 0x0003 struct sample_device { struct hidinput_simple_device device; }; static struct usb_device_id __id[] = { { USB_DEVICE(SAMPLE_ID_VENDOR, SAMPLE_ID_PRODUCT) }, {0, } }; MODULE_DEVICE_TABLE(usb, __id); static char device_name[] = "The sample of HID simple device #1"; static void sample_setup_usage(struct hid_field *field, struct hid_usage *usage) { struct input_dev *input = &field->hidinput->input; if ((usage->hid & HID_USAGE_PAGE) == HID_UP_BUTTON) set_bit(EV_REP, input->evbit); } static void sample_clear_usage(struct hid_field *field, struct hid_usage *usage) { struct input_dev *input = &field->hidinput->input; if ((usage->hid & HID_USAGE_PAGE) == HID_UP_BUTTON) clear_bit(EV_REP, input->evbit); } static struct sample_device sample_device = { .device = { .name = device_name, .setup_usage = sample_setup_usage, .clear_usage = sample_clear_usage, .id = { { USB_DEVICE(SAMPLE_ID_VENDOR, SAMPLE_ID_PRODUCT) }, {} } } }; static int __init sample_init(void) { int result = hidinput_register_simple_device(&sample_device.device); if (result == 1) { /* * The device that matched is busy, this can see as one error, * but we bypass it in this sample. */ printk("hid device busy\n"); } if (result >= 0) info(DRIVER_DESC ":" DRIVER_VERSION); return 0; } static void __exit sample_exit(void) { hidinput_unregister_simple_device(&sample_device.device); } module_init(sample_init); module_exit(sample_exit); MODULE_LICENSE("GPL"); /* The sample showed, the sample use simple interface is simple :) */