Skip to content

Commit

Permalink
SHIFT configurator support (Massdrop#14)
Browse files Browse the repository at this point in the history
(cherry picked from commit d52719f)
  • Loading branch information
just-another-jxliu authored and Gentoli committed Jul 24, 2020
1 parent cce8318 commit 6f61d1c
Show file tree
Hide file tree
Showing 12 changed files with 132 additions and 17 deletions.
18 changes: 16 additions & 2 deletions keyboards/massdrop/alt/keymaps/default_md/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ enum alt_keycodes {
L_PTP, //LED Pattern Select Previous
L_PSI, //LED Pattern Speed Increase
L_PSD, //LED Pattern Speed Decrease
L_RATIOD,
L_RATIOI,
L_T_MD, //LED Toggle Mode
L_T_ONF, //LED Toggle On / Off
L_ON, //LED On
Expand Down Expand Up @@ -106,6 +108,18 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
if (led_edge_brightness < 0) { led_edge_brightness = 0; }
}
return false;
case L_RATIOI:
if (record->event.pressed) {
led_ratio_brightness += 0.2;
if (led_ratio_brightness > 2.0) { led_ratio_brightness = 2.0; }
}
return false;
case L_RATIOD:
if (record->event.pressed) {
led_ratio_brightness -= 0.2;
if (led_ratio_brightness < 0.0) { led_ratio_brightness = 0.0; }
}
return false;
case L_PTN:
if (record->event.pressed) {
if (led_animation_id == led_setups_count - 1) led_animation_id = 0;
Expand Down Expand Up @@ -247,7 +261,7 @@ led_instruction_t led_instructions[] = {
//Flags can be found in tmk_core/protocol/arm_atsam/led_matrix.h (prefixed with LED_FLAG_)
//LED IDs can be found in config_led.h in the keyboard's directory
//Examples are below

//All LEDs use the user's selected pattern (this is the factory default)
{ .flags = LED_FLAG_USE_ROTATE_PATTERN },

Expand All @@ -256,7 +270,7 @@ led_instruction_t led_instructions[] = {

//Specific LEDs use specified RGB values while all others are off
// { .flags = LED_FLAG_MATCH_ID | LED_FLAG_USE_RGB, .id0 = 0xFF, .id1 = 0x00FF, .id2 = 0x0000FF00, .id3 = 0xFF000000, .r = 75, .g = 150, .b = 225 },

//All LEDs use the user's selected pattern
//On layer 1, all key LEDs (except the top row which keeps active pattern) are red while all edge LEDs are green
//When layer 1 is active, key LEDs use red (id0 32 - 16: 1111 1111 1111 1111 1000 0000 0000 0000 = 0xFFFF8000) (except top row 15 - 1)
Expand Down
14 changes: 14 additions & 0 deletions keyboards/massdrop/alt/keymaps/mac_md/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ enum alt_keycodes {
L_PTP, //LED Pattern Select Previous
L_PSI, //LED Pattern Speed Increase
L_PSD, //LED Pattern Speed Decrease
L_RATIOD,
L_RATIOI,
L_T_MD, //LED Toggle Mode
L_T_ONF, //LED Toggle On / Off
L_ON, //LED On
Expand Down Expand Up @@ -106,6 +108,18 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
if (led_edge_brightness < 0) { led_edge_brightness = 0; }
}
return false;
case L_RATIOI:
if (record->event.pressed) {
led_ratio_brightness += 0.2;
if (led_ratio_brightness > 2.0) { led_ratio_brightness = 2.0; }
}
return false;
case L_RATIOD:
if (record->event.pressed) {
led_ratio_brightness -= 0.2;
if (led_ratio_brightness < 0.0) { led_ratio_brightness = 0.0; }
}
return false;
case L_PTN:
if (record->event.pressed) {
if (led_animation_id == led_setups_count - 1) led_animation_id = 0;
Expand Down
18 changes: 16 additions & 2 deletions keyboards/massdrop/ctrl/keymaps/default_md/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ enum ctrl_keycodes {
L_PTP, //LED Pattern Select Previous
L_PSI, //LED Pattern Speed Increase
L_PSD, //LED Pattern Speed Decrease
L_RATIOD,
L_RATIOI,
L_T_MD, //LED Toggle Mode
L_T_ONF, //LED Toggle On / Off
L_ON, //LED On
Expand Down Expand Up @@ -109,6 +111,18 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
if (led_edge_brightness < 0) { led_edge_brightness = 0; }
}
return false;
case L_RATIOI:
if (record->event.pressed) {
led_ratio_brightness += 0.2;
if (led_ratio_brightness > 2.0) { led_ratio_brightness = 2.0; }
}
return false;
case L_RATIOD:
if (record->event.pressed) {
led_ratio_brightness -= 0.2;
if (led_ratio_brightness < 0.0) { led_ratio_brightness = 0.0; }
}
return false;
case L_PTN:
if (record->event.pressed) {
if (led_animation_id == led_setups_count - 1) led_animation_id = 0;
Expand Down Expand Up @@ -250,7 +264,7 @@ led_instruction_t led_instructions[] = {
//Flags can be found in tmk_core/protocol/arm_atsam/led_matrix.h (prefixed with LED_FLAG_)
//LED IDs can be found in config_led.h in the keyboard's directory
//Examples are below

//All LEDs use the user's selected pattern (this is the factory default)
{ .flags = LED_FLAG_USE_ROTATE_PATTERN },

Expand All @@ -259,7 +273,7 @@ led_instruction_t led_instructions[] = {

//Specific LEDs use specified RGB values while all others are off
// { .flags = LED_FLAG_MATCH_ID | LED_FLAG_USE_RGB, .id0 = 0xFF, .id1 = 0x00FF, .id2 = 0x0000FF00, .id3 = 0xFF000000, .r = 75, .g = 150, .b = 225 },

//All LEDs use the user's selected pattern
//On layer 1, all key LEDs (except the top row which keeps active pattern) are red while all edge LEDs are green
//When layer 1 is active, key LEDs use red (id0 32 - 17: 1111 1111 1111 1111 0000 0000 0000 0000 = 0xFFFF0000) (except top row 16 - 1)
Expand Down
14 changes: 14 additions & 0 deletions keyboards/massdrop/ctrl/keymaps/mac_md/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ enum ctrl_keycodes {
L_PTP, //LED Pattern Select Previous
L_PSI, //LED Pattern Speed Increase
L_PSD, //LED Pattern Speed Decrease
L_RATIOD,
L_RATIOI,
L_T_MD, //LED Toggle Mode
L_T_ONF, //LED Toggle On / Off
L_ON, //LED On
Expand Down Expand Up @@ -109,6 +111,18 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
if (led_edge_brightness < 0) { led_edge_brightness = 0; }
}
return false;
case L_RATIOI:
if (record->event.pressed) {
led_ratio_brightness += 0.2;
if (led_ratio_brightness > 2.0) { led_ratio_brightness = 2.0; }
}
return false;
case L_RATIOD:
if (record->event.pressed) {
led_ratio_brightness -= 0.2;
if (led_ratio_brightness < 0.0) { led_ratio_brightness = 0.0; }
}
return false;
case L_PTN:
if (record->event.pressed) {
if (led_animation_id == led_setups_count - 1) led_animation_id = 0;
Expand Down
18 changes: 16 additions & 2 deletions keyboards/massdrop/numpad/keymaps/default_md/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ enum shift_keycodes {
L_PTP, //LED Pattern Select Previous
L_PSI, //LED Pattern Speed Increase
L_PSD, //LED Pattern Speed Decrease
L_RATIOD,
L_RATIOI,
L_T_MD, //LED Toggle Mode
L_T_ONF, //LED Toggle On / Off
L_ON, //LED On
Expand Down Expand Up @@ -109,6 +111,18 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
if (led_edge_brightness < 0) { led_edge_brightness = 0; }
}
return false;
case L_RATIOI:
if (record->event.pressed) {
led_ratio_brightness += 0.2;
if (led_ratio_brightness > 2.0) { led_ratio_brightness = 2.0; }
}
return false;
case L_RATIOD:
if (record->event.pressed) {
led_ratio_brightness -= 0.2;
if (led_ratio_brightness < 0.0) { led_ratio_brightness = 0.0; }
}
return false;
case L_PTN:
if (record->event.pressed) {
if (led_animation_id == led_setups_count - 1) led_animation_id = 0;
Expand Down Expand Up @@ -250,7 +264,7 @@ led_instruction_t led_instructions[] = {
//Flags can be found in tmk_core/protocol/arm_atsam/led_matrix.h (prefixed with LED_FLAG_)
//LED IDs can be found in config_led.h in the keyboard's directory
//Examples are below

//All LEDs use the user's selected pattern (this is the factory default)
{ .flags = LED_FLAG_USE_ROTATE_PATTERN },

Expand All @@ -259,7 +273,7 @@ led_instruction_t led_instructions[] = {

//Specific LEDs use specified RGB values while all others are off
// { .flags = LED_FLAG_MATCH_ID | LED_FLAG_USE_RGB, .id0 = 0xFF, .id1 = 0x00FF, .id2 = 0x0000FF00, .id3 = 0xFF000000, .r = 75, .g = 150, .b = 225 },

//All LEDs use the user's selected pattern
//On layer 1, all key LEDs (except the top row which keeps active pattern) are red while all edge LEDs are green
//When layer 1 is active, key LEDs use red (id0 32 - 17: 1111 1111 1111 1111 0000 0000 0000 0000 = 0xFFFF0000) (except top row 16 - 1)
Expand Down
18 changes: 16 additions & 2 deletions keyboards/massdrop/numpad/keymaps/mac_md/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ enum shift_keycodes {
L_PTP, //LED Pattern Select Previous
L_PSI, //LED Pattern Speed Increase
L_PSD, //LED Pattern Speed Decrease
L_RATIOD,
L_RATIOI,
L_T_MD, //LED Toggle Mode
L_T_ONF, //LED Toggle On / Off
L_ON, //LED On
Expand Down Expand Up @@ -109,6 +111,18 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
if (led_edge_brightness < 0) { led_edge_brightness = 0; }
}
return false;
case L_RATIOI:
if (record->event.pressed) {
led_ratio_brightness += 0.2;
if (led_ratio_brightness > 2.0) { led_ratio_brightness = 2.0; }
}
return false;
case L_RATIOD:
if (record->event.pressed) {
led_ratio_brightness -= 0.2;
if (led_ratio_brightness < 0.0) { led_ratio_brightness = 0.0; }
}
return false;
case L_PTN:
if (record->event.pressed) {
if (led_animation_id == led_setups_count - 1) led_animation_id = 0;
Expand Down Expand Up @@ -250,7 +264,7 @@ led_instruction_t led_instructions[] = {
//Flags can be found in tmk_core/protocol/arm_atsam/led_matrix.h (prefixed with LED_FLAG_)
//LED IDs can be found in config_led.h in the keyboard's directory
//Examples are below

//All LEDs use the user's selected pattern (this is the factory default)
{ .flags = LED_FLAG_USE_ROTATE_PATTERN },

Expand All @@ -259,7 +273,7 @@ led_instruction_t led_instructions[] = {

//Specific LEDs use specified RGB values while all others are off
// { .flags = LED_FLAG_MATCH_ID | LED_FLAG_USE_RGB, .id0 = 0xFF, .id1 = 0x00FF, .id2 = 0x0000FF00, .id3 = 0xFF000000, .r = 75, .g = 150, .b = 225 },

//All LEDs use the user's selected pattern
//On layer 1, all key LEDs (except the top row which keeps active pattern) are red while all edge LEDs are green
//When layer 1 is active, key LEDs use red (id0 32 - 17: 1111 1111 1111 1111 0000 0000 0000 0000 = 0xFFFF0000) (except top row 16 - 1)
Expand Down
14 changes: 14 additions & 0 deletions keyboards/massdrop/rocketeer/keymaps/default_md/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ enum rocketeer_keycodes {
L_PTP, //LED Pattern Select Previous
L_PSI, //LED Pattern Speed Increase
L_PSD, //LED Pattern Speed Decrease
L_RATIOD,
L_RATIOI,
L_T_MD, //LED Toggle Mode
L_T_ONF, //LED Toggle On / Off
L_ON, //LED On
Expand Down Expand Up @@ -106,6 +108,18 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
if (led_edge_brightness < 0) { led_edge_brightness = 0; }
}
return false;
case L_RATIOI:
if (record->event.pressed) {
led_ratio_brightness += 0.2;
if (led_ratio_brightness > 2.0) { led_ratio_brightness = 2.0; }
}
return false;
case L_RATIOD:
if (record->event.pressed) {
led_ratio_brightness -= 0.2;
if (led_ratio_brightness < 0.0) { led_ratio_brightness = 0.0; }
}
return false;
case L_PTN:
if (record->event.pressed) {
if (led_animation_id == led_setups_count - 1) led_animation_id = 0;
Expand Down
14 changes: 14 additions & 0 deletions keyboards/massdrop/rocketeer/keymaps/mac_md/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ enum rocketeer_keycodes {
L_PTP, //LED Pattern Select Previous
L_PSI, //LED Pattern Speed Increase
L_PSD, //LED Pattern Speed Decrease
L_RATIOD,
L_RATIOI,
L_T_MD, //LED Toggle Mode
L_T_ONF, //LED Toggle On / Off
L_ON, //LED On
Expand Down Expand Up @@ -106,6 +108,18 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
if (led_edge_brightness < 0) { led_edge_brightness = 0; }
}
return false;
case L_RATIOI:
if (record->event.pressed) {
led_ratio_brightness += 0.2;
if (led_ratio_brightness > 2.0) { led_ratio_brightness = 2.0; }
}
return false;
case L_RATIOD:
if (record->event.pressed) {
led_ratio_brightness -= 0.2;
if (led_ratio_brightness < 0.0) { led_ratio_brightness = 0.0; }
}
return false;
case L_PTN:
if (record->event.pressed) {
if (led_animation_id == led_setups_count - 1) led_animation_id = 0;
Expand Down
6 changes: 3 additions & 3 deletions keyboards/massdrop/shift/keymaps/default_md/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
return false;
case L_RATIOD:
if (record->event.pressed) {
led_ratio_brightness -= 0.2;
led_ratio_brightness -= 0.2;
if (led_ratio_brightness < 0.0) { led_ratio_brightness = 0.0; }
}
return false;
Expand Down Expand Up @@ -274,7 +274,7 @@ led_instruction_t led_instructions[] = {
//Flags can be found in tmk_core/protocol/arm_atsam/led_matrix.h (prefixed with LED_FLAG_)
//LED IDs can be found in config_led.h in the keyboard's directory
//Examples are below

//All LEDs use the user's selected pattern (this is the factory default)
{ .flags = LED_FLAG_USE_ROTATE_PATTERN },

Expand All @@ -283,7 +283,7 @@ led_instruction_t led_instructions[] = {

//Specific LEDs use specified RGB values while all others are off
// { .flags = LED_FLAG_MATCH_ID | LED_FLAG_USE_RGB, .id0 = 0xFF, .id1 = 0x00FF, .id2 = 0x0000FF00, .id3 = 0xFF000000, .r = 75, .g = 150, .b = 225 },

//All LEDs use the user's selected pattern
//On layer 1, all key LEDs (except the top row which keeps active pattern) are red while all edge LEDs are green
//When layer 1 is active, key LEDs use red (id0 32 - 17: 1111 1111 1111 1111 0000 0000 0000 0000 = 0xFFFF0000) (except top row 16 - 1)
Expand Down
6 changes: 3 additions & 3 deletions keyboards/massdrop/shift/keymaps/mac_md/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
return false;
case L_RATIOD:
if (record->event.pressed) {
led_ratio_brightness -= 0.2;
led_ratio_brightness -= 0.2;
if (led_ratio_brightness < 0.0) { led_ratio_brightness = 0.0; }
}
return false;
Expand Down Expand Up @@ -274,7 +274,7 @@ led_instruction_t led_instructions[] = {
//Flags can be found in tmk_core/protocol/arm_atsam/led_matrix.h (prefixed with LED_FLAG_)
//LED IDs can be found in config_led.h in the keyboard's directory
//Examples are below

//All LEDs use the user's selected pattern (this is the factory default)
{ .flags = LED_FLAG_USE_ROTATE_PATTERN },

Expand All @@ -283,7 +283,7 @@ led_instruction_t led_instructions[] = {

//Specific LEDs use specified RGB values while all others are off
// { .flags = LED_FLAG_MATCH_ID | LED_FLAG_USE_RGB, .id0 = 0xFF, .id1 = 0x00FF, .id2 = 0x0000FF00, .id3 = 0xFF000000, .r = 75, .g = 150, .b = 225 },

//All LEDs use the user's selected pattern
//On layer 1, all key LEDs (except the top row which keeps active pattern) are red while all edge LEDs are green
//When layer 1 is active, key LEDs use red (id0 32 - 17: 1111 1111 1111 1111 0000 0000 0000 0000 = 0xFFFF0000) (except top row 16 - 1)
Expand Down
7 changes: 4 additions & 3 deletions tmk_core/protocol/arm_atsam/led_matrix.c
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ static void md_led_matrix_indicators(void) {
# ifdef USB_LED_KANA_SCANCODE
(led_map[i].scan == USB_LED_KANA_SCANCODE && (kbled & (1 << USB_LED_KANA))) ||
# endif // KANA
// Dedicated LEDs (Could be done more efficiently - meh)
// Dedicated LEDs (Could be done more efficiently - meh)
(0))) {
led_buffer[i].r = 255 - led_buffer[i].r;
led_buffer[i].g = 255 - led_buffer[i].g;
Expand Down Expand Up @@ -534,8 +534,9 @@ static void led_matrix_massdrop_config_override(int i) {

// Check if this applies to current index
if (led_cur_instruction->flags & LED_FLAG_MATCH_ID) {
uint8_t modid = i / 32; // Calculate which id# contains the led bit
uint32_t modidbit = 1 << (i % 32); // Calculate the bit within the id#
uint8_t ledid = led_map[i].id - 1;
uint8_t modid = ledid / 32; // Calculate which id# contains the led bit
uint32_t modidbit = 1 << (ledid % 32); // Calculate the bit within the id#
uint32_t* bitfield = &led_cur_instruction->id0 + modid; // Add modid as offset to id0 address. *bitfield is now idX of the led id
if (~(*bitfield) & modidbit) { // Check if led bit is not set in idX
goto next_iter;
Expand Down
2 changes: 2 additions & 0 deletions tmk_core/protocol/arm_atsam/led_matrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ typedef struct led_instruction_s {
uint32_t id1; // Bitwise id, IDs 32-63
uint32_t id2; // Bitwise id, IDs 64-95
uint32_t id3; // Bitwise id, IDs 96-127
uint32_t id4; // Bitwise id, IDs 128-159
uint32_t id5; // Bitwise id, IDs 160-191
uint8_t layer;
uint8_t r;
uint8_t g;
Expand Down

0 comments on commit 6f61d1c

Please sign in to comment.