cellKbCnvRawCode: don't use caps lock as shift lock unless we are using the qwertz or azerty layout

This commit is contained in:
Megamouse 2024-05-25 23:19:08 +02:00
parent 4bc719470c
commit c0ed56cba0
1 changed files with 5 additions and 3 deletions

View File

@ -177,6 +177,7 @@ u16 cellKbCnvRawCode(u32 arrange, u32 mkey, u32 led, u16 rawcode)
const bool is_shift = mkey & (CELL_KB_MKEY_L_SHIFT | CELL_KB_MKEY_R_SHIFT);
const bool is_caps_lock = led & (CELL_KB_LED_CAPS_LOCK);
const bool is_num_lock = led & (CELL_KB_LED_NUM_LOCK);
const bool is_shift_lock = is_caps_lock && (arrange == CELL_KB_MAPPING_GERMAN_GERMANY || arrange == CELL_KB_MAPPING_FRENCH_FRANCE);
// CELL_KB_NUMPAD
@ -194,13 +195,14 @@ u16 cellKbCnvRawCode(u32 arrange, u32 mkey, u32 led, u16 rawcode)
// ASCII
const auto get_ascii = [is_alt, is_shift, is_caps_lock](u16 raw, u16 shifted = 0, u16 altered = 0)
const auto get_ascii = [&](u16 raw, u16 shifted = 0, u16 altered = 0)
{
if ((is_shift || is_caps_lock) && shifted)
// Usually caps lock only applies uppercase to letters, but some layouts treat it as shift lock for all keys.
if ((is_shift || (is_caps_lock && (is_shift_lock || std::isalpha(raw)))) && shifted)
{
return shifted;
}
else if (is_alt && altered)
if (is_alt && altered)
{
return altered;
}