2 * HID driver for some ntrig "special" devices
4 * Copyright (c) 1999 Andreas Gal
5 * Copyright (c) 2000-2005 Vojtech Pavlik <vojtech@suse.cz>
6 * Copyright (c) 2005 Michael Haboustak <mike-@cinci.rr.com> for Concept2, Inc
7 * Copyright (c) 2006-2007 Jiri Kosina
8 * Copyright (c) 2007 Paul Walmsley
9 * Copyright (c) 2008 Jiri Slaby
10 * Copyright (c) 2008 Rafi Rubin
15 * This program is free software; you can redistribute it and/or modify it
16 * under the terms of the GNU General Public License as published by the Free
17 * Software Foundation; either version 2 of the License, or (at your option)
21 #include <linux/device.h>
22 #include <linux/hid.h>
23 #include <linux/module.h>
27 #define NTRIG_DUPLICATE_USAGES 0x001
29 #define nt_map_key_clear(c) hid_map_usage_clear(hi, usage, bit, max, \
32 static int ntrig_input_mapping(struct hid_device
*hdev
, struct hid_input
*hi
,
33 struct hid_field
*field
, struct hid_usage
*usage
,
34 unsigned long **bit
, int *max
)
36 if ((usage
->hid
& HID_USAGE_PAGE
) == HID_UP_DIGITIZER
&&
37 (usage
->hid
& 0xff) == 0x47) {
38 nt_map_key_clear(BTN_TOOL_DOUBLETAP
);
44 static int ntrig_input_mapped(struct hid_device
*hdev
, struct hid_input
*hi
,
45 struct hid_field
*field
, struct hid_usage
*usage
,
46 unsigned long **bit
, int *max
)
48 if (usage
->type
== EV_KEY
|| usage
->type
== EV_REL
49 || usage
->type
== EV_ABS
)
50 clear_bit(usage
->code
, *bit
);
54 static const struct hid_device_id ntrig_devices
[] = {
55 { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG
, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN
),
56 .driver_data
= NTRIG_DUPLICATE_USAGES
},
59 MODULE_DEVICE_TABLE(hid
, ntrig_devices
);
61 static struct hid_driver ntrig_driver
= {
63 .id_table
= ntrig_devices
,
64 .input_mapping
= ntrig_input_mapping
,
65 .input_mapped
= ntrig_input_mapped
,
68 static int ntrig_init(void)
70 return hid_register_driver(&ntrig_driver
);
73 static void ntrig_exit(void)
75 hid_unregister_driver(&ntrig_driver
);
78 module_init(ntrig_init
);
79 module_exit(ntrig_exit
);
80 MODULE_LICENSE("GPL");
82 HID_COMPAT_LOAD_DRIVER(ntrig
);