diff options
| author | tmk <nobody@nowhere> | 2012-06-28 20:15:56 +0900 |
|---|---|---|
| committer | tmk <nobody@nowhere> | 2012-06-28 20:15:56 +0900 |
| commit | 3d81d5221eac9ca9620ba9043a250dcb8371b22e (patch) | |
| tree | ae8f467e1691d42e01feaebc968aaade989924f3 | |
| parent | a9a3610dd4a168e473d2d6a2eb3fbc37aabb46c9 (diff) | |
| download | qmk_firmware-3d81d5221eac9ca9620ba9043a250dcb8371b22e.tar.gz qmk_firmware-3d81d5221eac9ca9620ba9043a250dcb8371b22e.zip | |
Add consumer/system control feature to LUFA.
| -rw-r--r-- | common/keyboard.c | 17 | ||||
| -rw-r--r-- | common/mousekey.c | 4 | ||||
| -rw-r--r-- | keyboard/lufa/Makefile | 5 | ||||
| -rw-r--r-- | keyboard/lufa/config.h | 4 | ||||
| -rw-r--r-- | keyboard/lufa/descriptor.c | 143 | ||||
| -rw-r--r-- | keyboard/lufa/descriptor.h | 28 | ||||
| -rw-r--r-- | keyboard/lufa/keymap.c | 2 | ||||
| -rw-r--r-- | keyboard/lufa/lufa.c | 62 | ||||
| -rw-r--r-- | protocol/vusb/main.c | 5 | ||||
| -rw-r--r-- | protocol/vusb/vusb.c | 37 |
10 files changed, 210 insertions, 97 deletions
diff --git a/common/keyboard.c b/common/keyboard.c index 5c2643c95..25f32eb02 100644 --- a/common/keyboard.c +++ b/common/keyboard.c | |||
| @@ -49,6 +49,7 @@ void keyboard_proc(void) | |||
| 49 | uint8_t fn_bits = 0; | 49 | uint8_t fn_bits = 0; |
| 50 | #ifdef EXTRAKEY_ENABLE | 50 | #ifdef EXTRAKEY_ENABLE |
| 51 | uint16_t consumer_code = 0; | 51 | uint16_t consumer_code = 0; |
| 52 | uint16_t system_code = 0; | ||
| 52 | #endif | 53 | #endif |
| 53 | 54 | ||
| 54 | matrix_scan(); | 55 | matrix_scan(); |
| @@ -89,22 +90,13 @@ void keyboard_proc(void) | |||
| 89 | #ifdef HOST_PJRC | 90 | #ifdef HOST_PJRC |
| 90 | if (suspend && remote_wakeup) { | 91 | if (suspend && remote_wakeup) { |
| 91 | usb_remote_wakeup(); | 92 | usb_remote_wakeup(); |
| 92 | } else { | ||
| 93 | host_system_send(SYSTEM_POWER_DOWN); | ||
| 94 | } | 93 | } |
| 95 | #else | ||
| 96 | host_system_send(SYSTEM_POWER_DOWN); | ||
| 97 | #endif | 94 | #endif |
| 98 | host_system_send(0); | 95 | system_code = SYSTEM_POWER_DOWN; |
| 99 | _delay_ms(500); | ||
| 100 | } else if (code == KB_SYSTEM_SLEEP) { | 96 | } else if (code == KB_SYSTEM_SLEEP) { |
| 101 | host_system_send(SYSTEM_SLEEP); | 97 | system_code = SYSTEM_SLEEP; |
| 102 | host_system_send(0); | ||
| 103 | _delay_ms(500); | ||
| 104 | } else if (code == KB_SYSTEM_WAKE) { | 98 | } else if (code == KB_SYSTEM_WAKE) { |
| 105 | host_system_send(SYSTEM_WAKE_UP); | 99 | system_code = SYSTEM_WAKE_UP; |
| 106 | host_system_send(0); | ||
| 107 | _delay_ms(500); | ||
| 108 | } | 100 | } |
| 109 | // Consumer Page | 101 | // Consumer Page |
| 110 | else if (code == KB_AUDIO_MUTE) { | 102 | else if (code == KB_AUDIO_MUTE) { |
| @@ -173,6 +165,7 @@ void keyboard_proc(void) | |||
| 173 | host_send_keyboard_report(); | 165 | host_send_keyboard_report(); |
| 174 | #ifdef EXTRAKEY_ENABLE | 166 | #ifdef EXTRAKEY_ENABLE |
| 175 | host_consumer_send(consumer_code); | 167 | host_consumer_send(consumer_code); |
| 168 | host_system_send(system_code); | ||
| 176 | #endif | 169 | #endif |
| 177 | #ifdef DEBUG_LED | 170 | #ifdef DEBUG_LED |
| 178 | // LED flash for debug | 171 | // LED flash for debug |
diff --git a/common/mousekey.c b/common/mousekey.c index 76bd0fd36..1d35355b4 100644 --- a/common/mousekey.c +++ b/common/mousekey.c | |||
| @@ -121,12 +121,12 @@ void mousekey_clear_report(void) | |||
| 121 | static void mousekey_debug(void) | 121 | static void mousekey_debug(void) |
| 122 | { | 122 | { |
| 123 | if (!debug_mouse) return; | 123 | if (!debug_mouse) return; |
| 124 | print("mousekey[btn|x y v h]: "); | 124 | print("mousekey [btn|x y v h]rep: ["); |
| 125 | phex(report.buttons); print("|"); | 125 | phex(report.buttons); print("|"); |
| 126 | phex(report.x); print(" "); | 126 | phex(report.x); print(" "); |
| 127 | phex(report.y); print(" "); | 127 | phex(report.y); print(" "); |
| 128 | phex(report.v); print(" "); | 128 | phex(report.v); print(" "); |
| 129 | phex(report.h); | 129 | phex(report.h); print("]"); |
| 130 | phex(mousekey_repeat); | 130 | phex(mousekey_repeat); |
| 131 | print("\n"); | 131 | print("\n"); |
| 132 | } | 132 | } |
diff --git a/keyboard/lufa/Makefile b/keyboard/lufa/Makefile index b386fb381..030f4061d 100644 --- a/keyboard/lufa/Makefile +++ b/keyboard/lufa/Makefile | |||
| @@ -128,7 +128,8 @@ LUFA_SRC = $(TARGET).c \ | |||
| 128 | SRC = $(subst $(LUFA_PATH)/LUFA/,,$(LUFA_SRC)) | 128 | SRC = $(subst $(LUFA_PATH)/LUFA/,,$(LUFA_SRC)) |
| 129 | SRC += keymap.c \ | 129 | SRC += keymap.c \ |
| 130 | matrix.c \ | 130 | matrix.c \ |
| 131 | led.c | 131 | led.c \ |
| 132 | pjrc/bootloader_teensy.c | ||
| 132 | CONFIG_H = config.h | 133 | CONFIG_H = config.h |
| 133 | 134 | ||
| 134 | 135 | ||
| @@ -137,7 +138,7 @@ CONFIG_H = config.h | |||
| 137 | # | 138 | # |
| 138 | MOUSEKEY_ENABLE = yes # Mouse keys | 139 | MOUSEKEY_ENABLE = yes # Mouse keys |
| 139 | #PS2_MOUSE_ENABLE = yes # PS/2 mouse(TrackPoint) support | 140 | #PS2_MOUSE_ENABLE = yes # PS/2 mouse(TrackPoint) support |
| 140 | #EXTRAKEY_ENABLE = yes # Audio control and System control | 141 | EXTRAKEY_ENABLE = yes # Audio control and System control |
| 141 | #NKRO_ENABLE = yes # USB Nkey Rollover | 142 | #NKRO_ENABLE = yes # USB Nkey Rollover |
| 142 | 143 | ||
| 143 | 144 | ||
diff --git a/keyboard/lufa/config.h b/keyboard/lufa/config.h index c375a576f..5368b38d2 100644 --- a/keyboard/lufa/config.h +++ b/keyboard/lufa/config.h | |||
| @@ -24,8 +24,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 24 | 24 | ||
| 25 | /* USB Device descriptor */ | 25 | /* USB Device descriptor */ |
| 26 | #define VENDOR_ID 0xFEED | 26 | #define VENDOR_ID 0xFEED |
| 27 | #define PRODUCT_ID 0xBEE1 | 27 | #define PRODUCT_ID 0xBEE6 |
| 28 | #define DEVICE_VER 0x0101 | 28 | #define DEVICE_VER 0x0202 |
| 29 | #define MANUFACTURER t.m.k. | 29 | #define MANUFACTURER t.m.k. |
| 30 | #define PRODUCT Macway mod(LUFA) | 30 | #define PRODUCT Macway mod(LUFA) |
| 31 | 31 | ||
diff --git a/keyboard/lufa/descriptor.c b/keyboard/lufa/descriptor.c index f9ca355a6..e9925cca2 100644 --- a/keyboard/lufa/descriptor.c +++ b/keyboard/lufa/descriptor.c | |||
| @@ -37,6 +37,7 @@ | |||
| 37 | */ | 37 | */ |
| 38 | 38 | ||
| 39 | #include "util.h" | 39 | #include "util.h" |
| 40 | #include "report.h" | ||
| 40 | #include "descriptor.h" | 41 | #include "descriptor.h" |
| 41 | 42 | ||
| 42 | 43 | ||
| @@ -86,27 +87,43 @@ const USB_Descriptor_HIDReport_Datatype_t PROGMEM MouseReport[] = | |||
| 86 | HID_RI_COLLECTION(8, 0x01), /* Application */ | 87 | HID_RI_COLLECTION(8, 0x01), /* Application */ |
| 87 | HID_RI_USAGE(8, 0x01), /* Pointer */ | 88 | HID_RI_USAGE(8, 0x01), /* Pointer */ |
| 88 | HID_RI_COLLECTION(8, 0x00), /* Physical */ | 89 | HID_RI_COLLECTION(8, 0x00), /* Physical */ |
| 90 | |||
| 89 | HID_RI_USAGE_PAGE(8, 0x09), /* Button */ | 91 | HID_RI_USAGE_PAGE(8, 0x09), /* Button */ |
| 90 | HID_RI_USAGE_MINIMUM(8, 0x01), | 92 | HID_RI_USAGE_MINIMUM(8, 0x01), /* Button 1 */ |
| 91 | HID_RI_USAGE_MAXIMUM(8, 0x03), | 93 | HID_RI_USAGE_MAXIMUM(8, 0x05), /* Button 5 */ |
| 92 | HID_RI_LOGICAL_MINIMUM(8, 0x00), | 94 | HID_RI_LOGICAL_MINIMUM(8, 0x00), |
| 93 | HID_RI_LOGICAL_MAXIMUM(8, 0x01), | 95 | HID_RI_LOGICAL_MAXIMUM(8, 0x01), |
| 94 | HID_RI_REPORT_COUNT(8, 0x03), | 96 | HID_RI_REPORT_COUNT(8, 0x05), |
| 95 | HID_RI_REPORT_SIZE(8, 0x01), | 97 | HID_RI_REPORT_SIZE(8, 0x01), |
| 96 | HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE), | 98 | HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE), |
| 97 | HID_RI_REPORT_COUNT(8, 0x01), | 99 | HID_RI_REPORT_COUNT(8, 0x01), |
| 98 | HID_RI_REPORT_SIZE(8, 0x05), | 100 | HID_RI_REPORT_SIZE(8, 0x03), |
| 99 | HID_RI_INPUT(8, HID_IOF_CONSTANT), | 101 | HID_RI_INPUT(8, HID_IOF_CONSTANT), |
| 102 | |||
| 100 | HID_RI_USAGE_PAGE(8, 0x01), /* Generic Desktop */ | 103 | HID_RI_USAGE_PAGE(8, 0x01), /* Generic Desktop */ |
| 101 | HID_RI_USAGE(8, 0x30), /* Usage X */ | 104 | HID_RI_USAGE(8, 0x30), /* Usage X */ |
| 102 | HID_RI_USAGE(8, 0x31), /* Usage Y */ | 105 | HID_RI_USAGE(8, 0x31), /* Usage Y */ |
| 103 | HID_RI_LOGICAL_MINIMUM(8, -1), | 106 | HID_RI_LOGICAL_MINIMUM(8, -127), |
| 104 | HID_RI_LOGICAL_MAXIMUM(8, 1), | 107 | HID_RI_LOGICAL_MAXIMUM(8, 127), |
| 105 | HID_RI_PHYSICAL_MINIMUM(8, -1), | ||
| 106 | HID_RI_PHYSICAL_MAXIMUM(8, 1), | ||
| 107 | HID_RI_REPORT_COUNT(8, 0x02), | 108 | HID_RI_REPORT_COUNT(8, 0x02), |
| 108 | HID_RI_REPORT_SIZE(8, 0x08), | 109 | HID_RI_REPORT_SIZE(8, 0x08), |
| 109 | HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_RELATIVE), | 110 | HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_RELATIVE), |
| 111 | |||
| 112 | HID_RI_USAGE(8, 0x38), /* Wheel */ | ||
| 113 | HID_RI_LOGICAL_MINIMUM(8, -127), | ||
| 114 | HID_RI_LOGICAL_MAXIMUM(8, 127), | ||
| 115 | HID_RI_REPORT_COUNT(8, 0x01), | ||
| 116 | HID_RI_REPORT_SIZE(8, 0x08), | ||
| 117 | HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_RELATIVE), | ||
| 118 | |||
| 119 | HID_RI_USAGE_PAGE(8, 0x0C), /* Consumer */ | ||
| 120 | HID_RI_USAGE(16, 0x0238), /* AC Pan (Horizontal wheel) */ | ||
| 121 | HID_RI_LOGICAL_MINIMUM(8, -127), | ||
| 122 | HID_RI_LOGICAL_MAXIMUM(8, 127), | ||
| 123 | HID_RI_REPORT_COUNT(8, 0x01), | ||
| 124 | HID_RI_REPORT_SIZE(8, 0x08), | ||
| 125 | HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_RELATIVE), | ||
| 126 | |||
| 110 | HID_RI_END_COLLECTION(0), | 127 | HID_RI_END_COLLECTION(0), |
| 111 | HID_RI_END_COLLECTION(0), | 128 | HID_RI_END_COLLECTION(0), |
| 112 | }; | 129 | }; |
| @@ -115,22 +132,50 @@ const USB_Descriptor_HIDReport_Datatype_t PROGMEM ConsoleReport[] = | |||
| 115 | { | 132 | { |
| 116 | HID_RI_USAGE_PAGE(16, 0xFF00), /* Vendor Page 0 */ | 133 | HID_RI_USAGE_PAGE(16, 0xFF00), /* Vendor Page 0 */ |
| 117 | HID_RI_USAGE(8, 0x01), /* Vendor Usage 1 */ | 134 | HID_RI_USAGE(8, 0x01), /* Vendor Usage 1 */ |
| 118 | HID_RI_COLLECTION(8, 0x01), /* Vendor Usage 1 */ | 135 | HID_RI_COLLECTION(8, 0x01), /* Application */ |
| 119 | HID_RI_USAGE(8, 0x02), /* Vendor Usage 2 */ | 136 | HID_RI_USAGE(8, 0x02), /* Vendor Usage 2 */ |
| 120 | HID_RI_LOGICAL_MINIMUM(8, 0x00), | 137 | HID_RI_LOGICAL_MINIMUM(8, 0x00), |
| 121 | HID_RI_LOGICAL_MAXIMUM(8, 0xFF), | 138 | HID_RI_LOGICAL_MAXIMUM(8, 0xFF), |
| 122 | HID_RI_REPORT_SIZE(8, 0x08), | 139 | HID_RI_REPORT_SIZE(8, 0x08), |
| 123 | HID_RI_REPORT_COUNT(8, GENERIC_REPORT_SIZE), | 140 | HID_RI_REPORT_COUNT(8, CONSOLE_EPSIZE), |
| 124 | HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE), | 141 | HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE), |
| 125 | HID_RI_USAGE(8, 0x03), /* Vendor Usage 3 */ | 142 | HID_RI_USAGE(8, 0x03), /* Vendor Usage 3 */ |
| 126 | HID_RI_LOGICAL_MINIMUM(8, 0x00), | 143 | HID_RI_LOGICAL_MINIMUM(8, 0x00), |
| 127 | HID_RI_LOGICAL_MAXIMUM(8, 0xFF), | 144 | HID_RI_LOGICAL_MAXIMUM(8, 0xFF), |
| 128 | HID_RI_REPORT_SIZE(8, 0x08), | 145 | HID_RI_REPORT_SIZE(8, 0x08), |
| 129 | HID_RI_REPORT_COUNT(8, GENERIC_REPORT_SIZE), | 146 | HID_RI_REPORT_COUNT(8, CONSOLE_EPSIZE), |
| 130 | HID_RI_OUTPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_NON_VOLATILE), | 147 | HID_RI_OUTPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_NON_VOLATILE), |
| 131 | HID_RI_END_COLLECTION(0), | 148 | HID_RI_END_COLLECTION(0), |
| 132 | }; | 149 | }; |
| 133 | 150 | ||
| 151 | const USB_Descriptor_HIDReport_Datatype_t PROGMEM ExtraReport[] = | ||
| 152 | { | ||
| 153 | HID_RI_USAGE_PAGE(8, 0x01), /* Generic Desktop */ | ||
| 154 | HID_RI_USAGE(8, 0x80), /* System Control */ | ||
| 155 | HID_RI_COLLECTION(8, 0x01), /* Application */ | ||
| 156 | HID_RI_REPORT_ID(8, REPORT_ID_SYSTEM), | ||
| 157 | HID_RI_LOGICAL_MINIMUM(16, 0x0081), | ||
| 158 | HID_RI_LOGICAL_MAXIMUM(16, 0x00B7), | ||
| 159 | HID_RI_USAGE_MINIMUM(16, 0x0081), /* System Power Down */ | ||
| 160 | HID_RI_USAGE_MAXIMUM(16, 0x00B7), /* System Display LCD Autoscale */ | ||
| 161 | HID_RI_REPORT_SIZE(8, 16), | ||
| 162 | HID_RI_REPORT_COUNT(8, 1), | ||
| 163 | HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_ARRAY | HID_IOF_ABSOLUTE), | ||
| 164 | HID_RI_END_COLLECTION(0), | ||
| 165 | |||
| 166 | HID_RI_USAGE_PAGE(8, 0x0C), /* Consumer */ | ||
| 167 | HID_RI_USAGE(8, 0x01), /* Consumer Control */ | ||
| 168 | HID_RI_COLLECTION(8, 0x01), /* Application */ | ||
| 169 | HID_RI_REPORT_ID(8, REPORT_ID_CONSUMER), | ||
| 170 | HID_RI_LOGICAL_MINIMUM(16, 0x0010), | ||
| 171 | HID_RI_LOGICAL_MAXIMUM(16, 0x029C), | ||
| 172 | HID_RI_USAGE_MINIMUM(16, 0x0010), /* +10 */ | ||
| 173 | HID_RI_USAGE_MAXIMUM(16, 0x029C), /* AC Distribute Vertically */ | ||
| 174 | HID_RI_REPORT_SIZE(8, 16), | ||
| 175 | HID_RI_REPORT_COUNT(8, 1), | ||
| 176 | HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_ARRAY | HID_IOF_ABSOLUTE), | ||
| 177 | HID_RI_END_COLLECTION(0), | ||
| 178 | }; | ||
| 134 | 179 | ||
| 135 | /******************************************************************************* | 180 | /******************************************************************************* |
| 136 | * Device Descriptors | 181 | * Device Descriptors |
| @@ -167,7 +212,7 @@ const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = | |||
| 167 | .Header = {.Size = sizeof(USB_Descriptor_Configuration_Header_t), .Type = DTYPE_Configuration}, | 212 | .Header = {.Size = sizeof(USB_Descriptor_Configuration_Header_t), .Type = DTYPE_Configuration}, |
| 168 | 213 | ||
| 169 | .TotalConfigurationSize = sizeof(USB_Descriptor_Configuration_t), | 214 | .TotalConfigurationSize = sizeof(USB_Descriptor_Configuration_t), |
| 170 | .TotalInterfaces = 3, | 215 | .TotalInterfaces = TOTAL_INTERFACES, |
| 171 | 216 | ||
| 172 | .ConfigurationNumber = 1, | 217 | .ConfigurationNumber = 1, |
| 173 | .ConfigurationStrIndex = NO_DESCRIPTOR, | 218 | .ConfigurationStrIndex = NO_DESCRIPTOR, |
| @@ -177,9 +222,9 @@ const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = | |||
| 177 | .MaxPowerConsumption = USB_CONFIG_POWER_MA(100) | 222 | .MaxPowerConsumption = USB_CONFIG_POWER_MA(100) |
| 178 | }, | 223 | }, |
| 179 | 224 | ||
| 180 | /* | 225 | /* |
| 181 | * Keyboard | 226 | * Keyboard |
| 182 | */ | 227 | */ |
| 183 | .Keyboard_Interface = | 228 | .Keyboard_Interface = |
| 184 | { | 229 | { |
| 185 | .Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, | 230 | .Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, |
| @@ -213,7 +258,7 @@ const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = | |||
| 213 | 258 | ||
| 214 | .EndpointAddress = (ENDPOINT_DIR_IN | KEYBOARD_IN_EPNUM), | 259 | .EndpointAddress = (ENDPOINT_DIR_IN | KEYBOARD_IN_EPNUM), |
| 215 | .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), | 260 | .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), |
| 216 | .EndpointSize = HID_EPSIZE, | 261 | .EndpointSize = KEYBOARD_EPSIZE, |
| 217 | .PollingIntervalMS = 0x01 | 262 | .PollingIntervalMS = 0x01 |
| 218 | }, | 263 | }, |
| 219 | 264 | ||
| @@ -253,7 +298,7 @@ const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = | |||
| 253 | 298 | ||
| 254 | .EndpointAddress = (ENDPOINT_DIR_IN | MOUSE_IN_EPNUM), | 299 | .EndpointAddress = (ENDPOINT_DIR_IN | MOUSE_IN_EPNUM), |
| 255 | .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), | 300 | .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), |
| 256 | .EndpointSize = HID_EPSIZE, | 301 | .EndpointSize = MOUSE_EPSIZE, |
| 257 | .PollingIntervalMS = 0x01 | 302 | .PollingIntervalMS = 0x01 |
| 258 | }, | 303 | }, |
| 259 | 304 | ||
| @@ -264,7 +309,7 @@ const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = | |||
| 264 | { | 309 | { |
| 265 | .Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, | 310 | .Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, |
| 266 | 311 | ||
| 267 | .InterfaceNumber = GENERIC_INTERFACE, | 312 | .InterfaceNumber = CONSOLE_INTERFACE, |
| 268 | .AlternateSetting = 0x00, | 313 | .AlternateSetting = 0x00, |
| 269 | 314 | ||
| 270 | .TotalEndpoints = 2, | 315 | .TotalEndpoints = 2, |
| @@ -291,9 +336,9 @@ const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = | |||
| 291 | { | 336 | { |
| 292 | .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, | 337 | .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, |
| 293 | 338 | ||
| 294 | .EndpointAddress = (ENDPOINT_DIR_IN | GENERIC_IN_EPNUM), | 339 | .EndpointAddress = (ENDPOINT_DIR_IN | CONSOLE_IN_EPNUM), |
| 295 | .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), | 340 | .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), |
| 296 | .EndpointSize = GENERIC_EPSIZE, | 341 | .EndpointSize = CONSOLE_EPSIZE, |
| 297 | .PollingIntervalMS = 0x01 | 342 | .PollingIntervalMS = 0x01 |
| 298 | }, | 343 | }, |
| 299 | 344 | ||
| @@ -301,11 +346,51 @@ const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = | |||
| 301 | { | 346 | { |
| 302 | .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, | 347 | .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, |
| 303 | 348 | ||
| 304 | .EndpointAddress = (ENDPOINT_DIR_OUT | GENERIC_OUT_EPNUM), | 349 | .EndpointAddress = (ENDPOINT_DIR_OUT | CONSOLE_OUT_EPNUM), |
| 350 | .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), | ||
| 351 | .EndpointSize = CONSOLE_EPSIZE, | ||
| 352 | .PollingIntervalMS = 0x01 | ||
| 353 | }, | ||
| 354 | |||
| 355 | /* | ||
| 356 | * Extra | ||
| 357 | */ | ||
| 358 | .Extra_Interface = | ||
| 359 | { | ||
| 360 | .Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, | ||
| 361 | |||
| 362 | .InterfaceNumber = EXTRA_INTERFACE, | ||
| 363 | .AlternateSetting = 0x00, | ||
| 364 | |||
| 365 | .TotalEndpoints = 1, | ||
| 366 | |||
| 367 | .Class = HID_CSCP_HIDClass, | ||
| 368 | .SubClass = HID_CSCP_NonBootSubclass, | ||
| 369 | .Protocol = HID_CSCP_NonBootProtocol, | ||
| 370 | |||
| 371 | .InterfaceStrIndex = NO_DESCRIPTOR | ||
| 372 | }, | ||
| 373 | |||
| 374 | .Extra_HID = | ||
| 375 | { | ||
| 376 | .Header = {.Size = sizeof(USB_HID_Descriptor_HID_t), .Type = HID_DTYPE_HID}, | ||
| 377 | |||
| 378 | .HIDSpec = VERSION_BCD(01.11), | ||
| 379 | .CountryCode = 0x00, | ||
| 380 | .TotalReportDescriptors = 1, | ||
| 381 | .HIDReportType = HID_DTYPE_Report, | ||
| 382 | .HIDReportLength = sizeof(ExtraReport) | ||
| 383 | }, | ||
| 384 | |||
| 385 | .Extra_INEndpoint = | ||
| 386 | { | ||
| 387 | .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, | ||
| 388 | |||
| 389 | .EndpointAddress = (ENDPOINT_DIR_IN | EXTRA_IN_EPNUM), | ||
| 305 | .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), | 390 | .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), |
| 306 | .EndpointSize = GENERIC_EPSIZE, | 391 | .EndpointSize = EXTRA_EPSIZE, |
| 307 | .PollingIntervalMS = 0x01 | 392 | .PollingIntervalMS = 0x01 |
| 308 | } | 393 | }, |
| 309 | }; | 394 | }; |
| 310 | 395 | ||
| 311 | 396 | ||
| @@ -387,10 +472,14 @@ uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, | |||
| 387 | Address = &ConfigurationDescriptor.Mouse_HID; | 472 | Address = &ConfigurationDescriptor.Mouse_HID; |
| 388 | Size = sizeof(USB_HID_Descriptor_HID_t); | 473 | Size = sizeof(USB_HID_Descriptor_HID_t); |
| 389 | break; | 474 | break; |
| 390 | case GENERIC_INTERFACE: | 475 | case CONSOLE_INTERFACE: |
| 391 | Address = &ConfigurationDescriptor.Console_HID; | 476 | Address = &ConfigurationDescriptor.Console_HID; |
| 392 | Size = sizeof(USB_HID_Descriptor_HID_t); | 477 | Size = sizeof(USB_HID_Descriptor_HID_t); |
| 393 | break; | 478 | break; |
| 479 | case EXTRA_INTERFACE: | ||
| 480 | Address = &ConfigurationDescriptor.Extra_HID; | ||
| 481 | Size = sizeof(USB_HID_Descriptor_HID_t); | ||
| 482 | break; | ||
| 394 | } | 483 | } |
| 395 | break; | 484 | break; |
| 396 | case HID_DTYPE_Report: | 485 | case HID_DTYPE_Report: |
| @@ -403,10 +492,14 @@ uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, | |||
| 403 | Address = &MouseReport; | 492 | Address = &MouseReport; |
| 404 | Size = sizeof(MouseReport); | 493 | Size = sizeof(MouseReport); |
| 405 | break; | 494 | break; |
| 406 | case GENERIC_INTERFACE: | 495 | case CONSOLE_INTERFACE: |
| 407 | Address = &ConsoleReport; | 496 | Address = &ConsoleReport; |
| 408 | Size = sizeof(ConsoleReport); | 497 | Size = sizeof(ConsoleReport); |
| 409 | break; | 498 | break; |
| 499 | case EXTRA_INTERFACE: | ||
| 500 | Address = &ExtraReport; | ||
| 501 | Size = sizeof(ExtraReport); | ||
| 502 | break; | ||
| 410 | } | 503 | } |
| 411 | break; | 504 | break; |
| 412 | } | 505 | } |
diff --git a/keyboard/lufa/descriptor.h b/keyboard/lufa/descriptor.h index d45e905c6..6b1b4d484 100644 --- a/keyboard/lufa/descriptor.h +++ b/keyboard/lufa/descriptor.h | |||
| @@ -60,22 +60,34 @@ typedef struct | |||
| 60 | USB_HID_Descriptor_HID_t Console_HID; | 60 | USB_HID_Descriptor_HID_t Console_HID; |
| 61 | USB_Descriptor_Endpoint_t Console_INEndpoint; | 61 | USB_Descriptor_Endpoint_t Console_INEndpoint; |
| 62 | USB_Descriptor_Endpoint_t Console_OUTEndpoint; | 62 | USB_Descriptor_Endpoint_t Console_OUTEndpoint; |
| 63 | |||
| 64 | // Extra HID Interface | ||
| 65 | USB_Descriptor_Interface_t Extra_Interface; | ||
| 66 | USB_HID_Descriptor_HID_t Extra_HID; | ||
| 67 | USB_Descriptor_Endpoint_t Extra_INEndpoint; | ||
| 63 | } USB_Descriptor_Configuration_t; | 68 | } USB_Descriptor_Configuration_t; |
| 64 | 69 | ||
| 65 | 70 | ||
| 71 | /* nubmer of interfaces */ | ||
| 72 | #define TOTAL_INTERFACES 4 | ||
| 73 | |||
| 74 | /* index of interface */ | ||
| 66 | #define KEYBOARD_INTERFACE 0 | 75 | #define KEYBOARD_INTERFACE 0 |
| 67 | #define MOUSE_INTERFACE 1 | 76 | #define MOUSE_INTERFACE 1 |
| 68 | #define GENERIC_INTERFACE 2 | 77 | #define CONSOLE_INTERFACE 2 |
| 78 | #define EXTRA_INTERFACE 3 | ||
| 69 | 79 | ||
| 70 | // Endopoint number/size | 80 | // Endopoint number and size |
| 71 | #define KEYBOARD_IN_EPNUM 1 | 81 | #define KEYBOARD_IN_EPNUM 1 |
| 72 | #define MOUSE_IN_EPNUM 2 | 82 | #define MOUSE_IN_EPNUM 2 |
| 73 | #define GENERIC_IN_EPNUM 3 | 83 | #define CONSOLE_IN_EPNUM 3 |
| 74 | #define GENERIC_OUT_EPNUM 4 | 84 | #define CONSOLE_OUT_EPNUM 4 |
| 75 | 85 | #define EXTRA_IN_EPNUM 5 | |
| 76 | #define HID_EPSIZE 8 | 86 | |
| 77 | #define GENERIC_EPSIZE 8 | 87 | #define KEYBOARD_EPSIZE 8 |
| 78 | #define GENERIC_REPORT_SIZE 8 | 88 | #define MOUSE_EPSIZE 8 |
| 89 | #define CONSOLE_EPSIZE 8 | ||
| 90 | #define EXTRA_EPSIZE 8 | ||
| 79 | 91 | ||
| 80 | 92 | ||
| 81 | uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, | 93 | uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, |
diff --git a/keyboard/lufa/keymap.c b/keyboard/lufa/keymap.c index a223da731..aa563651a 100644 --- a/keyboard/lufa/keymap.c +++ b/keyboard/lufa/keymap.c | |||
| @@ -110,7 +110,7 @@ static const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | |||
| 110 | * | |Gui |Alt | |Alt |Gui| | |Ctr| | 110 | * | |Gui |Alt | |Alt |Gui| | |Ctr| |
| 111 | * `-----------------------------------------------------------' | 111 | * `-----------------------------------------------------------' |
| 112 | */ | 112 | */ |
| 113 | KEYMAP(ESC, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, DEL, \ | 113 | KEYMAP(PWR, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, DEL, \ |
| 114 | CAPS,NO, NO, NO, NO, NO, NO, NO, PSCR,SLCK,BRK, UP, NO, NO, \ | 114 | CAPS,NO, NO, NO, NO, NO, NO, NO, PSCR,SLCK,BRK, UP, NO, NO, \ |
| 115 | LCTL,VOLD,VOLU,MUTE,NO, NO, PAST,PSLS,HOME,PGUP,LEFT,RGHT,ENT, \ | 115 | LCTL,VOLD,VOLU,MUTE,NO, NO, PAST,PSLS,HOME,PGUP,LEFT,RGHT,ENT, \ |
| 116 | LSFT,NO, NO, NO, NO, NO, PPLS,PMNS,END, PGDN,DOWN,RSFT,FN1, \ | 116 | LSFT,NO, NO, NO, NO, NO, PPLS,PMNS,END, PGDN,DOWN,RSFT,FN1, \ |
diff --git a/keyboard/lufa/lufa.c b/keyboard/lufa/lufa.c index a87d8474a..09da96b2e 100644 --- a/keyboard/lufa/lufa.c +++ b/keyboard/lufa/lufa.c | |||
| @@ -117,7 +117,7 @@ static void Console_HID_Task(void) | |||
| 117 | return; | 117 | return; |
| 118 | 118 | ||
| 119 | // TODO: impl receivechar()/recvchar() | 119 | // TODO: impl receivechar()/recvchar() |
| 120 | Endpoint_SelectEndpoint(GENERIC_OUT_EPNUM); | 120 | Endpoint_SelectEndpoint(CONSOLE_OUT_EPNUM); |
| 121 | 121 | ||
| 122 | /* Check to see if a packet has been sent from the host */ | 122 | /* Check to see if a packet has been sent from the host */ |
| 123 | if (Endpoint_IsOUTReceived()) | 123 | if (Endpoint_IsOUTReceived()) |
| @@ -126,7 +126,7 @@ static void Console_HID_Task(void) | |||
| 126 | if (Endpoint_IsReadWriteAllowed()) | 126 | if (Endpoint_IsReadWriteAllowed()) |
| 127 | { | 127 | { |
| 128 | /* Create a temporary buffer to hold the read in report from the host */ | 128 | /* Create a temporary buffer to hold the read in report from the host */ |
| 129 | uint8_t ConsoleData[GENERIC_REPORT_SIZE]; | 129 | uint8_t ConsoleData[CONSOLE_EPSIZE]; |
| 130 | 130 | ||
| 131 | /* Read Console Report Data */ | 131 | /* Read Console Report Data */ |
| 132 | Endpoint_Read_Stream_LE(&ConsoleData, sizeof(ConsoleData), NULL); | 132 | Endpoint_Read_Stream_LE(&ConsoleData, sizeof(ConsoleData), NULL); |
| @@ -140,7 +140,7 @@ static void Console_HID_Task(void) | |||
| 140 | } | 140 | } |
| 141 | 141 | ||
| 142 | /* IN packet */ | 142 | /* IN packet */ |
| 143 | Endpoint_SelectEndpoint(GENERIC_IN_EPNUM); | 143 | Endpoint_SelectEndpoint(CONSOLE_IN_EPNUM); |
| 144 | // send IN packet | 144 | // send IN packet |
| 145 | if (Endpoint_IsINReady()) | 145 | if (Endpoint_IsINReady()) |
| 146 | Endpoint_ClearIN(); | 146 | Endpoint_ClearIN(); |
| @@ -169,17 +169,21 @@ void EVENT_USB_Device_ConfigurationChanged(void) | |||
| 169 | 169 | ||
| 170 | /* Setup Keyboard HID Report Endpoints */ | 170 | /* Setup Keyboard HID Report Endpoints */ |
| 171 | ConfigSuccess &= Endpoint_ConfigureEndpoint(KEYBOARD_IN_EPNUM, EP_TYPE_INTERRUPT, ENDPOINT_DIR_IN, | 171 | ConfigSuccess &= Endpoint_ConfigureEndpoint(KEYBOARD_IN_EPNUM, EP_TYPE_INTERRUPT, ENDPOINT_DIR_IN, |
| 172 | HID_EPSIZE, ENDPOINT_BANK_SINGLE); | 172 | KEYBOARD_EPSIZE, ENDPOINT_BANK_SINGLE); |
| 173 | 173 | ||
| 174 | /* Setup Mouse HID Report Endpoint */ | 174 | /* Setup Mouse HID Report Endpoint */ |
| 175 | ConfigSuccess &= Endpoint_ConfigureEndpoint(MOUSE_IN_EPNUM, EP_TYPE_INTERRUPT, ENDPOINT_DIR_IN, | 175 | ConfigSuccess &= Endpoint_ConfigureEndpoint(MOUSE_IN_EPNUM, EP_TYPE_INTERRUPT, ENDPOINT_DIR_IN, |
| 176 | HID_EPSIZE, ENDPOINT_BANK_SINGLE); | 176 | MOUSE_EPSIZE, ENDPOINT_BANK_SINGLE); |
| 177 | 177 | ||
| 178 | /* Setup Console HID Report Endpoints */ | 178 | /* Setup Console HID Report Endpoints */ |
| 179 | ConfigSuccess &= Endpoint_ConfigureEndpoint(GENERIC_IN_EPNUM, EP_TYPE_INTERRUPT, ENDPOINT_DIR_IN, | 179 | ConfigSuccess &= Endpoint_ConfigureEndpoint(CONSOLE_IN_EPNUM, EP_TYPE_INTERRUPT, ENDPOINT_DIR_IN, |
| 180 | GENERIC_EPSIZE, ENDPOINT_BANK_SINGLE); | 180 | CONSOLE_EPSIZE, ENDPOINT_BANK_SINGLE); |
| 181 | ConfigSuccess &= Endpoint_ConfigureEndpoint(GENERIC_OUT_EPNUM, EP_TYPE_INTERRUPT, ENDPOINT_DIR_OUT, | 181 | ConfigSuccess &= Endpoint_ConfigureEndpoint(CONSOLE_OUT_EPNUM, EP_TYPE_INTERRUPT, ENDPOINT_DIR_OUT, |
| 182 | GENERIC_EPSIZE, ENDPOINT_BANK_SINGLE); | 182 | CONSOLE_EPSIZE, ENDPOINT_BANK_SINGLE); |
| 183 | |||
| 184 | /* Setup Extra HID Report Endpoint */ | ||
| 185 | ConfigSuccess &= Endpoint_ConfigureEndpoint(EXTRA_IN_EPNUM, EP_TYPE_INTERRUPT, ENDPOINT_DIR_IN, | ||
| 186 | EXTRA_EPSIZE, ENDPOINT_BANK_SINGLE); | ||
| 183 | } | 187 | } |
| 184 | 188 | ||
| 185 | /* | 189 | /* |
| @@ -223,7 +227,9 @@ void EVENT_USB_Device_ControlRequest(void) | |||
| 223 | ReportData = (uint8_t*)&mouse_report_sent; | 227 | ReportData = (uint8_t*)&mouse_report_sent; |
| 224 | ReportSize = sizeof(mouse_report_sent); | 228 | ReportSize = sizeof(mouse_report_sent); |
| 225 | break; | 229 | break; |
| 226 | case GENERIC_INTERFACE: | 230 | case CONSOLE_INTERFACE: |
| 231 | break; | ||
| 232 | case EXTRA_INTERFACE: | ||
| 227 | break; | 233 | break; |
| 228 | } | 234 | } |
| 229 | 235 | ||
| @@ -254,7 +260,9 @@ void EVENT_USB_Device_ControlRequest(void) | |||
| 254 | break; | 260 | break; |
| 255 | case MOUSE_INTERFACE: | 261 | case MOUSE_INTERFACE: |
| 256 | break; | 262 | break; |
| 257 | case GENERIC_INTERFACE: | 263 | case CONSOLE_INTERFACE: |
| 264 | break; | ||
| 265 | case EXTRA_INTERFACE: | ||
| 258 | break; | 266 | break; |
| 259 | } | 267 | } |
| 260 | 268 | ||
| @@ -301,12 +309,7 @@ static void send_mouse(report_mouse_t *report) | |||
| 301 | if (Endpoint_IsReadWriteAllowed()) | 309 | if (Endpoint_IsReadWriteAllowed()) |
| 302 | { | 310 | { |
| 303 | /* Write Mouse Report Data */ | 311 | /* Write Mouse Report Data */ |
| 304 | /* Mouse report data structure | 312 | Endpoint_Write_Stream_LE(report, sizeof(report_mouse_t), NULL); |
| 305 | * LUFA: { buttons, x, y } | ||
| 306 | * tmk: { buttons, x, y, v, h } | ||
| 307 | */ | ||
| 308 | //Endpoint_Write_Stream_LE((uint8_t *)report+1, 3, NULL); | ||
| 309 | Endpoint_Write_Stream_LE(report, 3, NULL); | ||
| 310 | 313 | ||
| 311 | /* Finalize the stream transfer to send the last packet */ | 314 | /* Finalize the stream transfer to send the last packet */ |
| 312 | Endpoint_ClearIN(); | 315 | Endpoint_ClearIN(); |
| @@ -314,12 +317,35 @@ static void send_mouse(report_mouse_t *report) | |||
| 314 | mouse_report_sent = *report; | 317 | mouse_report_sent = *report; |
| 315 | } | 318 | } |
| 316 | 319 | ||
| 320 | typedef struct { | ||
| 321 | uint8_t report_id; | ||
| 322 | uint16_t usage; | ||
| 323 | } __attribute__ ((packed)) report_extra_t; | ||
| 324 | |||
| 317 | static void send_system(uint16_t data) | 325 | static void send_system(uint16_t data) |
| 318 | { | 326 | { |
| 327 | Endpoint_SelectEndpoint(EXTRA_IN_EPNUM); | ||
| 328 | if (Endpoint_IsReadWriteAllowed()) { | ||
| 329 | report_extra_t r = { | ||
| 330 | .report_id = REPORT_ID_SYSTEM, | ||
| 331 | .usage = data | ||
| 332 | }; | ||
| 333 | Endpoint_Write_Stream_LE(&r, sizeof(report_extra_t), NULL); | ||
| 334 | Endpoint_ClearIN(); | ||
| 335 | } | ||
| 319 | } | 336 | } |
| 320 | 337 | ||
| 321 | static void send_consumer(uint16_t data) | 338 | static void send_consumer(uint16_t data) |
| 322 | { | 339 | { |
| 340 | Endpoint_SelectEndpoint(EXTRA_IN_EPNUM); | ||
| 341 | if (Endpoint_IsReadWriteAllowed()) { | ||
| 342 | report_extra_t r = { | ||
| 343 | .report_id = REPORT_ID_CONSUMER, | ||
| 344 | .usage = data | ||
| 345 | }; | ||
| 346 | Endpoint_Write_Stream_LE(&r, sizeof(report_extra_t), NULL); | ||
| 347 | Endpoint_ClearIN(); | ||
| 348 | } | ||
| 323 | } | 349 | } |
| 324 | 350 | ||
| 325 | 351 | ||
| @@ -331,7 +357,7 @@ int8_t sendchar(uint8_t c) | |||
| 331 | if (USB_DeviceState != DEVICE_STATE_Configured) | 357 | if (USB_DeviceState != DEVICE_STATE_Configured) |
| 332 | return -1; | 358 | return -1; |
| 333 | 359 | ||
| 334 | Endpoint_SelectEndpoint(GENERIC_IN_EPNUM); | 360 | Endpoint_SelectEndpoint(CONSOLE_IN_EPNUM); |
| 335 | 361 | ||
| 336 | uint8_t timeout = 10; | 362 | uint8_t timeout = 10; |
| 337 | uint16_t prevFN = USB_Device_GetFrameNumber(); | 363 | uint16_t prevFN = USB_Device_GetFrameNumber(); |
diff --git a/protocol/vusb/main.c b/protocol/vusb/main.c index 1ba40a27a..3deb82238 100644 --- a/protocol/vusb/main.c +++ b/protocol/vusb/main.c | |||
| @@ -62,11 +62,6 @@ int main(void) | |||
| 62 | 62 | ||
| 63 | debug("initForUsbConnectivity()\n"); | 63 | debug("initForUsbConnectivity()\n"); |
| 64 | initForUsbConnectivity(); | 64 | initForUsbConnectivity(); |
| 65 | int i; | ||
| 66 | while(--i){ /* To configured */ | ||
| 67 | usbPoll(); | ||
| 68 | _delay_ms(1); | ||
| 69 | } | ||
| 70 | 65 | ||
| 71 | debug("main loop\n"); | 66 | debug("main loop\n"); |
| 72 | while (1) { | 67 | while (1) { |
diff --git a/protocol/vusb/vusb.c b/protocol/vusb/vusb.c index 1dff5dea2..4e11836e1 100644 --- a/protocol/vusb/vusb.c +++ b/protocol/vusb/vusb.c | |||
| @@ -107,32 +107,25 @@ static void send_mouse(report_mouse_t *report) | |||
| 107 | } | 107 | } |
| 108 | } | 108 | } |
| 109 | 109 | ||
| 110 | /* | 110 | |
| 111 | typedef struct { | 111 | typedef struct { |
| 112 | uint8_t report_id; | 112 | uint8_t report_id; |
| 113 | uint8_t data0; | 113 | uint16_t usage; |
| 114 | uint8_t data1; | 114 | } __attribute__ ((packed)) report_extra_t; |
| 115 | } __attribute__ ((packed)) vusb_system_report_t; | ||
| 116 | */ | ||
| 117 | 115 | ||
| 118 | static void send_system(uint16_t data) | 116 | static void send_system(uint16_t data) |
| 119 | { | 117 | { |
| 120 | /* | 118 | static uint16_t last_data = 0; |
| 121 | // Not need static? | 119 | if (data == last_data) return; |
| 122 | static uint8_t report[] = { REPORT_ID_SYSTEM, 0, 0 }; | 120 | last_data = data; |
| 123 | report[1] = data&0xFF; | 121 | |
| 124 | report[2] = (data>>8)&0xFF; | 122 | report_extra_t report = { |
| 125 | */ | ||
| 126 | /* | ||
| 127 | vusb_system_report_t r = { | ||
| 128 | .report_id = REPORT_ID_SYSTEM, | 123 | .report_id = REPORT_ID_SYSTEM, |
| 129 | .data0 = data&0xFF, | 124 | .usage = data |
| 130 | .data1 = (data>>8)&0xFF | ||
| 131 | }; | 125 | }; |
| 132 | if (usbInterruptIsReady3()) { | 126 | if (usbInterruptIsReady3()) { |
| 133 | usbSetInterrupt3((void *)&r, sizeof(vusb_system_report_t)); | 127 | usbSetInterrupt3((void *)&report, sizeof(report)); |
| 134 | } | 128 | } |
| 135 | */ | ||
| 136 | } | 129 | } |
| 137 | 130 | ||
| 138 | static void send_consumer(uint16_t data) | 131 | static void send_consumer(uint16_t data) |
| @@ -141,10 +134,10 @@ static void send_consumer(uint16_t data) | |||
| 141 | if (data == last_data) return; | 134 | if (data == last_data) return; |
| 142 | last_data = data; | 135 | last_data = data; |
| 143 | 136 | ||
| 144 | // Not need static? | 137 | report_extra_t report = { |
| 145 | static uint8_t report[] = { REPORT_ID_CONSUMER, 0, 0 }; | 138 | .report_id = REPORT_ID_CONSUMER, |
| 146 | report[1] = data&0xFF; | 139 | .usage = data |
| 147 | report[2] = (data>>8)&0xFF; | 140 | }; |
| 148 | if (usbInterruptIsReady3()) { | 141 | if (usbInterruptIsReady3()) { |
| 149 | usbSetInterrupt3((void *)&report, sizeof(report)); | 142 | usbSetInterrupt3((void *)&report, sizeof(report)); |
| 150 | } | 143 | } |
