aboutsummaryrefslogtreecommitdiff
path: root/tmk_core/protocol/lufa
diff options
context:
space:
mode:
Diffstat (limited to 'tmk_core/protocol/lufa')
-rw-r--r--tmk_core/protocol/lufa/lufa.c49
-rw-r--r--tmk_core/protocol/lufa/lufa.h42
2 files changed, 43 insertions, 48 deletions
diff --git a/tmk_core/protocol/lufa/lufa.c b/tmk_core/protocol/lufa/lufa.c
index c3234b8ce..eae3e8f29 100644
--- a/tmk_core/protocol/lufa/lufa.c
+++ b/tmk_core/protocol/lufa/lufa.c
@@ -72,7 +72,7 @@
72 #include "virtser.h" 72 #include "virtser.h"
73#endif 73#endif
74 74
75#ifdef RGB_MIDI 75#if (defined(RGB_MIDI) | defined(RGBLIGHT_ANIMATIONS)) & defined(RGBLIGHT_ENABLE)
76 #include "rgblight.h" 76 #include "rgblight.h"
77#endif 77#endif
78 78
@@ -1156,35 +1156,6 @@ uint32_t bytes_to_dword(uint8_t * bytes, uint8_t index) {
1156 return ((uint32_t)bytes[index + 0] << 24) | ((uint32_t)bytes[index + 1] << 16) | ((uint32_t)bytes[index + 2] << 8) | (uint32_t)bytes[index + 3]; 1156 return ((uint32_t)bytes[index + 0] << 24) | ((uint32_t)bytes[index + 1] << 16) | ((uint32_t)bytes[index + 2] << 8) | (uint32_t)bytes[index + 3];
1157} 1157}
1158 1158
1159enum MESSAGE_TYPE {
1160 MT_GET_DATA = 0x10, // Get data from keyboard
1161 MT_GET_DATA_ACK = 0x11, // returned data to process (ACK)
1162 MT_SET_DATA = 0x20, // Set data on keyboard
1163 MT_SET_DATA_ACK = 0x21, // returned data to confirm (ACK)
1164 MT_SEND_DATA = 0x30, // Sending data/action from keyboard
1165 MT_SEND_DATA_ACK = 0x31, // returned data/action confirmation (ACK)
1166 MT_EXE_ACTION = 0x40, // executing actions on keyboard
1167 MT_EXE_ACTION_ACK =0x41, // return confirmation/value (ACK)
1168 MT_TYPE_ERROR = 0x80 // type not recofgnised (ACK)
1169};
1170
1171enum DATA_TYPE {
1172 DT_NONE = 0x00,
1173 DT_HANDSHAKE,
1174 DT_DEFAULT_LAYER,
1175 DT_CURRENT_LAYER,
1176 DT_KEYMAP_OPTIONS,
1177 DT_BACKLIGHT,
1178 DT_RGBLIGHT,
1179 DT_UNICODE,
1180 DT_DEBUG,
1181 DT_AUDIO,
1182 DT_QUANTUM_ACTION,
1183 DT_KEYBOARD_ACTION,
1184 DT_USER_ACTION,
1185
1186};
1187
1188void send_bytes_sysex(uint8_t message_type, uint8_t data_type, uint8_t * bytes, uint8_t length) { 1159void send_bytes_sysex(uint8_t message_type, uint8_t data_type, uint8_t * bytes, uint8_t length) {
1189 // SEND_STRING("\nTX: "); 1160 // SEND_STRING("\nTX: ");
1190 // for (uint8_t i = 0; i < length; i++) { 1161 // for (uint8_t i = 0; i < length; i++) {
@@ -1213,15 +1184,6 @@ void send_bytes_sysex(uint8_t message_type, uint8_t data_type, uint8_t * bytes,
1213 // } 1184 // }
1214} 1185}
1215 1186
1216#define MT_GET_DATA(data_type, data, length) send_bytes_sysex(MT_GET_DATA, data_type, data, length)
1217#define MT_GET_DATA_ACK(data_type, data, length) send_bytes_sysex(MT_GET_DATA_ACK, data_type, data, length)
1218#define MT_SET_DATA(data_type, data, length) send_bytes_sysex(MT_SET_DATA, data_type, data, length)
1219#define MT_SET_DATA_ACK(data_type, data, length) send_bytes_sysex(MT_SET_DATA_ACK, data_type, data, length)
1220#define MT_SEND_DATA(data_type, data, length) send_bytes_sysex(MT_SEND_DATA, data_type, data, length)
1221#define MT_SEND_DATA_ACK(data_type, data, length) send_bytes_sysex(MT_SEND_DATA_ACK, data_type, data, length)
1222#define MT_EXE_ACTION(data_type, data, length) send_bytes_sysex(MT_EXE_ACTION, data_type, data, length)
1223#define MT_EXE_ACTION_ACK(data_type, data, length) send_bytes_sysex(MT_EXE_ACTION_ACK, data_type, data, length)
1224
1225__attribute__ ((weak)) 1187__attribute__ ((weak))
1226bool sysex_process_quantum(uint8_t length, uint8_t * data) { 1188bool sysex_process_quantum(uint8_t length, uint8_t * data) {
1227 return sysex_process_keyboard(length, data); 1189 return sysex_process_keyboard(length, data);
@@ -1312,7 +1274,7 @@ void sysex_buffer_callback(MidiDevice * device, uint8_t length, uint8_t * data)
1312 dword_to_bytes(eeconfig_read_rgblight(), rgblight_bytes); 1274 dword_to_bytes(eeconfig_read_rgblight(), rgblight_bytes);
1313 MT_GET_DATA_ACK(DT_RGBLIGHT, rgblight_bytes, 4); 1275 MT_GET_DATA_ACK(DT_RGBLIGHT, rgblight_bytes, 4);
1314 #else 1276 #else
1315 MT_GET_DATA_ACK(DT_RGBLIGHT, NULL, 0) 1277 MT_GET_DATA_ACK(DT_RGBLIGHT, NULL, 0);
1316 #endif 1278 #endif
1317 break; 1279 break;
1318 } 1280 }
@@ -1360,11 +1322,4 @@ void sysex_buffer_callback(MidiDevice * device, uint8_t length, uint8_t * data)
1360 1322
1361} 1323}
1362 1324
1363void send_unicode_midi(uint32_t unicode) {
1364 uint8_t chunk[4];
1365 dword_to_bytes(unicode, chunk);
1366 MT_SEND_DATA(DT_UNICODE, chunk, 5);
1367}
1368
1369
1370#endif 1325#endif
diff --git a/tmk_core/protocol/lufa/lufa.h b/tmk_core/protocol/lufa/lufa.h
index 99b089f42..0962dda8d 100644
--- a/tmk_core/protocol/lufa/lufa.h
+++ b/tmk_core/protocol/lufa/lufa.h
@@ -74,8 +74,9 @@ typedef struct {
74 74
75 void sysex_callback(MidiDevice * device, uint16_t start, uint8_t length, uint8_t * data); 75 void sysex_callback(MidiDevice * device, uint16_t start, uint8_t length, uint8_t * data);
76 void sysex_buffer_callback(MidiDevice * device, uint8_t length, uint8_t * data); 76 void sysex_buffer_callback(MidiDevice * device, uint8_t length, uint8_t * data);
77 void send_unicode_midi(uint32_t unicode);
78 void send_bytes_sysex(uint8_t message_type, uint8_t data_type, uint8_t * bytes, uint8_t length); 77 void send_bytes_sysex(uint8_t message_type, uint8_t data_type, uint8_t * bytes, uint8_t length);
78 void dword_to_bytes(uint32_t dword, uint8_t * bytes);
79 uint32_t bytes_to_dword(uint8_t * bytes, uint8_t index);
79 80
80 __attribute__ ((weak)) 81 __attribute__ ((weak))
81 bool sysex_process_quantum(uint8_t length, uint8_t * data); 82 bool sysex_process_quantum(uint8_t length, uint8_t * data);
@@ -86,6 +87,45 @@ typedef struct {
86 __attribute__ ((weak)) 87 __attribute__ ((weak))
87 bool sysex_process_user(uint8_t length, uint8_t * data); 88 bool sysex_process_user(uint8_t length, uint8_t * data);
88 89
90 enum MESSAGE_TYPE {
91 MT_GET_DATA = 0x10, // Get data from keyboard
92 MT_GET_DATA_ACK = 0x11, // returned data to process (ACK)
93 MT_SET_DATA = 0x20, // Set data on keyboard
94 MT_SET_DATA_ACK = 0x21, // returned data to confirm (ACK)
95 MT_SEND_DATA = 0x30, // Sending data/action from keyboard
96 MT_SEND_DATA_ACK = 0x31, // returned data/action confirmation (ACK)
97 MT_EXE_ACTION = 0x40, // executing actions on keyboard
98 MT_EXE_ACTION_ACK =0x41, // return confirmation/value (ACK)
99 MT_TYPE_ERROR = 0x80 // type not recofgnised (ACK)
100 };
101
102 enum DATA_TYPE {
103 DT_NONE = 0x00,
104 DT_HANDSHAKE,
105 DT_DEFAULT_LAYER,
106 DT_CURRENT_LAYER,
107 DT_KEYMAP_OPTIONS,
108 DT_BACKLIGHT,
109 DT_RGBLIGHT,
110 DT_UNICODE,
111 DT_DEBUG,
112 DT_AUDIO,
113 DT_QUANTUM_ACTION,
114 DT_KEYBOARD_ACTION,
115 DT_USER_ACTION,
116
117 };
118
119
120 #define MT_GET_DATA(data_type, data, length) send_bytes_sysex(MT_GET_DATA, data_type, data, length)
121 #define MT_GET_DATA_ACK(data_type, data, length) send_bytes_sysex(MT_GET_DATA_ACK, data_type, data, length)
122 #define MT_SET_DATA(data_type, data, length) send_bytes_sysex(MT_SET_DATA, data_type, data, length)
123 #define MT_SET_DATA_ACK(data_type, data, length) send_bytes_sysex(MT_SET_DATA_ACK, data_type, data, length)
124 #define MT_SEND_DATA(data_type, data, length) send_bytes_sysex(MT_SEND_DATA, data_type, data, length)
125 #define MT_SEND_DATA_ACK(data_type, data, length) send_bytes_sysex(MT_SEND_DATA_ACK, data_type, data, length)
126 #define MT_EXE_ACTION(data_type, data, length) send_bytes_sysex(MT_EXE_ACTION, data_type, data, length)
127 #define MT_EXE_ACTION_ACK(data_type, data, length) send_bytes_sysex(MT_EXE_ACTION_ACK, data_type, data, length)
128
89#endif 129#endif
90 130
91// #if LUFA_VERSION_INTEGER < 0x120730 131// #if LUFA_VERSION_INTEGER < 0x120730