diff options
| author | Priyadi Iman Nurcahyo <priyadi@priyadi.net> | 2017-02-11 00:07:10 +0700 |
|---|---|---|
| committer | Priyadi Iman Nurcahyo <priyadi@priyadi.net> | 2017-02-11 00:07:10 +0700 |
| commit | 909fd4ae64432206e80925f12268c17ea7f2f68f (patch) | |
| tree | 8a490cf10c84b41f06b44f841ed74a8c5167e3b1 | |
| parent | 229e38f097448c61b2311c00837362fe5de17889 (diff) | |
| download | qmk_firmware-909fd4ae64432206e80925f12268c17ea7f2f68f.tar.gz qmk_firmware-909fd4ae64432206e80925f12268c17ea7f2f68f.zip | |
Generalize layer indicators
| -rw-r--r-- | keyboards/handwired/promethium/keymaps/priyadi/keymap.c | 142 | ||||
| -rw-r--r-- | keyboards/handwired/promethium/promethium.c | 2 |
2 files changed, 61 insertions, 83 deletions
diff --git a/keyboards/handwired/promethium/keymaps/priyadi/keymap.c b/keyboards/handwired/promethium/keymaps/priyadi/keymap.c index 1e5e497df..72b625357 100644 --- a/keyboards/handwired/promethium/keymaps/priyadi/keymap.c +++ b/keyboards/handwired/promethium/keymaps/priyadi/keymap.c | |||
| @@ -413,61 +413,43 @@ void led_reset(void) { | |||
| 413 | } | 413 | } |
| 414 | } | 414 | } |
| 415 | 415 | ||
| 416 | void led_layer_normal(void) { | 416 | void led_set_layer_indicator(void) { |
| 417 | rgbsps_set(LED_IND_FUNC, 0, 0, 0); | 417 | static uint8_t oldlayer = 255; |
| 418 | rgbsps_set(LED_IND_NUM, 0, 0, 0); | ||
| 419 | rgbsps_set(LED_IND_EMOJI, 0, 0, 0); | ||
| 420 | |||
| 421 | led_reset(); | ||
| 422 | |||
| 423 | rgbsps_send(); | ||
| 424 | } | ||
| 425 | 418 | ||
| 426 | void led_layer_func(void) { | 419 | rgbsps_set(LED_IND_FUNC, 0, 0, 0); |
| 427 | rgbsps_set(LED_IND_FUNC, 0, 15, 0); | ||
| 428 | rgbsps_set(LED_IND_NUM, 0, 0, 0); | 420 | rgbsps_set(LED_IND_NUM, 0, 0, 0); |
| 429 | rgbsps_set(LED_IND_EMOJI, 0, 0, 0); | 421 | rgbsps_set(LED_IND_EMOJI, 0, 0, 0); |
| 430 | 422 | ||
| 431 | led_reset(); | 423 | led_reset(); |
| 432 | 424 | ||
| 433 | rgbsps_send(); | 425 | uint8_t layer = biton32(layer_state); |
| 434 | } | 426 | if (oldlayer == layer) { |
| 435 | 427 | return; | |
| 436 | void led_layer_punc(void) { | 428 | } |
| 437 | rgbsps_set(LED_IND_FUNC, 0, 15, 0); | ||
| 438 | rgbsps_set(LED_IND_NUM, 0, 0, 15); | ||
| 439 | rgbsps_set(LED_IND_EMOJI, 0, 0, 0); | ||
| 440 | |||
| 441 | led_reset(); | ||
| 442 | |||
| 443 | rgbsps_send(); | ||
| 444 | } | ||
| 445 | |||
| 446 | void led_layer_num(void) { | ||
| 447 | rgbsps_set(LED_IND_FUNC, 0, 0, 0); | ||
| 448 | rgbsps_set(LED_IND_NUM, 0, 0, 15); | ||
| 449 | rgbsps_set(LED_IND_EMOJI, 0, 0, 0); | ||
| 450 | |||
| 451 | led_reset(); | ||
| 452 | 429 | ||
| 453 | rgbsps_send(); | 430 | oldlayer = layer; |
| 454 | } | ||
| 455 | 431 | ||
| 456 | void led_layer_emoji(void) { | 432 | if (layer <= _NORMAN) { |
| 457 | rgbsps_set(LED_IND_FUNC, 0, 0, 0); | 433 | rgbsps_send(); |
| 458 | rgbsps_set(LED_IND_NUM, 0, 0, 0); | 434 | return; |
| 459 | rgbsps_set(LED_IND_EMOJI, 15, 15, 0); | 435 | } |
| 460 | |||
| 461 | rgbsps_set(LED_PUNC, 15, 15, 15); | ||
| 462 | rgbsps_set(LED_EMOJI, 15, 15, 15); | ||
| 463 | 436 | ||
| 464 | rgbsps_send(); | 437 | switch(layer) { |
| 465 | } | 438 | case _FUNC: |
| 439 | rgbsps_set(LED_IND_FUNC, 15, 0, 0); | ||
| 440 | break; | ||
| 441 | case _NUM: | ||
| 442 | rgbsps_set(LED_IND_NUM, 0, 0, 15); | ||
| 443 | break; | ||
| 444 | case _EMOJI: | ||
| 445 | rgbsps_set(LED_IND_EMOJI, 15, 15, 0); | ||
| 446 | break; | ||
| 447 | default: | ||
| 448 | rgbsps_set(LED_IND_FUNC, 3, 3, 3); | ||
| 449 | rgbsps_set(LED_IND_NUM, 3, 3, 3); | ||
| 450 | rgbsps_set(LED_IND_EMOJI, 3, 3, 3); | ||
| 451 | } | ||
| 466 | 452 | ||
| 467 | void led_layer_gui(void) { | ||
| 468 | rgbsps_set(LED_IND_FUNC, 15, 10, 15); | ||
| 469 | rgbsps_set(LED_IND_NUM, 15, 10, 15); | ||
| 470 | rgbsps_set(LED_IND_EMOJI, 15, 10, 15); | ||
| 471 | rgbsps_send(); | 453 | rgbsps_send(); |
| 472 | } | 454 | } |
| 473 | 455 | ||
| @@ -497,8 +479,6 @@ void led_init(void) { | |||
| 497 | rgbsps_set(LED_TRACKPOINT1, 15, 0, 0); | 479 | rgbsps_set(LED_TRACKPOINT1, 15, 0, 0); |
| 498 | rgbsps_set(LED_TRACKPOINT2, 0, 0, 15); | 480 | rgbsps_set(LED_TRACKPOINT2, 0, 0, 15); |
| 499 | rgbsps_set(LED_TRACKPOINT3, 15, 0, 0); | 481 | rgbsps_set(LED_TRACKPOINT3, 15, 0, 0); |
| 500 | |||
| 501 | led_layer_normal(); | ||
| 502 | } | 482 | } |
| 503 | 483 | ||
| 504 | 484 | ||
| @@ -798,6 +778,22 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { | |||
| 798 | return true; | 778 | return true; |
| 799 | break; | 779 | break; |
| 800 | 780 | ||
| 781 | // press both Supers to activate EMOJI layer | ||
| 782 | case KC_LGUI: | ||
| 783 | case KC_RGUI: | ||
| 784 | ; | ||
| 785 | bool lgui = keyboard_report->mods & MOD_BIT(KC_LGUI); | ||
| 786 | bool rgui = keyboard_report->mods & MOD_BIT(KC_RGUI); | ||
| 787 | if (record->event.pressed) { | ||
| 788 | if (lgui ^ rgui) { // if only one super was pressed | ||
| 789 | layer_on(_EMOJI); | ||
| 790 | } | ||
| 791 | } else { | ||
| 792 | layer_off(_EMOJI); | ||
| 793 | } | ||
| 794 | return true; | ||
| 795 | break; | ||
| 796 | |||
| 801 | // QWERTZ style comma and dot: semicolon and colon when shifted | 797 | // QWERTZ style comma and dot: semicolon and colon when shifted |
| 802 | case KC_COMM: | 798 | case KC_COMM: |
| 803 | if (record->event.pressed) { | 799 | if (record->event.pressed) { |
| @@ -873,19 +869,9 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { | |||
| 873 | if (record->event.pressed) { | 869 | if (record->event.pressed) { |
| 874 | layer_on(_PUNC); | 870 | layer_on(_PUNC); |
| 875 | update_tri_layer(_PUNC, _GREEKL, _GUI); | 871 | update_tri_layer(_PUNC, _GREEKL, _GUI); |
| 876 | if (IS_LAYER_ON(_GUI)) { | ||
| 877 | led_layer_normal(); | ||
| 878 | } else { | ||
| 879 | led_layer_punc(); | ||
| 880 | } | ||
| 881 | } else { | 872 | } else { |
| 882 | layer_off(_PUNC); | 873 | layer_off(_PUNC); |
| 883 | update_tri_layer(_PUNC, _GREEKL, _GUI); | 874 | update_tri_layer(_PUNC, _GREEKL, _GUI); |
| 884 | if (IS_LAYER_ON(_GREEKL)) { | ||
| 885 | led_layer_normal(); | ||
| 886 | } else { | ||
| 887 | led_layer_normal(); | ||
| 888 | } | ||
| 889 | } | 875 | } |
| 890 | return false; | 876 | return false; |
| 891 | break; | 877 | break; |
| @@ -899,21 +885,11 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { | |||
| 899 | layer_on(_GREEKL); | 885 | layer_on(_GREEKL); |
| 900 | layer_off(_GREEKU); | 886 | layer_off(_GREEKU); |
| 901 | update_tri_layer(_PUNC, _GREEKL, _GUI); | 887 | update_tri_layer(_PUNC, _GREEKL, _GUI); |
| 902 | if (IS_LAYER_ON(_GUI)) { | ||
| 903 | led_layer_normal(); | ||
| 904 | } else { | ||
| 905 | led_layer_normal(); | ||
| 906 | } | ||
| 907 | } | 888 | } |
| 908 | } else { | 889 | } else { |
| 909 | layer_off(_GREEKU); | 890 | layer_off(_GREEKU); |
| 910 | layer_off(_GREEKL); | 891 | layer_off(_GREEKL); |
| 911 | update_tri_layer(_PUNC, _GREEKL, _GUI); | 892 | update_tri_layer(_PUNC, _GREEKL, _GUI); |
| 912 | if (IS_LAYER_ON(_PUNC)) { | ||
| 913 | led_layer_normal(); | ||
| 914 | } else { | ||
| 915 | led_layer_normal(); | ||
| 916 | } | ||
| 917 | } | 893 | } |
| 918 | return false; | 894 | return false; |
| 919 | break; | 895 | break; |
| @@ -921,10 +897,8 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { | |||
| 921 | case NUM: | 897 | case NUM: |
| 922 | if (record->event.pressed) { | 898 | if (record->event.pressed) { |
| 923 | layer_on(_NUM); | 899 | layer_on(_NUM); |
| 924 | led_layer_num(); | ||
| 925 | } else { | 900 | } else { |
| 926 | layer_off(_NUM); | 901 | layer_off(_NUM); |
| 927 | led_layer_normal(); | ||
| 928 | } | 902 | } |
| 929 | return false; | 903 | return false; |
| 930 | break; | 904 | break; |
| @@ -932,10 +906,8 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { | |||
| 932 | case FUNC: | 906 | case FUNC: |
| 933 | if (record->event.pressed) { | 907 | if (record->event.pressed) { |
| 934 | layer_on(_FUNC); | 908 | layer_on(_FUNC); |
| 935 | led_layer_func(); | ||
| 936 | } else { | 909 | } else { |
| 937 | layer_off(_FUNC); | 910 | layer_off(_FUNC); |
| 938 | led_layer_normal(); | ||
| 939 | } | 911 | } |
| 940 | return false; | 912 | return false; |
| 941 | break; | 913 | break; |
| @@ -1003,6 +975,10 @@ void matrix_init_user(void) { | |||
| 1003 | } | 975 | } |
| 1004 | } | 976 | } |
| 1005 | 977 | ||
| 978 | void matrix_scan_user(void) { | ||
| 979 | led_set_layer_indicator(); | ||
| 980 | } | ||
| 981 | |||
| 1006 | void battery_poll(float percentage) { | 982 | void battery_poll(float percentage) { |
| 1007 | rgbsps_sethsv(LED_IND_BATTERY, percentage*120/100, 255, 15); | 983 | rgbsps_sethsv(LED_IND_BATTERY, percentage*120/100, 255, 15); |
| 1008 | rgbsps_send(); | 984 | rgbsps_send(); |
| @@ -1012,23 +988,23 @@ void ps2_mouse_init_user() { | |||
| 1012 | uint8_t rcv; | 988 | uint8_t rcv; |
| 1013 | 989 | ||
| 1014 | // set TrackPoint sensitivity | 990 | // set TrackPoint sensitivity |
| 1015 | PS2_MOUSE_SEND(0xE2, "set trackpoint sensitivity: 0xE2"); | 991 | PS2_MOUSE_SEND(0xE2, "tpsens: 0xE2"); |
| 1016 | PS2_MOUSE_SEND(0x81, "set trackpoint sensitivity: 0x81"); | 992 | PS2_MOUSE_SEND(0x81, "tpsens: 0x81"); |
| 1017 | PS2_MOUSE_SEND(0x4A, "set trackpoint sensitivity: 0x4A"); | 993 | PS2_MOUSE_SEND(0x4A, "tpsens: 0x4A"); |
| 1018 | PS2_MOUSE_SEND(0x49, "set trackpoint sensitivity: 0x59"); | 994 | PS2_MOUSE_SEND(0x49, "tpsens: 0x59"); |
| 1019 | 995 | ||
| 1020 | // set TrackPoint Negative Inertia factor | 996 | // set TrackPoint Negative Inertia factor |
| 1021 | PS2_MOUSE_SEND(0xE2, "set negative inertia factor: 0xE2"); | 997 | PS2_MOUSE_SEND(0xE2, "tpnegin: 0xE2"); |
| 1022 | PS2_MOUSE_SEND(0x81, "set negative inertia factor: 0x81"); | 998 | PS2_MOUSE_SEND(0x81, "tpnegin: 0x81"); |
| 1023 | PS2_MOUSE_SEND(0x4D, "set negative inertia factor: 0x4D"); | 999 | PS2_MOUSE_SEND(0x4D, "tpnegin: 0x4D"); |
| 1024 | PS2_MOUSE_SEND(0x06, "set negative inertia factor: 0x06"); | 1000 | PS2_MOUSE_SEND(0x06, "tpnegin: 0x06"); |
| 1025 | 1001 | ||
| 1026 | // set TrackPoint speed | 1002 | // set TrackPoint speed |
| 1027 | // (transfer function upper plateau speed) | 1003 | // (transfer function upper plateau speed) |
| 1028 | PS2_MOUSE_SEND(0xE2, "set trackpoint speed: 0xE2"); | 1004 | PS2_MOUSE_SEND(0xE2, "tpsp: 0xE2"); |
| 1029 | PS2_MOUSE_SEND(0x81, "set trackpoint speed: 0x81"); | 1005 | PS2_MOUSE_SEND(0x81, "tpsp: 0x81"); |
| 1030 | PS2_MOUSE_SEND(0x60, "set trackpoint speed: 0x60"); | 1006 | PS2_MOUSE_SEND(0x60, "tpsp: 0x60"); |
| 1031 | PS2_MOUSE_SEND(0x61, "set trackpoint speed: 0x61"); | 1007 | PS2_MOUSE_SEND(0x61, "tpsp: 0x61"); |
| 1032 | 1008 | ||
| 1033 | // inquire pts status | 1009 | // inquire pts status |
| 1034 | rcv = ps2_host_send(0xE2); | 1010 | rcv = ps2_host_send(0xE2); |
diff --git a/keyboards/handwired/promethium/promethium.c b/keyboards/handwired/promethium/promethium.c index 7f876c756..adfc11e2a 100644 --- a/keyboards/handwired/promethium/promethium.c +++ b/keyboards/handwired/promethium/promethium.c | |||
| @@ -31,6 +31,8 @@ void matrix_scan_kb(void) { | |||
| 31 | counter = 0; | 31 | counter = 0; |
| 32 | battery_poll(battery_percentage()); | 32 | battery_poll(battery_percentage()); |
| 33 | } | 33 | } |
| 34 | |||
| 35 | matrix_scan_user(); | ||
| 34 | } | 36 | } |
| 35 | 37 | ||
| 36 | 38 | ||
