Linux Kernel
3.7.1
Main Page
Related Pages
Modules
Namespaces
Data Structures
Files
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Groups
Pages
drivers
hid
hid-primax.c
Go to the documentation of this file.
1
/*
2
* HID driver for primax and similar keyboards with in-band modifiers
3
*
4
* Copyright 2011 Google Inc. All Rights Reserved
5
*
6
* Author:
7
* Terry Lambert <
[email protected]
>
8
*
9
* This software is licensed under the terms of the GNU General Public
10
* License version 2, as published by the Free Software Foundation, and
11
* may be copied, distributed, and modified under those terms.
12
*
13
* This program is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
* GNU General Public License for more details.
17
*/
18
19
#include <linux/device.h>
20
#include <linux/hid.h>
21
#include <linux/module.h>
22
23
#include "
hid-ids.h
"
24
25
static
int
px_raw_event(
struct
hid_device
*hid,
struct
hid_report
*
report
,
26
u8
*
data
,
int
size
)
27
{
28
int
idx
=
size
;
29
30
switch
(report->
id
) {
31
case
0:
/* keyboard input */
32
/*
33
* Convert in-band modifier key values into out of band
34
* modifier bits and pull the key strokes from the report.
35
* Thus a report data set which looked like:
36
*
37
* [00][00][E0][30][00][00][00][00]
38
* (no modifier bits + "Left Shift" key + "1" key)
39
*
40
* Would be converted to:
41
*
42
* [01][00][00][30][00][00][00][00]
43
* (Left Shift modifier bit + "1" key)
44
*
45
* As long as it's in the size range, the upper level
46
* drivers don't particularly care if there are in-band
47
* 0-valued keys, so they don't stop parsing.
48
*/
49
while
(--idx > 1) {
50
if
(data[idx] < 0xE0 || data[idx] > 0xE7)
51
continue
;
52
data[0] |= (1 << (data[
idx
] - 0xE0));
53
data[
idx
] = 0;
54
}
55
hid_report_raw_event
(hid,
HID_INPUT_REPORT
, data, size, 0);
56
return
1;
57
58
default
:
/* unknown report */
59
/* Unknown report type; pass upstream */
60
hid_info
(hid,
"unknown report type %d\n"
, report->
id
);
61
break
;
62
}
63
64
return
0;
65
}
66
67
static
const
struct
hid_device_id
px_devices[] = {
68
{
HID_USB_DEVICE
(
USB_VENDOR_ID_PRIMAX
,
USB_DEVICE_ID_PRIMAX_KEYBOARD
) },
69
{ }
70
};
71
MODULE_DEVICE_TABLE
(hid, px_devices);
72
73
static
struct
hid_driver
px_driver = {
74
.name =
"primax"
,
75
.id_table = px_devices,
76
.raw_event = px_raw_event,
77
};
78
79
static
int
__init
px_init(
void
)
80
{
81
return
hid_register_driver
(&px_driver);
82
}
83
84
static
void
__exit
px_exit(
void
)
85
{
86
hid_unregister_driver
(&px_driver);
87
}
88
89
module_init
(px_init);
90
module_exit
(px_exit);
91
MODULE_AUTHOR
(
"Terry Lambert <
[email protected]
>"
);
92
MODULE_LICENSE
(
"GPL"
);
Generated on Thu Jan 10 2013 13:34:09 for Linux Kernel by
1.8.2