modpost: add support for hid
[linux-block.git] / drivers / hid / hid-input.c
Content-type: text/html git.kernel.dk Git - linux-block.git/blame - drivers/hid/hid-input.c


500 - Internal Server Error

Malformed UTF-8 character (fatal) at (eval 8) line 1, <$fd> line 311.
CommitLineData
dde5845a 1/*
dde5845a 2 * Copyright (c) 2000-2001 Vojtech Pavlik
b55fd23c 3 * Copyright (c) 2006-2007 Jiri Kosina
dde5845a
JK
4 *
5 * HID to Linux Input mapping
6 */
7
8/*
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 *
23 * Should you need to contact me, the author, you can do so either by
24 * e-mail - mail your message to <vojtech@ucw.cz>, or by paper mail:
25 * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic
26 */
27
28#include <linux/module.h>
29#include <linux/slab.h>
30#include <linux/kernel.h>
dde5845a 31
dde5845a 32#include <linux/hid.h>
c080d89a 33#include <linux/hid-debug.h>
dde5845a 34
81e1a875
MD
35static int hid_apple_fnmode = 1;
36module_param_named(pb_fnmode, hid_apple_fnmode, int, 0644);
76398f96 37MODULE_PARM_DESC(pb_fnmode,
81e1a875 38 "Mode of fn key on Apple keyboards (0 = disabled, 1 = fkeyslast, 2 = fkeysfirst)");
76398f96 39
dde5845a
JK
40#define unk KEY_UNKNOWN
41
42static const unsigned char hid_keyboard[256] = {
43 0, 0, 0, 0, 30, 48, 46, 32, 18, 33, 34, 35, 23, 36, 37, 38,
44 50, 49, 24, 25, 16, 19, 31, 20, 22, 47, 17, 45, 21, 44, 2, 3,
45 4, 5, 6, 7, 8, 9, 10, 11, 28, 1, 14, 15, 57, 12, 13, 26,
46 27, 43, 43, 39, 40, 41, 51, 52, 53, 58, 59, 60, 61, 62, 63, 64,
47 65, 66, 67, 68, 87, 88, 99, 70,119,110,102,104,111,107,109,106,
48 105,108,103, 69, 98, 55, 74, 78, 96, 79, 80, 81, 75, 76, 77, 71,
49 72, 73, 82, 83, 86,127,116,117,183,184,185,186,187,188,189,190,
50 191,192,193,194,134,138,130,132,128,129,131,137,133,135,136,113,
51 115,114,unk,unk,unk,121,unk, 89, 93,124, 92, 94, 95,unk,unk,unk,
52 122,123, 90, 91, 85,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,
53 unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,
1fe8736d 54 unk,unk,unk,unk,unk,unk,179,180,unk,unk,unk,unk,unk,unk,unk,unk,
dde5845a
JK
55 unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,
56 unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,unk,
57 29, 42, 56,125, 97, 54,100,126,164,166,165,163,161,115,114,113,
58 150,158,159,128,136,177,178,176,142,152,173,140,unk,unk,unk,unk
59};
60
5f9c464a
RD
61/* extended mapping for certain Logitech hardware (Logitech cordless desktop LX500) */
62#define LOGITECH_EXPANDED_KEYMAP_SIZE 80
63static int logitech_expanded_keymap[LOGITECH_EXPANDED_KEYMAP_SIZE] = {
64 0,216, 0,213,175,156, 0, 0, 0, 0,
65 144, 0, 0, 0, 0, 0, 0, 0, 0,212,
66 174,167,152,161,112, 0, 0, 0,154, 0,
67 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
68 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
69 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
70 0, 0, 0, 0, 0,183,184,185,186,187,
71 188,189,190,191,192,193,194, 0, 0, 0
72};
73
dde5845a
JK
74static const struct {
75 __s32 x;
76 __s32 y;
77} hid_hat_to_axis[] = {{ 0, 0}, { 0,-1}, { 1,-1}, { 1, 0}, { 1, 1}, { 0, 1}, {-1, 1}, {-1, 0}, {-1,-1}};
78
79#define map_abs(c) do { usage->code = c; usage->type = EV_ABS; bit = input->absbit; max = ABS_MAX; } while (0)
80#define map_rel(c) do { usage->code = c; usage->type = EV_REL; bit = input->relbit; max = REL_MAX; } while (0)
81#define map_key(c) do { usage->code = c; usage->type = EV_KEY; bit = input->keybit; max = KEY_MAX; } while (0)
82#define map_led(c) do { usage->code = c; usage->type = EV_LED; bit = input->ledbit; max = LED_MAX; } while (0)
83
84#define map_abs_clear(c) do { map_abs(c); clear_bit(c, bit); } while (0)
85#define map_key_clear(c) do { map_key(c); clear_bit(c, bit); } while (0)
86
87#ifdef CONFIG_USB_HIDINPUT_POWERBOOK
88
89struct hidinput_key_translation {
90 u16 from;
91 u16 to;
92 u8 flags;
93};
94
81e1a875 95#define APPLE_FLAG_FKEY 0x01
dde5845a 96
a45d82d1 97static struct hidinput_key_translation apple_fn_keys[] = {
5906a044 98 { KEY_BACKSPACE, KEY_DELETE },
07146648
MH
99 { KEY_F1, KEY_BRIGHTNESSDOWN, APPLE_FLAG_FKEY },
100 { KEY_F2, KEY_BRIGHTNESSUP, APPLE_FLAG_FKEY },
101