Skip to content

Commit

Permalink
Dedicated setting to change right Alt (AltGr) to left Alt
Browse files Browse the repository at this point in the history
  • Loading branch information
lleonini committed Aug 31, 2024
1 parent 71f612a commit 87f8116
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions keyboards/adm42/v2/keymaps/default/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ static union {
int pending_shift : 2;
bool opposite_mods_as_tap : 1;
int compose_key: 2; // DISABLED, F19, R_ALT, R_ALT (+ L_ALT replacing R_ALT)
bool ralt_as_lalt: 1;
bool error_reduction: 1;
};
} user_config;
Expand Down Expand Up @@ -109,6 +110,7 @@ enum custom_keycodes {
PEN_SHFT,
OPP_TOGG,
COMP_SEL,
ALT_SEL,
ERE_TOGG,
};

Expand Down Expand Up @@ -175,7 +177,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[_SETUP] = LAYOUT_3x12_6(
REFLASH, XXXXXXX, DF_COMK, XXXXXXX, XXXXXXX, XXXXXXX, PEN_WIN, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, ADM_INF,
XXXXXXX, DF_QWER, DF_CODH, DF_DVRK, DF_CUST, XXXXXXX, PEN_CTRL, OPP_TOGG, ERE_TOGG, XXXXXXX, XXXXXXX, XXXXXXX,
XXXXXXX, XXXXXXX, DF_COMX, XXXXXXX, XXXXXXX, XXXXXXX, PEN_ALT, XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, EE_CLR,
XXXXXXX, XXXXXXX, DF_COMX, XXXXXXX, XXXXXXX, XXXXXXX, PEN_ALT, ALT_SEL, XXXXXXX, XXXXXXX, XXXXXXX, EE_CLR,
XXXXXXX, XXXXXXX, XXXXXXX, XXXXXXX, PEN_SHFT, COMP_SEL
),
};
Expand Down Expand Up @@ -586,15 +588,16 @@ void adm_info(void) {
}

PK("* Compose key: ");
if (user_config.compose_key == 3) {
PK("R_ALT (+ L_ALT replacing R_ALT)\n");
} else if (user_config.compose_key == 2) {
if (user_config.compose_key == 2) {
PK("R_ALT\n");
} else if (user_config.compose_key == 1) {
PK("F19\n");
} else {
PK("DISABLED\n");
}
if (user_config.ralt_as_lalt) {
PK("* R_ALT as L_ALT\n");
}

#if defined(NKRO_ENABLE) && defined(FORCE_NKRO)
PK("* NKRO");
Expand Down Expand Up @@ -792,10 +795,8 @@ void lt_release(uint16_t key) {
}

void config_compose(void) {
MODTAP(RA_ZIN).mod = KC_RALT;
if (user_config.compose_key == 3) {
LAYERTAP(LLS_COMP).tap = KC_RALT;
MODTAP(RA_ZIN).mod = KC_LALT;
} else if (user_config.compose_key == 2) {
LAYERTAP(LLS_COMP).tap = KC_RALT;
} else if (user_config.compose_key == 1) {
Expand Down Expand Up @@ -971,8 +972,14 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
adm_info();
return false;

case ALT_SEL:
user_config.ralt_as_lalt = !user_config.ralt_as_lalt;
MODTAP(RA_ZIN).mod = (user_config.ralt_as_lalt) ? KC_LALT : KC_RALT;
eeconfig_update_user(user_config.raw);
return false;

case COMP_SEL:
if (user_config.compose_key == 3) {
if (user_config.compose_key == 2) {
user_config.compose_key = 0;
} else {
user_config.compose_key++;
Expand Down Expand Up @@ -1088,7 +1095,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
register_code(LAYERTAP(LLS_COMP).tap);
return false;
case LOR_ALT:
register_code((user_config.compose_key == 3) ? KC_LALT : KC_RALT);
register_code((user_config.ralt_as_lalt) ? KC_LALT : KC_RALT);
return false;
}
} else {
Expand All @@ -1097,7 +1104,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
unregister_code(LAYERTAP(LLS_COMP).tap);
return false;
case LOR_ALT:
unregister_code((user_config.compose_key == 3) ? KC_LALT : KC_RALT);
unregister_code((user_config.ralt_as_lalt) ? KC_LALT : KC_RALT);
return false;
}
}
Expand Down Expand Up @@ -1127,6 +1134,7 @@ void keyboard_post_init_kb(void) {
rgb_up();

user_config.raw = eeconfig_read_user();
MODTAP(RA_ZIN).mod = (user_config.ralt_as_lalt) ? KC_LALT : KC_RALT;
config_compose();
config_pending();
}
Expand All @@ -1139,6 +1147,7 @@ void eeconfig_init_user(void) {
user_config.pending_shift = 1;
user_config.opposite_mods_as_tap = 1;
user_config.compose_key = 0;
user_config.ralt_as_lalt = false;
user_config.error_reduction = 0;
eeconfig_update_user(user_config.raw);
}
Expand Down

0 comments on commit 87f8116

Please sign in to comment.