summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--keyboard/macway/Makefile.lufa2
-rw-r--r--protocol/lufa/descriptor.c65
-rw-r--r--protocol/lufa/descriptor.h29
-rw-r--r--protocol/lufa/lufa.c32
4 files changed, 105 insertions, 23 deletions
diff --git a/keyboard/macway/Makefile.lufa b/keyboard/macway/Makefile.lufa
index a3395a2ab7..8f50776dfc 100644
--- a/keyboard/macway/Makefile.lufa
+++ b/keyboard/macway/Makefile.lufa
@@ -100,9 +100,9 @@ F_USB = $(F_CPU)
# 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
+#PS2_MOUSE_ENABLE = yes # PS/2 mouse(TrackPoint) support
# Search Path
diff --git a/protocol/lufa/descriptor.c b/protocol/lufa/descriptor.c
index 59adcd184c..d3f740bfe6 100644
--- a/protocol/lufa/descriptor.c
+++ b/protocol/lufa/descriptor.c
@@ -54,8 +54,8 @@ const USB_Descriptor_HIDReport_Datatype_t PROGMEM KeyboardReport[] =
HID_RI_USAGE_MAXIMUM(8, 0xE7), /* Keyboard Right GUI */
HID_RI_LOGICAL_MINIMUM(8, 0x00),
HID_RI_LOGICAL_MAXIMUM(8, 0x01),
- HID_RI_REPORT_SIZE(8, 0x01),
HID_RI_REPORT_COUNT(8, 0x08),
+ HID_RI_REPORT_SIZE(8, 0x01),
HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE),
HID_RI_REPORT_COUNT(8, 0x01),
HID_RI_REPORT_SIZE(8, 0x08),
@@ -69,11 +69,11 @@ const USB_Descriptor_HIDReport_Datatype_t PROGMEM KeyboardReport[] =
HID_RI_REPORT_COUNT(8, 0x01),
HID_RI_REPORT_SIZE(8, 0x03),
HID_RI_OUTPUT(8, HID_IOF_CONSTANT),
- HID_RI_LOGICAL_MINIMUM(8, 0x00),
- HID_RI_LOGICAL_MAXIMUM(8, 0x65),
HID_RI_USAGE_PAGE(8, 0x07), /* Keyboard */
HID_RI_USAGE_MINIMUM(8, 0x00), /* Reserved (no event indicated) */
- HID_RI_USAGE_MAXIMUM(8, 0x65), /* Keyboard Application */
+ HID_RI_USAGE_MAXIMUM(8, 0xFF), /* Keyboard Application */
+ HID_RI_LOGICAL_MINIMUM(8, 0x00),
+ HID_RI_LOGICAL_MAXIMUM(8, 0xFF),
HID_RI_REPORT_COUNT(8, 0x06),
HID_RI_REPORT_SIZE(8, 0x08),
HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_ARRAY | HID_IOF_ABSOLUTE),
@@ -133,21 +133,22 @@ const USB_Descriptor_HIDReport_Datatype_t PROGMEM ConsoleReport[] =
HID_RI_USAGE_PAGE(16, 0xFF31), /* Vendor Page(PJRC Teensy compatible) */
HID_RI_USAGE(8, 0x74), /* Vendor Usage(PJRC Teensy compatible) */
HID_RI_COLLECTION(8, 0x01), /* Application */
- HID_RI_USAGE(8, 0x02), /* Vendor Usage 2 */
+ HID_RI_USAGE(8, 0x75), /* Vendor Usage 0x75 */
HID_RI_LOGICAL_MINIMUM(8, 0x00),
HID_RI_LOGICAL_MAXIMUM(8, 0xFF),
- HID_RI_REPORT_SIZE(8, 0x08),
HID_RI_REPORT_COUNT(8, CONSOLE_EPSIZE),
+ HID_RI_REPORT_SIZE(8, 0x08),
HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE),
- HID_RI_USAGE(8, 0x03), /* Vendor Usage 3 */
+ HID_RI_USAGE(8, 0x76), /* Vendor Usage 0x76 */
HID_RI_LOGICAL_MINIMUM(8, 0x00),
HID_RI_LOGICAL_MAXIMUM(8, 0xFF),
- HID_RI_REPORT_SIZE(8, 0x08),
HID_RI_REPORT_COUNT(8, CONSOLE_EPSIZE),
+ HID_RI_REPORT_SIZE(8, 0x08),
HID_RI_OUTPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_NON_VOLATILE),
HID_RI_END_COLLECTION(0),
};
+#ifdef EXTRAKEY_ENABLE
const USB_Descriptor_HIDReport_Datatype_t PROGMEM ExtraReport[] =
{
HID_RI_USAGE_PAGE(8, 0x01), /* Generic Desktop */
@@ -176,6 +177,42 @@ const USB_Descriptor_HIDReport_Datatype_t PROGMEM ExtraReport[] =
HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_ARRAY | HID_IOF_ABSOLUTE),
HID_RI_END_COLLECTION(0),
};
+#endif
+
+#ifdef NKRO_ENABLE
+const USB_Descriptor_HIDReport_Datatype_t PROGMEM NKROReport[] =
+{
+ HID_RI_USAGE_PAGE(8, 0x01), /* Generic Desktop */
+ HID_RI_USAGE(8, 0x06), /* Keyboard */
+ HID_RI_COLLECTION(8, 0x01), /* Application */
+ HID_RI_USAGE_PAGE(8, 0x07), /* Key Codes */
+ HID_RI_USAGE_MINIMUM(8, 0xE0), /* Keyboard Left Control */
+ HID_RI_USAGE_MAXIMUM(8, 0xE7), /* Keyboard Right GUI */
+ HID_RI_LOGICAL_MINIMUM(8, 0x00),
+ HID_RI_LOGICAL_MAXIMUM(8, 0x01),
+ HID_RI_REPORT_COUNT(8, 0x08),
+ HID_RI_REPORT_SIZE(8, 0x01),
+ HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE),
+
+ HID_RI_USAGE_PAGE(8, 0x08), /* LEDs */
+ HID_RI_USAGE_MINIMUM(8, 0x01), /* Num Lock */
+ HID_RI_USAGE_MAXIMUM(8, 0x05), /* Kana */
+ HID_RI_REPORT_COUNT(8, 0x05),
+ HID_RI_REPORT_SIZE(8, 0x01),
+ HID_RI_OUTPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_NON_VOLATILE),
+ HID_RI_REPORT_COUNT(8, 0x01),
+ HID_RI_REPORT_SIZE(8, 0x03),
+ HID_RI_OUTPUT(8, HID_IOF_CONSTANT),
+
+ HID_RI_USAGE_PAGE(8, 0x07), /* Key Codes */
+ HID_RI_USAGE_MINIMUM(8, 0x00), /* Keyboard 0 */
+ HID_RI_USAGE_MAXIMUM(8, NKRO_SIZE*8-1), /* Keyboard Right GUI */
+ HID_RI_LOGICAL_MINIMUM(8, 0x00),
+ HID_RI_LOGICAL_MAXIMUM(8, 0x01),
+ HID_RI_REPORT_COUNT(8, NKRO_SIZE*8),
+ HID_RI_REPORT_SIZE(8, 0x01),
+};
+#endif
/*******************************************************************************
* Device Descriptors
@@ -265,6 +302,7 @@ const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
/*
* Mouse
*/
+#ifdef MOUSE_ENABLE
.Mouse_Interface =
{
.Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
@@ -301,6 +339,7 @@ const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
.EndpointSize = MOUSE_EPSIZE,
.PollingIntervalMS = 0x01
},
+#endif
/*
* Console
@@ -355,6 +394,7 @@ const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
/*
* Extra
*/
+#ifdef EXTRAKEY_ENABLE
.Extra_Interface =
{
.Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
@@ -391,6 +431,7 @@ const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
.EndpointSize = EXTRA_EPSIZE,
.PollingIntervalMS = 0x01
},
+#endif
};
@@ -468,18 +509,22 @@ uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
Address = &ConfigurationDescriptor.Keyboard_HID;
Size = sizeof(USB_HID_Descriptor_HID_t);
break;
+#ifdef MOUSE_ENABLE
case MOUSE_INTERFACE:
Address = &ConfigurationDescriptor.Mouse_HID;
Size = sizeof(USB_HID_Descriptor_HID_t);
break;
+#endif
case CONSOLE_INTERFACE:
Address = &ConfigurationDescriptor.Console_HID;
Size = sizeof(USB_HID_Descriptor_HID_t);
break;
+#ifdef EXTRAKEY_ENABLE
case EXTRA_INTERFACE:
Address = &ConfigurationDescriptor.Extra_HID;
Size = sizeof(USB_HID_Descriptor_HID_t);
break;
+#endif
}
break;
case HID_DTYPE_Report:
@@ -488,18 +533,22 @@ uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
Address = &KeyboardReport;
Size = sizeof(KeyboardReport);
break;
+#ifdef MOUSE_ENABLE
case MOUSE_INTERFACE:
Address = &MouseReport;
Size = sizeof(MouseReport);
break;
+#endif
case CONSOLE_INTERFACE:
Address = &ConsoleReport;
Size = sizeof(ConsoleReport);
break;
+#ifdef EXTRAKEY_ENABLE
case EXTRA_INTERFACE:
Address = &ExtraReport;
Size = sizeof(ExtraReport);
break;
+#endif
}
break;
}
diff --git a/protocol/lufa/descriptor.h b/protocol/lufa/descriptor.h
index 6b1b4d4845..19bce999f2 100644
--- a/protocol/lufa/descriptor.h
+++ b/protocol/lufa/descriptor.h
@@ -51,9 +51,11 @@ typedef struct
USB_Descriptor_Endpoint_t Keyboard_INEndpoint;
// Mouse HID Interface
+#ifdef MOUSE_ENABLE
USB_Descriptor_Interface_t Mouse_Interface;
USB_HID_Descriptor_HID_t Mouse_HID;
USB_Descriptor_Endpoint_t Mouse_INEndpoint;
+#endif
// Console HID Interface
USB_Descriptor_Interface_t Console_Interface;
@@ -62,20 +64,35 @@ typedef struct
USB_Descriptor_Endpoint_t Console_OUTEndpoint;
// Extra HID Interface
+#ifdef EXTRAKEY_ENABLE
USB_Descriptor_Interface_t Extra_Interface;
USB_HID_Descriptor_HID_t Extra_HID;
USB_Descriptor_Endpoint_t Extra_INEndpoint;
+#endif
} USB_Descriptor_Configuration_t;
-/* nubmer of interfaces */
-#define TOTAL_INTERFACES 4
-
/* index of interface */
#define KEYBOARD_INTERFACE 0
-#define MOUSE_INTERFACE 1
-#define CONSOLE_INTERFACE 2
-#define EXTRA_INTERFACE 3
+
+#ifdef MOUSE_ENABLE
+# define MOUSE_INTERFACE (KEYBOARD_INTERFACE + 1)
+#else
+# define MOUSE_INTERFACE KEYBOARD_INTERFACE
+#endif
+
+#ifdef EXTRAKEY_ENABLE
+# define EXTRA_INTERFACE (MOUSE_INTERFACE + 1)
+#else
+# define EXTRA_INTERFACE MOUSE_INTERFACE
+#endif
+
+#define CONSOLE_INTERFACE (EXTRA_INTERFACE + 1)
+
+
+/* nubmer of interfaces */
+#define TOTAL_INTERFACES (CONSOLE_INTERFACE + 1)
+
// Endopoint number and size
#define KEYBOARD_IN_EPNUM 1
diff --git a/protocol/lufa/lufa.c b/protocol/lufa/lufa.c
index 09da96b2e5..f485e24bf0 100644
--- a/protocol/lufa/lufa.c
+++ b/protocol/lufa/lufa.c
@@ -50,7 +50,9 @@ static uint8_t keyboard_led_stats = 0;
// TODO: impl Control Request GET_REPORT
static report_keyboard_t keyboard_report_sent;
+#ifdef MOUSE_ENABLE
static report_mouse_t mouse_report_sent;
+#endif
/* Host driver */
static uint8_t keyboard_leds(void);
@@ -171,19 +173,23 @@ void EVENT_USB_Device_ConfigurationChanged(void)
ConfigSuccess &= Endpoint_ConfigureEndpoint(KEYBOARD_IN_EPNUM, EP_TYPE_INTERRUPT, ENDPOINT_DIR_IN,
KEYBOARD_EPSIZE, ENDPOINT_BANK_SINGLE);
+#ifdef MOUSE_ENABLE
/* Setup Mouse HID Report Endpoint */
ConfigSuccess &= Endpoint_ConfigureEndpoint(MOUSE_IN_EPNUM, EP_TYPE_INTERRUPT, ENDPOINT_DIR_IN,
MOUSE_EPSIZE, ENDPOINT_BANK_SINGLE);
+#endif
+
+#ifdef EXTRAKEY_ENABLE
+ /* Setup Extra HID Report Endpoint */
+ ConfigSuccess &= Endpoint_ConfigureEndpoint(EXTRA_IN_EPNUM, EP_TYPE_INTERRUPT, ENDPOINT_DIR_IN,
+ EXTRA_EPSIZE, ENDPOINT_BANK_SINGLE);
+#endif
/* Setup Console HID Report Endpoints */
ConfigSuccess &= Endpoint_ConfigureEndpoint(CONSOLE_IN_EPNUM, EP_TYPE_INTERRUPT, ENDPOINT_DIR_IN,
CONSOLE_EPSIZE, ENDPOINT_BANK_SINGLE);
ConfigSuccess &= Endpoint_ConfigureEndpoint(CONSOLE_OUT_EPNUM, EP_TYPE_INTERRUPT, ENDPOINT_DIR_OUT,
CONSOLE_EPSIZE, ENDPOINT_BANK_SINGLE);
-
- /* Setup Extra HID Report Endpoint */
- ConfigSuccess &= Endpoint_ConfigureEndpoint(EXTRA_IN_EPNUM, EP_TYPE_INTERRUPT, ENDPOINT_DIR_IN,
- EXTRA_EPSIZE, ENDPOINT_BANK_SINGLE);
}
/*
@@ -222,15 +228,19 @@ void EVENT_USB_Device_ControlRequest(void)
ReportData = (uint8_t*)&keyboard_report_sent;
ReportSize = sizeof(keyboard_report_sent);
break;
+#ifdef MOUSE_ENABLE
case MOUSE_INTERFACE:
// TODO: test/check
ReportData = (uint8_t*)&mouse_report_sent;
ReportSize = sizeof(mouse_report_sent);
break;
- case CONSOLE_INTERFACE:
- break;
+#endif
+#ifdef EXTRAKEY_ENABLE
case EXTRA_INTERFACE:
break;
+#endif
+ case CONSOLE_INTERFACE:
+ break;
}
/* Write the report data to the control endpoint */
@@ -258,12 +268,16 @@ void EVENT_USB_Device_ControlRequest(void)
/* Read in the LED report from the host */
keyboard_led_stats = Endpoint_Read_8();
break;
+#ifdef MOUSE_ENABLE
case MOUSE_INTERFACE:
break;
- case CONSOLE_INTERFACE:
- break;
+#endif
+#ifdef EXTRAKEY_ENABLE
case EXTRA_INTERFACE:
break;
+#endif
+ case CONSOLE_INTERFACE:
+ break;
}
Endpoint_ClearOUT();
@@ -302,6 +316,7 @@ static void send_keyboard(report_keyboard_t *report)
static void send_mouse(report_mouse_t *report)
{
+#ifdef MOUSE_ENABLE
/* Select the Mouse Report Endpoint */
Endpoint_SelectEndpoint(MOUSE_IN_EPNUM);
@@ -315,6 +330,7 @@ static void send_mouse(report_mouse_t *report)
Endpoint_ClearIN();
}
mouse_report_sent = *report;
+#endif
}
typedef struct {