jian/rev1: convert to DIP Switch (#22248)

master
Ryan 2023-10-14 07:02:44 +11:00 committed by GitHub
parent 527a4ee846
commit 539c8e3b72
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 77 additions and 90 deletions

View File

@ -24,3 +24,5 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
//#define AUTO_SHIFT_MODIFIERS //#define AUTO_SHIFT_MODIFIERS
#define ALT_LAYOUTS_ENABLE #define ALT_LAYOUTS_ENABLE
//#define TRAINING_HALFES_LOCK //#define TRAINING_HALFES_LOCK
#define LAYER_STATE_32BIT

View File

@ -86,9 +86,6 @@ enum jian_layers {
_LEFT, _LEFT,
_RIGHT, _RIGHT,
#endif //TRAINING_HALFES_LOCK #endif //TRAINING_HALFES_LOCK
#ifdef DIPS_ENABLE
_DIPS,
#endif // DIPS_ENABLE
#ifdef STENO_ENABLE #ifdef STENO_ENABLE
_PLOVER _PLOVER
#endif // STENO_ENABLE #endif // STENO_ENABLE
@ -107,7 +104,7 @@ enum jian_keycodes {
CH_QWE, CH_QWE,
CH_DVK, CH_DVK,
//endif // ALT_LAYOUTS_ENABLE //endif // ALT_LAYOUTS_ENABLE
#ifdef DIPS_ENABLE #ifdef DIP_SWITCH_ENABLE
LAYOUT0, LAYOUT0,
LAYOUT1, LAYOUT1,
LAYOUT2, LAYOUT2,
@ -120,18 +117,18 @@ enum jian_keycodes {
DIP9, DIP9,
DIP10, DIP10,
DIP11, DIP11,
#endif // DIPS_ENABLE #endif // DIP_SWITCH_ENABLE
}; };
#ifdef TRAINING_HALFES_LOCK #ifdef TRAINING_HALFES_LOCK
static uint8_t lock_timeout = 1; static uint8_t lock_timeout = 1;
static uint8_t lock_cooldown = 0; static uint8_t lock_cooldown = 0;
#endif //TRAINING_HALFES_LOCK #endif //TRAINING_HALFES_LOCK
#ifdef DIPS_ENABLE #ifdef DIP_SWITCH_ENABLE
#ifdef ALT_LAYOUTS_ENABLE #ifdef ALT_LAYOUTS_ENABLE
static uint8_t layout_conversion_dip_state = 0; static uint8_t layout_conversion_dip_state = 0;
#endif // ALT_LAYOUTS_ENABLE #endif // ALT_LAYOUTS_ENABLE
#endif // DIPS_ENABLE #endif // DIP_SWITCH_ENABLE
#define LOWER MO(_LOWER) #define LOWER MO(_LOWER)
#define RAISE MO(_RAISE) #define RAISE MO(_RAISE)
@ -190,13 +187,6 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[_QWERTY] = LAYOUT_base_wrapper(QWERTY_base), [_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( [_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, _______, 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, 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); return update_tri_layer_state(state, _LOWER, _RAISE, _ADJUST);
} }
#ifdef DIPS_ENABLE #ifdef DIP_SWITCH_ENABLE
#ifdef ALT_LAYOUTS_ENABLE #ifdef ALT_LAYOUTS_ENABLE
void layout_convert(uint8_t statuses) { void layout_convert(uint8_t statuses) {
switch (0b1111 & statuses) { switch (0b1111 & statuses) {
@ -337,13 +327,7 @@ void layout_convert(uint8_t statuses) {
} }
} }
#endif // ALT_LAYOUTS_ENABLE #endif // ALT_LAYOUTS_ENABLE
#endif // DIPS_ENABLE #endif // DIP_SWITCH_ENABLE
void matrix_init_user(void) {
#ifdef DIPS_ENABLE
layer_on(_DIPS);
#endif // DIPS_ENABLE
}
void keyboard_post_init_user(void) { void keyboard_post_init_user(void) {
user_config.raw = eeconfig_read_user(); user_config.raw = eeconfig_read_user();
@ -515,56 +499,6 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
} }
return false; return false;
#endif // ALT_LAYOUTS_ENABLE #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: case THUMB_ALT:
if (record->event.pressed) { if (record->event.pressed) {
layer_invert(_THUMB_ALT); layer_invert(_THUMB_ALT);
@ -582,3 +516,66 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
} }
return true; 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

View File

@ -25,7 +25,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define EE_HANDS #define EE_HANDS
// different Jian configs // different Jian configs
#define DIPS_ENABLE
#define PHYSICAL_LEDS_ENABLE #define PHYSICAL_LEDS_ENABLE
#define NUM_LOCK_LED_PIN C6 #define NUM_LOCK_LED_PIN C6
#define CAPS_LOCK_LED_PIN D7 #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 // iOS device need lessthan 100
#define USB_MAX_POWER_CONSUMPTION 100 #define USB_MAX_POWER_CONSUMPTION 100
#endif #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} \
}

View File

@ -90,23 +90,6 @@
{"matrix": [7, 5], "x": 10, "y": 3.375}, {"matrix": [7, 5], "x": 10, "y": 3.375},
{"matrix": [7, 4], "x": 11, "y": 3.25} {"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}
]
} }
} }
} }

View File

@ -5,3 +5,4 @@ CONSOLE_ENABLE = no
SPLIT_KEYBOARD = yes SPLIT_KEYBOARD = yes
BACKLIGHT_ENABLE = yes BACKLIGHT_ENABLE = yes
RGBLIGHT_ENABLE = yes RGBLIGHT_ENABLE = yes
DIP_SWITCH_ENABLE = yes