summaryrefslogtreecommitdiff
path: root/euler
diff options
context:
space:
mode:
Diffstat (limited to 'euler')
-rw-r--r--euler/include/euler/syscall.hpp15
-rw-r--r--euler/source/euler/syscall.asm28
2 files changed, 40 insertions, 3 deletions
diff --git a/euler/include/euler/syscall.hpp b/euler/include/euler/syscall.hpp
index 9255642..761dbcc 100644
--- a/euler/include/euler/syscall.hpp
+++ b/euler/include/euler/syscall.hpp
@@ -58,4 +58,17 @@ extern "C" uint32_t *__euler_get_framebuffer(
extern "C" uint32_t __euler_encode_color(uint8_t r, uint8_t g, uint8_t b);
-extern "C" uint32_t __euler_read_key_packet();
+enum __euler_mouse_buttons : uint8_t {
+ __EULER_MB_LEFT = 1,
+ __EULER_MB_RIGHT = 2,
+ __EULER_MB_MIDDLE = 4
+};
+
+enum __euler_input_packet_type : uint8_t {
+ __EULER_IPT_MOUSE = 1,
+ __EULER_IPT_KEYBOARD = 2
+};
+
+extern "C" __euler_input_packet_type __euler_get_input_packet(
+ __euler_mouse_buttons &buttons_out, int16_t &x_change_out,
+ int16_t &y_change_out, uint32_t &keyboard_packet_out);
diff --git a/euler/source/euler/syscall.asm b/euler/source/euler/syscall.asm
index 34f2735..41bd05c 100644
--- a/euler/source/euler/syscall.asm
+++ b/euler/source/euler/syscall.asm
@@ -11,7 +11,7 @@ global __euler_end_this_thread
global __euler_read_from_stream
global __euler_get_framebuffer
global __euler_encode_color
-global __euler_read_key_packet
+global __euler_get_input_packet
section .text
@@ -96,7 +96,31 @@ __euler_encode_color:
syscall
ret
-__euler_read_key_packet:
+__euler_get_input_packet:
+ push rdi
+ push rsi
+ push rdx
+ push rcx
mov rax, 5
syscall
+
+ test al, 0x80
+ jnz .mouse_packet
+
+ pop rcx
+ mov dword [rcx], edi
+ add rsp, 24
+ mov al, 2
+ ret
+
+.mouse_packet:
+ add rsp, 8
+ pop rdx
+ mov word [rdx], si
+ pop rdx
+ mov word [rdx], di
+ pop rdx
+ and al, 0x7f
+ mov byte [rdx], al
+ mov al, 1
ret