2010-09-23 11:23:50 +00:00
|
|
|
#ifndef USB_KEYBOARD_H
|
|
|
|
#define USB_KEYBOARD_H 1
|
|
|
|
|
|
|
|
#include <stdint.h>
|
2010-10-23 16:17:26 +00:00
|
|
|
#include <stdbool.h>
|
2010-09-30 05:17:01 +00:00
|
|
|
#include "usb.h"
|
2010-09-23 11:23:50 +00:00
|
|
|
|
|
|
|
|
2010-12-07 16:47:57 +00:00
|
|
|
#define KBD_INTERFACE 0
|
|
|
|
#define KBD_ENDPOINT 1
|
|
|
|
#define KBD_SIZE 8
|
|
|
|
#define KBD_BUFFER EP_DOUBLE_BUFFER
|
|
|
|
#define KBD_REPORT_KEYS (KBD_SIZE - 2)
|
|
|
|
|
|
|
|
// secondary keyboard
|
2011-01-02 14:52:13 +00:00
|
|
|
#ifdef USB_NKRO_ENABLE
|
2010-12-07 16:47:57 +00:00
|
|
|
#define KBD2_INTERFACE 4
|
|
|
|
#define KBD2_ENDPOINT 5
|
|
|
|
#define KBD2_SIZE 16
|
|
|
|
#define KBD2_BUFFER EP_DOUBLE_BUFFER
|
2010-12-11 14:20:49 +00:00
|
|
|
#define KBD2_REPORT_KEYS (KBD2_SIZE - 1)
|
2010-12-07 16:47:57 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(KBD2_REPORT_KEYS) && KBD2_REPORT_KEYS > KBD_REPORT_KEYS
|
|
|
|
#define KEYS_MAX KBD2_REPORT_KEYS
|
|
|
|
#else
|
|
|
|
#define KEYS_MAX KBD_REPORT_KEYS
|
2010-11-25 16:56:21 +00:00
|
|
|
#endif
|
2010-09-23 11:23:50 +00:00
|
|
|
|
2010-09-24 06:01:21 +00:00
|
|
|
|
2010-11-03 08:33:20 +00:00
|
|
|
typedef struct report {
|
2010-12-07 16:47:57 +00:00
|
|
|
uint8_t keys[KEYS_MAX];
|
2010-11-03 08:33:20 +00:00
|
|
|
uint8_t mods;
|
|
|
|
bool is_sent;
|
|
|
|
} usb_keyboard_report_t;
|
2010-09-23 11:23:50 +00:00
|
|
|
|
2010-11-03 08:33:20 +00:00
|
|
|
|
|
|
|
#define usb_keyboard_keys usb_keyboard_report->keys
|
|
|
|
#define usb_keyboard_mods usb_keyboard_report->mods
|
2010-11-24 13:17:35 +00:00
|
|
|
#define usb_keyboard_keys_prev usb_keyboard_report_prev->keys
|
|
|
|
#define usb_keyboard_mods_prev usb_keyboard_report_prev->mods
|
2010-11-03 08:33:20 +00:00
|
|
|
|
|
|
|
|
|
|
|
extern usb_keyboard_report_t *usb_keyboard_report;
|
|
|
|
extern usb_keyboard_report_t *usb_keyboard_report_prev;
|
|
|
|
extern uint8_t usb_keyboard_protocol;
|
|
|
|
extern uint8_t usb_keyboard_idle_config;
|
|
|
|
extern uint8_t usb_keyboard_idle_count;
|
|
|
|
extern volatile uint8_t usb_keyboard_leds;
|
2010-12-07 16:47:57 +00:00
|
|
|
extern bool usb_keyboard_nkro;
|
2010-09-23 11:23:50 +00:00
|
|
|
|
|
|
|
|
|
|
|
int8_t usb_keyboard_send(void);
|
2010-11-03 08:33:20 +00:00
|
|
|
int8_t usb_keyboard_send_report(usb_keyboard_report_t *report);
|
|
|
|
|
|
|
|
void usb_keyboard_swap_report(void);
|
|
|
|
|
|
|
|
void usb_keyboard_clear_report(void);
|
|
|
|
void usb_keyboard_clear_keys(void);
|
|
|
|
void usb_keyboard_clear_mods(void);
|
|
|
|
|
2010-12-07 16:47:57 +00:00
|
|
|
void usb_keyboard_set_keys(uint8_t *keys);
|
2010-11-03 08:33:20 +00:00
|
|
|
void usb_keyboard_set_mods(uint8_t mods);
|
|
|
|
|
|
|
|
void usb_keyboard_add_code(uint8_t code);
|
|
|
|
void usb_keyboard_add_key(uint8_t code);
|
|
|
|
void usb_keyboard_add_mod(uint8_t code);
|
|
|
|
|
|
|
|
void usb_keyboard_del_code(uint8_t code);
|
|
|
|
void usb_keyboard_del_key(uint8_t code);
|
|
|
|
void usb_keyboard_del_mod(uint8_t code);
|
|
|
|
|
2010-10-23 16:17:26 +00:00
|
|
|
bool usb_keyboard_is_sent(void);
|
|
|
|
bool usb_keyboard_has_key(void);
|
|
|
|
bool usb_keyboard_has_mod(void);
|
2010-11-03 08:33:20 +00:00
|
|
|
|
2010-12-07 16:47:57 +00:00
|
|
|
uint8_t usb_keyboard_get_key(void);
|
|
|
|
|
2010-11-03 08:33:20 +00:00
|
|
|
void usb_keyboard_print_report(usb_keyboard_report_t *report);
|
2010-09-23 11:23:50 +00:00
|
|
|
|
|
|
|
#endif
|