diff options
Diffstat (limited to 'Userland/Libraries/LibKeyboard/CharacterMap.cpp')
-rw-r--r-- | Userland/Libraries/LibKeyboard/CharacterMap.cpp | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/Userland/Libraries/LibKeyboard/CharacterMap.cpp b/Userland/Libraries/LibKeyboard/CharacterMap.cpp index 9d5b186383..3ea6604df2 100644 --- a/Userland/Libraries/LibKeyboard/CharacterMap.cpp +++ b/Userland/Libraries/LibKeyboard/CharacterMap.cpp @@ -33,17 +33,23 @@ namespace Keyboard { -CharacterMap::CharacterMap(const String& file_name) +CharacterMap::CharacterMap(const String& map_name) { #ifdef KERNEL m_character_map_data = default_character_map; #else - auto result = CharacterMapFile::load_from_file(file_name); + auto result = CharacterMapFile::load_from_file(map_name); ASSERT(result.has_value()); m_character_map_data = result.value(); #endif - m_character_map_name = file_name; + m_character_map_name = map_name; +} + +CharacterMap::CharacterMap(const String& map_name, const CharacterMapData& map_data) + : m_character_map_data(map_data) + , m_character_map_name(map_name) +{ } #ifndef KERNEL @@ -54,6 +60,26 @@ int CharacterMap::set_system_map() return syscall(SC_setkeymap, ¶ms); } +Result<CharacterMap, OSError> CharacterMap::fetch_system_map() +{ + CharacterMapData map_data; + char keymap_name[50 + 1] = { 0 }; + + Syscall::SC_getkeymap_params params { + map_data.map, map_data.shift_map, + map_data.alt_map, + map_data.altgr_map, + map_data.shift_altgr_map, + { keymap_name, sizeof(keymap_name) } + }; + int rc = syscall(SC_getkeymap, ¶ms); + if (rc < 0) { + return OSError(-rc); + } + + return CharacterMap { keymap_name, map_data }; +} + #endif u32 CharacterMap::get_char(KeyEvent event) |