summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Kernel/Devices/KeyboardDevice.cpp17
-rw-r--r--Kernel/Devices/KeyboardDevice.h2
-rw-r--r--Kernel/KeyCode.h4
-rw-r--r--Kernel/Process.cpp15
-rw-r--r--Kernel/Process.h2
-rw-r--r--Kernel/Syscall.h7
6 files changed, 34 insertions, 13 deletions
diff --git a/Kernel/Devices/KeyboardDevice.cpp b/Kernel/Devices/KeyboardDevice.cpp
index 060431419b..00df52ab4f 100644
--- a/Kernel/Devices/KeyboardDevice.cpp
+++ b/Kernel/Devices/KeyboardDevice.cpp
@@ -20,6 +20,7 @@
char *map;
char *shift_map;
char *alt_map;
+char *altgr_map;
static char en_map[0x80] = {
0, '\033', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=', 0x08, '\t',
@@ -246,7 +247,7 @@ static KeyCode numpad_key_map[13] = { Key_7, Key_8, Key_9, Key_Invalid, Key_4, K
void KeyboardDevice::key_state_changed(u8 raw, bool pressed)
{
KeyCode key = (m_modifiers & Mod_Shift) ? shifted_key_map[raw] : unshifted_key_map[raw];
- char character = (m_modifiers & Mod_Shift) ? shift_map[raw]: (m_modifiers & Mod_Alt) ? alt_map[raw] : map[raw];
+ char character = (m_modifiers & Mod_Shift) ? shift_map[raw] : (m_modifiers & Mod_Alt) ? alt_map[raw] : (m_modifiers & Mod_AltGr) ? altgr_map[raw] : map[raw];
if (key == Key_NumLock && pressed)
m_num_lock_on = !m_num_lock_on;
@@ -318,7 +319,10 @@ void KeyboardDevice::handle_irq()
#endif
switch (ch) {
case 0x38:
- update_modifier(Mod_Alt, pressed);
+ if (m_has_e0_prefix)
+ update_modifier(Mod_AltGr, pressed);
+ else
+ update_modifier(Mod_Alt, pressed);
break;
case 0x1d:
update_modifier(Mod_Ctrl, pressed);
@@ -368,7 +372,7 @@ KeyboardDevice::KeyboardDevice()
{
s_the = this;
- KeyboardDevice::set_maps(en_map, en_shift_map, en_map);
+ KeyboardDevice::set_maps(en_map, en_shift_map, en_map, en_map);
// Empty the buffer of any pending data.
// I don't care what you've been pressing until now!
@@ -412,19 +416,22 @@ KeyboardClient::~KeyboardClient()
{
}
-void KeyboardDevice::set_maps(char* n_map, char* n_shift_map, char* n_alt_map)
+void KeyboardDevice::set_maps(const char* n_map, const char* n_shift_map, const char* n_alt_map, const char* n_altgr_map)
{
kfree(map);
kfree(shift_map);
kfree(alt_map);
+ kfree(altgr_map);
map = (char*) kmalloc(0x80);
shift_map = (char*) kmalloc(0x80);
alt_map = (char*) kmalloc(0x80);
+ altgr_map = (char*) kmalloc(0x80);
for(int i=0; i < 0x80; i++) {
map[i] = n_map[i];
shift_map[i] = n_shift_map[i];
alt_map[i] = n_alt_map[i];
+ altgr_map[i] = n_altgr_map[i];
}
-} \ No newline at end of file
+}
diff --git a/Kernel/Devices/KeyboardDevice.h b/Kernel/Devices/KeyboardDevice.h
index 65c3cd2f6b..c28f2a899b 100644
--- a/Kernel/Devices/KeyboardDevice.h
+++ b/Kernel/Devices/KeyboardDevice.h
@@ -21,7 +21,7 @@ public:
KeyboardDevice();
void set_client(KeyboardClient* client) { m_client = client; }
- void set_maps(char* n_map, char* n_shift_map, char* n_alt_map);
+ void set_maps(const char* n_map, const char* n_shift_map, const char* n_alt_map, const char* n_altgr_map);
// ^CharacterDevice
virtual ssize_t read(FileDescription&, u8* buffer, ssize_t) override;
diff --git a/Kernel/KeyCode.h b/Kernel/KeyCode.h
index 5765465fc3..3d5e51e660 100644
--- a/Kernel/KeyCode.h
+++ b/Kernel/KeyCode.h
@@ -119,7 +119,8 @@ enum KeyModifier {
Mod_Ctrl = 0x02,
Mod_Shift = 0x04,
Mod_Logo = 0x08,
- Mod_Mask = 0x0f,
+ Mod_AltGr = 0x10,
+ Mod_Mask = 0x1f,
Is_Press = 0x80,
};
@@ -132,6 +133,7 @@ struct KeyEvent {
bool ctrl() const { return flags & Mod_Ctrl; }
bool shift() const { return flags & Mod_Shift; }
bool logo() const { return flags & Mod_Logo; }
+ bool altgr() const { return flags & Mod_AltGr; }
unsigned modifiers() const { return flags & Mod_Mask; }
bool is_press() const { return flags & Is_Press; }
};
diff --git a/Kernel/Process.cpp b/Kernel/Process.cpp
index 14a8cb9423..3eae6059a1 100644
--- a/Kernel/Process.cpp
+++ b/Kernel/Process.cpp
@@ -3584,19 +3584,24 @@ int Process::sys$getrandom(void* buffer, size_t buffer_size, unsigned int flags
return 0;
}
-int Process::sys$setkeymap(char* map, char* shift_map, char* alt_map)
+int Process::sys$setkeymap(const Syscall::SC_setkeymap_params* params)
{
if (!is_superuser())
return -EPERM;
- if (!validate_read(map, 0x80))
+ if (!validate_read_typed(params))
+ return -EFAULT;
+
+ if (!validate_read(params->map, 0x80))
+ return -EFAULT;
+ if (!validate_read(params->shift_map, 0x80))
return -EFAULT;
- if (!validate_read(shift_map, 0x80))
+ if (!validate_read(params->alt_map, 0x80))
return -EFAULT;
- if (!validate_read(alt_map, 0x80))
+ if (!validate_read(params->altgr_map, 0x80))
return -EFAULT;
- KeyboardDevice::the().set_maps(map, shift_map, alt_map);
+ KeyboardDevice::the().set_maps(params->map, params->shift_map, params->alt_map, params->altgr_map);
return 0;
}
diff --git a/Kernel/Process.h b/Kernel/Process.h
index d91c5668a1..347a2ebc75 100644
--- a/Kernel/Process.h
+++ b/Kernel/Process.h
@@ -227,7 +227,7 @@ public:
int sys$set_process_icon(int icon_id);
int sys$realpath(const char* pathname, char*, size_t);
ssize_t sys$getrandom(void*, size_t, unsigned int);
- int sys$setkeymap(char* map, char* shift_map, char* alt_map);
+ int sys$setkeymap(const Syscall::SC_setkeymap_params*);
int sys$module_load(const char* path, size_t path_length);
int sys$module_unload(const char* name, size_t name_length);
int sys$profiling_enable(pid_t);
diff --git a/Kernel/Syscall.h b/Kernel/Syscall.h
index 3661d9a594..58942d1d31 100644
--- a/Kernel/Syscall.h
+++ b/Kernel/Syscall.h
@@ -270,6 +270,13 @@ struct SC_futex_params {
const timespec* timeout;
};
+struct SC_setkeymap_params {
+ const char* map;
+ const char* shift_map;
+ const char* alt_map;
+ const char* altgr_map;
+};
+
struct SC_create_thread_params {
unsigned int m_detach_state = 0; // JOINABLE or DETACHED
int m_schedule_priority = 30; // THREAD_PRIORITY_NORMAL