Commit | Line | Data |
---|---|---|
23839b8c | 1 | /* Copyright 2016 Jack Humbert |
2 | * | |
3 | * This program is free software: you can redistribute it and/or modify | |
4 | * it under the terms of the GNU General Public License as published by | |
5 | * the Free Software Foundation, either version 2 of the License, or | |
6 | * (at your option) any later version. | |
7 | * | |
8 | * This program is distributed in the hope that it will be useful, | |
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
11 | * GNU General Public License for more details. | |
12 | * | |
13 | * You should have received a copy of the GNU General Public License | |
14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
15 | */ | |
16 | ||
7edac212 JH |
17 | #ifndef _API_H_ |
18 | #define _API_H_ | |
19 | ||
1dc1e12f | 20 | #ifdef __AVR__ |
b624f32f | 21 | # include "lufa.h" |
1dc1e12f | 22 | #endif |
7edac212 JH |
23 | |
24 | enum MESSAGE_TYPE { | |
b624f32f | 25 | MT_GET_DATA = 0x10, // Get data from keyboard |
26 | MT_GET_DATA_ACK = 0x11, // returned data to process (ACK) | |
27 | MT_SET_DATA = 0x20, // Set data on keyboard | |
28 | MT_SET_DATA_ACK = 0x21, // returned data to confirm (ACK) | |
29 | MT_SEND_DATA = 0x30, // Sending data/action from keyboard | |
30 | MT_SEND_DATA_ACK = 0x31, // returned data/action confirmation (ACK) | |
31 | MT_EXE_ACTION = 0x40, // executing actions on keyboard | |
32 | MT_EXE_ACTION_ACK = 0x41, // return confirmation/value (ACK) | |
33 | MT_TYPE_ERROR = 0x80 // type not recognised (ACK) | |
7edac212 JH |
34 | }; |
35 | ||
b624f32f | 36 | enum DATA_TYPE { DT_NONE = 0x00, DT_HANDSHAKE, DT_DEFAULT_LAYER, DT_CURRENT_LAYER, DT_KEYMAP_OPTIONS, DT_BACKLIGHT, DT_RGBLIGHT, DT_UNICODE, DT_DEBUG, DT_AUDIO, DT_QUANTUM_ACTION, DT_KEYBOARD_ACTION, DT_USER_ACTION, DT_KEYMAP_SIZE, DT_KEYMAP }; |
7edac212 | 37 | |
b624f32f | 38 | void dword_to_bytes(uint32_t dword, uint8_t* bytes); |
39 | uint32_t bytes_to_dword(uint8_t* bytes, uint8_t index); | |
7edac212 JH |
40 | |
41 | #define MT_GET_DATA(data_type, data, length) SEND_BYTES(MT_GET_DATA, data_type, data, length) | |
42 | #define MT_GET_DATA_ACK(data_type, data, length) SEND_BYTES(MT_GET_DATA_ACK, data_type, data, length) | |
43 | #define MT_SET_DATA(data_type, data, length) SEND_BYTES(MT_SET_DATA, data_type, data, length) | |
44 | #define MT_SET_DATA_ACK(data_type, data, length) SEND_BYTES(MT_SET_DATA_ACK, data_type, data, length) | |
45 | #define MT_SEND_DATA(data_type, data, length) SEND_BYTES(MT_SEND_DATA, data_type, data, length) | |
46 | #define MT_SEND_DATA_ACK(data_type, data, length) SEND_BYTES(MT_SEND_DATA_ACK, data_type, data, length) | |
47 | #define MT_EXE_ACTION(data_type, data, length) SEND_BYTES(MT_EXE_ACTION, data_type, data, length) | |
48 | #define MT_EXE_ACTION_ACK(data_type, data, length) SEND_BYTES(MT_EXE_ACTION_ACK, data_type, data, length) | |
49 | ||
b624f32f | 50 | void process_api(uint16_t length, uint8_t* data); |
7edac212 | 51 | |
b624f32f | 52 | __attribute__((weak)) bool process_api_quantum(uint8_t length, uint8_t* data); |
7edac212 | 53 | |
b624f32f | 54 | __attribute__((weak)) bool process_api_keyboard(uint8_t length, uint8_t* data); |
7edac212 | 55 | |
b624f32f | 56 | __attribute__((weak)) bool process_api_user(uint8_t length, uint8_t* data); |
7edac212 | 57 | |
23839b8c | 58 | #endif |