mirror of
https://github.com/RGBCube/serenity
synced 2025-05-30 22:58:12 +00:00
CharacterMap: Added a new Shift+AltGr map.
If this map isn't found in a keymap the Alt+Gr map gets used.
This commit is contained in:
parent
ca9e0a70f5
commit
f146ff87f1
3 changed files with 24 additions and 4 deletions
|
@ -50,7 +50,7 @@ CharacterMap::CharacterMap(const String& file_name)
|
||||||
|
|
||||||
int CharacterMap::set_system_map()
|
int CharacterMap::set_system_map()
|
||||||
{
|
{
|
||||||
Syscall::SC_setkeymap_params params { m_character_map_data.map, m_character_map_data.shift_map, m_character_map_data.alt_map, m_character_map_data.altgr_map, { m_character_map_name.characters(), m_character_map_name.length() } };
|
Syscall::SC_setkeymap_params params { m_character_map_data.map, m_character_map_data.shift_map, m_character_map_data.alt_map, m_character_map_data.altgr_map, m_character_map_data.shift_altgr_map, { m_character_map_name.characters(), m_character_map_name.length() } };
|
||||||
return syscall(SC_setkeymap, ¶ms);
|
return syscall(SC_setkeymap, ¶ms);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,10 +63,12 @@ u32 CharacterMap::get_char(KeyEvent event)
|
||||||
auto caps_lock_on = event.caps_lock_on;
|
auto caps_lock_on = event.caps_lock_on;
|
||||||
|
|
||||||
u32 code_point;
|
u32 code_point;
|
||||||
if (modifiers & Mod_Shift)
|
if (modifiers & Mod_Alt)
|
||||||
code_point = m_character_map_data.shift_map[index];
|
|
||||||
else if (modifiers & Mod_Alt)
|
|
||||||
code_point = m_character_map_data.alt_map[index];
|
code_point = m_character_map_data.alt_map[index];
|
||||||
|
else if ((modifiers & Mod_Shift) && (modifiers & Mod_AltGr))
|
||||||
|
code_point = m_character_map_data.shift_altgr_map[index];
|
||||||
|
else if (modifiers & Mod_Shift)
|
||||||
|
code_point = m_character_map_data.shift_map[index];
|
||||||
else if (modifiers & Mod_AltGr)
|
else if (modifiers & Mod_AltGr)
|
||||||
code_point = m_character_map_data.altgr_map[index];
|
code_point = m_character_map_data.altgr_map[index];
|
||||||
else
|
else
|
||||||
|
|
|
@ -37,6 +37,7 @@ struct CharacterMapData {
|
||||||
u32 shift_map[CHAR_MAP_SIZE];
|
u32 shift_map[CHAR_MAP_SIZE];
|
||||||
u32 alt_map[CHAR_MAP_SIZE];
|
u32 alt_map[CHAR_MAP_SIZE];
|
||||||
u32 altgr_map[CHAR_MAP_SIZE];
|
u32 altgr_map[CHAR_MAP_SIZE];
|
||||||
|
u32 shift_altgr_map[CHAR_MAP_SIZE];
|
||||||
};
|
};
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
|
@ -85,6 +86,16 @@ static const CharacterMapData default_character_map =
|
||||||
//60 70 80
|
//60 70 80
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '7', '8', '9', '-', '4', '5', '6', '+', '1', '2', '3', '0', '.', 0, 0, '\\', 0, 0, 0,
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '7', '8', '9', '-', '4', '5', '6', '+', '1', '2', '3', '0', '.', 0, 0, '\\', 0, 0, 0,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
.shift_altgr_map = {
|
||||||
|
0, '\033', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=', 0x08,
|
||||||
|
'\t', 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', '[', ']', '\n',
|
||||||
|
0, 'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', '\'', '`', 0,
|
||||||
|
'\\', 'z', 'x', 'c', 'v', 'b', 'n', 'm', ',', '.', '/', 0, '*', 0,
|
||||||
|
' ', 0, 0,
|
||||||
|
//60 70 80
|
||||||
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '7', '8', '9', '-', '4', '5', '6', '+', '1', '2', '3', '0', '.', 0, 0, '\\', 0, 0, 0,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
|
|
|
@ -59,6 +59,7 @@ Optional<CharacterMapData> CharacterMapFile::load_from_file(const String& file_n
|
||||||
Vector<u32> shift_map = read_map(json, "shift_map");
|
Vector<u32> shift_map = read_map(json, "shift_map");
|
||||||
Vector<u32> alt_map = read_map(json, "alt_map");
|
Vector<u32> alt_map = read_map(json, "alt_map");
|
||||||
Vector<u32> altgr_map = read_map(json, "altgr_map");
|
Vector<u32> altgr_map = read_map(json, "altgr_map");
|
||||||
|
Vector<u32> shift_altgr_map = read_map(json, "shift_altgr_map");
|
||||||
|
|
||||||
CharacterMapData character_map;
|
CharacterMapData character_map;
|
||||||
for (int i = 0; i < CHAR_MAP_SIZE; i++) {
|
for (int i = 0; i < CHAR_MAP_SIZE; i++) {
|
||||||
|
@ -71,6 +72,12 @@ Optional<CharacterMapData> CharacterMapFile::load_from_file(const String& file_n
|
||||||
} else {
|
} else {
|
||||||
character_map.altgr_map[i] = altgr_map.at(i);
|
character_map.altgr_map[i] = altgr_map.at(i);
|
||||||
}
|
}
|
||||||
|
if (shift_altgr_map.is_empty()) {
|
||||||
|
// Shift+AltGr map was not found, using Alt map as fallback.
|
||||||
|
character_map.shift_altgr_map[i] = alt_map.at(i);
|
||||||
|
} else {
|
||||||
|
character_map.shift_altgr_map[i] = shift_altgr_map.at(i);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return character_map;
|
return character_map;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue