diff options
author | Benji Dial <benji@benjidial.net> | 2024-05-19 04:34:40 -0400 |
---|---|---|
committer | Benji Dial <benji@benjidial.net> | 2024-05-19 04:34:40 -0400 |
commit | e60fa7740cd7d245d1b22a25fea9df0768d32668 (patch) | |
tree | 728fa422d3a2abc66a3e2d89e4ef03b72074bb3e /kernel/source/syscall.cpp | |
parent | b1a912a8a6ff472a49b2e0a09cfd433adfc2cb24 (diff) | |
download | hilbert-os-e60fa7740cd7d245d1b22a25fea9df0768d32668.tar.gz |
mouse support (working in qemu, semi-working in virtualbox)
Diffstat (limited to 'kernel/source/syscall.cpp')
-rw-r--r-- | kernel/source/syscall.cpp | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/kernel/source/syscall.cpp b/kernel/source/syscall.cpp index 768ff0d..5d9714c 100644 --- a/kernel/source/syscall.cpp +++ b/kernel/source/syscall.cpp @@ -157,7 +157,7 @@ namespace hilbert::kernel::syscall { } - void read_key_packet_syscall( + void get_input_packet_syscall( uint64_t &rax, uint64_t &rdi, uint64_t &rsi, uint64_t &rdx ) { @@ -165,8 +165,17 @@ namespace hilbert::kernel::syscall { auto *t = application::running_thread; do - if (input::key_queue->count > 0) { - rax = (uint64_t)input::key_queue->take(); + if (input::input_queue->count > 0) { + input::input_packet packet = input::input_queue->take(); + if (packet.is_mouse) { + rax = packet.mouse.buttons | 0x80; + rdi = (uint16_t)packet.mouse.x_change; + rsi = (uint16_t)packet.mouse.y_change; + } + else { + rax = 0; + rdi = packet.keyboard; + } return; } while (application::save_thread_state(t->cpu)); @@ -504,7 +513,7 @@ namespace hilbert::kernel::syscall { &open_file_syscall, &end_this_thread_syscall, &get_new_pages_syscall, - &read_key_packet_syscall, + &get_input_packet_syscall, &create_private_socket_syscall, &create_socket_listener_syscall, &stop_socket_listener_syscall, @@ -520,7 +529,7 @@ namespace hilbert::kernel::syscall { &set_stream_length_syscall }; - static constexpr int max_syscall_number = 18; + static constexpr int max_syscall_number = 19; } |