Skip to content

Commit 6cf8c85

Browse files
author
Jiri Kosina
committed
Merge branch 'for-3.15/microsoft' into for-linus
Conflicts: drivers/hid/hid-core.c
2 parents ded7566 + 34e75dc commit 6cf8c85

4 files changed

Lines changed: 75 additions & 4 deletions

File tree

drivers/hid/hid-core.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1823,6 +1823,7 @@ static const struct hid_device_id hid_have_special_driver[] = {
18231823
{ HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_WIRELESS_OPTICAL_DESKTOP_3_0) },
18241824
{ HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_TYPE_COVER_2) },
18251825
{ HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_TOUCH_COVER_2) },
1826+
{ HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_OFFICE_KB) },
18261827
{ HID_USB_DEVICE(USB_VENDOR_ID_MONTEREY, USB_DEVICE_ID_GENIUS_KB29E) },
18271828
{ HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN) },
18281829
{ HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_1) },

drivers/hid/hid-ids.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -615,6 +615,7 @@
615615

616616
#define USB_VENDOR_ID_MICROSOFT 0x045e
617617
#define USB_DEVICE_ID_SIDEWINDER_GV 0x003b
618+
#define USB_DEVICE_ID_MS_OFFICE_KB 0x0048
618619
#define USB_DEVICE_ID_WIRELESS_OPTICAL_DESKTOP_3_0 0x009d
619620
#define USB_DEVICE_ID_MS_NE4K 0x00db
620621
#define USB_DEVICE_ID_MS_NE4K_JP 0x00dc

drivers/hid/hid-input.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -789,10 +789,13 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
789789
case 0x199: map_key_clear(KEY_CHAT); break;
790790
case 0x19c: map_key_clear(KEY_LOGOFF); break;
791791
case 0x19e: map_key_clear(KEY_COFFEE); break;
792+
case 0x1a3: map_key_clear(KEY_NEXT); break;
793+
case 0x1a4: map_key_clear(KEY_PREVIOUS); break;
792794
case 0x1a6: map_key_clear(KEY_HELP); break;
793795
case 0x1a7: map_key_clear(KEY_DOCUMENTS); break;
794796
case 0x1ab: map_key_clear(KEY_SPELLCHECK); break;
795797
case 0x1ae: map_key_clear(KEY_KEYBOARD); break;
798+
case 0x1b4: map_key_clear(KEY_FILE); break;
796799
case 0x1b6: map_key_clear(KEY_IMAGES); break;
797800
case 0x1b7: map_key_clear(KEY_AUDIO); break;
798801
case 0x1b8: map_key_clear(KEY_VIDEO); break;

drivers/hid/hid-microsoft.c

