@@ -232,6 +232,97 @@ static int samsung_kbd_input_mapping(struct hid_device *hdev,
232
232
return 1 ;
233
233
}
234
234
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
+
235
326
static __u8 * samsung_report_fixup (struct hid_device * hdev , __u8 * rdesc ,
236
327
unsigned int * rsize )
237
328
{
@@ -252,6 +343,9 @@ static int samsung_input_mapping(struct hid_device *hdev, struct hid_input *hi,
252
343
else if (hdev -> product == USB_DEVICE_ID_SAMSUNG_WIRELESS_KBD )
253
344
ret = samsung_kbd_input_mapping (hdev ,
254
345
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 );
255
349
256
350
return ret ;
257
351
}
@@ -295,6 +389,7 @@ static const struct hid_device_id samsung_devices[] = {
295
389
{ HID_USB_DEVICE (USB_VENDOR_ID_SAMSUNG , USB_DEVICE_ID_SAMSUNG_IR_REMOTE ) },
296
390
{ HID_USB_DEVICE (USB_VENDOR_ID_SAMSUNG , USB_DEVICE_ID_SAMSUNG_WIRELESS_KBD_MOUSE ) },
297
391
{ 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 ) },
298
393
{ }
299
394
};
300
395
MODULE_DEVICE_TABLE (hid , samsung_devices );
0 commit comments