• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *  HID driver for some ntrig "special" devices
3  *
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
11  *
12  */
13 
14 /*
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)
18  * any later version.
19  */
20 
21 #include <linux/device.h>
22 #include <linux/hid.h>
23 #include <linux/module.h>
24 
25 #include "hid-ids.h"
26 
27 #define NTRIG_DUPLICATE_USAGES	0x001
28 
29 #define nt_map_key_clear(c)	hid_map_usage_clear(hi, usage, bit, max, \
30 					EV_KEY, (c))
31 
ntrig_input_mapping(struct hid_device * hdev,struct hid_input * hi,struct hid_field * field,struct hid_usage * usage,unsigned long ** bit,int * 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)
35 {
36 	if ((usage->hid & HID_USAGE_PAGE) == HID_UP_DIGITIZER &&
37 			(usage->hid & 0xff) == 0x47) {
38 		nt_map_key_clear(BTN_TOOL_DOUBLETAP);
39 		return 1;
40 	}
41 	return 0;
42 }
43 
ntrig_input_mapped(struct hid_device * hdev,struct hid_input * hi,struct hid_field * field,struct hid_usage * usage,unsigned long ** bit,int * max)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)
47 {
48 	if (usage->type == EV_KEY || usage->type == EV_REL
49 			|| usage->type == EV_ABS)
50 		clear_bit(usage->code, *bit);
51 
52 	return 0;
53 }
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 },
57 	{ }
58 };
59 MODULE_DEVICE_TABLE(hid, ntrig_devices);
60 
61 static struct hid_driver ntrig_driver = {
62 	.name = "ntrig",
63 	.id_table = ntrig_devices,
64 	.input_mapping = ntrig_input_mapping,
65 	.input_mapped = ntrig_input_mapped,
66 };
67 
ntrig_init(void)68 static int ntrig_init(void)
69 {
70 	return hid_register_driver(&ntrig_driver);
71 }
72 
ntrig_exit(void)73 static void ntrig_exit(void)
74 {
75 	hid_unregister_driver(&ntrig_driver);
76 }
77 
78 module_init(ntrig_init);
79 module_exit(ntrig_exit);
80 MODULE_LICENSE("GPL");
81 
82 HID_COMPAT_LOAD_DRIVER(ntrig);
83