Lines changed: 70 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,48 @@ static int ms_ergonomy_kb_quirk(struct hid_input *hi, struct hid_usage *usage,
6262
{
6363
struct input_dev *input = hi->input;
6464

65+
if ((usage->hid & HID_USAGE_PAGE) == HID_UP_CONSUMER) {
66+
switch (usage->hid & HID_USAGE) {
67+
/*
68+
* Microsoft uses these 2 reserved usage ids for 2 keys on
69+
* the MS office kb labelled "Office Home" and "Task Pane".
70+
*/
71+
case 0x29d:
72+
ms_map_key_clear(KEY_PROG1);
73+
return 1;
74+
case 0x29e:
75+
ms_map_key_clear(KEY_PROG2);
76+
return 1;
77+
}
78+
return 0;
79+
}
80+
81+
if ((usage->hid & HID_USAGE_PAGE) != HID_UP_MSVENDOR)
82+
return 0;
83+
6584
switch (usage->hid & HID_USAGE) {
6685
case 0xfd06: ms_map_key_clear(KEY_CHAT); break;
6786
case 0xfd07: ms_map_key_clear(KEY_PHONE); break;
87+
case 0xff00:
88+
/* Special keypad keys */
89+
ms_map_key_clear(KEY_KPEQUAL);
90+
set_bit(KEY_KPLEFTPAREN, input->keybit);
91+
set_bit(KEY_KPRIGHTPAREN, input->keybit);
92+
break;
93+
case 0xff01:
94+
/* Scroll wheel */
95+
hid_map_usage_clear(hi, usage, bit, max, EV_REL, REL_WHEEL);
96+
break;
97+
case 0xff02:
98+
/*
99+
* This byte contains a copy of the modifier keys byte of a
100+
* standard hid keyboard report, as send by interface 0
101+
* (this usage is found on interface 1).
102+
*
103+
* This byte only gets send when another key in the same report
104+
* changes state, and as such is useless, ignore it.
105+
*/
106+
return -1;
68107
case 0xff05:
69108
set_bit(EV_REP, input->evbit);
70109
ms_map_key_clear(KEY_F13);
@@ -83,6 +122,9 @@ static int ms_ergonomy_kb_quirk(struct hid_input *hi, struct hid_usage *usage,
83122
static int ms_presenter_8k_quirk(struct hid_input *hi, struct hid_usage *usage,
84123
unsigned long **bit, int *max)
85124
{
125+
if ((usage->hid & HID_USAGE_PAGE) != HID_UP_MSVENDOR)
126+
return 0;
127+
86128
set_bit(EV_REP, hi->input->evbit);
87129
switch (usage->hid & HID_USAGE) {
88130
case 0xfd08: ms_map_key_clear(KEY_FORWARD); break;
@@ -102,9 +144,6 @@ static int ms_input_mapping(struct hid_device *hdev, struct hid_input *hi,
102144
{
103145
unsigned long quirks = (unsigned long)hid_get_drvdata(hdev);
104146

105-
if ((usage->hid & HID_USAGE_PAGE) != HID_UP_MSVENDOR)
106-
return 0;
107-
108147
if (quirks & MS_ERGONOMY) {
109148
int ret = ms_ergonomy_kb_quirk(hi, usage, bit, max);
110149
if (ret)
@@ -134,14 +173,39 @@ static int ms_event(struct hid_device *hdev, struct hid_field *field,
134173
struct hid_usage *usage, __s32 value)
135174
{
136175
unsigned long quirks = (unsigned long)hid_get_drvdata(hdev);
176+
struct input_dev *input;
137177

138178
if (!(hdev->claimed & HID_CLAIMED_INPUT) || !field->hidinput ||
139179
!usage->type)
140180
return 0;
141181

182+
input = field->hidinput->input;
183+
142184
/* Handling MS keyboards special buttons */
185+
if (quirks & MS_ERGONOMY && usage->hid == (HID_UP_MSVENDOR | 0xff00)) {
186+
/* Special keypad keys */
187+
input_report_key(input, KEY_KPEQUAL, value & 0x01);
188+
input_report_key(input, KEY_KPLEFTPAREN, value & 0x02);
189+
input_report_key(input, KEY_KPRIGHTPAREN, value & 0x04);
190+
return 1;
191+
}
192+
193+
if (quirks & MS_ERGONOMY && usage->hid == (HID_UP_MSVENDOR | 0xff01)) {
194+
/* Scroll wheel */
195+
int step = ((value & 0x60) >> 5) + 1;
196+
197+
switch (value & 0x1f) {
198+
case 0x01:
199+
input_report_rel(input, REL_WHEEL, step);
200+
break;
201+
case 0x1f:
202+
input_report_rel(input, REL_WHEEL, -step);
203+
break;
204+
}
205+
return 1;
206+
}
207+
143208
if (quirks & MS_ERGONOMY && usage->hid == (HID_UP_MSVENDOR | 0xff05)) {
144-
struct input_dev *input = field->hidinput->input;
145209
static unsigned int last_key = 0;
146210
unsigned int key = 0;
147211
switch (value) {
@@ -194,6 +258,8 @@ static int ms_probe(struct hid_device *hdev, const struct hid_device_id *id)
194258
static const struct hid_device_id ms_devices[] = {
195259
{ HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_SIDEWINDER_GV),
196260
.driver_data = MS_HIDINPUT },
261+
{ HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_OFFICE_KB),
262+
.driver_data = MS_ERGONOMY },
197263
{ HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_NE4K),
198264
.driver_data = MS_ERGONOMY },
199265
{ HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_NE4K_JP),

0 commit comments

Comments
 (0)