summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--keyboards/ergodox/keymaps/jack/keymap.c7
-rw-r--r--tmk_core/protocol/lufa/lufa.c62
-rw-r--r--tmk_core/protocol/lufa/lufa.h1
3 files changed, 52 insertions, 18 deletions
diff --git a/keyboards/ergodox/keymaps/jack/keymap.c b/keyboards/ergodox/keymaps/jack/keymap.c
index 8721b9644a..eb41f12127 100644
--- a/keyboards/ergodox/keymaps/jack/keymap.c
+++ b/keyboards/ergodox/keymaps/jack/keymap.c
@@ -26,7 +26,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
MO(1), KC_LEFT,KC_DOWN,KC_UP, KC_RGHT,
RGB_TOG, RGB_HUI,
RGB_MOD,
- KC_PGDN, KC_SPC,KC_SPC
+ M(2), KC_SPC,KC_SPC
),
[SYMB] = KEYMAP(
// left hand
@@ -89,6 +89,11 @@ const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
eeconfig_init();
}
break;
+ case 2:
+ if (record->event.pressed) { // For resetting EEPROM
+ send_unicode_midi(0x0CA0);
+ }
+ break;
}
return MACRO_NONE;
};
diff --git a/tmk_core/protocol/lufa/lufa.c b/tmk_core/protocol/lufa/lufa.c
index 7eb9be601e..ae9cc2f962 100644
--- a/tmk_core/protocol/lufa/lufa.c
+++ b/tmk_core/protocol/lufa/lufa.c
@@ -1161,7 +1161,7 @@ void sysex_callback(MidiDevice * device,
// send_byte(*data);
midi_buffer[start + place] = *data;
if (*data == 0xF7)
- sysex_buffer_callback(start + place, &midi_buffer);
+ sysex_buffer_callback(device, start + place, &midi_buffer);
// SEND_STRING(" ");
data++;
}
@@ -1169,7 +1169,24 @@ void sysex_callback(MidiDevice * device,
}
-void sysex_buffer_callback(uint8_t length, uint8_t * data) {
+uint32_t decode_4byte_chunk(uint8_t * data) {
+ uint32_t part1 = *data++;
+ uint32_t part2 = *data++;
+ uint32_t part3 = *data++;
+ uint32_t part4 = *data++;
+ uint32_t part5 = *data++;
+ return ((part1 & 0x1FUL) << 28) | (part2 << 21) | (part3 << 14) | (part4 << 7) | part5;
+}
+
+void encode_4byte_chunk(uint32_t data, uint8_t * pointer) {
+ *pointer++ = (data >> 28) & 0x7F;
+ *pointer++ = (data >> 21) & 0x7F;
+ *pointer++ = (data >> 14) & 0x7F;
+ *pointer++ = (data >> 7) & 0x7F;
+ *pointer++ = (data) & 0x7F;
+}
+
+void sysex_buffer_callback(MidiDevice * device, uint8_t length, uint8_t * data) {
uint8_t * pointer_copy = data;
if (*data++ != 0xF0)
@@ -1180,28 +1197,31 @@ void sysex_buffer_callback(uint8_t length, uint8_t * data) {
data++;
switch (*data++) {
+ case 0x13: ; // Get info from keyboard
+ switch (*data++) {
+ case 0x00: ; // Get layer state
+ // send_dword(layer_state);
+ uint8_t chunk[5];
+ encode_4byte_chunk(layer_state | default_layer_state, &chunk);
+
+ uint8_t array[] = {0xF0, 0x00, 0x00, 0x00, 0x00, chunk[0], chunk[1], chunk[2], chunk[3], chunk[4], 0xF7};
+ midi_send_array(&midi_device, 11, &array);
+ // midi_send_data(device, 3, 0x00, layer_state >> 24 & 0x7f, layer_state >> 16 & 0x7f);
+ // midi_send_data(device, 6, layer_state >> 8 & 0x7f, layer_state & 0x7f, 0xF7);
+ break;
+ }
+ #ifdef RGBLIGHT_ENABLE
case 0x27: ; // RGB LED functions
- switch (*data++)
+ switch (*data++) {
case 0x00: ; // Update HSV
- uint32_t part1 = *data++;
- uint32_t part2 = *data++;
- uint32_t part3 = *data++;
- uint32_t part4 = *data++;
- uint32_t part5 = *data++;
- uint32_t chunk = ((part1 & 0x1FUL) << 28) | (part2 << 21) | (part3 << 14) | (part4 << 7) | part5;
- // SEND_STRING("\nCHUNK: ");
- // send_dword(chunk);
+ uint32_t chunk = decode_4byte_chunk(data);
rgblight_sethsv(((chunk >> 16) & 0xFFFF) % 360, (chunk >> 8) & 0xFF, chunk & 0xFF);
- // SEND_STRING("\nHUE: ");
- // send_word(((chunk >> 16) & 0xFFFF) % 360);
- // SEND_STRING("\nSAT: ");
- // send_word((chunk >> 8) & 0xFF);
- // SEND_STRING("\nVAL: ");
- // send_word(chunk & 0xFF);
break;
case 0x01: ; // Update RGB
break;
+ }
break;
+ #endif
}
// SEND_STRING("\nDATA:\n");
@@ -1212,4 +1232,12 @@ void sysex_buffer_callback(uint8_t length, uint8_t * data) {
}
+void send_unicode_midi(uint32_t unicode) {
+ uint8_t chunk[5];
+ encode_4byte_chunk(unicode, &chunk);
+
+ uint8_t array[] = {0xF0, 0x00, 0x00, 0x00, 0x05, chunk[0], chunk[1], chunk[2], chunk[3], chunk[4], 0xF7};
+ midi_send_array(&midi_device, 11, &array);
+}
+
#endif
diff --git a/tmk_core/protocol/lufa/lufa.h b/tmk_core/protocol/lufa/lufa.h
index aad08d6407..3fec797b6c 100644
--- a/tmk_core/protocol/lufa/lufa.h
+++ b/tmk_core/protocol/lufa/lufa.h
@@ -70,6 +70,7 @@ typedef struct {
#ifdef MIDI_ENABLE
void MIDI_Task(void);
MidiDevice midi_device;
+void send_unicode_midi(uint32_t unicode);
#endif
// #if LUFA_VERSION_INTEGER < 0x120730