diff options
| author | tmk <nobody@nowhere> | 2012-07-14 02:47:29 +0900 |
|---|---|---|
| committer | tmk <nobody@nowhere> | 2012-07-20 13:08:18 +0900 |
| commit | e075361b6f6bfe24e8d12d125bdab46345087432 (patch) | |
| tree | 1d51d5cea14bde40fbad8a3354d518fb335c71b1 | |
| parent | fb8394da83d1af1e52eac1bdeadf3b5a925b6560 (diff) | |
| download | qmk_firmware-e075361b6f6bfe24e8d12d125bdab46345087432.tar.gz qmk_firmware-e075361b6f6bfe24e8d12d125bdab46345087432.zip | |
Add CONSOLE_ENABLE build option to LUFA.
| -rw-r--r-- | common.mk | 16 | ||||
| -rw-r--r-- | keyboard/hhkb/Makefile.lufa | 3 | ||||
| -rw-r--r-- | keyboard/hhkb/config.h | 2 | ||||
| -rw-r--r-- | protocol/lufa/descriptor.c | 130 | ||||
| -rw-r--r-- | protocol/lufa/descriptor.h | 50 | ||||
| -rw-r--r-- | protocol/lufa/lufa.c | 47 |
6 files changed, 152 insertions, 96 deletions
| @@ -15,20 +15,24 @@ ifdef MOUSEKEY_ENABLE | |||
| 15 | OPT_DEFS += -DMOUSEKEY_ENABLE | 15 | OPT_DEFS += -DMOUSEKEY_ENABLE |
| 16 | endif | 16 | endif |
| 17 | 17 | ||
| 18 | ifdef PS2_MOUSE_ENABLE | ||
| 19 | SRC += $(COMMON_DIR)/ps2.c \ | ||
| 20 | $(COMMON_DIR)/ps2_mouse.c | ||
| 21 | OPT_DEFS += -DPS2_MOUSE_ENABLE | ||
| 22 | endif | ||
| 23 | |||
| 24 | ifdef EXTRAKEY_ENABLE | 18 | ifdef EXTRAKEY_ENABLE |
| 25 | OPT_DEFS += -DEXTRAKEY_ENABLE | 19 | OPT_DEFS += -DEXTRAKEY_ENABLE |
| 26 | endif | 20 | endif |
| 27 | 21 | ||
| 22 | ifdef CONSOLE_ENABLE | ||
| 23 | OPT_DEFS += -DCONSOLE_ENABLE | ||
| 24 | endif | ||
| 25 | |||
| 28 | ifdef NKRO_ENABLE | 26 | ifdef NKRO_ENABLE |
| 29 | OPT_DEFS += -DNKRO_ENABLE | 27 | OPT_DEFS += -DNKRO_ENABLE |
| 30 | endif | 28 | endif |
| 31 | 29 | ||
| 30 | ifdef PS2_MOUSE_ENABLE | ||
| 31 | SRC += $(COMMON_DIR)/ps2.c \ | ||
| 32 | $(COMMON_DIR)/ps2_mouse.c | ||
| 33 | OPT_DEFS += -DPS2_MOUSE_ENABLE | ||
| 34 | endif | ||
| 35 | |||
| 32 | ifdef $(or MOUSEKEY_ENABLE, PS2_MOUSE_ENABLE) | 36 | ifdef $(or MOUSEKEY_ENABLE, PS2_MOUSE_ENABLE) |
| 33 | OPT_DEFS += -DMOUSE_ENABLE | 37 | OPT_DEFS += -DMOUSE_ENABLE |
| 34 | endif | 38 | endif |
diff --git a/keyboard/hhkb/Makefile.lufa b/keyboard/hhkb/Makefile.lufa index 0dc295e62..5acc93a23 100644 --- a/keyboard/hhkb/Makefile.lufa +++ b/keyboard/hhkb/Makefile.lufa | |||
| @@ -101,7 +101,8 @@ OPT_DEFS += -DINTERRUPT_CONTROL_ENDPOINT | |||
| 101 | # comment out to disable the options. | 101 | # comment out to disable the options. |
| 102 | # | 102 | # |
| 103 | MOUSEKEY_ENABLE = yes # Mouse keys | 103 | MOUSEKEY_ENABLE = yes # Mouse keys |
| 104 | EXTRAKEY_ENABLE = yes # Audio control and System control | 104 | EXTRAKEY_ENABLE = yes # Media control and System control |
| 105 | CONSOLE_ENABLE = yes # Console for debug | ||
| 105 | #NKRO_ENABLE = yes # USB Nkey Rollover | 106 | #NKRO_ENABLE = yes # USB Nkey Rollover |
| 106 | #PS2_MOUSE_ENABLE = yes # PS/2 mouse(TrackPoint) support | 107 | #PS2_MOUSE_ENABLE = yes # PS/2 mouse(TrackPoint) support |
| 107 | 108 | ||
diff --git a/keyboard/hhkb/config.h b/keyboard/hhkb/config.h index a8cefd5ed..bf946ac01 100644 --- a/keyboard/hhkb/config.h +++ b/keyboard/hhkb/config.h | |||
| @@ -24,7 +24,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
| 24 | 24 | ||
| 25 | #define VENDOR_ID 0xFEED | 25 | #define VENDOR_ID 0xFEED |
| 26 | #define PRODUCT_ID 0xCAFE | 26 | #define PRODUCT_ID 0xCAFE |
| 27 | #define DEVICE_VER 0x0101 | 27 | #define DEVICE_VER 0x0103 |
| 28 | #define MANUFACTURER t.m.k. | 28 | #define MANUFACTURER t.m.k. |
| 29 | #define PRODUCT HHKB mod | 29 | #define PRODUCT HHKB mod |
| 30 | 30 | ||
diff --git a/protocol/lufa/descriptor.c b/protocol/lufa/descriptor.c index 3c98819ff..ff98d8876 100644 --- a/protocol/lufa/descriptor.c +++ b/protocol/lufa/descriptor.c | |||
| @@ -80,6 +80,7 @@ const USB_Descriptor_HIDReport_Datatype_t PROGMEM KeyboardReport[] = | |||
| 80 | HID_RI_END_COLLECTION(0), | 80 | HID_RI_END_COLLECTION(0), |
| 81 | }; | 81 | }; |
| 82 | 82 | ||
| 83 | #ifdef MOUSE_ENABLE | ||
| 83 | const USB_Descriptor_HIDReport_Datatype_t PROGMEM MouseReport[] = | 84 | const USB_Descriptor_HIDReport_Datatype_t PROGMEM MouseReport[] = |
| 84 | { | 85 | { |
| 85 | HID_RI_USAGE_PAGE(8, 0x01), /* Generic Desktop */ | 86 | HID_RI_USAGE_PAGE(8, 0x01), /* Generic Desktop */ |
| @@ -127,29 +128,10 @@ const USB_Descriptor_HIDReport_Datatype_t PROGMEM MouseReport[] = | |||
| 127 | HID_RI_END_COLLECTION(0), | 128 | HID_RI_END_COLLECTION(0), |
| 128 | HID_RI_END_COLLECTION(0), | 129 | HID_RI_END_COLLECTION(0), |
| 129 | }; | 130 | }; |
| 130 | 131 | #endif | |
| 131 | const USB_Descriptor_HIDReport_Datatype_t PROGMEM ConsoleReport[] = | ||
| 132 | { | ||
| 133 | HID_RI_USAGE_PAGE(16, 0xFF31), /* Vendor Page(PJRC Teensy compatible) */ | ||
| 134 | HID_RI_USAGE(8, 0x74), /* Vendor Usage(PJRC Teensy compatible) */ | ||
| 135 | HID_RI_COLLECTION(8, 0x01), /* Application */ | ||
| 136 | HID_RI_USAGE(8, 0x75), /* Vendor Usage 0x75 */ | ||
| 137 | HID_RI_LOGICAL_MINIMUM(8, 0x00), | ||
| 138 | HID_RI_LOGICAL_MAXIMUM(8, 0xFF), | ||
| 139 | HID_RI_REPORT_COUNT(8, CONSOLE_EPSIZE), | ||
| 140 | HID_RI_REPORT_SIZE(8, 0x08), | ||
| 141 | HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE), | ||
| 142 | HID_RI_USAGE(8, 0x76), /* Vendor Usage 0x76 */ | ||
| 143 | HID_RI_LOGICAL_MINIMUM(8, 0x00), | ||
| 144 | HID_RI_LOGICAL_MAXIMUM(8, 0xFF), | ||
| 145 | HID_RI_REPORT_COUNT(8, CONSOLE_EPSIZE), | ||
| 146 | HID_RI_REPORT_SIZE(8, 0x08), | ||
| 147 | HID_RI_OUTPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_NON_VOLATILE), | ||
| 148 | HID_RI_END_COLLECTION(0), | ||
| 149 | }; | ||
| 150 | 132 | ||
| 151 | #ifdef EXTRAKEY_ENABLE | 133 | #ifdef EXTRAKEY_ENABLE |
| 152 | const USB_Descriptor_HIDReport_Datatype_t PROGMEM ExtraReport[] = | 134 | const USB_Descriptor_HIDReport_Datatype_t PROGMEM ExtrakeyReport[] = |
| 153 | { | 135 | { |
| 154 | HID_RI_USAGE_PAGE(8, 0x01), /* Generic Desktop */ | 136 | HID_RI_USAGE_PAGE(8, 0x01), /* Generic Desktop */ |
| 155 | HID_RI_USAGE(8, 0x80), /* System Control */ | 137 | HID_RI_USAGE(8, 0x80), /* System Control */ |
| @@ -179,6 +161,28 @@ const USB_Descriptor_HIDReport_Datatype_t PROGMEM ExtraReport[] = | |||
| 179 | }; | 161 | }; |
| 180 | #endif | 162 | #endif |
| 181 | 163 | ||
| 164 | #ifdef CONSOLE_ENABLE | ||
| 165 | const USB_Descriptor_HIDReport_Datatype_t PROGMEM ConsoleReport[] = | ||
| 166 | { | ||
| 167 | HID_RI_USAGE_PAGE(16, 0xFF31), /* Vendor Page(PJRC Teensy compatible) */ | ||
| 168 | HID_RI_USAGE(8, 0x74), /* Vendor Usage(PJRC Teensy compatible) */ | ||
| 169 | HID_RI_COLLECTION(8, 0x01), /* Application */ | ||
| 170 | HID_RI_USAGE(8, 0x75), /* Vendor Usage 0x75 */ | ||
| 171 | HID_RI_LOGICAL_MINIMUM(8, 0x00), | ||
| 172 | HID_RI_LOGICAL_MAXIMUM(8, 0xFF), | ||
| 173 | HID_RI_REPORT_COUNT(8, CONSOLE_EPSIZE), | ||
| 174 | HID_RI_REPORT_SIZE(8, 0x08), | ||
| 175 | HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE), | ||
| 176 | HID_RI_USAGE(8, 0x76), /* Vendor Usage 0x76 */ | ||
| 177 | HID_RI_LOGICAL_MINIMUM(8, 0x00), | ||
| 178 | HID_RI_LOGICAL_MAXIMUM(8, 0xFF), | ||
| 179 | HID_RI_REPORT_COUNT(8, CONSOLE_EPSIZE), | ||
| 180 | HID_RI_REPORT_SIZE(8, 0x08), | ||
| 181 | HID_RI_OUTPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_NON_VOLATILE), | ||
| 182 | HID_RI_END_COLLECTION(0), | ||
| 183 | }; | ||
| 184 | #endif | ||
| 185 | |||
| 182 | #ifdef NKRO_ENABLE | 186 | #ifdef NKRO_ENABLE |
| 183 | const USB_Descriptor_HIDReport_Datatype_t PROGMEM NKROReport[] = | 187 | const USB_Descriptor_HIDReport_Datatype_t PROGMEM NKROReport[] = |
| 184 | { | 188 | { |
| @@ -342,16 +346,17 @@ const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = | |||
| 342 | #endif | 346 | #endif |
| 343 | 347 | ||
| 344 | /* | 348 | /* |
| 345 | * Console | 349 | * Extra |
| 346 | */ | 350 | */ |
| 347 | .Console_Interface = | 351 | #ifdef EXTRAKEY_ENABLE |
| 352 | .Extrakey_Interface = | ||
| 348 | { | 353 | { |
| 349 | .Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, | 354 | .Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, |
| 350 | 355 | ||
| 351 | .InterfaceNumber = CONSOLE_INTERFACE, | 356 | .InterfaceNumber = EXTRAKEY_INTERFACE, |
| 352 | .AlternateSetting = 0x00, | 357 | .AlternateSetting = 0x00, |
| 353 | 358 | ||
| 354 | .TotalEndpoints = 2, | 359 | .TotalEndpoints = 1, |
| 355 | 360 | ||
| 356 | .Class = HID_CSCP_HIDClass, | 361 | .Class = HID_CSCP_HIDClass, |
| 357 | .SubClass = HID_CSCP_NonBootSubclass, | 362 | .SubClass = HID_CSCP_NonBootSubclass, |
| @@ -360,7 +365,7 @@ const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = | |||
| 360 | .InterfaceStrIndex = NO_DESCRIPTOR | 365 | .InterfaceStrIndex = NO_DESCRIPTOR |
| 361 | }, | 366 | }, |
| 362 | 367 | ||
| 363 | .Console_HID = | 368 | .Extrakey_HID = |
| 364 | { | 369 | { |
| 365 | .Header = {.Size = sizeof(USB_HID_Descriptor_HID_t), .Type = HID_DTYPE_HID}, | 370 | .Header = {.Size = sizeof(USB_HID_Descriptor_HID_t), .Type = HID_DTYPE_HID}, |
| 366 | 371 | ||
| @@ -368,41 +373,32 @@ const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = | |||
| 368 | .CountryCode = 0x00, | 373 | .CountryCode = 0x00, |
| 369 | .TotalReportDescriptors = 1, | 374 | .TotalReportDescriptors = 1, |
| 370 | .HIDReportType = HID_DTYPE_Report, | 375 | .HIDReportType = HID_DTYPE_Report, |
| 371 | .HIDReportLength = sizeof(ConsoleReport) | 376 | .HIDReportLength = sizeof(ExtrakeyReport) |
| 372 | }, | 377 | }, |
| 373 | 378 | ||
| 374 | .Console_INEndpoint = | 379 | .Extrakey_INEndpoint = |
| 375 | { | 380 | { |
| 376 | .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, | 381 | .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, |
| 377 | 382 | ||
| 378 | .EndpointAddress = (ENDPOINT_DIR_IN | CONSOLE_IN_EPNUM), | 383 | .EndpointAddress = (ENDPOINT_DIR_IN | EXTRAKEY_IN_EPNUM), |
| 379 | .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), | 384 | .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), |
| 380 | .EndpointSize = CONSOLE_EPSIZE, | 385 | .EndpointSize = EXTRAKEY_EPSIZE, |
| 381 | .PollingIntervalMS = 0x01 | ||
| 382 | }, | ||
| 383 | |||
| 384 | .Console_OUTEndpoint = | ||
| 385 | { | ||
| 386 | .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, | ||
| 387 | |||
| 388 | .EndpointAddress = (ENDPOINT_DIR_OUT | CONSOLE_OUT_EPNUM), | ||
| 389 | .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), | ||
| 390 | .EndpointSize = CONSOLE_EPSIZE, | ||
| 391 | .PollingIntervalMS = 0x01 | 386 | .PollingIntervalMS = 0x01 |
| 392 | }, | 387 | }, |
| 388 | #endif | ||
| 393 | 389 | ||
| 394 | /* | 390 | /* |
| 395 | * Extra | 391 | * Console |
| 396 | */ | 392 | */ |
| 397 | #ifdef EXTRAKEY_ENABLE | 393 | #ifdef CONSOLE_ENABLE |
| 398 | .Extra_Interface = | 394 | .Console_Interface = |
| 399 | { | 395 | { |
| 400 | .Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, | 396 | .Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, |
| 401 | 397 | ||
| 402 | .InterfaceNumber = EXTRA_INTERFACE, | 398 | .InterfaceNumber = CONSOLE_INTERFACE, |
| 403 | .AlternateSetting = 0x00, | 399 | .AlternateSetting = 0x00, |
| 404 | 400 | ||
| 405 | .TotalEndpoints = 1, | 401 | .TotalEndpoints = 2, |
| 406 | 402 | ||
| 407 | .Class = HID_CSCP_HIDClass, | 403 | .Class = HID_CSCP_HIDClass, |
| 408 | .SubClass = HID_CSCP_NonBootSubclass, | 404 | .SubClass = HID_CSCP_NonBootSubclass, |
| @@ -411,7 +407,7 @@ const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = | |||
| 411 | .InterfaceStrIndex = NO_DESCRIPTOR | 407 | .InterfaceStrIndex = NO_DESCRIPTOR |
| 412 | }, | 408 | }, |
| 413 | 409 | ||
| 414 | .Extra_HID = | 410 | .Console_HID = |
| 415 | { | 411 | { |
| 416 | .Header = {.Size = sizeof(USB_HID_Descriptor_HID_t), .Type = HID_DTYPE_HID}, | 412 | .Header = {.Size = sizeof(USB_HID_Descriptor_HID_t), .Type = HID_DTYPE_HID}, |
| 417 | 413 | ||
| @@ -419,16 +415,26 @@ const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = | |||
| 419 | .CountryCode = 0x00, | 415 | .CountryCode = 0x00, |
| 420 | .TotalReportDescriptors = 1, | 416 | .TotalReportDescriptors = 1, |
| 421 | .HIDReportType = HID_DTYPE_Report, | 417 | .HIDReportType = HID_DTYPE_Report, |
| 422 | .HIDReportLength = sizeof(ExtraReport) | 418 | .HIDReportLength = sizeof(ConsoleReport) |
| 423 | }, | 419 | }, |
| 424 | 420 | ||
| 425 | .Extra_INEndpoint = | 421 | .Console_INEndpoint = |
| 426 | { | 422 | { |
| 427 | .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, | 423 | .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, |
| 428 | 424 | ||
| 429 | .EndpointAddress = (ENDPOINT_DIR_IN | EXTRA_IN_EPNUM), | 425 | .EndpointAddress = (ENDPOINT_DIR_IN | CONSOLE_IN_EPNUM), |
| 430 | .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), | 426 | .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), |
| 431 | .EndpointSize = EXTRA_EPSIZE, | 427 | .EndpointSize = CONSOLE_EPSIZE, |
| 428 | .PollingIntervalMS = 0x01 | ||
| 429 | }, | ||
| 430 | |||
| 431 | .Console_OUTEndpoint = | ||
| 432 | { | ||
| 433 | .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, | ||
| 434 | |||
| 435 | .EndpointAddress = (ENDPOINT_DIR_OUT | CONSOLE_OUT_EPNUM), | ||
| 436 | .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), | ||
| 437 | .EndpointSize = CONSOLE_EPSIZE, | ||
| 432 | .PollingIntervalMS = 0x01 | 438 | .PollingIntervalMS = 0x01 |
| 433 | }, | 439 | }, |
| 434 | #endif | 440 | #endif |
| @@ -515,13 +521,15 @@ uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, | |||
| 515 | Size = sizeof(USB_HID_Descriptor_HID_t); | 521 | Size = sizeof(USB_HID_Descriptor_HID_t); |
| 516 | break; | 522 | break; |
| 517 | #endif | 523 | #endif |
| 518 | case CONSOLE_INTERFACE: | 524 | #ifdef EXTRAKEY_ENABLE |
| 519 | Address = &ConfigurationDescriptor.Console_HID; | 525 | case EXTRAKEY_INTERFACE: |
| 526 | Address = &ConfigurationDescriptor.Extrakey_HID; | ||
| 520 | Size = sizeof(USB_HID_Descriptor_HID_t); | 527 | Size = sizeof(USB_HID_Descriptor_HID_t); |
| 521 | break; | 528 | break; |
| 522 | #ifdef EXTRAKEY_ENABLE | 529 | #endif |
| 523 | case EXTRA_INTERFACE: | 530 | #ifdef CONSOLE_ENABLE |
| 524 | Address = &ConfigurationDescriptor.Extra_HID; | 531 | case CONSOLE_INTERFACE: |
| 532 | Address = &ConfigurationDescriptor.Console_HID; | ||
| 525 | Size = sizeof(USB_HID_Descriptor_HID_t); | 533 | Size = sizeof(USB_HID_Descriptor_HID_t); |
| 526 | break; | 534 | break; |
| 527 | #endif | 535 | #endif |
| @@ -539,15 +547,17 @@ uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, | |||
| 539 | Size = sizeof(MouseReport); | 547 | Size = sizeof(MouseReport); |
| 540 | break; | 548 | break; |
| 541 | #endif | 549 | #endif |
| 550 | #ifdef EXTRAKEY_ENABLE | ||
| 551 | case EXTRAKEY_INTERFACE: | ||
| 552 | Address = &ExtrakeyReport; | ||
| 553 | Size = sizeof(ExtrakeyReport); | ||
| 554 | break; | ||
| 555 | #endif | ||
| 556 | #ifdef CONSOLE_ENABLE | ||
| 542 | case CONSOLE_INTERFACE: | 557 | case CONSOLE_INTERFACE: |
| 543 | Address = &ConsoleReport; | 558 | Address = &ConsoleReport; |
| 544 | Size = sizeof(ConsoleReport); | 559 | Size = sizeof(ConsoleReport); |
| 545 | break; | 560 | break; |
| 546 | #ifdef EXTRAKEY_ENABLE | ||
| 547 | case EXTRA_INTERFACE: | ||
| 548 | Address = &ExtraReport; | ||
| 549 | Size = sizeof(ExtraReport); | ||
| 550 | break; | ||
| 551 | #endif | 561 | #endif |
| 552 | } | 562 | } |
| 553 | break; | 563 | break; |
diff --git a/protocol/lufa/descriptor.h b/protocol/lufa/descriptor.h index 09fb24acc..44f20d5a2 100644 --- a/protocol/lufa/descriptor.h +++ b/protocol/lufa/descriptor.h | |||
| @@ -57,24 +57,26 @@ typedef struct | |||
| 57 | USB_HID_Descriptor_HID_t Keyboard_HID; | 57 | USB_HID_Descriptor_HID_t Keyboard_HID; |
| 58 | USB_Descriptor_Endpoint_t Keyboard_INEndpoint; | 58 | USB_Descriptor_Endpoint_t Keyboard_INEndpoint; |
| 59 | 59 | ||
| 60 | // Mouse HID Interface | ||
| 61 | #ifdef MOUSE_ENABLE | 60 | #ifdef MOUSE_ENABLE |
| 61 | // Mouse HID Interface | ||
| 62 | USB_Descriptor_Interface_t Mouse_Interface; | 62 | USB_Descriptor_Interface_t Mouse_Interface; |
| 63 | USB_HID_Descriptor_HID_t Mouse_HID; | 63 | USB_HID_Descriptor_HID_t Mouse_HID; |
| 64 | USB_Descriptor_Endpoint_t Mouse_INEndpoint; | 64 | USB_Descriptor_Endpoint_t Mouse_INEndpoint; |
| 65 | #endif | 65 | #endif |
| 66 | 66 | ||
| 67 | #ifdef EXTRAKEY_ENABLE | ||
| 68 | // Extrakey HID Interface | ||
| 69 | USB_Descriptor_Interface_t Extrakey_Interface; | ||
| 70 | USB_HID_Descriptor_HID_t Extrakey_HID; | ||
| 71 | USB_Descriptor_Endpoint_t Extrakey_INEndpoint; | ||
| 72 | #endif | ||
| 73 | |||
| 74 | #ifdef CONSOLE_ENABLE | ||
| 67 | // Console HID Interface | 75 | // Console HID Interface |
| 68 | USB_Descriptor_Interface_t Console_Interface; | 76 | USB_Descriptor_Interface_t Console_Interface; |
| 69 | USB_HID_Descriptor_HID_t Console_HID; | 77 | USB_HID_Descriptor_HID_t Console_HID; |
| 70 | USB_Descriptor_Endpoint_t Console_INEndpoint; | 78 | USB_Descriptor_Endpoint_t Console_INEndpoint; |
| 71 | USB_Descriptor_Endpoint_t Console_OUTEndpoint; | 79 | USB_Descriptor_Endpoint_t Console_OUTEndpoint; |
| 72 | |||
| 73 | // Extra HID Interface | ||
| 74 | #ifdef EXTRAKEY_ENABLE | ||
| 75 | USB_Descriptor_Interface_t Extra_Interface; | ||
| 76 | USB_HID_Descriptor_HID_t Extra_HID; | ||
| 77 | USB_Descriptor_Endpoint_t Extra_INEndpoint; | ||
| 78 | #endif | 80 | #endif |
| 79 | } USB_Descriptor_Configuration_t; | 81 | } USB_Descriptor_Configuration_t; |
| 80 | 82 | ||
| @@ -89,12 +91,16 @@ typedef struct | |||
| 89 | #endif | 91 | #endif |
| 90 | 92 | ||
| 91 | #ifdef EXTRAKEY_ENABLE | 93 | #ifdef EXTRAKEY_ENABLE |
| 92 | # define EXTRA_INTERFACE (MOUSE_INTERFACE + 1) | 94 | # define EXTRAKEY_INTERFACE (MOUSE_INTERFACE + 1) |
| 93 | #else | 95 | #else |
| 94 | # define EXTRA_INTERFACE MOUSE_INTERFACE | 96 | # define EXTRAKEY_INTERFACE MOUSE_INTERFACE |
| 95 | #endif | 97 | #endif |
| 96 | 98 | ||
| 97 | #define CONSOLE_INTERFACE (EXTRA_INTERFACE + 1) | 99 | #ifdef CONSOLE_ENABLE |
| 100 | # define CONSOLE_INTERFACE (EXTRAKEY_INTERFACE + 1) | ||
| 101 | #else | ||
| 102 | # define CONSOLE_INTERFACE EXTRAKEY_INTERFACE | ||
| 103 | #endif | ||
| 98 | 104 | ||
| 99 | 105 | ||
| 100 | /* nubmer of interfaces */ | 106 | /* nubmer of interfaces */ |
| @@ -103,15 +109,29 @@ typedef struct | |||
| 103 | 109 | ||
| 104 | // Endopoint number and size | 110 | // Endopoint number and size |
| 105 | #define KEYBOARD_IN_EPNUM 1 | 111 | #define KEYBOARD_IN_EPNUM 1 |
| 106 | #define MOUSE_IN_EPNUM 2 | 112 | |
| 107 | #define CONSOLE_IN_EPNUM 3 | 113 | #ifdef MOUSE_ENABLE |
| 108 | #define CONSOLE_OUT_EPNUM 4 | 114 | # define MOUSE_IN_EPNUM (KEYBOARD_IN_EPNUM + 1) |
| 109 | #define EXTRA_IN_EPNUM 5 | 115 | #else |
| 116 | # define MOUSE_IN_EPNUM KEYBOARD_IN_EPNUM | ||
| 117 | #endif | ||
| 118 | |||
| 119 | #ifdef EXTRAKEY_ENABLE | ||
| 120 | # define EXTRAKEY_IN_EPNUM (MOUSE_IN_EPNUM + 1) | ||
| 121 | #else | ||
| 122 | # define EXTRAKEY_IN_EPNUM MOUSE_IN_EPNUM | ||
| 123 | #endif | ||
| 124 | |||
| 125 | #ifdef CONSOLE_ENABLE | ||
| 126 | # define CONSOLE_IN_EPNUM (EXTRAKEY_IN_EPNUM + 1) | ||
| 127 | # define CONSOLE_OUT_EPNUM (EXTRAKEY_IN_EPNUM + 2) | ||
| 128 | #endif | ||
| 129 | |||
| 110 | 130 | ||
| 111 | #define KEYBOARD_EPSIZE 8 | 131 | #define KEYBOARD_EPSIZE 8 |
| 112 | #define MOUSE_EPSIZE 8 | 132 | #define MOUSE_EPSIZE 8 |
| 133 | #define EXTRAKEY_EPSIZE 8 | ||
| 113 | #define CONSOLE_EPSIZE 32 | 134 | #define CONSOLE_EPSIZE 32 |
| 114 | #define EXTRA_EPSIZE 8 | ||
| 115 | 135 | ||
| 116 | 136 | ||
| 117 | uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, | 137 | uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, |
diff --git a/protocol/lufa/lufa.c b/protocol/lufa/lufa.c index 10511ba67..99d241ded 100644 --- a/protocol/lufa/lufa.c +++ b/protocol/lufa/lufa.c | |||
| @@ -111,6 +111,7 @@ void SetupHardware(void) | |||
| 111 | USB_Device_EnableSOFEvents(); | 111 | USB_Device_EnableSOFEvents(); |
| 112 | } | 112 | } |
| 113 | 113 | ||
| 114 | #ifdef CONSOLE_ENABLE | ||
| 114 | static void Console_Task(void) | 115 | static void Console_Task(void) |
| 115 | { | 116 | { |
| 116 | /* Device must be connected and configured for the task to run */ | 117 | /* Device must be connected and configured for the task to run */ |
| @@ -146,6 +147,11 @@ static void Console_Task(void) | |||
| 146 | 147 | ||
| 147 | /* IN packet */ | 148 | /* IN packet */ |
| 148 | Endpoint_SelectEndpoint(CONSOLE_IN_EPNUM); | 149 | Endpoint_SelectEndpoint(CONSOLE_IN_EPNUM); |
| 150 | |||
| 151 | // fill empty bank | ||
| 152 | while (Endpoint_IsReadWriteAllowed()) | ||
| 153 | Endpoint_Write_8(0); | ||
| 154 | |||
| 149 | // flash senchar packet | 155 | // flash senchar packet |
| 150 | if (Endpoint_IsINReady()) { | 156 | if (Endpoint_IsINReady()) { |
| 151 | Endpoint_ClearIN(); | 157 | Endpoint_ClearIN(); |
| @@ -153,6 +159,11 @@ static void Console_Task(void) | |||
| 153 | 159 | ||
| 154 | Endpoint_SelectEndpoint(ep); | 160 | Endpoint_SelectEndpoint(ep); |
| 155 | } | 161 | } |
| 162 | #else | ||
| 163 | static void Console_Task(void) | ||
| 164 | { | ||
| 165 | } | ||
| 166 | #endif | ||
| 156 | 167 | ||
| 157 | 168 | ||
| 158 | /******************************************************************************* | 169 | /******************************************************************************* |
| @@ -168,14 +179,9 @@ void EVENT_USB_Device_Disconnect(void) | |||
| 168 | { | 179 | { |
| 169 | } | 180 | } |
| 170 | 181 | ||
| 171 | #define CONSOLE_TASK_INTERVAL 50 | ||
| 172 | void EVENT_USB_Device_StartOfFrame(void) | 182 | void EVENT_USB_Device_StartOfFrame(void) |
| 173 | { | 183 | { |
| 174 | static uint8_t interval; | 184 | Console_Task(); |
| 175 | if (++interval == CONSOLE_TASK_INTERVAL) { | ||
| 176 | Console_Task(); | ||
| 177 | interval = 0; | ||
| 178 | } | ||
| 179 | } | 185 | } |
| 180 | 186 | ||
| 181 | /** Event handler for the USB_ConfigurationChanged event. | 187 | /** Event handler for the USB_ConfigurationChanged event. |
| @@ -197,15 +203,17 @@ void EVENT_USB_Device_ConfigurationChanged(void) | |||
| 197 | 203 | ||
| 198 | #ifdef EXTRAKEY_ENABLE | 204 | #ifdef EXTRAKEY_ENABLE |
| 199 | /* Setup Extra HID Report Endpoint */ | 205 | /* Setup Extra HID Report Endpoint */ |
| 200 | ConfigSuccess &= Endpoint_ConfigureEndpoint(EXTRA_IN_EPNUM, EP_TYPE_INTERRUPT, ENDPOINT_DIR_IN, | 206 | ConfigSuccess &= Endpoint_ConfigureEndpoint(EXTRAKEY_IN_EPNUM, EP_TYPE_INTERRUPT, ENDPOINT_DIR_IN, |
| 201 | EXTRA_EPSIZE, ENDPOINT_BANK_SINGLE); | 207 | EXTRAKEY_EPSIZE, ENDPOINT_BANK_SINGLE); |
| 202 | #endif | 208 | #endif |
| 203 | 209 | ||
| 210 | #ifdef CONSOLE_ENABLE | ||
| 204 | /* Setup Console HID Report Endpoints */ | 211 | /* Setup Console HID Report Endpoints */ |
| 205 | ConfigSuccess &= Endpoint_ConfigureEndpoint(CONSOLE_IN_EPNUM, EP_TYPE_INTERRUPT, ENDPOINT_DIR_IN, | 212 | ConfigSuccess &= Endpoint_ConfigureEndpoint(CONSOLE_IN_EPNUM, EP_TYPE_INTERRUPT, ENDPOINT_DIR_IN, |
| 206 | CONSOLE_EPSIZE, ENDPOINT_BANK_DOUBLE); | 213 | CONSOLE_EPSIZE, ENDPOINT_BANK_DOUBLE); |
| 207 | ConfigSuccess &= Endpoint_ConfigureEndpoint(CONSOLE_OUT_EPNUM, EP_TYPE_INTERRUPT, ENDPOINT_DIR_OUT, | 214 | ConfigSuccess &= Endpoint_ConfigureEndpoint(CONSOLE_OUT_EPNUM, EP_TYPE_INTERRUPT, ENDPOINT_DIR_OUT, |
| 208 | CONSOLE_EPSIZE, ENDPOINT_BANK_SINGLE); | 215 | CONSOLE_EPSIZE, ENDPOINT_BANK_SINGLE); |
| 216 | #endif | ||
| 209 | } | 217 | } |
| 210 | 218 | ||
| 211 | /* | 219 | /* |
| @@ -371,7 +379,7 @@ static void send_system(uint16_t data) | |||
| 371 | .report_id = REPORT_ID_SYSTEM, | 379 | .report_id = REPORT_ID_SYSTEM, |
| 372 | .usage = data | 380 | .usage = data |
| 373 | }; | 381 | }; |
| 374 | Endpoint_SelectEndpoint(EXTRA_IN_EPNUM); | 382 | Endpoint_SelectEndpoint(EXTRAKEY_IN_EPNUM); |
| 375 | if (Endpoint_IsReadWriteAllowed()) { | 383 | if (Endpoint_IsReadWriteAllowed()) { |
| 376 | Endpoint_Write_Stream_LE(&r, sizeof(report_extra_t), NULL); | 384 | Endpoint_Write_Stream_LE(&r, sizeof(report_extra_t), NULL); |
| 377 | Endpoint_ClearIN(); | 385 | Endpoint_ClearIN(); |
| @@ -384,7 +392,7 @@ static void send_consumer(uint16_t data) | |||
| 384 | .report_id = REPORT_ID_CONSUMER, | 392 | .report_id = REPORT_ID_CONSUMER, |
| 385 | .usage = data | 393 | .usage = data |
| 386 | }; | 394 | }; |
| 387 | Endpoint_SelectEndpoint(EXTRA_IN_EPNUM); | 395 | Endpoint_SelectEndpoint(EXTRAKEY_IN_EPNUM); |
| 388 | if (Endpoint_IsReadWriteAllowed()) { | 396 | if (Endpoint_IsReadWriteAllowed()) { |
| 389 | Endpoint_Write_Stream_LE(&r, sizeof(report_extra_t), NULL); | 397 | Endpoint_Write_Stream_LE(&r, sizeof(report_extra_t), NULL); |
| 390 | Endpoint_ClearIN(); | 398 | Endpoint_ClearIN(); |
| @@ -395,12 +403,14 @@ static void send_consumer(uint16_t data) | |||
| 395 | /******************************************************************************* | 403 | /******************************************************************************* |
| 396 | * sendchar | 404 | * sendchar |
| 397 | ******************************************************************************/ | 405 | ******************************************************************************/ |
| 398 | #define SEND_TIMEOUT 10 | 406 | #ifdef CONSOLE_ENABLE |
| 407 | #define SEND_TIMEOUT 5 | ||
| 399 | int8_t sendchar(uint8_t c) | 408 | int8_t sendchar(uint8_t c) |
| 400 | { | 409 | { |
| 401 | if (USB_DeviceState != DEVICE_STATE_Configured) | 410 | if (USB_DeviceState != DEVICE_STATE_Configured) |
| 402 | return -1; | 411 | return -1; |
| 403 | 412 | ||
| 413 | uint8_t ep = Endpoint_GetCurrentEndpoint(); | ||
| 404 | Endpoint_SelectEndpoint(CONSOLE_IN_EPNUM); | 414 | Endpoint_SelectEndpoint(CONSOLE_IN_EPNUM); |
| 405 | 415 | ||
| 406 | uint8_t timeout = SEND_TIMEOUT; | 416 | uint8_t timeout = SEND_TIMEOUT; |
| @@ -411,11 +421,15 @@ int8_t sendchar(uint8_t c) | |||
| 411 | case DEVICE_STATE_Suspended: | 421 | case DEVICE_STATE_Suspended: |
| 412 | return -1; | 422 | return -1; |
| 413 | } | 423 | } |
| 414 | if (Endpoint_IsStalled()) | 424 | if (Endpoint_IsStalled()) { |
| 425 | Endpoint_SelectEndpoint(ep); | ||
| 415 | return -1; | 426 | return -1; |
| 427 | } | ||
| 416 | if (prevFN != USB_Device_GetFrameNumber()) { | 428 | if (prevFN != USB_Device_GetFrameNumber()) { |
| 417 | if (!(timeout--)) | 429 | if (!(timeout--)) { |
| 430 | Endpoint_SelectEndpoint(ep); | ||
| 418 | return -1; | 431 | return -1; |
| 432 | } | ||
| 419 | prevFN = USB_Device_GetFrameNumber(); | 433 | prevFN = USB_Device_GetFrameNumber(); |
| 420 | } | 434 | } |
| 421 | } | 435 | } |
| @@ -426,5 +440,12 @@ int8_t sendchar(uint8_t c) | |||
| 426 | if (!Endpoint_IsReadWriteAllowed()) | 440 | if (!Endpoint_IsReadWriteAllowed()) |
| 427 | Endpoint_ClearIN(); | 441 | Endpoint_ClearIN(); |
| 428 | 442 | ||
| 443 | Endpoint_SelectEndpoint(ep); | ||
| 444 | return 0; | ||
| 445 | } | ||
| 446 | #else | ||
| 447 | int8_t sendchar(uint8_t c) | ||
| 448 | { | ||
| 429 | return 0; | 449 | return 0; |
| 430 | } | 450 | } |
| 451 | #endif | ||
