mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-23 17:52:26 -05:00
Kernel+LibKeyboard: Store the keymap name when setting system keymap
This way we can query the kernel to see which keymap is currently in use.
This commit is contained in:
parent
8dd0c391e9
commit
00a0e525e6
Notes:
sideshowbarker
2024-07-19 04:13:23 +09:00
Author: https://github.com/vkoskiv Commit: https://github.com/SerenityOS/serenity/commit/00a0e525e68 Pull-request: https://github.com/SerenityOS/serenity/pull/3021 Issue: https://github.com/SerenityOS/serenity/issues/2684 Reviewed-by: https://github.com/awesomekling
6 changed files with 32 additions and 6 deletions
|
@ -342,6 +342,7 @@ struct SC_setkeymap_params {
|
||||||
Userspace<const u32*> shift_map;
|
Userspace<const u32*> shift_map;
|
||||||
Userspace<const u32*> alt_map;
|
Userspace<const u32*> alt_map;
|
||||||
Userspace<const u32*> altgr_map;
|
Userspace<const u32*> altgr_map;
|
||||||
|
StringArgument map_name;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SC_create_thread_params {
|
struct SC_create_thread_params {
|
||||||
|
|
|
@ -391,10 +391,11 @@ KeyboardClient::~KeyboardClient()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void KeyboardDevice::set_maps(Keyboard::CharacterMapData character_map_data)
|
void KeyboardDevice::set_maps(const Keyboard::CharacterMapData& character_map_data, const String& character_map_name)
|
||||||
{
|
{
|
||||||
m_character_map.set_character_map_data(character_map_data);
|
m_character_map.set_character_map_data(character_map_data);
|
||||||
dbg() << "New Character map passing to client.";
|
m_character_map.set_character_map_name(character_map_name);
|
||||||
|
dbg() << "New Character map \"" << character_map_name << "\" passing to client.";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,7 +51,9 @@ public:
|
||||||
KeyboardDevice();
|
KeyboardDevice();
|
||||||
|
|
||||||
void set_client(KeyboardClient* client) { m_client = client; }
|
void set_client(KeyboardClient* client) { m_client = client; }
|
||||||
void set_maps(Keyboard::CharacterMapData character_map);
|
void set_maps(const Keyboard::CharacterMapData& character_map, const String& character_map_name);
|
||||||
|
|
||||||
|
const String keymap_name() { return m_character_map.character_map_name(); }
|
||||||
|
|
||||||
// ^CharacterDevice
|
// ^CharacterDevice
|
||||||
virtual KResultOr<size_t> read(FileDescription&, size_t, u8*, size_t) override;
|
virtual KResultOr<size_t> read(FileDescription&, size_t, u8*, size_t) override;
|
||||||
|
|
|
@ -56,7 +56,16 @@ int Process::sys$setkeymap(Userspace<const Syscall::SC_setkeymap_params*> user_p
|
||||||
copy_from_user(character_map_data.alt_map, params.alt_map, CHAR_MAP_SIZE * sizeof(u32));
|
copy_from_user(character_map_data.alt_map, params.alt_map, CHAR_MAP_SIZE * sizeof(u32));
|
||||||
copy_from_user(character_map_data.altgr_map, params.altgr_map, CHAR_MAP_SIZE * sizeof(u32));
|
copy_from_user(character_map_data.altgr_map, params.altgr_map, CHAR_MAP_SIZE * sizeof(u32));
|
||||||
|
|
||||||
KeyboardDevice::the().set_maps(character_map_data);
|
auto map_name = get_syscall_path_argument(params.map_name);
|
||||||
|
if (map_name.is_error()) {
|
||||||
|
return map_name.error();
|
||||||
|
}
|
||||||
|
constexpr size_t map_name_max_size = 50;
|
||||||
|
if (map_name.value().length() > map_name_max_size) {
|
||||||
|
return -ENAMETOOLONG;
|
||||||
|
}
|
||||||
|
|
||||||
|
KeyboardDevice::the().set_maps(character_map_data, map_name.value());
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,6 @@ namespace Keyboard {
|
||||||
CharacterMap::CharacterMap(const String& file_name)
|
CharacterMap::CharacterMap(const String& file_name)
|
||||||
{
|
{
|
||||||
#ifdef KERNEL
|
#ifdef KERNEL
|
||||||
UNUSED_PARAM(file_name);
|
|
||||||
m_character_map_data = default_character_map;
|
m_character_map_data = default_character_map;
|
||||||
#else
|
#else
|
||||||
auto result = CharacterMapFile::load_from_file(file_name);
|
auto result = CharacterMapFile::load_from_file(file_name);
|
||||||
|
@ -44,13 +43,14 @@ CharacterMap::CharacterMap(const String& file_name)
|
||||||
|
|
||||||
m_character_map_data = result.value();
|
m_character_map_data = result.value();
|
||||||
#endif
|
#endif
|
||||||
|
m_character_map_name = file_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef KERNEL
|
#ifndef KERNEL
|
||||||
|
|
||||||
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 };
|
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() } };
|
||||||
return syscall(SC_setkeymap, ¶ms);
|
return syscall(SC_setkeymap, ¶ms);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,4 +92,13 @@ void CharacterMap::set_character_map_data(CharacterMapData character_map_data)
|
||||||
m_character_map_data = character_map_data;
|
m_character_map_data = character_map_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CharacterMap::set_character_map_name(const String& character_map_name)
|
||||||
|
{
|
||||||
|
m_character_map_name = character_map_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
const String CharacterMap::character_map_name()
|
||||||
|
{
|
||||||
|
return m_character_map_name;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,9 +43,13 @@ public:
|
||||||
|
|
||||||
u32 get_char(KeyEvent);
|
u32 get_char(KeyEvent);
|
||||||
void set_character_map_data(CharacterMapData character_map_data);
|
void set_character_map_data(CharacterMapData character_map_data);
|
||||||
|
void set_character_map_name(const String& character_map_name);
|
||||||
|
|
||||||
|
const String character_map_name();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CharacterMapData m_character_map_data;
|
CharacterMapData m_character_map_data;
|
||||||
|
String m_character_map_name;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue