mirror of
https://github.com/JannisHeydemann/BoredOS.git
synced 2026-05-30 02:16:58 +00:00
feature(input): implement keyboard layouts and utf-8 input subsystem
* Adding keyboard layout (backend) * Update settings.c with new keyboard tab * Fixing keyboard icon && Fixing long loading time in settings.c * Refactor of key handling for a larger compatibility with the keyboard layout * Adding keyboard handler * Udating ps2.c with the new logic * Updating WM/kernel/userland with the new input system * Fixing keycode range && Updating dead keys handling * Add comments for explanation * Update notepad & vm.c to parse utf-8 * Adding utf-8 parsing utils in libc && Update notepad.c * Adding icon for icon settings * Fixing a warning with double definition * Adding new kb kayout: QWERTZ and DVORAK && Update new layout instrauction * Add documentation for keyboard input subsystem This document outlines the architecture and design of the input subsystem, focusing on keyboard input processing, driver responsibilities, keycode representation, and keymap functionality. --------- Co-authored-by: boreddevnl <chris@boreddev.nl>
This commit is contained in:
@@ -22,14 +22,17 @@
|
||||
#include "tty.h"
|
||||
#include "font_manager.h"
|
||||
#include "graphics.h"
|
||||
#include "input/keycodes.h"
|
||||
#include "input/keymap.h"
|
||||
#include "app_metadata.h"
|
||||
|
||||
extern bool ps2_ctrl_pressed;
|
||||
|
||||
#define SPAWN_FLAG_TERMINAL 0x1
|
||||
#define SPAWN_FLAG_INHERIT_TTY 0x2
|
||||
#define SPAWN_FLAG_TTY_ID 0x4
|
||||
|
||||
#define SYSTEM_CMD_SET_KEYBOARD_LAYOUT 49
|
||||
#define SYSTEM_CMD_GET_KEYBOARD_LAYOUT 51
|
||||
|
||||
// Read MSR
|
||||
static inline uint64_t rdmsr(uint32_t msr) {
|
||||
uint32_t low, high;
|
||||
@@ -158,10 +161,17 @@ void syscall_send_mouse_up_event(Window *win, int x, int y) {
|
||||
user_window_mouse_up(win, x, y);
|
||||
}
|
||||
|
||||
static void user_window_key(Window *win, char c, bool pressed) {
|
||||
static void user_window_key(Window *win, int legacy, uint16_t keycode, uint32_t codepoint, uint32_t mods, bool pressed) {
|
||||
process_t *proc = process_get_by_ui_window(win);
|
||||
if (!proc) return;
|
||||
gui_event_t ev = { .type = pressed ? GUI_EVENT_KEY : GUI_EVENT_KEYUP, .arg1 = (int)c, .arg3 = (int)ps2_ctrl_pressed };
|
||||
|
||||
gui_event_t ev = {
|
||||
.type = pressed ? GUI_EVENT_KEY : GUI_EVENT_KEYUP,
|
||||
.arg1 = legacy,
|
||||
.arg2 = (int)keycode,
|
||||
.arg3 = (int)mods,
|
||||
.arg4 = (int)codepoint
|
||||
};
|
||||
process_push_gui_event(proc, &ev);
|
||||
}
|
||||
|
||||
@@ -2105,6 +2115,16 @@ static uint64_t sys_cmd_get_elf_primary_image(const syscall_args_t *args) {
|
||||
return app_metadata_get_primary_image(path, out_path, out_size) ? 1 : 0;
|
||||
}
|
||||
|
||||
static uint64_t sys_cmd_set_keyboard_layout(const syscall_args_t *args) {
|
||||
keymap_set_current((keymap_id_t)args->arg2);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static uint64_t sys_cmd_get_keyboard_layout(const syscall_args_t *args) {
|
||||
(void)args;
|
||||
return (uint64_t)keymap_get_current();
|
||||
}
|
||||
|
||||
#define SYS_CMD_TABLE_SIZE 78
|
||||
static const syscall_handler_fn sys_cmd_table[SYS_CMD_TABLE_SIZE] = {
|
||||
[SYSTEM_CMD_SET_BG_COLOR] = sys_cmd_set_bg_color,
|
||||
@@ -2152,6 +2172,8 @@ static const syscall_handler_fn sys_cmd_table[SYS_CMD_TABLE_SIZE] = {
|
||||
[SYSTEM_CMD_SET_RESOLUTION] = sys_cmd_set_resolution,
|
||||
[SYSTEM_CMD_NETWORK_GET_NIC_NAME] = sys_cmd_network_get_nic_name,
|
||||
[SYSTEM_CMD_PARALLEL_RUN] = sys_cmd_parallel_run,
|
||||
[SYSTEM_CMD_SET_KEYBOARD_LAYOUT] = sys_cmd_set_keyboard_layout,
|
||||
[SYSTEM_CMD_GET_KEYBOARD_LAYOUT] = sys_cmd_get_keyboard_layout,
|
||||
[SYSTEM_CMD_TTY_CREATE] = sys_cmd_tty_create,
|
||||
[SYSTEM_CMD_TTY_READ_OUT] = sys_cmd_tty_read_out,
|
||||
[SYSTEM_CMD_TTY_WRITE_IN] = sys_cmd_tty_write_in,
|
||||
|
||||
@@ -100,7 +100,9 @@ typedef struct {
|
||||
#define SYSTEM_CMD_SLEEP 46
|
||||
#define SYSTEM_CMD_SET_RESOLUTION 47
|
||||
#define SYSTEM_CMD_NETWORK_GET_NIC_NAME 48
|
||||
#define SYSTEM_CMD_SET_KEYBOARD_LAYOUT 49
|
||||
#define SYSTEM_CMD_PARALLEL_RUN 50
|
||||
#define SYSTEM_CMD_GET_KEYBOARD_LAYOUT 51
|
||||
#define SYSTEM_CMD_TTY_CREATE 60
|
||||
#define SYSTEM_CMD_TTY_READ_OUT 61
|
||||
#define SYSTEM_CMD_TTY_WRITE_IN 62
|
||||
|
||||
Reference in New Issue
Block a user