diff options
| -rw-r--r-- | drivers/hid/Kconfig | 15 | ||||
| -rw-r--r-- | drivers/hid/Makefile | 1 | ||||
| -rw-r--r-- | drivers/hid/hid-ps3remote.c | 204 | ||||
| -rw-r--r-- | drivers/hid/hid-sony.c | 184 |
4 files changed, 185 insertions, 219 deletions
diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig index 5bad26ef227a..8280eba43e14 100644 --- a/drivers/hid/Kconfig +++ b/drivers/hid/Kconfig | |||
| @@ -561,15 +561,6 @@ config HID_PRIMAX | |||
| 561 | Support for Primax devices that are not fully compliant with the | 561 | Support for Primax devices that are not fully compliant with the |
| 562 | HID standard. | 562 | HID standard. |
| 563 | 563 | ||
| 564 | config HID_PS3REMOTE | ||
| 565 | tristate "Sony PS3 BD Remote Control" | ||
| 566 | depends on HID | ||
| 567 | ---help--- | ||
| 568 | Support for the Sony PS3 Blue-ray Disk Remote Control and Logitech | ||
| 569 | Harmony Adapter for PS3, which connect over Bluetooth. | ||
| 570 | |||
| 571 | Support for the 6-axis controllers is provided by HID_SONY. | ||
| 572 | |||
| 573 | config HID_ROCCAT | 564 | config HID_ROCCAT |
| 574 | tristate "Roccat device support" | 565 | tristate "Roccat device support" |
| 575 | depends on USB_HID | 566 | depends on USB_HID |
| @@ -600,11 +591,11 @@ config HID_SONY | |||
| 600 | depends on LEDS_CLASS | 591 | depends on LEDS_CLASS |
| 601 | ---help--- | 592 | ---help--- |
| 602 | Support for | 593 | Support for |
| 603 | 594 | ||
| 604 | * Sony PS3 6-axis controllers | 595 | * Sony PS3 6-axis controllers |
| 605 | * Buzz controllers | 596 | * Buzz controllers |
| 606 | 597 | * Sony PS3 Blue-ray Disk Remote Control (Bluetooth) | |
| 607 | Support for the Sony PS3 BD Remote is provided by HID_PS3REMOTE. | 598 | * Logitech Harmony adapter for Sony Playstation 3 (Bluetooth) |
| 608 | 599 | ||
| 609 | config HID_SPEEDLINK | 600 | config HID_SPEEDLINK |
| 610 | tristate "Speedlink VAD Cezanne mouse support" | 601 | tristate "Speedlink VAD Cezanne mouse support" |
diff --git a/drivers/hid/Makefile b/drivers/hid/Makefile index 2065694f57ab..833abcf19d68 100644 --- a/drivers/hid/Makefile +++ b/drivers/hid/Makefile | |||
| @@ -92,7 +92,6 @@ hid-picolcd-y += hid-picolcd_debugfs.o | |||
| 92 | endif | 92 | endif |
| 93 | 93 | ||
| 94 | obj-$(CONFIG_HID_PRIMAX) += hid-primax.o | 94 | obj-$(CONFIG_HID_PRIMAX) += hid-primax.o |
| 95 | obj-$(CONFIG_HID_PS3REMOTE) += hid-ps3remote.o | ||
| 96 | obj-$(CONFIG_HID_ROCCAT) += hid-roccat.o hid-roccat-common.o \ | 95 | obj-$(CONFIG_HID_ROCCAT) += hid-roccat.o hid-roccat-common.o \ |
| 97 | hid-roccat-arvo.o hid-roccat-isku.o hid-roccat-kone.o \ | 96 | hid-roccat-arvo.o hid-roccat-isku.o hid-roccat-kone.o \ |
| 98 | hid-roccat-koneplus.o hid-roccat-konepure.o hid-roccat-kovaplus.o \ | 97 | hid-roccat-koneplus.o hid-roccat-konepure.o hid-roccat-kovaplus.o \ |
diff --git a/drivers/hid/hid-ps3remote.c b/drivers/hid/hid-ps3remote.c deleted file mode 100644 index f1239d3c5b14..000000000000 --- a/drivers/hid/hid-ps3remote.c +++ /dev/null | |||
| @@ -1,204 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * HID driver for Sony PS3 BD Remote Control | ||
| 3 | * | ||
| 4 | * Copyright (c) 2012 David Dillow <dave@thedillows.org> | ||
| 5 | * Based on a blend of the bluez fakehid user-space code by Marcel Holtmann | ||
| 6 | * and other kernel HID drivers. | ||
| 7 | */ | ||
| 8 | |||
| 9 | /* | ||
| 10 | * This program is free software; you can redistribute it and/or modify it | ||
| 11 | * under the terms of the GNU General Public License as published by the Free | ||
| 12 | * Software Foundation; either version 2 of the License, or (at your option) | ||
| 13 | * any later version. | ||
| 14 | */ | ||
| 15 | |||
| 16 | /* NOTE: in order for the Sony PS3 BD Remote Control to be found by | ||
| 17 | * a Bluetooth host, the key combination Start+Enter has to be kept pressed | ||
| 18 | * for about 7 seconds with the Bluetooth Host Controller in discovering mode. | ||
| 19 | * | ||
| 20 | * There will be no PIN request from the device. | ||
| 21 | */ | ||
| 22 | |||
| 23 | #include <linux/device.h> | ||
| 24 | #include <linux/hid.h> | ||
| 25 | #include <linux/module.h> | ||
| 26 | |||
| 27 | #include "hid-ids.h" | ||
| 28 | |||
| 29 | static __u8 ps3remote_rdesc[] = { | ||
| 30 | 0x05, 0x01, /* GUsagePage Generic Desktop */ | ||
| 31 | 0x09, 0x05, /* LUsage 0x05 [Game Pad] */ | ||
| 32 | 0xA1, 0x01, /* MCollection Application (mouse, keyboard) */ | ||
| 33 | |||
| 34 | /* Use collection 1 for joypad buttons */ | ||
| 35 | 0xA1, 0x02, /* MCollection Logical (interrelated data) */ | ||
| 36 | |||
| 37 | /* Ignore the 1st byte, maybe it is used for a controller | ||
| 38 | * number but it's not needed for correct operation */ | ||
| 39 | 0x75, 0x08, /* GReportSize 0x08 [8] */ | ||
| 40 | 0x95, 0x01, /* GReportCount 0x01 [1] */ | ||
| 41 | 0x81, 0x01, /* MInput 0x01 (Const[0] Arr[1] Abs[2]) */ | ||
| 42 | |||
| 43 | /* Bytes from 2nd to 4th are a bitmap for joypad buttons, for these | ||
| 44 | * buttons multiple keypresses are allowed */ | ||
| 45 | 0x05, 0x09, /* GUsagePage Button */ | ||
| 46 | 0x19, 0x01, /* LUsageMinimum 0x01 [Button 1 (primary/trigger)] */ | ||
| 47 | 0x29, 0x18, /* LUsageMaximum 0x18 [Button 24] */ | ||
| 48 | 0x14, /* GLogicalMinimum [0] */ | ||
| 49 | 0x25, 0x01, /* GLogicalMaximum 0x01 [1] */ | ||
| 50 | 0x75, 0x01, /* GReportSize 0x01 [1] */ | ||
| 51 | 0x95, 0x18, /* GReportCount 0x18 [24] */ | ||
| 52 | 0x81, 0x02, /* MInput 0x02 (Data[0] Var[1] Abs[2]) */ | ||
| 53 | |||
| 54 | 0xC0, /* MEndCollection */ | ||
| 55 | |||
| 56 | /* Use collection 2 for remote control buttons */ | ||
| 57 | 0xA1, 0x02, /* MCollection Logical (interrelated data) */ | ||
| 58 | |||
| 59 | /* 5th byte is used for remote control buttons */ | ||
| 60 | 0x05, 0x09, /* GUsagePage Button */ | ||
| 61 | 0x18, /* LUsageMinimum [No button pressed] */ | ||
| 62 | 0x29, 0xFE, /* LUsageMaximum 0xFE [Button 254] */ | ||
| 63 | 0x14, /* GLogicalMinimum [0] */ | ||
| 64 | 0x26, 0xFE, 0x00, /* GLogicalMaximum 0x00FE [254] */ | ||
| 65 | 0x75, 0x08, /* GReportSize 0x08 [8] */ | ||
| 66 | 0x95, 0x01, /* GReportCount 0x01 [1] */ | ||
| 67 | 0x80, /* MInput */ | ||
| 68 | |||
| 69 | /* Ignore bytes from 6th to 11th, 6th to 10th are always constant at | ||
| 70 | * 0xff and 11th is for press indication */ | ||
| 71 | 0x75, 0x08, /* GReportSize 0x08 [8] */ | ||
| 72 | 0x95, 0x06, /* GReportCount 0x06 [6] */ | ||
| 73 | 0x81, 0x01, /* MInput 0x01 (Const[0] Arr[1] Abs[2]) */ | ||
| 74 | |||
| 75 | /* 12th byte is for battery strength */ | ||
| 76 | 0x05, 0x06, /* GUsagePage Generic Device Controls */ | ||
| 77 | 0x09, 0x20, /* LUsage 0x20 [Battery Strength] */ | ||
| 78 | 0x14, /* GLogicalMinimum [0] */ | ||
| 79 | 0x25, 0x05, /* GLogicalMaximum 0x05 [5] */ | ||
| 80 | 0x75, 0x08, /* GReportSize 0x08 [8] */ | ||
| 81 | 0x95, 0x01, /* GReportCount 0x01 [1] */ | ||
| 82 | 0x81, 0x02, /* MInput 0x02 (Data[0] Var[1] Abs[2]) */ | ||
| 83 | |||
| 84 | 0xC0, /* MEndCollection */ | ||
| 85 | |||
| 86 | 0xC0 /* MEndCollection [Game Pad] */ | ||
| 87 | }; | ||
| 88 | |||
| 89 | static const unsigned int ps3remote_keymap_joypad_buttons[] = { | ||
| 90 | [0x01] = KEY_SELECT, | ||
| 91 | [0x02] = BTN_THUMBL, /* L3 */ | ||
| 92 | [0x03] = BTN_THUMBR, /* R3 */ | ||
| 93 | [0x04] = BTN_START, | ||
| 94 | [0x05] = KEY_UP, | ||
| 95 | [0x06] = KEY_RIGHT, | ||
| 96 | [0x07] = KEY_DOWN, | ||
| 97 | [0x08] = KEY_LEFT, | ||
| 98 | [0x09] = BTN_TL2, /* L2 */ | ||
| 99 | [0x0a] = BTN_TR2, /* R2 */ | ||
| 100 | [0x0b] = BTN_TL, /* L1 */ | ||
| 101 | [0x0c] = BTN_TR, /* R1 */ | ||
| 102 | [0x0d] = KEY_OPTION, /* options/triangle */ | ||
| 103 | [0x0e] = KEY_BACK, /* back/circle */ | ||
| 104 | [0x0f] = BTN_0, /* cross */ | ||
| 105 | [0x10] = KEY_SCREEN, /* view/square */ | ||
| 106 | [0x11] = KEY_HOMEPAGE, /* PS button */ | ||
| 107 | [0x14] = KEY_ENTER, | ||
| 108 | }; | ||
| 109 | static const unsigned int ps3remote_keymap_remote_buttons[] = { | ||
| 110 | [0x00] = KEY_1, | ||
| 111 | [0x01] = KEY_2, | ||
| 112 | [0x02] = KEY_3, | ||
| 113 | [0x03] = KEY_4, | ||
| 114 | [0x04] = KEY_5, | ||
| 115 | [0x05] = KEY_6, | ||
| 116 | [0x06] = KEY_7, | ||
| 117 | [0x07] = KEY_8, | ||
| 118 | [0x08] = KEY_9, | ||
| 119 | [0x09] = KEY_0, | ||
| 120 | [0x0e] = KEY_ESC, /* return */ | ||
| 121 | [0x0f] = KEY_CLEAR, | ||
| 122 | [0x16] = KEY_EJECTCD, | ||
| 123 | [0x1a] = KEY_MENU, /* top menu */ | ||
| 124 | [0x28] = KEY_TIME, | ||
| 125 | [0x30] = KEY_PREVIOUS, | ||
| 126 | [0x31] = KEY_NEXT, | ||
| 127 | [0x32] = KEY_PLAY, | ||
| 128 | [0x33] = KEY_REWIND, /* scan back */ | ||
| 129 | [0x34] = KEY_FORWARD, /* scan forward */ | ||
| 130 | [0x38] = KEY_STOP, | ||
| 131 | [0x39] = KEY_PAUSE, | ||
| 132 | [0x40] = KEY_CONTEXT_MENU, /* pop up/menu */ | ||
| 133 | [0x60] = KEY_FRAMEBACK, /* slow/step back */ | ||
| 134 | [0x61] = KEY_FRAMEFORWARD, /* slow/step forward */ | ||
| 135 | [0x63] = KEY_SUBTITLE, | ||
| 136 | [0x64] = KEY_AUDIO, | ||
| 137 | [0x65] = KEY_ANGLE, | ||
| 138 | [0x70] = KEY_INFO, /* display */ | ||
| 139 | [0x80] = KEY_BLUE, | ||
| 140 | [0x81] = KEY_RED, | ||
| 141 | [0x82] = KEY_GREEN, | ||
| 142 | [0x83] = KEY_YELLOW, | ||
| 143 | }; | ||
| 144 | |||
| 145 | static __u8 *ps3remote_fixup(struct hid_device *hdev, __u8 *rdesc, | ||
| 146 | unsigned int *rsize) | ||
| 147 | { | ||
| 148 | *rsize = sizeof(ps3remote_rdesc); | ||
| 149 | return ps3remote_rdesc; | ||
| 150 | } | ||
| 151 | |||
| 152 | static int ps3remote_mapping(struct hid_device *hdev, struct hid_input *hi, | ||
| 153 | struct hid_field *field, struct hid_usage *usage, | ||
| 154 | unsigned long **bit, int *max) | ||
| 155 | { | ||
| 156 | unsigned int key = usage->hid & HID_USAGE; | ||
| 157 | |||
| 158 | if ((usage->hid & HID_USAGE_PAGE) != HID_UP_BUTTON) | ||
| 159 | return -1; | ||
| 160 | |||
| 161 | switch (usage->collection_index) { | ||
| 162 | case 1: | ||
| 163 | if (key >= ARRAY_SIZE(ps3remote_keymap_joypad_buttons)) | ||
| 164 | return -1; | ||
| 165 | |||
| 166 | key = ps3remote_keymap_joypad_buttons[key]; | ||
| 167 | if (!key) | ||
| 168 | return -1; | ||
| 169 | break; | ||
| 170 | case 2: | ||
| 171 | if (key >= ARRAY_SIZE(ps3remote_keymap_remote_buttons)) | ||
| 172 | return -1; | ||
| 173 | |||
| 174 | key = ps3remote_keymap_remote_buttons[key]; | ||
| 175 | if (!key) | ||
| 176 | return -1; | ||
| 177 | break; | ||
| 178 | default: | ||
| 179 | return -1; | ||
| 180 | } | ||
| 181 | |||
| 182 | hid_map_usage_clear(hi, usage, bit, max, EV_KEY, key); | ||
| 183 | return 1; | ||
| 184 | } | ||
| 185 | |||
| 186 | static const struct hid_device_id ps3remote_devices[] = { | ||
| 187 | /* PS3 BD Remote Control */ | ||
| 188 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_BDREMOTE) }, | ||
| 189 | /* Logitech Harmony Adapter for PS3 */ | ||
| 190 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_HARMONY_PS3) }, | ||
| 191 | { } | ||
| 192 | }; | ||
| 193 | MODULE_DEVICE_TABLE(hid, ps3remote_devices); | ||
| 194 | |||
| 195 | static struct hid_driver ps3remote_driver = { | ||
| 196 | .name = "ps3_remote", | ||
| 197 | .id_table = ps3remote_devices, | ||
| 198 | .report_fixup = ps3remote_fixup, | ||
| 199 | .input_mapping = ps3remote_mapping, | ||
| 200 | }; | ||
| 201 | module_hid_driver(ps3remote_driver); | ||
| 202 | |||
| 203 | MODULE_LICENSE("GPL"); | ||
| 204 | MODULE_AUTHOR("David Dillow <dave@thedillows.org>, Antonio Ospite <ospite@studenti.unina.it>"); | ||
diff --git a/drivers/hid/hid-sony.c b/drivers/hid/hid-sony.c index f1c906176615..ecbc74923d06 100644 --- a/drivers/hid/hid-sony.c +++ b/drivers/hid/hid-sony.c | |||
| @@ -1,11 +1,12 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * HID driver for some sony "special" devices | 2 | * HID driver for Sony / PS2 / PS3 BD devices. |
| 3 | * | 3 | * |
| 4 | * Copyright (c) 1999 Andreas Gal | 4 | * Copyright (c) 1999 Andreas Gal |
| 5 | * Copyright (c) 2000-2005 Vojtech Pavlik <vojtech@suse.cz> | 5 | * Copyright (c) 2000-2005 Vojtech Pavlik <vojtech@suse.cz> |
| 6 | * Copyright (c) 2005 Michael Haboustak <mike-@cinci.rr.com> for Concept2, Inc | 6 | * Copyright (c) 2005 Michael Haboustak <mike-@cinci.rr.com> for Concept2, Inc |
| 7 | * Copyright (c) 2008 Jiri Slaby | 7 | * Copyright (c) 2008 Jiri Slaby |
| 8 | * Copyright (c) 2006-2008 Jiri Kosina | 8 | * Copyright (c) 2012 David Dillow <dave@thedillows.org> |
| 9 | * Copyright (c) 2006-2013 Jiri Kosina | ||
| 9 | * Copyright (c) 2013 Colin Leitner <colin.leitner@gmail.com> | 10 | * Copyright (c) 2013 Colin Leitner <colin.leitner@gmail.com> |
| 10 | */ | 11 | */ |
| 11 | 12 | ||
| @@ -16,6 +17,13 @@ | |||
| 16 | * any later version. | 17 | * any later version. |
| 17 | */ | 18 | */ |
| 18 | 19 | ||
| 20 | /* NOTE: in order for the Sony PS3 BD Remote Control to be found by | ||
| 21 | * a Bluetooth host, the key combination Start+Enter has to be kept pressed | ||
| 22 | * for about 7 seconds with the Bluetooth Host Controller in discovering mode. | ||
| 23 | * | ||
| 24 | * There will be no PIN request from the device. | ||
| 25 | */ | ||
| 26 | |||
| 19 | #include <linux/device.h> | 27 | #include <linux/device.h> |
| 20 | #include <linux/hid.h> | 28 | #include <linux/hid.h> |
| 21 | #include <linux/module.h> | 29 | #include <linux/module.h> |
| @@ -29,6 +37,7 @@ | |||
| 29 | #define SIXAXIS_CONTROLLER_USB (1 << 1) | 37 | #define SIXAXIS_CONTROLLER_USB (1 << 1) |
| 30 | #define SIXAXIS_CONTROLLER_BT (1 << 2) | 38 | #define SIXAXIS_CONTROLLER_BT (1 << 2) |
| 31 | #define BUZZ_CONTROLLER (1 << 3) | 39 | #define BUZZ_CONTROLLER (1 << 3) |
| 40 | #define PS3REMOTE (1 << 4) | ||
| 32 | 41 | ||
| 33 | static const u8 sixaxis_rdesc_fixup[] = { | 42 | static const u8 sixaxis_rdesc_fixup[] = { |
| 34 | 0x95, 0x13, 0x09, 0x01, 0x81, 0x02, 0x95, 0x0C, | 43 | 0x95, 0x13, 0x09, 0x01, 0x81, 0x02, 0x95, 0x0C, |
| @@ -58,6 +67,122 @@ static const u8 sixaxis_rdesc_fixup2[] = { | |||
| 58 | 0xb1, 0x02, 0xc0, 0xc0, | 67 | 0xb1, 0x02, 0xc0, 0xc0, |
| 59 | }; | 68 | }; |
| 60 | 69 | ||
| 70 | static __u8 ps3remote_rdesc[] = { | ||
| 71 | 0x05, 0x01, /* GUsagePage Generic Desktop */ | ||
| 72 | 0x09, 0x05, /* LUsage 0x05 [Game Pad] */ | ||
| 73 | 0xA1, 0x01, /* MCollection Application (mouse, keyboard) */ | ||
| 74 | |||
| 75 | /* Use collection 1 for joypad buttons */ | ||
| 76 | 0xA1, 0x02, /* MCollection Logical (interrelated data) */ | ||
| 77 | |||
| 78 | /* Ignore the 1st byte, maybe it is used for a controller | ||
| 79 | * number but it's not needed for correct operation */ | ||
| 80 | 0x75, 0x08, /* GReportSize 0x08 [8] */ | ||
| 81 | 0x95, 0x01, /* GReportCount 0x01 [1] */ | ||
| 82 | 0x81, 0x01, /* MInput 0x01 (Const[0] Arr[1] Abs[2]) */ | ||
| 83 | |||
| 84 | /* Bytes from 2nd to 4th are a bitmap for joypad buttons, for these | ||
| 85 | * buttons multiple keypresses are allowed */ | ||
| 86 | 0x05, 0x09, /* GUsagePage Button */ | ||
| 87 | 0x19, 0x01, /* LUsageMinimum 0x01 [Button 1 (primary/trigger)] */ | ||
| 88 | 0x29, 0x18, /* LUsageMaximum 0x18 [Button 24] */ | ||
| 89 | 0x14, /* GLogicalMinimum [0] */ | ||
| 90 | 0x25, 0x01, /* GLogicalMaximum 0x01 [1] */ | ||
| 91 | 0x75, 0x01, /* GReportSize 0x01 [1] */ | ||
| 92 | 0x95, 0x18, /* GReportCount 0x18 [24] */ | ||
| 93 | 0x81, 0x02, /* MInput 0x02 (Data[0] Var[1] Abs[2]) */ | ||
| 94 | |||
| 95 | 0xC0, /* MEndCollection */ | ||
| 96 | |||
| 97 | /* Use collection 2 for remote control buttons */ | ||
| 98 | 0xA1, 0x02, /* MCollection Logical (interrelated data) */ | ||
| 99 | |||
| 100 | /* 5th byte is used for remote control buttons */ | ||
| 101 | 0x05, 0x09, /* GUsagePage Button */ | ||
| 102 | 0x18, /* LUsageMinimum [No button pressed] */ | ||
| 103 | 0x29, 0xFE, /* LUsageMaximum 0xFE [Button 254] */ | ||
| 104 | 0x14, /* GLogicalMinimum [0] */ | ||
| 105 | 0x26, 0xFE, 0x00, /* GLogicalMaximum 0x00FE [254] */ | ||
| 106 | 0x75, 0x08, /* GReportSize 0x08 [8] */ | ||
| 107 | 0x95, 0x01, /* GReportCount 0x01 [1] */ | ||
| 108 | 0x80, /* MInput */ | ||
| 109 | |||
| 110 | /* Ignore bytes from 6th to 11th, 6th to 10th are always constant at | ||
| 111 | * 0xff and 11th is for press indication */ | ||
| 112 | 0x75, 0x08, /* GReportSize 0x08 [8] */ | ||
| 113 | 0x95, 0x06, /* GReportCount 0x06 [6] */ | ||
| 114 | 0x81, 0x01, /* MInput 0x01 (Const[0] Arr[1] Abs[2]) */ | ||
| 115 | |||
| 116 | /* 12th byte is for battery strength */ | ||
| 117 | 0x05, 0x06, /* GUsagePage Generic Device Controls */ | ||
| 118 | 0x09, 0x20, /* LUsage 0x20 [Battery Strength] */ | ||
| 119 | 0x14, /* GLogicalMinimum [0] */ | ||
| 120 | 0x25, 0x05, /* GLogicalMaximum 0x05 [5] */ | ||
| 121 | 0x75, 0x08, /* GReportSize 0x08 [8] */ | ||
| 122 | 0x95, 0x01, /* GReportCount 0x01 [1] */ | ||
| 123 | 0x81, 0x02, /* MInput 0x02 (Data[0] Var[1] Abs[2]) */ | ||
| 124 | |||
| 125 | 0xC0, /* MEndCollection */ | ||
| 126 | |||
| 127 | 0xC0 /* MEndCollection [Game Pad] */ | ||
| 128 | }; | ||
| 129 | |||
| 130 | static const unsigned int ps3remote_keymap_joypad_buttons[] = { | ||
| 131 | [0x01] = KEY_SELECT, | ||
| 132 | [0x02] = BTN_THUMBL, /* L3 */ | ||
| 133 | [0x03] = BTN_THUMBR, /* R3 */ | ||
| 134 | [0x04] = BTN_START, | ||
| 135 | [0x05] = KEY_UP, | ||
| 136 | [0x06] = KEY_RIGHT, | ||
| 137 | [0x07] = KEY_DOWN, | ||
| 138 | [0x08] = KEY_LEFT, | ||
| 139 | [0x09] = BTN_TL2, /* L2 */ | ||
| 140 | [0x0a] = BTN_TR2, /* R2 */ | ||
| 141 | [0x0b] = BTN_TL, /* L1 */ | ||
| 142 | [0x0c] = BTN_TR, /* R1 */ | ||
| 143 | [0x0d] = KEY_OPTION, /* options/triangle */ | ||
| 144 | [0x0e] = KEY_BACK, /* back/circle */ | ||
| 145 | [0x0f] = BTN_0, /* cross */ | ||
| 146 | [0x10] = KEY_SCREEN, /* view/square */ | ||
| 147 | [0x11] = KEY_HOMEPAGE, /* PS button */ | ||
| 148 | [0x14] = KEY_ENTER, | ||
| 149 | }; | ||
| 150 | static const unsigned int ps3remote_keymap_remote_buttons[] = { | ||
| 151 | [0x00] = KEY_1, | ||
| 152 | [0x01] = KEY_2, | ||
| 153 | [0x02] = KEY_3, | ||
| 154 | [0x03] = KEY_4, | ||
| 155 | [0x04] = KEY_5, | ||
| 156 | [0x05] = KEY_6, | ||
| 157 | [0x06] = KEY_7, | ||
| 158 | [0x07] = KEY_8, | ||
| 159 | [0x08] = KEY_9, | ||
| 160 | [0x09] = KEY_0, | ||
| 161 | [0x0e] = KEY_ESC, /* return */ | ||
| 162 | [0x0f] = KEY_CLEAR, | ||
| 163 | [0x16] = KEY_EJECTCD, | ||
| 164 | [0x1a] = KEY_MENU, /* top menu */ | ||
| 165 | [0x28] = KEY_TIME, | ||
| 166 | [0x30] = KEY_PREVIOUS, | ||
| 167 | [0x31] = KEY_NEXT, | ||
| 168 | [0x32] = KEY_PLAY, | ||
| 169 | [0x33] = KEY_REWIND, /* scan back */ | ||
| 170 | [0x34] = KEY_FORWARD, /* scan forward */ | ||
| 171 | [0x38] = KEY_STOP, | ||
| 172 | [0x39] = KEY_PAUSE, | ||
| 173 | [0x40] = KEY_CONTEXT_MENU, /* pop up/menu */ | ||
| 174 | [0x60] = KEY_FRAMEBACK, /* slow/step back */ | ||
| 175 | [0x61] = KEY_FRAMEFORWARD, /* slow/step forward */ | ||
| 176 | [0x63] = KEY_SUBTITLE, | ||
| 177 | [0x64] = KEY_AUDIO, | ||
| 178 | [0x65] = KEY_ANGLE, | ||
| 179 | [0x70] = KEY_INFO, /* display */ | ||
| 180 | [0x80] = KEY_BLUE, | ||
| 181 | [0x81] = KEY_RED, | ||
| 182 | [0x82] = KEY_GREEN, | ||
| 183 | [0x83] = KEY_YELLOW, | ||
| 184 | }; | ||
| 185 | |||
| 61 | static const unsigned int buzz_keymap[] = { | 186 | static const unsigned int buzz_keymap[] = { |
| 62 | /* The controller has 4 remote buzzers, each with one LED and 5 | 187 | /* The controller has 4 remote buzzers, each with one LED and 5 |
| 63 | * buttons. | 188 | * buttons. |
| @@ -108,6 +233,48 @@ struct buzz_extra { | |||
| 108 | struct led_classdev *leds[4]; | 233 | struct led_classdev *leds[4]; |
| 109 | }; | 234 | }; |
| 110 | 235 | ||
| 236 | static __u8 *ps3remote_fixup(struct hid_device *hdev, __u8 *rdesc, | ||
| 237 | unsigned int *rsize) | ||
| 238 | { | ||
| 239 | *rsize = sizeof(ps3remote_rdesc); | ||
| 240 | return ps3remote_rdesc; | ||
| 241 | } | ||
| 242 | |||
| 243 | static int ps3remote_mapping(struct hid_device *hdev, struct hid_input *hi, | ||
| 244 | struct hid_field *field, struct hid_usage *usage, | ||
| 245 | unsigned long **bit, int *max) | ||
| 246 | { | ||
| 247 | unsigned int key = usage->hid & HID_USAGE; | ||
| 248 | |||
| 249 | if ((usage->hid & HID_USAGE_PAGE) != HID_UP_BUTTON) | ||
| 250 | return -1; | ||
| 251 | |||
| 252 | switch (usage->collection_index) { | ||
| 253 | case 1: | ||
| 254 | if (key >= ARRAY_SIZE(ps3remote_keymap_joypad_buttons)) | ||
| 255 | return -1; | ||
| 256 | |||
| 257 | key = ps3remote_keymap_joypad_buttons[key]; | ||
| 258 | if (!key) | ||
| 259 | return -1; | ||
| 260 | break; | ||
| 261 | case 2: | ||
| 262 | if (key >= ARRAY_SIZE(ps3remote_keymap_remote_buttons)) | ||
| 263 | return -1; | ||
| 264 | |||
| 265 | key = ps3remote_keymap_remote_buttons[key]; | ||
| 266 | if (!key) | ||
| 267 | return -1; | ||
| 268 | break; | ||
| 269 | default: | ||
| 270 | return -1; | ||
| 271 | } | ||
| 272 | |||
| 273 | hid_map_usage_clear(hi, usage, bit, max, EV_KEY, key); | ||
| 274 | return 1; | ||
| 275 | } | ||
| 276 | |||
| 277 | |||
| 111 | /* Sony Vaio VGX has wrongly mouse pointer declared as constant */ | 278 | /* Sony Vaio VGX has wrongly mouse pointer declared as constant */ |
| 112 | static __u8 *sony_report_fixup(struct hid_device *hdev, __u8 *rdesc, | 279 | static __u8 *sony_report_fixup(struct hid_device *hdev, __u8 *rdesc, |
| 113 | unsigned int *rsize) | 280 | unsigned int *rsize) |
| @@ -144,6 +311,10 @@ static __u8 *sony_report_fixup(struct hid_device *hdev, __u8 *rdesc, | |||
| 144 | *rsize = sizeof(sixaxis_rdesc_fixup2); | 311 | *rsize = sizeof(sixaxis_rdesc_fixup2); |
| 145 | memcpy(rdesc, &sixaxis_rdesc_fixup2, *rsize); | 312 | memcpy(rdesc, &sixaxis_rdesc_fixup2, *rsize); |
| 146 | } | 313 | } |
| 314 | |||
| 315 | if (sc->quirks & PS3REMOTE) | ||
| 316 | return ps3remote_fixup(hdev, rdesc, rsize); | ||
| 317 | |||
| 147 | return rdesc; | 318 | return rdesc; |
| 148 | } | 319 | } |
| 149 | 320 | ||
| @@ -195,6 +366,9 @@ static int sony_mapping(struct hid_device *hdev, struct hid_input *hi, | |||
| 195 | return 1; | 366 | return 1; |
| 196 | } | 367 | } |
| 197 | 368 | ||
| 369 | if (sc->quirks & PS3REMOTE) | ||
| 370 | return ps3remote_mapping(hdev, hi, field, usage, bit, max); | ||
| 371 | |||
| 198 | return -1; | 372 | return -1; |
| 199 | } | 373 | } |
| 200 | 374 | ||
| @@ -527,6 +701,12 @@ static const struct hid_device_id sony_devices[] = { | |||
| 527 | .driver_data = BUZZ_CONTROLLER }, | 701 | .driver_data = BUZZ_CONTROLLER }, |
| 528 | { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_WIRELESS_BUZZ_CONTROLLER), | 702 | { HID_USB_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_WIRELESS_BUZZ_CONTROLLER), |
| 529 | .driver_data = BUZZ_CONTROLLER }, | 703 | .driver_data = BUZZ_CONTROLLER }, |
| 704 | /* PS3 BD Remote Control */ | ||
| 705 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_BDREMOTE), | ||
| 706 | .driver_data = PS3REMOTE }, | ||
| 707 | /* Logitech Harmony Adapter for PS3 */ | ||
| 708 | { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_HARMONY_PS3), | ||
| 709 | .driver_data = PS3REMOTE }, | ||
| 530 | { } | 710 | { } |
| 531 | }; | 711 | }; |
| 532 | MODULE_DEVICE_TABLE(hid, sony_devices); | 712 | MODULE_DEVICE_TABLE(hid, sony_devices); |
