Skip to content

Commit 944536c

Browse files
Sandeep C SJiri Kosina
authored andcommitted
HID: samsung: Add Samsung wireless gamepad support
Add support for samsung wireless gamepad with input mapping events. Device a000 (Samsung wireless gamepad) Signed-off-by: Sandeep C S <[email protected]> Signed-off-by: Junwan Cho <[email protected]> Signed-off-by: Jitender Sajwan <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent 9b8e4ad commit 944536c

File tree

2 files changed

+96
-0
lines changed

2 files changed

+96
-0
lines changed

drivers/hid/hid-ids.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1147,6 +1147,7 @@
11471147
#define USB_DEVICE_ID_SAMSUNG_IR_REMOTE 0x0001
11481148
#define USB_DEVICE_ID_SAMSUNG_WIRELESS_KBD_MOUSE 0x0600
11491149
#define USB_DEVICE_ID_SAMSUNG_WIRELESS_KBD 0x7021
1150+
#define USB_DEVICE_ID_SAMSUNG_WIRELESS_GAMEPAD 0xa000
11501151

11511152
#define USB_VENDOR_ID_SEMICO 0x1a2c
11521153
#define USB_DEVICE_ID_SEMICO_USB_KEYKOARD 0x0023

drivers/hid/hid-samsung.c

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,97 @@ static int samsung_kbd_input_mapping(struct hid_device *hdev,
232232
return 1;
233233
}
234234

235+
static int samsung_gamepad_input_mapping(struct hid_device *hdev,
236+
struct hid_input *hi, struct hid_field *field, struct hid_usage *usage,
237+
unsigned long **bit, int *max)
238+
{
239+
if (!(HID_UP_BUTTON == (usage->hid & HID_USAGE_PAGE) ||
240+
HID_UP_CONSUMER == (usage->hid & HID_USAGE_PAGE)))
241+
return 0;
242+
243+
dbg_hid("samsung wireless gamepad input mapping event [0x%x], %ld, %ld, [0x%x]\n",
244+
usage->hid & HID_USAGE, hi->input->evbit[0], hi->input->absbit[0], usage->hid & HID_USAGE_PAGE);
245+
246+
if (HID_UP_BUTTON == (usage->hid & HID_USAGE_PAGE)) {
247+
switch (usage->hid & HID_USAGE) {
248+
case 0x01:
249+
samsung_kbd_mouse_map_key_clear(BTN_A);
250+
break;
251+
case 0x02:
252+
samsung_kbd_mouse_map_key_clear(BTN_B);
253+
break;
254+
case 0x03:
255+
samsung_kbd_mouse_map_key_clear(BTN_C);
256+
break;
257+
case 0x04:
258+
samsung_kbd_mouse_map_key_clear(BTN_X);
259+
break;
260+
case 0x05:
261+
samsung_kbd_mouse_map_key_clear(BTN_Y);
262+
break;
263+
case 0x06:
264+
samsung_kbd_mouse_map_key_clear(BTN_Z);
265+
break;
266+
case 0x07:
267+
samsung_kbd_mouse_map_key_clear(BTN_TL);
268+
break;
269+
case 0x08:
270+
samsung_kbd_mouse_map_key_clear(BTN_TR);
271+
break;
272+
case 0x09:
273+
samsung_kbd_mouse_map_key_clear(BTN_TL2);
274+
break;
275+
case 0x0a:
276+
samsung_kbd_mouse_map_key_clear(BTN_TR2);
277+
break;
278+
case 0x0b:
279+
samsung_kbd_mouse_map_key_clear(BTN_SELECT);
280+
break;
281+
case 0x0c:
282+
samsung_kbd_mouse_map_key_clear(BTN_START);
283+
break;
284+
case 0x0d:
285+
samsung_kbd_mouse_map_key_clear(BTN_MODE);
286+
break;
287+
case 0x0e:
288+
samsung_kbd_mouse_map_key_clear(BTN_THUMBL);
289+
break;
290+
case 0x0f:
291+
samsung_kbd_mouse_map_key_clear(BTN_THUMBR);
292+
break;
293+
case 0x10:
294+
samsung_kbd_mouse_map_key_clear(0x13f);
295+
break;
296+
default:
297+
return 0;
298+
}
299+
}
300+
301+
if (HID_UP_CONSUMER == (usage->hid & HID_USAGE_PAGE)) {
302+
switch (usage->hid & HID_USAGE) {
303+
case 0x040:
304+
samsung_kbd_mouse_map_key_clear(KEY_MENU);
305+
break;
306+
case 0x223:
307+
samsung_kbd_mouse_map_key_clear(KEY_HOMEPAGE);
308+
break;
309+
case 0x224:
310+
samsung_kbd_mouse_map_key_clear(KEY_BACK);
311+
break;
312+
313+
/* Screen Capture */
314+
case 0x303:
315+
samsung_kbd_mouse_map_key_clear(KEY_SYSRQ);
316+
break;
317+
318+
default:
319+
return 0;
320+
}
321+
}
322+
323+
return 1;
324+
}
325+
235326
static __u8 *samsung_report_fixup(struct hid_device *hdev, __u8 *rdesc,
236327
unsigned int *rsize)
237328
{
@@ -252,6 +343,9 @@ static int samsung_input_mapping(struct hid_device *hdev, struct hid_input *hi,
252343
else if (hdev->product == USB_DEVICE_ID_SAMSUNG_WIRELESS_KBD)
253344
ret = samsung_kbd_input_mapping(hdev,
254345
hi, field, usage, bit, max);
346+
else if (hdev->product == USB_DEVICE_ID_SAMSUNG_WIRELESS_GAMEPAD)
347+
ret = samsung_gamepad_input_mapping(hdev,
348+
hi, field, usage, bit, max);
255349

256350
return ret;
257351
}
@@ -295,6 +389,7 @@ static const struct hid_device_id samsung_devices[] = {
295389
{ HID_USB_DEVICE(USB_VENDOR_ID_SAMSUNG, USB_DEVICE_ID_SAMSUNG_IR_REMOTE) },
296390
{ HID_USB_DEVICE(USB_VENDOR_ID_SAMSUNG, USB_DEVICE_ID_SAMSUNG_WIRELESS_KBD_MOUSE) },
297391
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SAMSUNG_ELECTRONICS, USB_DEVICE_ID_SAMSUNG_WIRELESS_KBD) },
392+
{ HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SAMSUNG_ELECTRONICS, USB_DEVICE_ID_SAMSUNG_WIRELESS_GAMEPAD) },
298393
{ }
299394
};
300395
MODULE_DEVICE_TABLE(hid, samsung_devices);

0 commit comments

Comments
 (0)