You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
82 lines
2.0 KiB
C
82 lines
2.0 KiB
C
14 years ago
|
#ifndef USB_KEYBOARD_H
|
||
|
#define USB_KEYBOARD_H 1
|
||
|
|
||
|
#include <stdint.h>
|
||
14 years ago
|
#include <stdbool.h>
|
||
14 years ago
|
#include "usb.h"
|
||
14 years ago
|
|
||
|
|
||
14 years ago
|
#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
|
||
14 years ago
|
#ifdef USB_NKRO_ENABLE
|
||
14 years ago
|
#define KBD2_INTERFACE 4
|
||
|
#define KBD2_ENDPOINT 5
|
||
|
#define KBD2_SIZE 16
|
||
|
#define KBD2_BUFFER EP_DOUBLE_BUFFER
|
||
14 years ago
|
#define KBD2_REPORT_KEYS (KBD2_SIZE - 1)
|
||
14 years ago
|
#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
|
||
14 years ago
|
#endif
|
||
14 years ago
|
|
||
14 years ago
|
|
||
14 years ago
|
typedef struct report {
|
||
14 years ago
|
uint8_t keys[KEYS_MAX];
|
||
14 years ago
|
uint8_t mods;
|
||
|
bool is_sent;
|
||
|
} usb_keyboard_report_t;
|
||
14 years ago
|
|
||
14 years ago
|
|
||
|
#define usb_keyboard_keys usb_keyboard_report->keys
|
||
|
#define usb_keyboard_mods usb_keyboard_report->mods
|
||
14 years ago
|
#define usb_keyboard_keys_prev usb_keyboard_report_prev->keys
|
||
|
#define usb_keyboard_mods_prev usb_keyboard_report_prev->mods
|
||
14 years ago
|
|
||
|
|
||
|
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;
|
||
14 years ago
|
extern bool usb_keyboard_nkro;
|
||
14 years ago
|
|
||
|
|
||
|
int8_t usb_keyboard_send(void);
|
||
14 years ago
|
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);
|
||
|
|
||
14 years ago
|
void usb_keyboard_set_keys(uint8_t *keys);
|
||
14 years ago
|
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);
|
||
|
|
||
14 years ago
|
bool usb_keyboard_is_sent(void);
|
||
|
bool usb_keyboard_has_key(void);
|
||
|
bool usb_keyboard_has_mod(void);
|
||
14 years ago
|
|
||
14 years ago
|
uint8_t usb_keyboard_get_key(void);
|
||
|
|
||
14 years ago
|
void usb_keyboard_print_report(usb_keyboard_report_t *report);
|
||
14 years ago
|
|
||
|
#endif
|