diff options
Diffstat (limited to 'keyboard')
-rw-r--r-- | keyboard/lufa/Makefile | 8 | ||||
-rw-r--r-- | keyboard/lufa/descriptor.c | 36 | ||||
-rw-r--r-- | keyboard/lufa/descriptor.h | 24 | ||||
-rw-r--r-- | keyboard/lufa/lufa.c | 38 |
4 files changed, 66 insertions, 40 deletions
diff --git a/keyboard/lufa/Makefile b/keyboard/lufa/Makefile index 12af013f89..b386fb3818 100644 --- a/keyboard/lufa/Makefile +++ b/keyboard/lufa/Makefile @@ -132,6 +132,14 @@ SRC += keymap.c \ CONFIG_H = config.h +# Build Options +# comment out to disable the options. +# +MOUSEKEY_ENABLE = yes # Mouse keys +#PS2_MOUSE_ENABLE = yes # PS/2 mouse(TrackPoint) support +#EXTRAKEY_ENABLE = yes # Audio control and System control +#NKRO_ENABLE = yes # USB Nkey Rollover + # LUFA library compile-time options and predefined tokens LUFA_OPTS = -D USB_DEVICE_ONLY diff --git a/keyboard/lufa/descriptor.c b/keyboard/lufa/descriptor.c index 6059fd4a82..f9ca355a6e 100644 --- a/keyboard/lufa/descriptor.c +++ b/keyboard/lufa/descriptor.c @@ -111,7 +111,7 @@ const USB_Descriptor_HIDReport_Datatype_t PROGMEM MouseReport[] = HID_RI_END_COLLECTION(0), }; -const USB_Descriptor_HIDReport_Datatype_t PROGMEM GenericReport[] = +const USB_Descriptor_HIDReport_Datatype_t PROGMEM ConsoleReport[] = { HID_RI_USAGE_PAGE(16, 0xFF00), /* Vendor Page 0 */ HID_RI_USAGE(8, 0x01), /* Vendor Usage 1 */ @@ -180,7 +180,7 @@ const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = /* * Keyboard */ - .HID0_KeyboardInterface = + .Keyboard_Interface = { .Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, @@ -196,7 +196,7 @@ const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = .InterfaceStrIndex = NO_DESCRIPTOR }, - .HID0_KeyboardHID = + .Keyboard_HID = { .Header = {.Size = sizeof(USB_HID_Descriptor_HID_t), .Type = HID_DTYPE_HID}, @@ -207,7 +207,7 @@ const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = .HIDReportLength = sizeof(KeyboardReport) }, - .HID0_ReportINEndpoint = + .Keyboard_INEndpoint = { .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, @@ -220,7 +220,7 @@ const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = /* * Mouse */ - .HID1_MouseInterface = + .Mouse_Interface = { .Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, @@ -236,7 +236,7 @@ const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = .InterfaceStrIndex = NO_DESCRIPTOR }, - .HID1_MouseHID = + .Mouse_HID = { .Header = {.Size = sizeof(USB_HID_Descriptor_HID_t), .Type = HID_DTYPE_HID}, @@ -247,7 +247,7 @@ const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = .HIDReportLength = sizeof(MouseReport) }, - .HID1_ReportINEndpoint = + .Mouse_INEndpoint = { .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, @@ -258,9 +258,9 @@ const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = }, /* - * Generic + * Console */ - .HID2_GenericInterface = + .Console_Interface = { .Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, @@ -276,7 +276,7 @@ const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = .InterfaceStrIndex = NO_DESCRIPTOR }, - .HID2_GenericHID = + .Console_HID = { .Header = {.Size = sizeof(USB_HID_Descriptor_HID_t), .Type = HID_DTYPE_HID}, @@ -284,10 +284,10 @@ const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = .CountryCode = 0x00, .TotalReportDescriptors = 1, .HIDReportType = HID_DTYPE_Report, - .HIDReportLength = sizeof(GenericReport) + .HIDReportLength = sizeof(ConsoleReport) }, - .HID2_ReportINEndpoint = + .Console_INEndpoint = { .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, @@ -297,7 +297,7 @@ const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = .PollingIntervalMS = 0x01 }, - .HID2_ReportOUTEndpoint = + .Console_OUTEndpoint = { .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, @@ -380,15 +380,15 @@ uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, case HID_DTYPE_HID: switch (wIndex) { case KEYBOARD_INTERFACE: - Address = &ConfigurationDescriptor.HID0_KeyboardHID; + Address = &ConfigurationDescriptor.Keyboard_HID; Size = sizeof(USB_HID_Descriptor_HID_t); break; case MOUSE_INTERFACE: - Address = &ConfigurationDescriptor.HID1_MouseHID; + Address = &ConfigurationDescriptor.Mouse_HID; Size = sizeof(USB_HID_Descriptor_HID_t); break; case GENERIC_INTERFACE: - Address = &ConfigurationDescriptor.HID2_GenericHID; + Address = &ConfigurationDescriptor.Console_HID; Size = sizeof(USB_HID_Descriptor_HID_t); break; } @@ -404,8 +404,8 @@ uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, Size = sizeof(MouseReport); break; case GENERIC_INTERFACE: - Address = &GenericReport; - Size = sizeof(GenericReport); + Address = &ConsoleReport; + Size = sizeof(ConsoleReport); break; } break; diff --git a/keyboard/lufa/descriptor.h b/keyboard/lufa/descriptor.h index 19e24c2013..d45e905c64 100644 --- a/keyboard/lufa/descriptor.h +++ b/keyboard/lufa/descriptor.h @@ -46,20 +46,20 @@ typedef struct USB_Descriptor_Configuration_Header_t Config; // Keyboard HID Interface - USB_Descriptor_Interface_t HID0_KeyboardInterface; - USB_HID_Descriptor_HID_t HID0_KeyboardHID; - USB_Descriptor_Endpoint_t HID0_ReportINEndpoint; + USB_Descriptor_Interface_t Keyboard_Interface; + USB_HID_Descriptor_HID_t Keyboard_HID; + USB_Descriptor_Endpoint_t Keyboard_INEndpoint; // Mouse HID Interface - USB_Descriptor_Interface_t HID1_MouseInterface; - USB_HID_Descriptor_HID_t HID1_MouseHID; - USB_Descriptor_Endpoint_t HID1_ReportINEndpoint; - - // Generic HID Interface - USB_Descriptor_Interface_t HID2_GenericInterface; - USB_HID_Descriptor_HID_t HID2_GenericHID; - USB_Descriptor_Endpoint_t HID2_ReportINEndpoint; - USB_Descriptor_Endpoint_t HID2_ReportOUTEndpoint; + USB_Descriptor_Interface_t Mouse_Interface; + USB_HID_Descriptor_HID_t Mouse_HID; + USB_Descriptor_Endpoint_t Mouse_INEndpoint; + + // Console HID Interface + USB_Descriptor_Interface_t Console_Interface; + USB_HID_Descriptor_HID_t Console_HID; + USB_Descriptor_Endpoint_t Console_INEndpoint; + USB_Descriptor_Endpoint_t Console_OUTEndpoint; } USB_Descriptor_Configuration_t; diff --git a/keyboard/lufa/lufa.c b/keyboard/lufa/lufa.c index 569960e2a9..a87d8474a2 100644 --- a/keyboard/lufa/lufa.c +++ b/keyboard/lufa/lufa.c @@ -68,7 +68,7 @@ static host_driver_t lufa_driver = { static void SetupHardware(void); -static void Generic_HID_Task(void); +static void Console_HID_Task(void); int main(void) { @@ -93,7 +93,7 @@ int main(void) while (1) { keyboard_proc(); - Generic_HID_Task(); + Console_HID_Task(); USB_USBTask(); } } @@ -110,7 +110,7 @@ void SetupHardware(void) USB_Init(); } -static void Generic_HID_Task(void) +static void Console_HID_Task(void) { /* Device must be connected and configured for the task to run */ if (USB_DeviceState != DEVICE_STATE_Configured) @@ -126,13 +126,13 @@ static void Generic_HID_Task(void) if (Endpoint_IsReadWriteAllowed()) { /* Create a temporary buffer to hold the read in report from the host */ - uint8_t GenericData[GENERIC_REPORT_SIZE]; + uint8_t ConsoleData[GENERIC_REPORT_SIZE]; - /* Read Generic Report Data */ - Endpoint_Read_Stream_LE(&GenericData, sizeof(GenericData), NULL); + /* Read Console Report Data */ + Endpoint_Read_Stream_LE(&ConsoleData, sizeof(ConsoleData), NULL); - /* Process Generic Report Data */ - //ProcessGenericHIDReport(GenericData); + /* Process Console Report Data */ + //ProcessConsoleHIDReport(ConsoleData); } /* Finalize the stream transfer to send the last packet */ @@ -175,13 +175,26 @@ void EVENT_USB_Device_ConfigurationChanged(void) ConfigSuccess &= Endpoint_ConfigureEndpoint(MOUSE_IN_EPNUM, EP_TYPE_INTERRUPT, ENDPOINT_DIR_IN, HID_EPSIZE, ENDPOINT_BANK_SINGLE); - /* Setup Generic HID Report Endpoints */ + /* Setup Console HID Report Endpoints */ ConfigSuccess &= Endpoint_ConfigureEndpoint(GENERIC_IN_EPNUM, EP_TYPE_INTERRUPT, ENDPOINT_DIR_IN, GENERIC_EPSIZE, ENDPOINT_BANK_SINGLE); ConfigSuccess &= Endpoint_ConfigureEndpoint(GENERIC_OUT_EPNUM, EP_TYPE_INTERRUPT, ENDPOINT_DIR_OUT, GENERIC_EPSIZE, ENDPOINT_BANK_SINGLE); } +/* +Appendix G: HID Request Support Requirements + +The following table enumerates the requests that need to be supported by various types of HID class devices. + +Device type GetReport SetReport GetIdle SetIdle GetProtocol SetProtocol +------------------------------------------------------------------------------------------ +Boot Mouse Required Optional Optional Optional Required Required +Non-Boot Mouse Required Optional Optional Optional Optional Optional +Boot Keyboard Required Optional Required Required Required Required +Non-Boot Keybrd Required Optional Required Required Optional Optional +Other Device Required Optional Optional Optional Optional Optional +*/ /** Event handler for the USB_ControlRequest event. * This is fired before passing along unhandled control requests to the library for processing internally. */ @@ -288,7 +301,12 @@ static void send_mouse(report_mouse_t *report) if (Endpoint_IsReadWriteAllowed()) { /* Write Mouse Report Data */ - Endpoint_Write_Stream_LE(report, sizeof(report_mouse_t), NULL); + /* Mouse report data structure + * LUFA: { buttons, x, y } + * tmk: { buttons, x, y, v, h } + */ + //Endpoint_Write_Stream_LE((uint8_t *)report+1, 3, NULL); + Endpoint_Write_Stream_LE(report, 3, NULL); /* Finalize the stream transfer to send the last packet */ Endpoint_ClearIN(); |