mirror of
https://github.com/Keychron/qmk_firmware.git
synced 2024-11-25 01:47:10 +06:00
jian/rev1: convert to DIP Switch (#22248)
This commit is contained in:
parent
527a4ee846
commit
539c8e3b72
|
@ -24,3 +24,5 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
//#define AUTO_SHIFT_MODIFIERS
|
||||
#define ALT_LAYOUTS_ENABLE
|
||||
//#define TRAINING_HALFES_LOCK
|
||||
|
||||
#define LAYER_STATE_32BIT
|
||||
|
|
|
@ -86,9 +86,6 @@ enum jian_layers {
|
|||
_LEFT,
|
||||
_RIGHT,
|
||||
#endif //TRAINING_HALFES_LOCK
|
||||
#ifdef DIPS_ENABLE
|
||||
_DIPS,
|
||||
#endif // DIPS_ENABLE
|
||||
#ifdef STENO_ENABLE
|
||||
_PLOVER
|
||||
#endif // STENO_ENABLE
|
||||
|
@ -107,7 +104,7 @@ enum jian_keycodes {
|
|||
CH_QWE,
|
||||
CH_DVK,
|
||||
//endif // ALT_LAYOUTS_ENABLE
|
||||
#ifdef DIPS_ENABLE
|
||||
#ifdef DIP_SWITCH_ENABLE
|
||||
LAYOUT0,
|
||||
LAYOUT1,
|
||||
LAYOUT2,
|
||||
|
@ -120,18 +117,18 @@ enum jian_keycodes {
|
|||
DIP9,
|
||||
DIP10,
|
||||
DIP11,
|
||||
#endif // DIPS_ENABLE
|
||||
#endif // DIP_SWITCH_ENABLE
|
||||
};
|
||||
|
||||
#ifdef TRAINING_HALFES_LOCK
|
||||
static uint8_t lock_timeout = 1;
|
||||
static uint8_t lock_cooldown = 0;
|
||||
#endif //TRAINING_HALFES_LOCK
|
||||
#ifdef DIPS_ENABLE
|
||||
#ifdef DIP_SWITCH_ENABLE
|
||||
#ifdef ALT_LAYOUTS_ENABLE
|
||||
static uint8_t layout_conversion_dip_state = 0;
|
||||
#endif // ALT_LAYOUTS_ENABLE
|
||||
#endif // DIPS_ENABLE
|
||||
#endif // DIP_SWITCH_ENABLE
|
||||
|
||||
#define LOWER MO(_LOWER)
|
||||
#define RAISE MO(_RAISE)
|
||||
|
@ -190,13 +187,6 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
|
|||
|
||||
[_QWERTY] = LAYOUT_base_wrapper(QWERTY_base),
|
||||
|
||||
#ifdef DIPS_ENABLE
|
||||
[_DIPS] = LAYOUT_dips(
|
||||
LAYOUT0, LAYOUT1, LAYOUT2, LAYOUT3, DIP_ISO, FLIP_TH,
|
||||
LAYOUT0, LAYOUT1, LAYOUT2, LAYOUT3, DIP_ISO, FLIP_TH
|
||||
),
|
||||
#endif // DIPS_ENABLE
|
||||
|
||||
[_LOWER] = LAYOUT(
|
||||
_______, KC_UNDS, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, F12_RGU,
|
||||
EQL_LCT, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, MIN_RCT,
|
||||
|
@ -282,7 +272,7 @@ layer_state_t layer_state_set_user(layer_state_t state) {
|
|||
return update_tri_layer_state(state, _LOWER, _RAISE, _ADJUST);
|
||||
}
|
||||
|
||||
#ifdef DIPS_ENABLE
|
||||
#ifdef DIP_SWITCH_ENABLE
|
||||
#ifdef ALT_LAYOUTS_ENABLE
|
||||
void layout_convert(uint8_t statuses) {
|
||||
switch (0b1111 & statuses) {
|
||||
|
@ -337,13 +327,7 @@ void layout_convert(uint8_t statuses) {
|
|||
}
|
||||
}
|
||||
#endif // ALT_LAYOUTS_ENABLE
|
||||
#endif // DIPS_ENABLE
|
||||
|
||||
void matrix_init_user(void) {
|
||||
#ifdef DIPS_ENABLE
|
||||
layer_on(_DIPS);
|
||||
#endif // DIPS_ENABLE
|
||||
}
|
||||
#endif // DIP_SWITCH_ENABLE
|
||||
|
||||
void keyboard_post_init_user(void) {
|
||||
user_config.raw = eeconfig_read_user();
|
||||
|
@ -515,56 +499,6 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
|||
}
|
||||
return false;
|
||||
#endif // ALT_LAYOUTS_ENABLE
|
||||
#ifdef DIPS_ENABLE
|
||||
#ifdef ALT_LAYOUTS_ENABLE
|
||||
case LAYOUT0:
|
||||
if (record->event.pressed) {
|
||||
layout_conversion_dip_state |= 1 << 0;
|
||||
} else {
|
||||
layout_conversion_dip_state &= ~(1 << 0);
|
||||
}
|
||||
layout_convert(layout_conversion_dip_state);
|
||||
return false;
|
||||
case LAYOUT1:
|
||||
if (record->event.pressed) {
|
||||
layout_conversion_dip_state |= 1 << 1;
|
||||
} else {
|
||||
layout_conversion_dip_state &= ~(1 << 1);
|
||||
}
|
||||
layout_convert(layout_conversion_dip_state);
|
||||
return false;
|
||||
case LAYOUT2:
|
||||
if (record->event.pressed) {
|
||||
layout_conversion_dip_state |= 1 << 2;
|
||||
} else {
|
||||
layout_conversion_dip_state &= ~(1 << 2);
|
||||
}
|
||||
layout_convert(layout_conversion_dip_state);
|
||||
return false;
|
||||
case LAYOUT3:
|
||||
if (record->event.pressed) {
|
||||
layout_conversion_dip_state |= 1 << 3;
|
||||
} else {
|
||||
layout_conversion_dip_state &= ~(1 << 3);
|
||||
}
|
||||
layout_convert(layout_conversion_dip_state);
|
||||
return false;
|
||||
#endif // ALT_LAYOUTS_ENABLE
|
||||
case DIP_ISO:
|
||||
if (record->event.pressed) {
|
||||
layer_on(_ISO);
|
||||
} else {
|
||||
layer_off(_ISO);
|
||||
}
|
||||
return false;
|
||||
case FLIP_TH:
|
||||
if (record->event.pressed) {
|
||||
layer_on(_THUMB_ALT);
|
||||
} else {
|
||||
layer_off(_THUMB_ALT);
|
||||
}
|
||||
return false;
|
||||
#endif // DIPS_ENABLE
|
||||
case THUMB_ALT:
|
||||
if (record->event.pressed) {
|
||||
layer_invert(_THUMB_ALT);
|
||||
|
@ -582,3 +516,66 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
#if defined(DIP_SWITCH_ENABLE)
|
||||
bool dip_switch_update_user(uint8_t index, bool active) {
|
||||
switch (index) {
|
||||
# if defined(ALT_LAYOUTS_ENABLE)
|
||||
case 0: // LAYOUT0
|
||||
case 6:
|
||||
if (active) {
|
||||
layout_conversion_dip_state |= 1 << 0;
|
||||
} else {
|
||||
layout_conversion_dip_state &= ~(1 << 0);
|
||||
}
|
||||
layout_convert(layout_conversion_dip_state);
|
||||
break;
|
||||
case 1: // LAYOUT1
|
||||
case 7:
|
||||
if (active) {
|
||||
layout_conversion_dip_state |= 1 << 1;
|
||||
} else {
|
||||
layout_conversion_dip_state &= ~(1 << 1);
|
||||
}
|
||||
layout_convert(layout_conversion_dip_state);
|
||||
break;
|
||||
case 2: // LAYOUT2
|
||||
case 8:
|
||||
if (active) {
|
||||
layout_conversion_dip_state |= 1 << 2;
|
||||
} else {
|
||||
layout_conversion_dip_state &= ~(1 << 2);
|
||||
}
|
||||
layout_convert(layout_conversion_dip_state);
|
||||
break;
|
||||
case 3: // LAYOUT3
|
||||
case 9:
|
||||
if (active) {
|
||||
layout_conversion_dip_state |= 1 << 3;
|
||||
} else {
|
||||
layout_conversion_dip_state &= ~(1 << 3);
|
||||
}
|
||||
layout_convert(layout_conversion_dip_state);
|
||||
break;
|
||||
case 4: // DIP_ISO
|
||||
case 10:
|
||||
if (active) {
|
||||
layer_on(_ISO);
|
||||
} else {
|
||||
layer_off(_ISO);
|
||||
}
|
||||
break;
|
||||
case 5: // FLIP_TH
|
||||
case 11:
|
||||
if (active) {
|
||||
layer_on(_THUMB_ALT);
|
||||
} else {
|
||||
layer_off(_THUMB_ALT);
|
||||
}
|
||||
break;
|
||||
# endif
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -25,7 +25,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#define EE_HANDS
|
||||
|
||||
// different Jian configs
|
||||
#define DIPS_ENABLE
|
||||
#define PHYSICAL_LEDS_ENABLE
|
||||
#define NUM_LOCK_LED_PIN C6
|
||||
#define CAPS_LOCK_LED_PIN D7
|
||||
|
@ -79,3 +78,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
// iOS device need lessthan 100
|
||||
#define USB_MAX_POWER_CONSUMPTION 100
|
||||
#endif
|
||||
|
||||
#define DIP_SWITCH_MATRIX_GRID { \
|
||||
{1, 0}, {2, 0}, {3, 0}, {3, 1}, {3, 2}, {3, 3}, \
|
||||
{7, 3}, {7, 2}, {7, 1}, {7, 0}, {6, 0}, {5, 0} \
|
||||
}
|
||||
|
|
|
@ -90,23 +90,6 @@
|
|||
{"matrix": [7, 5], "x": 10, "y": 3.375},
|
||||
{"matrix": [7, 4], "x": 11, "y": 3.25}
|
||||
]
|
||||
},
|
||||
"LAYOUT_dips": {
|
||||
"layout": [
|
||||
{"matrix": [1, 0], "x": 0, "y": 0},
|
||||
{"matrix": [2, 0], "x": 1, "y": 0},
|
||||
{"matrix": [3, 0], "x": 2, "y": 0},
|
||||
{"matrix": [3, 1], "x": 3, "y": 0},
|
||||
{"matrix": [3, 2], "x": 4, "y": 0},
|
||||
{"matrix": [3, 3], "x": 5, "y": 0},
|
||||
|
||||
{"matrix": [7, 3], "x": 6, "y": 0},
|
||||
{"matrix": [7, 2], "x": 7, "y": 0},
|
||||
{"matrix": [7, 1], "x": 8, "y": 0},
|
||||
{"matrix": [7, 0], "x": 9, "y": 0},
|
||||
{"matrix": [6, 0], "x": 10, "y": 0},
|
||||
{"matrix": [5, 0], "x": 11, "y": 0}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,3 +5,4 @@ CONSOLE_ENABLE = no
|
|||
SPLIT_KEYBOARD = yes
|
||||
BACKLIGHT_ENABLE = yes
|
||||
RGBLIGHT_ENABLE = yes
|
||||
DIP_SWITCH_ENABLE = yes
|
||||
|
|
Loading…
Reference in New Issue
Block a user