mirror of
https://github.com/RGBCube/serenity
synced 2025-05-30 11:15:06 +00:00
LibKeyboard: Use ErrorOr<T> for CharacterMap::fetch_system_map()
This commit is contained in:
parent
e76b21a66f
commit
c6cc0a88a1
2 changed files with 5 additions and 7 deletions
|
@ -40,14 +40,13 @@ int CharacterMap::set_system_map()
|
||||||
return setkeymap(m_character_map_name.characters(), 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);
|
return setkeymap(m_character_map_name.characters(), 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
Result<CharacterMap, OSError> CharacterMap::fetch_system_map()
|
ErrorOr<CharacterMap> CharacterMap::fetch_system_map()
|
||||||
{
|
{
|
||||||
CharacterMapData map_data;
|
CharacterMapData map_data;
|
||||||
char keymap_name[50 + 1] = { 0 };
|
char keymap_name[50 + 1] = { 0 };
|
||||||
|
|
||||||
if (getkeymap(keymap_name, sizeof(keymap_name), map_data.map, map_data.shift_map, map_data.alt_map, map_data.altgr_map, map_data.shift_altgr_map) < 0) {
|
if (getkeymap(keymap_name, sizeof(keymap_name), map_data.map, map_data.shift_map, map_data.alt_map, map_data.altgr_map, map_data.shift_altgr_map) < 0)
|
||||||
return OSError(errno);
|
return Error::from_errno(errno);
|
||||||
}
|
|
||||||
|
|
||||||
return CharacterMap { keymap_name, map_data };
|
return CharacterMap { keymap_name, map_data };
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,8 +7,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#ifndef KERNEL
|
#ifndef KERNEL
|
||||||
# include <AK/OSError.h>
|
# include <AK/Error.h>
|
||||||
# include <AK/Result.h>
|
|
||||||
#endif
|
#endif
|
||||||
#include <AK/String.h>
|
#include <AK/String.h>
|
||||||
#include <Kernel/API/KeyCode.h>
|
#include <Kernel/API/KeyCode.h>
|
||||||
|
@ -24,7 +23,7 @@ public:
|
||||||
|
|
||||||
#ifndef KERNEL
|
#ifndef KERNEL
|
||||||
int set_system_map();
|
int set_system_map();
|
||||||
static Result<CharacterMap, OSError> fetch_system_map();
|
static ErrorOr<CharacterMap> fetch_system_map();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
u32 get_char(KeyEvent) const;
|
u32 get_char(KeyEvent) const;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue