From 43443ee9ba206b0963c49123bd03c250ed8e7b26 Mon Sep 17 00:00:00 2001 From: root Date: Sun, 7 Jun 2015 01:33:33 +0100 Subject: finished! --- app/Makefile | 2 +- app/at_scancodes.h | 70 ++++++++++++------- app/atkbd.c | 25 +++---- app/consumer.c | 33 ++++++++- app/dfu.c | 4 +- app/keyboard.c | 145 +++++++++++++++++++++++++++++++------- app/keymap.c | 142 ++++++++++++++++++++++++++++++++++++++ app/project.h | 8 +++ app/prototypes.h | 6 +- app/scancode.c | 10 --- app/tims_keyboard.c | 3 +- app/usb.c | 31 ++++++--- app/usb_scancodes.h | 195 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 13 files changed, 587 insertions(+), 87 deletions(-) create mode 100644 app/keymap.c delete mode 100644 app/scancode.c create mode 100644 app/usb_scancodes.h diff --git a/app/Makefile b/app/Makefile index a5e4d88..4761d45 100644 --- a/app/Makefile +++ b/app/Makefile @@ -24,7 +24,7 @@ PROG=tims_keyboard V=1 default: ${PROG}.elf -CSRCS=tims_keyboard.c dfu.c keyboard.c usb.c consumer.c atkbd.c ring.c usart.c stdio.c ticker.c scancode.c +CSRCS=tims_keyboard.c dfu.c keyboard.c usb.c consumer.c atkbd.c ring.c usart.c stdio.c ticker.c keymap.c BINARY = ${PROG} diff --git a/app/at_scancodes.h b/app/at_scancodes.h index 9af7bcc..8b943cf 100644 --- a/app/at_scancodes.h +++ b/app/at_scancodes.h @@ -1,12 +1,19 @@ #ifndef _AT_SCANCODES_H_ #define _AT_SCANCODES_H_ +/* the logic here is batshit, consult scancode.doc in the DOCS dir */ +/* we don't use FSHIFT and FCTRL, we just check the EMUL0 and EMUL1 */ +/* commands but we put them in here for completeness */ + #define AT_BS_EMUL0 0x0100 #define AT_BS_EMUL1 0x0200 #define AT_BS_FSHIFT_ON 0x0000 #define AT_BS_FSHIFT_OFF 0x0000 #define AT_BS_FCTRL_ON 0x0000 + +#define AT_SC_MAX 0x300 + #define AT_SC_GRAVE 0x0E #define AT_SC_1 0x16 #define AT_SC_2 0x1E @@ -65,33 +72,33 @@ #define AT_SC_SPACE 0x29 #define AT_SC_RIGHTALT (AT_BS_EMUL0 | 0x11) #define AT_SC_RIGHTCTRL (AT_BS_EMUL0 | 0x14) -#define AT_SC_INSERT (AT_SC_FSHIFT_OFF | AT_BS_EMUL0 | 0x70) -#define AT_SC_DELETE (AT_SC_FSHIFT_OFF | AT_BS_EMUL0 | 0x71) -#define AT_SC_LEFT (AT_SC_FSHIFT_OFF | AT_BS_EMUL0 | 0x79) -#define AT_SC_HOME (AT_SC_FSHIFT_OFF | AT_BS_EMUL0 | 0x6C) -#define AT_SC_END (AT_SC_FSHIFT_OFF | AT_BS_EMUL0 | 0x69) -#define AT_SC_UP (AT_SC_FSHIFT_OFF | AT_BS_EMUL0 | 0x75) -#define AT_SC_DOWN (AT_SC_FSHIFT_OFF | AT_BS_EMUL0 | 0x72) -#define AT_SC_PAGEUP (AT_SC_FSHIFT_OFF | AT_BS_EMUL0 | 0x7D) -#define AT_SC_PAGEDOWN (AT_SC_FSHIFT_OFF | AT_BS_EMUL0 | 0x7A) -#define AT_SC_RIGHT (AT_SC_FSHIFT_OFF | AT_BS_EMUL0 | 0x74) +#define AT_SC_INSERT (AT_BS_FSHIFT_OFF | AT_BS_EMUL0 | 0x70) +#define AT_SC_DELETE (AT_BS_FSHIFT_OFF | AT_BS_EMUL0 | 0x71) +#define AT_SC_LEFT (AT_BS_FSHIFT_OFF | AT_BS_EMUL0 | 0x79) +#define AT_SC_HOME (AT_BS_FSHIFT_OFF | AT_BS_EMUL0 | 0x6C) +#define AT_SC_END (AT_BS_FSHIFT_OFF | AT_BS_EMUL0 | 0x69) +#define AT_SC_UP (AT_BS_FSHIFT_OFF | AT_BS_EMUL0 | 0x75) +#define AT_SC_DOWN (AT_BS_FSHIFT_OFF | AT_BS_EMUL0 | 0x72) +#define AT_SC_PAGEUP (AT_BS_FSHIFT_OFF | AT_BS_EMUL0 | 0x7D) +#define AT_SC_PAGEDOWN (AT_BS_FSHIFT_OFF | AT_BS_EMUL0 | 0x7A) +#define AT_SC_RIGHT (AT_BS_FSHIFT_OFF | AT_BS_EMUL0 | 0x74) #define AT_SC_NUMLOCK 0x77 -#define AT_SC_KP7 (AT_SC_FSHIFT_ON | 0x6C) -#define AT_SC_KP4 (AT_SC_FSHIFT_ON | 0x6B) -#define AT_SC_KP1 (AT_SC_FSHIFT_ON | 0x69) -#define AT_SC_KPSLASH (AT_SC_FSHIFT_OFF | AT_BS_EMUL0 | 0x4A) -#define AT_SC_KP8 (AT_SC_FSHIFT_ON | 0x75) -#define AT_SC_KP5 (AT_SC_FSHIFT_ON | 0x73) -#define AT_SC_KP2 (AT_SC_FSHIFT_ON | 0x72) -#define AT_SC_KP0 (AT_SC_FSHIFT_ON | 0x70) +#define AT_SC_KP7 (AT_BS_FSHIFT_ON | 0x6C) +#define AT_SC_KP4 (AT_BS_FSHIFT_ON | 0x6B) +#define AT_SC_KP1 (AT_BS_FSHIFT_ON | 0x69) +#define AT_SC_KPSLASH (AT_BS_FSHIFT_OFF | AT_BS_EMUL0 | 0x4A) +#define AT_SC_KP8 (AT_BS_FSHIFT_ON | 0x75) +#define AT_SC_KP5 (AT_BS_FSHIFT_ON | 0x73) +#define AT_SC_KP2 (AT_BS_FSHIFT_ON | 0x72) +#define AT_SC_KP0 (AT_BS_FSHIFT_ON | 0x70) #define AT_SC_KPASTERISK 0x7C -#define AT_SC_KP9 (AT_SC_FSHIFT_ON | 0x7D) -#define AT_SC_KP6 (AT_SC_FSHIFT_ON | 0x74) -#define AT_SC_KP3 (AT_SC_FSHIFT_ON | 0x7A) -#define AT_SC_KPDOT (AT_SC_FSHIFT_ON | 0x71) +#define AT_SC_KP9 (AT_BS_FSHIFT_ON | 0x7D) +#define AT_SC_KP6 (AT_BS_FSHIFT_ON | 0x74) +#define AT_SC_KP3 (AT_BS_FSHIFT_ON | 0x7A) +#define AT_SC_KPDOT (AT_BS_FSHIFT_ON | 0x71) #define AT_SC_KPMINUS 0x7B #define AT_SC_KPPLUS 0x79 -#define AT_SC_KPENTER (AT_SC_FSHIFT_OFF | 0x5A) +#define AT_SC_KPENTER (AT_BS_FSHIFT_OFF | AT_BS_EMUL0 | 0x5A) #define AT_SC_ESC 0x76 #define AT_SC_F1 0x05 #define AT_SC_F2 0x06 @@ -105,7 +112,8 @@ #define AT_SC_F10 0x09 #define AT_SC_F11 0x78 #define AT_SC_F12 0x07 -#define AT_SC_SYSRQ (AT_BS_FSHIFT_ON | AT_BS_EMUL0 | 0x7C) +#define AT_SC_SYSRQ 0x84 +/*#define AT_SC_SYSRQ (AT_BS_FSHIFT_OFF | AT_BS_EMUL0 | 0x7C) */ #define AT_SC_SCROLLLOCK 0x7E #define AT_SC_PAUSE (AT_BS_FCTRL_ON | AT_BS_EMUL0 | 0x7E) #define AT_SC_LEFTMETA (AT_BS_EMUL0 | 0x1F) @@ -119,8 +127,22 @@ #define AT_SC_CONVERT 0x64 #define AT_SC_NONCONVERT 0x67 +/* Consumer keys */ +#define AT_SC_HOMEPAGE (AT_BS_EMUL0 | 0x3A) +#define AT_SC_MUTE (AT_BS_EMUL0 | 0x23) +#define AT_SC_VOLUMEUP (AT_BS_EMUL0 | 0x32) +#define AT_SC_VOLUMEDOWN (AT_BS_EMUL0 | 0x121) +#define AT_SC_KEY_PREVIOUSSONG (AT_BS_EMUL0 | 0x115) +#define AT_SC_KEY_PLAYPAUSE (AT_BS_EMUL0 | 0x134) +#define AT_SC_KEY_STOPCD (AT_BS_EMUL0 | 0x13b) +#define AT_SC_KEY_NEXTSONG (AT_BS_EMUL0 | 0x14d) + #define AT_SC_EMUL0 0xE0 #define AT_SC_EMUL1 0xE1 +#define AT_LED_CAPS 0x01 +#define AT_LED_NUMLOCK 0x02 +#define AT_LED_SCROLLLOCK 0x04 + #endif diff --git a/app/atkbd.c b/app/atkbd.c index 8191f2f..9091636 100644 --- a/app/atkbd.c +++ b/app/atkbd.c @@ -65,9 +65,6 @@ typedef enum #define ATKBD_KEY_UNKNOWN 0 #define ATKBD_KEY_NULL 255 -#define LED_CAPS 0x01 -#define LED_NUMLOCK 0x02 -#define LED_SCROLLOCK 0x04 @@ -97,9 +94,6 @@ cycle_diff (uint32_t a, uint32_t b) return b - a; } - - - static void atkbd_dispatch (int key, int updown) { @@ -114,9 +108,10 @@ atkbd_dispatch (int key, int updown) } - if (key == 0x84) + if (key == (AT_BS_EMUL0 | AT_SC_KPASTERISK)) key = AT_SC_SYSRQ; - if (key == 0x77) + + if (key == AT_SC_NUMLOCK) { /*Grr broken MS state machine in docs */ if ((!updown) && (pause_down)) @@ -152,7 +147,9 @@ atkbd_data_dispatch (uint8_t byte) static int release; static int emul; -// printf ("ATKBD < 0x%02x\r\n", byte); +#ifdef DEBUG + printf ("ATKBD < 0x%02x\r\n", byte); +#endif switch (byte) { @@ -338,7 +335,9 @@ atkbd_send (uint8_t d) atkbd_unmask_flush_irq (); -// printf ("ATKBD > 0x%02x\r\n", d); +#ifdef DEBUG + printf ("ATKBD > 0x%02x\r\n", d); +#endif return 0; @@ -353,7 +352,9 @@ err: atkbd_unmask_flush_irq (); -// printf ("ATKBD >! 0x%02x\r\n", d); +#ifdef DEBUG + printf ("ATKBD >! 0x%02x\r\n", d); +#endif return -1; } @@ -481,7 +482,7 @@ atkbd_init (void) atkbd_request_echo (); atkbd_set_mbr (); atkbd_set_scanset (2); - atkbd_set_leds (LED_CAPS); + atkbd_set_leds (0); } diff --git a/app/consumer.c b/app/consumer.c index 044c15b..c61c4cc 100644 --- a/app/consumer.c +++ b/app/consumer.c @@ -58,7 +58,7 @@ static const struct const struct usb_endpoint_descriptor consumer_endpoint = { .bLength = USB_DT_ENDPOINT_SIZE, .bDescriptorType = USB_DT_ENDPOINT, - .bEndpointAddress = 0x82, + .bEndpointAddress = CONSUMER_EP, .bmAttributes = USB_ENDPOINT_ATTR_INTERRUPT, .wMaxPacketSize = 2, .bInterval = 0x1 //0x20, @@ -91,3 +91,34 @@ consumer_get_descriptor (uint8_t ** buf, uint16_t * len) *len = sizeof (consumer_report_descriptor); } + + +static void +consumer_send (uint16_t keys) +{ + /*Last byte is the power wakeup stuff that we don't yet support */ + uint8_t buf[CONSUMER_EP_TXN_SIZE] = { keys & 0xff, keys >> 8 }; + + usbd_ep_write_packet (usbd_dev, CONSUMER_EP, buf, sizeof(buf)); +} + +void consumer_dispatch(int bit,int updown) +{ +static uint16_t keys; + +if (updown) + keys|=bit; +else + keys &= ~bit; + + +#ifdef DEBUG +printf("CNS> %02x %02x\r\n",keys & 0xff, keys >>8 ); +#endif + +consumer_send(keys); + + +} + + diff --git a/app/dfu.c b/app/dfu.c index 285c2b2..e6a8c10 100644 --- a/app/dfu.c +++ b/app/dfu.c @@ -15,13 +15,13 @@ const struct usb_dfu_descriptor dfu_function = { const struct usb_interface_descriptor dfu_iface = { .bLength = USB_DT_INTERFACE_SIZE, .bDescriptorType = USB_DT_INTERFACE, - .bInterfaceNumber = 4, + .bInterfaceNumber = 2, .bAlternateSetting = 0, .bNumEndpoints = 0, .bInterfaceClass = 0xFE, .bInterfaceSubClass = 1, .bInterfaceProtocol = 1, - .iInterface = 9, + .iInterface = 7, .extra = &dfu_function, .extralen = sizeof (dfu_function), diff --git a/app/keyboard.c b/app/keyboard.c index 44eb6c6..a20e070 100644 --- a/app/keyboard.c +++ b/app/keyboard.c @@ -1,5 +1,7 @@ #include "project.h" +#define KEY_LIST_LEN 6 + static const uint8_t keyboard_report_descriptor[] = { 0x05, 0x01, /* Usage Page (Generic Desktop) */ 0x09, 0x06, /* Usage (Keyboard) */ @@ -27,21 +29,35 @@ static const uint8_t keyboard_report_descriptor[] = { // 0x29, 0x65, /* Usage maximum (101) */ // 0x2A, 0xff, 0x03, /* Usage maximum (1023) */ 0x81, 0x00, /* Input (data, array) */ - 0x05, 0x01, /* USAGE_PAGE (Generic Desktop) */ - 0x09, 0x80, /* USAGE (System Control) */ - 0xA1, 0x01, /* COLLECTION (Application) */ - 0x75, 0x02, /* REPORT_SIZE (2) */ - 0x95, 0x01, /* REPORT_COUNT (1) */ - 0x15, 0x01, /* LOGICAL_MIN (1) */ - 0x25, 0x03, /* LOGICAL_MAX (3) */ - 0x09, 0x82, /* USAGE (System Sleep) */ - 0x09, 0x81, /* USAGE (System Power Down) */ - 0x09, 0x83, /* USAGE (System Wake Up) */ - 0x81, 0x60, /* INPUT (Data Ary Abs NPrf Null) */ - 0x75, 0x06, /* REPORT_SIZE (6) */ - 0x81, 0x03, /* INPUT (Cnst Var Abs) */ - 0xc0, /* END COLLECTION */ -0xC0 /* End Collection */ + + 0x05, 0x08, /* Usage page (leds) */ + 0x75, 0x01, /* Report size (1) */ + 0x95, 0x03, /* Report count (3) */ + 0x19, 0x01, /* Usage minimum (1) */ + 0x29, 0x03, /* Usage maximum (3) */ + 0x91, 0x02, /* Output (data, variable, absolute ) */ + 0x75, 0x05, /* Report size (5) */ + 0x95, 0x01, /* Report count (1) */ + 0x91, 0x01, /* Output (constant ) */ + + 0x05, 0x01, /* USAGE_PAGE (Generic Desktop) */ + 0x09, 0x80, /* USAGE (System Control) */ + + 0xA1, 0x01, /* COLLECTION (Application) */ + 0x75, 0x02, /* REPORT_SIZE (2) */ + 0x95, 0x01, /* REPORT_COUNT (1) */ + 0x15, 0x01, /* LOGICAL_MIN (1) */ + 0x25, 0x03, /* LOGICAL_MAX (3) */ + 0x09, 0x82, /* USAGE (System Sleep) */ + 0x09, 0x81, /* USAGE (System Power Down) */ + 0x09, 0x83, /* USAGE (System Wake Up) */ + 0x81, 0x60, /* INPUT (Data Ary Abs NPrf Null) */ + 0x75, 0x06, /* REPORT_SIZE (6) */ + 0x81, 0x03, /* INPUT (Cnst Var Abs) */ + 0xc0, /* END COLLECTION */ + + + 0xC0 /* End Collection */ }; @@ -68,7 +84,7 @@ static const struct const struct usb_endpoint_descriptor keyboard_endpoint = { .bLength = USB_DT_ENDPOINT_SIZE, .bDescriptorType = USB_DT_ENDPOINT, - .bEndpointAddress = 0x81, + .bEndpointAddress = KEYBOARD_EP, .bmAttributes = USB_ENDPOINT_ATTR_INTERRUPT, .wMaxPacketSize = 9, .bInterval = 0x1 //0x20, @@ -100,18 +116,99 @@ keyboard_get_descriptor (uint8_t ** buf, uint16_t * len) *len = sizeof (keyboard_report_descriptor); } -void -keyboard_test (void) + + +static void +keyboard_send (uint8_t modifiers, uint8_t *key_list) +{ + /*Last byte is the power wakeup stuff that we don't yet support */ + uint8_t buf[KEYBOARD_EP_TXN_SIZE] = { modifiers, 0, key_list[0], key_list[1], key_list[2], key_list[3], key_list[4], key_list[5] ,0}; + + usbd_ep_write_packet (usbd_dev, KEYBOARD_EP, buf, sizeof(buf)); +} + +void keyboard_dispatch(int sc,int updown) { - static int c = 0; - uint8_t buf[9] = { 0, 0, 0, 0, 0, 0, 0, 0 ,0}; +static uint8_t modifiers; +static uint8_t key_list[KEY_LIST_LEN]; +int i; +/*Windows needs the modifiers spliting out, so we do this as per our + * descriptor, others need them in the list so we do that as well */ - buf[0] = (c >> 1) & 7; +switch (sc) { + case USB_K_SC_LEFTCTRL: + case USB_K_SC_LEFTSHIFT: + case USB_K_SC_LEFTALT: + case USB_K_SC_LEFTMETA: + case USB_K_SC_RIGHTCTRL: + case USB_K_SC_RIGHTSHIFT: + case USB_K_SC_RIGHTALT: + case USB_K_SC_RIGHTMETA: + if (updown) + modifiers |= 1 <<(sc-USB_K_SC_LEFTCTRL); + else + modifiers &= ~(1 <<(sc-USB_K_SC_LEFTCTRL)); +} - buf[2] = (c & 1) ? 12 : 0; - c++; +/* Some oses are picky and need these not to move about so we make + * a list of the down keys */ - usbd_ep_write_packet (usbd_dev, 0x81, buf, 9); +if (updown) { +for (i=0;i %02x %02x %02x %02x %02x %02x %02x\r\n",modifiers, key_list[0], key_list[1], key_list[2], key_list[3], key_list[4], key_list[5]); +#endif + +keyboard_send(modifiers,key_list); + + +} + +int keyboard_control_request(usbd_device * usbd_dev, struct usb_setup_data *req, + uint8_t ** buf, uint16_t * len, + void (**complete) (usbd_device * usbd_dev, + struct usb_setup_data * req)) +{ +uint8_t at_leds=0; + + if (req->bmRequestType != (USB_REQ_TYPE_CLASS|USB_REQ_TYPE_INTERFACE)) return 0; + if (req->bRequest!=USB_REQ_SET_CONFIGURATION) return 0; + if (req->wValue!=0x200) return 0; + if (req->wIndex) return 0; + if (!len) return 0; + if (*len!=1) return 0; + if (!buf || !*buf) return 0; + + + if (**buf & USB_LED_CAPS) at_leds|=AT_LED_CAPS; + if (**buf & USB_LED_NUMLOCK) at_leds|=AT_LED_NUMLOCK; + if (**buf & USB_LED_SCROLLLOCK) at_leds|=AT_LED_SCROLLLOCK; + + +#ifdef DEBUG + printf("LEDS> %x\r\n",at_leds); +#endif + + atkbd_set_leds (at_leds); + + return 1; +} + + diff --git a/app/keymap.c b/app/keymap.c new file mode 100644 index 0000000..f6e529d --- /dev/null +++ b/app/keymap.c @@ -0,0 +1,142 @@ +#include "project.h" + +static int at_to_usb_keyboard[AT_SC_MAX]={ + [ AT_SC_GRAVE ] = USB_K_SC_GRAVE, + [ AT_SC_1 ] = USB_K_SC_1, + [ AT_SC_2 ] = USB_K_SC_2, + [ AT_SC_3 ] = USB_K_SC_3, + [ AT_SC_4 ] = USB_K_SC_4, + [ AT_SC_5 ] = USB_K_SC_5, + [ AT_SC_6 ] = USB_K_SC_6, + [ AT_SC_7 ] = USB_K_SC_7, + [ AT_SC_8 ] = USB_K_SC_8, + [ AT_SC_9 ] = USB_K_SC_9, + [ AT_SC_0 ] = USB_K_SC_0, + [ AT_SC_MINUS ] = USB_K_SC_MINUS, + [ AT_SC_EQUAL ] = USB_K_SC_EQUAL, + [ AT_SC_BACKSPACE ] = USB_K_SC_BACKSPACE, + [ AT_SC_TAB ] = USB_K_SC_TAB, + [ AT_SC_Q ] = USB_K_SC_Q, + [ AT_SC_W ] = USB_K_SC_W, + [ AT_SC_E ] = USB_K_SC_E, + [ AT_SC_R ] = USB_K_SC_R, + [ AT_SC_T ] = USB_K_SC_T, + [ AT_SC_Y ] = USB_K_SC_Y, + [ AT_SC_U ] = USB_K_SC_U, + [ AT_SC_I ] = USB_K_SC_I, + [ AT_SC_O ] = USB_K_SC_O, + [ AT_SC_P ] = USB_K_SC_P, + [ AT_SC_LEFTBRACE ] = USB_K_SC_LEFTBRACE, + [ AT_SC_RIGHTBRACE ] = USB_K_SC_RIGHTBRACE, + [ AT_SC_BACKSLASH ] = USB_K_SC_BACKSLASH, + [ AT_SC_CAPSLOCK ] = USB_K_SC_CAPSLOCK, + [ AT_SC_A ] = USB_K_SC_A, + [ AT_SC_S ] = USB_K_SC_S, + [ AT_SC_D ] = USB_K_SC_D, + [ AT_SC_F ] = USB_K_SC_F, + [ AT_SC_G ] = USB_K_SC_G, + [ AT_SC_H ] = USB_K_SC_H, + [ AT_SC_J ] = USB_K_SC_J, + [ AT_SC_K ] = USB_K_SC_K, + [ AT_SC_L ] = USB_K_SC_L, + [ AT_SC_SEMICOLON ] = USB_K_SC_SEMICOLON, + [ AT_SC_APOSTROPHE ] = USB_K_SC_APOSTROPHE, + [ AT_SC_ENTER ] = USB_K_SC_ENTER, + [ AT_SC_LEFTSHIFT ] = USB_K_SC_LEFTSHIFT, + [ AT_SC_Z ] = USB_K_SC_Z, + [ AT_SC_X ] = USB_K_SC_X, + [ AT_SC_C ] = USB_K_SC_C, + [ AT_SC_V ] = USB_K_SC_V, + [ AT_SC_B ] = USB_K_SC_B, + [ AT_SC_N ] = USB_K_SC_N, + [ AT_SC_M ] = USB_K_SC_M, + [ AT_SC_COMMA ] = USB_K_SC_COMMA, + [ AT_SC_DOT ] = USB_K_SC_DOT, + [ AT_SC_SLASH ] = USB_K_SC_SLASH, + [ AT_SC_RIGHTSHIFT ] = USB_K_SC_RIGHTSHIFT, + [ AT_SC_LEFTCTRL ] = USB_K_SC_LEFTCTRL, + [ AT_SC_LEFTALT ] = USB_K_SC_LEFTALT, + [ AT_SC_SPACE ] = USB_K_SC_SPACE, + [ AT_SC_RIGHTALT ] = USB_K_SC_RIGHTALT, + [ AT_SC_RIGHTCTRL ] = USB_K_SC_RIGHTCTRL, + [ AT_SC_INSERT ] = USB_K_SC_INSERT, + [ AT_SC_DELETE ] = USB_K_SC_DELETE, + [ AT_SC_LEFT ] = USB_K_SC_LEFT, + [ AT_SC_HOME ] = USB_K_SC_HOME, + [ AT_SC_END ] = USB_K_SC_END, + [ AT_SC_UP ] = USB_K_SC_UP, + [ AT_SC_DOWN ] = USB_K_SC_DOWN, + [ AT_SC_PAGEUP ] = USB_K_SC_PAGEUP, + [ AT_SC_PAGEDOWN ] = USB_K_SC_PAGEDOWN, + [ AT_SC_RIGHT ] = USB_K_SC_RIGHT, + [ AT_SC_NUMLOCK ] = USB_K_SC_NUMLOCK, + [ AT_SC_KP7 ] = USB_K_SC_KP7, + [ AT_SC_KP4 ] = USB_K_SC_KP4, + [ AT_SC_KP1 ] = USB_K_SC_KP1, + [ AT_SC_KPSLASH ] = USB_K_SC_KPSLASH, + [ AT_SC_KP8 ] = USB_K_SC_KP8, + [ AT_SC_KP5 ] = USB_K_SC_KP5, + [ AT_SC_KP2 ] = USB_K_SC_KP2, + [ AT_SC_KP0 ] = USB_K_SC_KP0, + [ AT_SC_KPASTERISK ] = USB_K_SC_KPASTERISK, + [ AT_SC_KP9 ] = USB_K_SC_KP9, + [ AT_SC_KP6 ] = USB_K_SC_KP6, + [ AT_SC_KP3 ] = USB_K_SC_KP3, + [ AT_SC_KPDOT ] = USB_K_SC_KPDOT, + [ AT_SC_KPMINUS ] = USB_K_SC_KPMINUS, + [ AT_SC_KPPLUS ] = USB_K_SC_KPPLUS, + [ AT_SC_KPENTER ] = USB_K_SC_KPENTER, + [ AT_SC_ESC ] = USB_K_SC_ESC, + [ AT_SC_F1 ] = USB_K_SC_F1, + [ AT_SC_F2 ] = USB_K_SC_F2, + [ AT_SC_F3 ] = USB_K_SC_F3, + [ AT_SC_F4 ] = USB_K_SC_F4, + [ AT_SC_F5 ] = USB_K_SC_F5, + [ AT_SC_F6 ] = USB_K_SC_F6, + [ AT_SC_F7 ] = USB_K_SC_F7, + [ AT_SC_F8 ] = USB_K_SC_F8, + [ AT_SC_F9 ] = USB_K_SC_F9, + [ AT_SC_F10 ] = USB_K_SC_F10, + [ AT_SC_F11 ] = USB_K_SC_F11, + [ AT_SC_F12 ] = USB_K_SC_F12, + [ AT_SC_SYSRQ ] = USB_K_SC_SYSRQ, + [ AT_SC_SCROLLLOCK ] = USB_K_SC_SCROLLLOCK, + [ AT_SC_PAUSE ] = USB_K_SC_PAUSE, + [ AT_SC_LEFTMETA ] = USB_K_SC_LEFTMETA, + [ AT_SC_RIGHTMETA ] = USB_K_SC_RIGHTMETA, + [ AT_SC_MENU ] = USB_K_SC_MENU, + [ AT_SC_POWER ] = USB_K_SC_POWER, + [ AT_SC_SLEEP ] = USB_K_SC_SLEEP, +// [ AT_SC_WAKEUP ] = USB_K_SC_WAKEUP, +// [ AT_SC_DBE_KATAKANA ] = USB_K_SC_DBE_KATAKANA, +// [ AT_SC_DBE_SBCSCHAR ] = USB_K_SC_DBE_SBCSCHAR, +// [ AT_SC_CONVERT ] = USB_K_SC_CONVERT, +// [ AT_SC_NONCONVERT ] = USB_K_SC_NONCONVERT, +}; + + +static int at_to_usb_consumer[AT_SC_MAX]={ + [ AT_SC_HOMEPAGE ] = USB_C_BF_HOMEPAGE, + [ AT_SC_MUTE ] = USB_C_BF_MUTE, + [ AT_SC_VOLUMEUP ] = USB_C_BF_VOLUMEUP, + [ AT_SC_VOLUMEDOWN ] = USB_C_BF_VOLUMEDOWN, + [ AT_SC_KEY_PREVIOUSSONG ] = USB_C_BF_PREVIOUSSONG, + [ AT_SC_KEY_PLAYPAUSE ] = USB_C_BF_PLAYPAUSE, + [ AT_SC_KEY_STOPCD ] = USB_C_BF_STOPCD, + [ AT_SC_KEY_NEXTSONG ] = USB_C_BF_NEXTSONG, +}; + + + + +void scancode_dispatch(int key,int updown) +{ + +if (at_to_usb_keyboard[key]) + keyboard_dispatch(at_to_usb_keyboard[key],updown); + +if (at_to_usb_consumer[key]) + consumer_dispatch(at_to_usb_consumer[key],updown); + +} + diff --git a/app/project.h b/app/project.h index 5885046..3271bb8 100644 --- a/app/project.h +++ b/app/project.h @@ -20,9 +20,17 @@ #include "pins.h" #include "at_scancodes.h" +#include "usb_scancodes.h" #include "id.h" +#define KEYBOARD_EP 0x81 +#define KEYBOARD_EP_TXN_SIZE 0x9 + +#define CONSUMER_EP 0x82 +#define CONSUMER_EP_TXN_SIZE 0x9 + + #include "prototypes.h" diff --git a/app/prototypes.h b/app/prototypes.h index ed15fd1..4349f48 100644 --- a/app/prototypes.h +++ b/app/prototypes.h @@ -8,7 +8,8 @@ extern int dfu_control_request(usbd_device *usbd_dev, struct usb_setup_data *req extern const struct usb_endpoint_descriptor keyboard_endpoint; extern const struct usb_interface_descriptor keyboard_iface; extern void keyboard_get_descriptor(uint8_t **buf, uint16_t *len); -extern void keyboard_test(void); +extern void keyboard_dispatch(int sc, int updown); +extern int keyboard_control_request(usbd_device *usbd_dev, struct usb_setup_data *req, uint8_t **buf, uint16_t *len, void (**complete)(usbd_device *usbd_dev, struct usb_setup_data *req)); /* usb.c */ extern const struct usb_device_descriptor dev; extern const struct usb_interface ifaces[]; @@ -21,6 +22,7 @@ extern void usb_run(void); extern const struct usb_endpoint_descriptor consumer_endpoint; extern const struct usb_interface_descriptor consumer_iface; extern void consumer_get_descriptor(uint8_t **buf, uint16_t *len); +extern void consumer_dispatch(int bit, int updown); /* atkbd.c */ extern void exti0_isr(void); extern void atkbd_set(int clk, int dat); @@ -60,5 +62,5 @@ extern void sys_tick_handler(void); extern void delay_ms(uint32_t d); extern int timed_out(uint32_t then, unsigned int ms); extern void ticker_init(void); -/* scancode.c */ +/* keymap.c */ extern void scancode_dispatch(int key, int updown); diff --git a/app/scancode.c b/app/scancode.c deleted file mode 100644 index a44c8b3..0000000 --- a/app/scancode.c +++ /dev/null @@ -1,10 +0,0 @@ - -#include "project.h" - - -void scancode_dispatch(int key,int updown) -{ - -printf("Key %4x ud %d\r\n",key,updown); -} - diff --git a/app/tims_keyboard.c b/app/tims_keyboard.c index ec1ce59..1b69d7b 100644 --- a/app/tims_keyboard.c +++ b/app/tims_keyboard.c @@ -30,8 +30,9 @@ main (void) ticker_init(); - +#ifdef DEBUG printf("Hello world!\r\n"); +#endif atkbd_init(); diff --git a/app/usb.c b/app/usb.c index 659a491..8dd38c6 100644 --- a/app/usb.c +++ b/app/usb.c @@ -61,19 +61,26 @@ usbd_device *usbd_dev; static int -usb_control_request (usbd_device * usbd_dev, struct usb_setup_data *req, +usb_control_class_request (usbd_device * usbd_dev, struct usb_setup_data *req, uint8_t ** buf, uint16_t * len, void (**complete) (usbd_device * usbd_dev, struct usb_setup_data * req)) { + if (keyboard_control_request(usbd_dev,req,buf,len,complete)) return 1; + if (dfu_control_request(usbd_dev,req,buf,len,complete)) return 1; + +return 0; +} +static int +usb_control_request (usbd_device * usbd_dev, struct usb_setup_data *req, + uint8_t ** buf, uint16_t * len, + void (**complete) (usbd_device * usbd_dev, + struct usb_setup_data * req)) +{ (void) complete; (void) usbd_dev; - if ((req->bmRequestType != 0x81) || - (req->bRequest != USB_REQ_GET_DESCRIPTOR) || (req->wValue != 0x2200)) - return 0; - switch (req->wIndex) { case 0: @@ -83,6 +90,10 @@ usb_control_request (usbd_device * usbd_dev, struct usb_setup_data *req, consumer_get_descriptor (buf, len); return 1; } + + *len = 0; + return 0; + *len = 0; return 0; @@ -95,19 +106,19 @@ usb_set_config (usbd_device * usbd_dev, uint16_t wValue) (void) wValue; (void) usbd_dev; - usbd_ep_setup (usbd_dev, 0x81, USB_ENDPOINT_ATTR_INTERRUPT, 4, NULL); - usbd_ep_setup (usbd_dev, 0x82, USB_ENDPOINT_ATTR_INTERRUPT, 4, NULL); + usbd_ep_setup (usbd_dev, KEYBOARD_EP, USB_ENDPOINT_ATTR_INTERRUPT, KEYBOARD_EP_TXN_SIZE, NULL); + usbd_ep_setup (usbd_dev, CONSUMER_EP, USB_ENDPOINT_ATTR_INTERRUPT, CONSUMER_EP_TXN_SIZE, NULL); usbd_register_control_callback (usbd_dev, - USB_REQ_TYPE_STANDARD | - USB_REQ_TYPE_INTERFACE, + USB_REQ_TYPE_STANDARD | USB_REQ_TYPE_INTERFACE, USB_REQ_TYPE_TYPE | USB_REQ_TYPE_RECIPIENT, usb_control_request); usbd_register_control_callback (usbd_dev, USB_REQ_TYPE_CLASS | USB_REQ_TYPE_INTERFACE, USB_REQ_TYPE_TYPE | USB_REQ_TYPE_RECIPIENT, - dfu_control_request); + usb_control_class_request); + } /* Buffer to be used for control requests. */ diff --git a/app/usb_scancodes.h b/app/usb_scancodes.h new file mode 100644 index 0000000..4d84ed4 --- /dev/null +++ b/app/usb_scancodes.h @@ -0,0 +1,195 @@ +#ifndef _USB_SCANCODES_H_ +#define _USB_SCANCODES_H_ + +#define USB_K_SC_ESC 0x29 /* 0x01, Keyboard ESCAPE */ +#define USB_K_SC_1 0x1e /* 0x02, Keyboard 1 and ! */ +#define USB_K_SC_2 0x1f /* 0x03, Keyboard 2 and @ */ +#define USB_K_SC_3 0x20 /* 0x04, Keyboard 3 and # */ +#define USB_K_SC_4 0x21 /* 0x05, Keyboard 4 and $ */ +#define USB_K_SC_5 0x22 /* 0x06, Keyboard 5 and % */ +#define USB_K_SC_6 0x23 /* 0x07, Keyboard 6 and ^ */ +#define USB_K_SC_7 0x24 /* 0x08, Keyboard 7 and & */ +#define USB_K_SC_8 0x25 /* 0x09, Keyboard 8 and * */ +#define USB_K_SC_9 0x26 /* 0x0a, Keyboard 9 and ( */ +#define USB_K_SC_0 0x27 /* 0x0b, Keyboard 0 and ) */ +#define USB_K_SC_MINUS 0x2d /* 0x0c, Keyboard - and (underscore) */ +#define USB_K_SC_EQUAL 0x2e /* 0x0d, Keyboard = and + */ +#define USB_K_SC_BACKSPACE 0x2a /* 0x0e, Keyboard DELETE (Backspace) */ +#define USB_K_SC_TAB 0x2b /* 0x0f, Keyboard Tab */ +#define USB_K_SC_Q 0x14 /* 0x10, Keyboard q and Q */ +#define USB_K_SC_W 0x1a /* 0x11, Keyboard w and W */ +#define USB_K_SC_E 0x08 /* 0x12, Keyboard e and E */ +#define USB_K_SC_R 0x15 /* 0x13, Keyboard r and R */ +#define USB_K_SC_T 0x17 /* 0x14, Keyboard t and T */ +#define USB_K_SC_Y 0x1c /* 0x15, Keyboard y and Y */ +#define USB_K_SC_U 0x18 /* 0x16, Keyboard u and U */ +#define USB_K_SC_I 0x0c /* 0x17, Keyboard i and I */ +#define USB_K_SC_O 0x12 /* 0x18, Keyboard o and O */ +#define USB_K_SC_P 0x13 /* 0x19, Keyboard p and P */ +#define USB_K_SC_LEFTBRACE 0x2f /* 0x1a, Keyboard [ and { */ +#define USB_K_SC_RIGHTBRACE 0x30 /* 0x1b, Keyboard ] and } */ +#define USB_K_SC_ENTER 0x28 /* 0x1c, Keyboard Return (ENTER) */ +#define USB_K_SC_LEFTCTRL 0xe0 /* 0x1d, Keyboard LeftControl */ +#define USB_K_SC_A 0x04 /* 0x1e, Keyboard a and A */ +#define USB_K_SC_S 0x16 /* 0x1f, Keyboard s and S */ +#define USB_K_SC_D 0x07 /* 0x20, Keyboard d and D */ +#define USB_K_SC_F 0x09 /* 0x21, Keyboard f and F */ +#define USB_K_SC_G 0x0a /* 0x22, Keyboard g and G */ +#define USB_K_SC_H 0x0b /* 0x23, Keyboard h and H */ +#define USB_K_SC_J 0x0d /* 0x24, Keyboard j and J */ +#define USB_K_SC_K 0x0e /* 0x25, Keyboard k and K */ +#define USB_K_SC_L 0x0f /* 0x26, Keyboard l and L */ +#define USB_K_SC_SEMICOLON 0x33 /* 0x27, Keyboard ; and : */ +#define USB_K_SC_APOSTROPHE 0x34 /* 0x28, Keyboard ' and " */ +#define USB_K_SC_GRAVE 0x35 /* 0x29, Keyboard Grave Accent and Tilde */ +#define USB_K_SC_LEFTSHIFT 0xe1 /* 0x2a, Keyboard LeftShift */ +#define USB_K_SC_BACKSLASH 0x32 /* 0x2b, Keyboard Non-US # and ~ */ +#define USB_K_SC_Z 0x1d /* 0x2c, Keyboard z and Z */ +#define USB_K_SC_X 0x1b /* 0x2d, Keyboard x and X */ +#define USB_K_SC_C 0x06 /* 0x2e, Keyboard c and C */ +#define USB_K_SC_V 0x19 /* 0x2f, Keyboard v and V */ +#define USB_K_SC_B 0x05 /* 0x30, Keyboard b and B */ +#define USB_K_SC_N 0x11 /* 0x31, Keyboard n and N */ +#define USB_K_SC_M 0x10 /* 0x32, Keyboard m and M */ +#define USB_K_SC_COMMA 0x36 /* 0x33, Keyboard, and < */ +#define USB_K_SC_DOT 0x37 /* 0x34, Keyboard.and > */ +#define USB_K_SC_SLASH 0x38 /* 0x35, Keyboard / and ? */ +#define USB_K_SC_RIGHTSHIFT 0xe5 /* 0x36, Keyboard RightShift */ +#define USB_K_SC_KPASTERISK 0x55 /* 0x37, Keypad * */ +#define USB_K_SC_LEFTALT 0xe2 /* 0x38, Keyboard LeftAlt */ +#define USB_K_SC_SPACE 0x2c /* 0x39, Keyboard Spacebar */ +#define USB_K_SC_CAPSLOCK 0x39 /* 0x3a, Keyboard Caps Lock */ +#define USB_K_SC_F1 0x3a /* 0x3b, Keyboard F1 */ +#define USB_K_SC_F2 0x3b /* 0x3c, Keyboard F2 */ +#define USB_K_SC_F3 0x3c /* 0x3d, Keyboard F3 */ +#define USB_K_SC_F4 0x3d /* 0x3e, Keyboard F4 */ +#define USB_K_SC_F5 0x3e /* 0x3f, Keyboard F5 */ +#define USB_K_SC_F6 0x3f /* 0x40, Keyboard F6 */ +#define USB_K_SC_F7 0x40 /* 0x41, Keyboard F7 */ +#define USB_K_SC_F8 0x41 /* 0x42, Keyboard F8 */ +#define USB_K_SC_F9 0x42 /* 0x43, Keyboard F9 */ +#define USB_K_SC_F10 0x43 /* 0x44, Keyboard F10 */ +#define USB_K_SC_NUMLOCK 0x53 /* 0x45, Keypad Num Lock and Clear */ +#define USB_K_SC_SCROLLLOCK 0x47 /* 0x46, Keyboard Scroll Lock */ +#define USB_K_SC_KP7 0x5f /* 0x47, Keypad 7 and Home */ +#define USB_K_SC_KP8 0x60 /* 0x48, Keypad 8 and Up Arrow */ +#define USB_K_SC_KP9 0x61 /* 0x49, Keypad 9 and PageUp */ +#define USB_K_SC_KPMINUS 0x56 /* 0x4a, Keypad - */ +#define USB_K_SC_KP4 0x5c /* 0x4b, Keypad 4 and Left Arrow */ +#define USB_K_SC_KP5 0x5d /* 0x4c, Keypad 5 */ +#define USB_K_SC_KP6 0x5e /* 0x4d, Keypad 6 and Right Arrow */ +#define USB_K_SC_KPPLUS 0x57 /* 0x4e, Keypad + */ +#define USB_K_SC_KP1 0x59 /* 0x4f, Keypad 1 and End */ +#define USB_K_SC_KP2 0x5a /* 0x50, Keypad 2 and Down Arrow */ +#define USB_K_SC_KP3 0x5b /* 0x51, Keypad 3 and PageDn */ +#define USB_K_SC_KP0 0x62 /* 0x52, Keypad 0 and Insert */ +#define USB_K_SC_KPDOT 0x63 /* 0x53, Keypad.and Delete */ +#define USB_K_SC_ZENKAKUHANKAKU 0x94 /* 0x55, Keyboard LANG5 */ +#define USB_K_SC_102ND 0x64 /* 0x56, Keyboard Non - US \ and | */ +#define USB_K_SC_F11 0x44 /* 0x57, Keyboard F11 */ +#define USB_K_SC_F12 0x45 /* 0x58, Keyboard F12 */ +#define USB_K_SC_RO 0x87 /* 0x59, Keyboard International1 */ +#define USB_K_SC_KATAKANA 0x92 /* 0x5a, Keyboard LANG3 */ +#define USB_K_SC_HIRAGANA 0x93 /* 0x5b, Keyboard LANG4 */ +#define USB_K_SC_HENKAN 0x8a /* 0x5c, Keyboard International4 */ +#define USB_K_SC_KATAKANAHIRAGANA 0x88 /* 0x5d, Keyboard International2 */ +#define USB_K_SC_MUHENKAN 0x8b /* 0x5e, Keyboard International5 */ +#define USB_K_SC_KPJPCOMMA 0x8c /* 0x5f, Keyboard International6 */ +#define USB_K_SC_KPENTER 0x58 /* 0x60, Keypad ENTER */ +#define USB_K_SC_RIGHTCTRL 0xe4 /* 0x61, Keyboard RightControl */ +#define USB_K_SC_KPSLASH 0x54 /* 0x62, Keypad / */ +#define USB_K_SC_SYSRQ 0x46 /* 0x63, Keyboard PrintScreen */ +#define USB_K_SC_RIGHTALT 0xe6 /* 0x64, Keyboard RightAlt */ +#define USB_K_SC_HOME 0x4a /* 0x66, Keyboard Home */ +#define USB_K_SC_UP 0x52 /* 0x67, Keyboard UpArrow */ +#define USB_K_SC_PAGEUP 0x4b /* 0x68, Keyboard PageUp */ +#define USB_K_SC_LEFT 0x50 /* 0x69, Keyboard LeftArrow */ +#define USB_K_SC_RIGHT 0x4f /* 0x6a, Keyboard RightArrow */ +#define USB_K_SC_END 0x4d /* 0x6b, Keyboard End */ +#define USB_K_SC_DOWN 0x51 /* 0x6c, Keyboard DownArrow */ +#define USB_K_SC_PAGEDOWN 0x4e /* 0x6d, Keyboard PageDown */ +#define USB_K_SC_INSERT 0x49 /* 0x6e, Keyboard Insert */ +#define USB_K_SC_DELETE 0xd8 /* 0x6f */ +#define USB_K_SC_MUTE 0xef /* 0x71 */ +#define USB_K_SC_VOLUMEDOWN 0xee /* 0x72 */ +#define USB_K_SC_VOLUMEUP 0xed /* 0x73 */ +#define USB_K_SC_POWER 0x66 /* 0x74, Keyboard Power */ +#define USB_K_SC_KPEQUAL 0x67 /* 0x75, Keypad = */ +#define USB_K_SC_PAUSE 0x48 /* 0x77, Keyboard Pause */ +#define USB_K_SC_KPCOMMA 0x85 /* 0x79, Keypad Comma */ +#define USB_K_SC_HANGEUL 0x90 /* 0x7a, Keyboard LANG1 */ +#define USB_K_SC_HANJA 0x91 /* 0x7b, Keyboard LANG2 */ +#define USB_K_SC_YEN 0x89 /* 0x7c, Keyboard International3 */ +#define USB_K_SC_LEFTMETA 0xe3 /* 0x7d, Keyboard Left GUI */ +#define USB_K_SC_RIGHTMETA 0xe7 /* 0x7e, Keyboard Right GUI */ +#define USB_K_SC_COMPOSE 0x65 /* 0x7f, Keyboard Application */ +#define USB_K_SC_STOP 0xf3 /* 0x80 */ +#define USB_K_SC_AGAIN 0x79 /* 0x81, Keyboard Again */ +#define USB_K_SC_MENU 0x76 /* 0x82, Keyboard Menu */ +#define USB_K_SC_UNDO 0x7a /* 0x83, Keyboard Undo */ +#define USB_K_SC_FRONT 0x77 /* 0x84, Keyboard Select */ +#define USB_K_SC_COPY 0x7c /* 0x85, Keyboard Copy */ +#define USB_K_SC_OPEN 0x74 /* 0x86, Keyboard Execute */ +#define USB_K_SC_PASTE 0x7d /* 0x87, Keyboard Paste */ +#define USB_K_SC_FIND 0xf4 /* 0x88 */ +#define USB_K_SC_CUT 0x7b /* 0x89, Keyboard Cut */ +#define USB_K_SC_HELP 0x75 /* 0x8a, Keyboard Help */ +#define USB_K_SC_CALC 0xfb /* 0x8c */ +#define USB_K_SC_SLEEP 0xf8 /* 0x8e */ +#define USB_K_SC_WWW 0xf0 /* 0x96 */ +#define USB_K_SC_COFFEE 0xf9 /* 0x98 */ +#define USB_K_SC_BACK 0xf1 /* 0x9e */ +#define USB_K_SC_FORWARD 0xf2 /* 0x9f */ +#define USB_K_SC_EJECTCD 0xec /* 0xa1 */ +#define USB_K_SC_NEXTSONG 0xeb /* 0xa3 */ +#define USB_K_SC_PLAYPAUSE 0xe8 /* 0xa4 */ +#define USB_K_SC_PREVIOUSSONG 0xea /* 0xa5 */ +#define USB_K_SC_STOPCD 0xe9 /* 0xa6 */ +#define USB_K_SC_REFRESH 0xfa /* 0xad */ +#define USB_K_SC_EDIT 0xf7 /* 0xb0 */ +#define USB_K_SC_SCROLLUP 0xf5 /* 0xb1 */ +#define USB_K_SC_SCROLLDOWN 0xf6 /* 0xb2 */ +#define USB_K_SC_KPLEFTPAREN 0xb6 /* 0xb3 */ +#define USB_K_SC_KPRIGHTPAREN 0xb7 /* 0xb4 */ +#define USB_K_SC_F13 0x68 /* 0xb7, Keyboard F13 */ +#define USB_K_SC_F14 0x69 /* 0xb8, Keyboard F14 */ +#define USB_K_SC_F15 0x6a /* 0xb9, Keyboard F15 */ +#define USB_K_SC_F16 0x6b /* 0xba, Keyboard F16 */ +#define USB_K_SC_F17 0x6c /* 0xbb, Keyboard F17 */ +#define USB_K_SC_F18 0x6d /* 0xbc, Keyboard F18 */ +#define USB_K_SC_F19 0x6e /* 0xbd, Keyboard F19 */ +#define USB_K_SC_F20 0x6f /* 0xbe, Keyboard F20 */ +#define USB_K_SC_F21 0x70 /* 0xbf, Keyboard F21 */ +#define USB_K_SC_F22 0x71 /* 0xc0, Keyboard F22 */ +#define USB_K_SC_F23 0x72 /* 0xc1, Keyboard F23 */ +#define USB_K_SC_F24 0x73 /* 0xc2, Keyboard F24 */ + + +/* these are our bit positions in consumer.c */ + +#define USB_C_BF_NEXTSONG (1 << 0) +#define USB_C_BF_PREVIOUSSONG (1 << 1) +#define USB_C_BF_STOPCD (1 << 2) +#define USB_C_BF_PLAYPAUSE (1 << 3) + +#define USB_C_BF_MUTE (1 << 4) +#define USB_C_BF_VOLUMEUP (1 << 5) +#define USB_C_BF_VOLUMEDOWN (1 << 6) +#define USB_C_BF_SEARCH (1 << 7) + +#define USB_C_BF_HOMEPAGE (1 << 8) +#define USB_C_BF_BACK (1 << 9) +#define USB_C_BF_FORWARD (1 << 10) +#define USB_C_BF_STOP (1 << 11) + +#define USB_C_BF_REFRESH (1 << 12) +#define USB_C_BF_FAVOURITES (1 << 13) +#define USB_C_BF_MAIL (1 << 14) +#define USB_C_BF_CALC (1 << 15) + +#define USB_LED_CAPS 0x02 +#define USB_LED_NUMLOCK 0x01 +#define USB_LED_SCROLLLOCK 0x04 + + +#endif -- cgit v1.2.3