qmk_firmware

QMK firmware for my keyboards (Corne, Sweep Ferris) and trackball (Ploopy Adept)
Log | Files | Refs | Submodules | LICENSE

rev1.c (2531B)


      1 /* Copyright 2023 splitkb.com <support@splitkb.com>
      2  *
      3  * This program is free software: you can redistribute it and/or modify
      4  * it under the terms of the GNU General Public License as published by
      5  * the Free Software Foundation, either version 2 of the License, or
      6  * (at your option) any later version.
      7  *
      8  * This program is distributed in the hope that it will be useful,
      9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
     10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     11  * GNU General Public License for more details.
     12  *
     13  * You should have received a copy of the GNU General Public License
     14  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
     15  */
     16 
     17 #include QMK_KEYBOARD_H
     18 
     19 //  Overriding is_keyboard_left() in qmk_firmware/quantum/split_common/split_util.c to limit the handedness check only once.
     20 //  reason: SPLIT_HAND_PIN is shared with the RGB pin so we don't want to keep reusing the pin for handedness checks.
     21 bool is_keyboard_left(void) {
     22 static enum { UNKNOWN, LEFT, RIGHT } hand_side = UNKNOWN;
     23     // only check once, as this is called often
     24     if (hand_side == UNKNOWN) {
     25         #if defined(SPLIT_HAND_PIN)
     26             // Test pin SPLIT_HAND_PIN for High/Low, if low it's right hand
     27             gpio_set_pin_input(SPLIT_HAND_PIN);
     28             hand_side = gpio_read_pin(SPLIT_HAND_PIN) ? LEFT : RIGHT;
     29             return (hand_side == LEFT);
     30         #endif
     31         hand_side = is_keyboard_master() ? LEFT : RIGHT;
     32         return (hand_side == LEFT);
     33     } else {
     34         return (hand_side == LEFT);
     35     }
     36 }
     37 
     38 #ifdef SWAP_HANDS_ENABLE
     39 // clang-format off
     40     __attribute__ ((weak)) const keypos_t PROGMEM hand_swap_config[MATRIX_ROWS][MATRIX_COLS] = {
     41         {{0, 5}, {1, 5}, {2, 5}, {3, 5}, {4, 5}, {5, 5}, {6, 5}},
     42         {{0, 6}, {1, 6}, {2, 6}, {3, 6}, {4, 6}, {5, 6}, {6, 6}},
     43         {{0, 7}, {1, 7}, {2, 7}, {3, 7}, {4, 7}, {5, 7}, {6, 7}},
     44         {{0, 8}, {1, 8}, {2, 8}, {3, 8}, {4, 8}, {5, 8}, {6, 8}},
     45         {{0, 9}, {1, 9}, {2, 9}, {3, 9}, {4, 9}, {5, 9}, {6, 9}},
     46         {{0, 0}, {1, 0}, {2, 0}, {3, 0}, {4, 0}, {5, 0}, {6, 0}},
     47         {{0, 1}, {1, 1}, {2, 1}, {3, 1}, {4, 1}, {5, 1}, {6, 1}},
     48         {{0, 2}, {1, 2}, {2, 2}, {3, 2}, {4, 2}, {5, 2}, {6, 2}},
     49         {{0, 3}, {1, 3}, {2, 3}, {3, 3}, {4, 3}, {5, 3}, {6, 3}},
     50         {{0, 4}, {1, 4}, {2, 4}, {3, 4}, {4, 4}, {5, 4}, {6, 4}}
     51     };
     52 // clang-format on
     53 #    ifdef ENCODER_MAP_ENABLE
     54         const uint8_t PROGMEM encoder_hand_swap_config[NUM_ENCODERS] = {1,0};
     55 #    endif
     56 #endif