diff options
Diffstat (limited to 'tmk_core/protocol/lufa/lufa.c')
| -rw-r--r-- | tmk_core/protocol/lufa/lufa.c | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/tmk_core/protocol/lufa/lufa.c b/tmk_core/protocol/lufa/lufa.c index dd78fe621..6dd5959dc 100644 --- a/tmk_core/protocol/lufa/lufa.c +++ b/tmk_core/protocol/lufa/lufa.c | |||
| @@ -732,7 +732,7 @@ static void send_system(uint16_t data) | |||
| 732 | 732 | ||
| 733 | report_extra_t r = { | 733 | report_extra_t r = { |
| 734 | .report_id = REPORT_ID_SYSTEM, | 734 | .report_id = REPORT_ID_SYSTEM, |
| 735 | .usage = data | 735 | .usage = data - SYSTEM_POWER_DOWN + 1 |
| 736 | }; | 736 | }; |
| 737 | Endpoint_SelectEndpoint(EXTRAKEY_IN_EPNUM); | 737 | Endpoint_SelectEndpoint(EXTRAKEY_IN_EPNUM); |
| 738 | 738 | ||
| @@ -1252,28 +1252,40 @@ void cc_callback(MidiDevice * device, | |||
| 1252 | // midi_send_cc(device, (chan + 1) % 16, num, val); | 1252 | // midi_send_cc(device, (chan + 1) % 16, num, val); |
| 1253 | } | 1253 | } |
| 1254 | 1254 | ||
| 1255 | #ifdef API_SYSEX_ENABLE | ||
| 1255 | uint8_t midi_buffer[MIDI_SYSEX_BUFFER] = {0}; | 1256 | uint8_t midi_buffer[MIDI_SYSEX_BUFFER] = {0}; |
| 1257 | #endif | ||
| 1256 | 1258 | ||
| 1257 | void sysex_callback(MidiDevice * device, uint16_t start, uint8_t length, uint8_t * data) { | 1259 | void sysex_callback(MidiDevice * device, uint16_t start, uint8_t length, uint8_t * data) { |
| 1258 | #ifdef API_SYSEX_ENABLE | 1260 | #ifdef API_SYSEX_ENABLE |
| 1259 | // SEND_STRING("\n"); | 1261 | // SEND_STRING("\n"); |
| 1260 | // send_word(start); | 1262 | // send_word(start); |
| 1261 | // SEND_STRING(": "); | 1263 | // SEND_STRING(": "); |
| 1264 | // Don't store the header | ||
| 1265 | int16_t pos = start - 4; | ||
| 1262 | for (uint8_t place = 0; place < length; place++) { | 1266 | for (uint8_t place = 0; place < length; place++) { |
| 1263 | // send_byte(*data); | 1267 | // send_byte(*data); |
| 1264 | midi_buffer[start + place] = *data; | 1268 | if (pos >= 0) { |
| 1265 | if (*data == 0xF7) { | 1269 | if (*data == 0xF7) { |
| 1266 | // SEND_STRING("\nRD: "); | 1270 | // SEND_STRING("\nRD: "); |
| 1267 | // for (uint8_t i = 0; i < start + place + 1; i++){ | 1271 | // for (uint8_t i = 0; i < start + place + 1; i++){ |
| 1268 | // send_byte(midi_buffer[i]); | 1272 | // send_byte(midi_buffer[i]); |
| 1269 | // SEND_STRING(" "); | 1273 | // SEND_STRING(" "); |
| 1270 | // } | 1274 | // } |
| 1271 | uint8_t * decoded = malloc(sizeof(uint8_t) * (sysex_decoded_length(start + place - 4))); | 1275 | const unsigned decoded_length = sysex_decoded_length(pos); |
| 1272 | uint16_t decode_length = sysex_decode(decoded, midi_buffer + 4, start + place - 4); | 1276 | uint8_t decoded[API_SYSEX_MAX_SIZE]; |
| 1273 | process_api(decode_length, decoded); | 1277 | sysex_decode(decoded, midi_buffer, pos); |
| 1278 | process_api(decoded_length, decoded); | ||
| 1279 | return; | ||
| 1280 | } | ||
| 1281 | else if (pos >= MIDI_SYSEX_BUFFER) { | ||
| 1282 | return; | ||
| 1283 | } | ||
| 1284 | midi_buffer[pos] = *data; | ||
| 1274 | } | 1285 | } |
| 1275 | // SEND_STRING(" "); | 1286 | // SEND_STRING(" "); |
| 1276 | data++; | 1287 | data++; |
| 1288 | pos++; | ||
| 1277 | } | 1289 | } |
| 1278 | #endif | 1290 | #endif |
| 1279 | } | 1291 | } |
