diff options
author | Damien <Dbroqua@users.noreply.github.com> | 2017-01-07 08:45:19 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-07 08:45:19 -0600 |
commit | 0fb82c15a5c9a69e17cff8dcd04c652d21381958 (patch) | |
tree | dd7a441ad7d086bb7cb4b093bd8d0cbd4d39d69d /tmk_core/protocol/lufa | |
parent | db48b28eeb5ebe5252cc04495d5eb326fa62dc26 (diff) | |
parent | e7df488a92da56cf160ac64c8cc7302ab717e145 (diff) |
Merge pull request #15 from jackhumbert/master
Merge from qmk
Diffstat (limited to 'tmk_core/protocol/lufa')
-rw-r--r-- | tmk_core/protocol/lufa/descriptor.c | 6 | ||||
-rw-r--r-- | tmk_core/protocol/lufa/lufa.c | 34 | ||||
-rw-r--r-- | tmk_core/protocol/lufa/lufa.h | 4 |
3 files changed, 29 insertions, 15 deletions
diff --git a/tmk_core/protocol/lufa/descriptor.c b/tmk_core/protocol/lufa/descriptor.c index 14d99b50bd..feeea76df0 100644 --- a/tmk_core/protocol/lufa/descriptor.c +++ b/tmk_core/protocol/lufa/descriptor.c @@ -143,10 +143,10 @@ const USB_Descriptor_HIDReport_Datatype_t PROGMEM ExtrakeyReport[] = HID_RI_USAGE(8, 0x80), /* System Control */ HID_RI_COLLECTION(8, 0x01), /* Application */ HID_RI_REPORT_ID(8, REPORT_ID_SYSTEM), - HID_RI_LOGICAL_MINIMUM(16, 0x0081), - HID_RI_LOGICAL_MAXIMUM(16, 0x00B7), + HID_RI_LOGICAL_MINIMUM(16, 0x0001), + HID_RI_LOGICAL_MAXIMUM(16, 0x0003), HID_RI_USAGE_MINIMUM(16, 0x0081), /* System Power Down */ - HID_RI_USAGE_MAXIMUM(16, 0x00B7), /* System Display LCD Autoscale */ + HID_RI_USAGE_MAXIMUM(16, 0x0083), /* System Wake Up */ HID_RI_REPORT_SIZE(8, 16), HID_RI_REPORT_COUNT(8, 1), HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_ARRAY | HID_IOF_ABSOLUTE), diff --git a/tmk_core/protocol/lufa/lufa.c b/tmk_core/protocol/lufa/lufa.c index dd78fe6213..6dd5959dc4 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) report_extra_t r = { .report_id = REPORT_ID_SYSTEM, - .usage = data + .usage = data - SYSTEM_POWER_DOWN + 1 }; Endpoint_SelectEndpoint(EXTRAKEY_IN_EPNUM); @@ -1252,28 +1252,40 @@ void cc_callback(MidiDevice * device, // midi_send_cc(device, (chan + 1) % 16, num, val); } +#ifdef API_SYSEX_ENABLE uint8_t midi_buffer[MIDI_SYSEX_BUFFER] = {0}; +#endif void sysex_callback(MidiDevice * device, uint16_t start, uint8_t length, uint8_t * data) { #ifdef API_SYSEX_ENABLE // SEND_STRING("\n"); // send_word(start); // SEND_STRING(": "); + // Don't store the header + int16_t pos = start - 4; for (uint8_t place = 0; place < length; place++) { // send_byte(*data); - midi_buffer[start + place] = *data; - if (*data == 0xF7) { - // SEND_STRING("\nRD: "); - // for (uint8_t i = 0; i < start + place + 1; i++){ - // send_byte(midi_buffer[i]); - // SEND_STRING(" "); - // } - uint8_t * decoded = malloc(sizeof(uint8_t) * (sysex_decoded_length(start + place - 4))); - uint16_t decode_length = sysex_decode(decoded, midi_buffer + 4, start + place - 4); - process_api(decode_length, decoded); + if (pos >= 0) { + if (*data == 0xF7) { + // SEND_STRING("\nRD: "); + // for (uint8_t i = 0; i < start + place + 1; i++){ + // send_byte(midi_buffer[i]); + // SEND_STRING(" "); + // } + const unsigned decoded_length = sysex_decoded_length(pos); + uint8_t decoded[API_SYSEX_MAX_SIZE]; + sysex_decode(decoded, midi_buffer, pos); + process_api(decoded_length, decoded); + return; + } + else if (pos >= MIDI_SYSEX_BUFFER) { + return; + } + midi_buffer[pos] = *data; } // SEND_STRING(" "); data++; + pos++; } #endif } diff --git a/tmk_core/protocol/lufa/lufa.h b/tmk_core/protocol/lufa/lufa.h index b11854101d..a049fd43c9 100644 --- a/tmk_core/protocol/lufa/lufa.h +++ b/tmk_core/protocol/lufa/lufa.h @@ -70,7 +70,6 @@ typedef struct { #ifdef MIDI_ENABLE void MIDI_Task(void); MidiDevice midi_device; - #define MIDI_SYSEX_BUFFER 32 #endif #ifdef API_ENABLE @@ -79,6 +78,9 @@ typedef struct { #ifdef API_SYSEX_ENABLE #include "api_sysex.h" + // Allocate space for encoding overhead. + //The header and terminator are not stored to save a few bytes of precious ram + #define MIDI_SYSEX_BUFFER (API_SYSEX_MAX_SIZE + API_SYSEX_MAX_SIZE / 7 + (API_SYSEX_MAX_SIZE % 7 ? 1 : 0)) #endif // #if LUFA_VERSION_INTEGER < 0x120730 |