From e60fa7740cd7d245d1b22a25fea9df0768d32668 Mon Sep 17 00:00:00 2001 From: Benji Dial Date: Sun, 19 May 2024 04:34:40 -0400 Subject: mouse support (working in qemu, semi-working in virtualbox) --- kernel/include/hilbert/kernel/input.hpp | 21 ++++++++++++++++++++- kernel/include/hilbert/kernel/utility.hpp | 5 +++++ 2 files changed, 25 insertions(+), 1 deletion(-) (limited to 'kernel/include') diff --git a/kernel/include/hilbert/kernel/input.hpp b/kernel/include/hilbert/kernel/input.hpp index 2209ddc..d1b7ca2 100644 --- a/kernel/include/hilbert/kernel/input.hpp +++ b/kernel/include/hilbert/kernel/input.hpp @@ -18,7 +18,26 @@ namespace hilbert::kernel::input { BREAK = 1 << 18, }; - extern utility::queue *key_queue; + enum buttons_t : uint8_t { + LEFT_BUTTON = 1, + RIGHT_BUTTON = 2, + MIDDLE_BUTTON = 4 + }; + + struct input_packet { + union { + struct { + int16_t x_change; + int16_t y_change; + buttons_t buttons; + } mouse; + uint32_t keyboard; + }; + bool is_mouse; + }; + + extern utility::queue *input_queue; + //notify a process waiting for input void got_input(); diff --git a/kernel/include/hilbert/kernel/utility.hpp b/kernel/include/hilbert/kernel/utility.hpp index 47f78ea..c0b8c19 100644 --- a/kernel/include/hilbert/kernel/utility.hpp +++ b/kernel/include/hilbert/kernel/utility.hpp @@ -342,6 +342,11 @@ namespace hilbert::kernel::utility { return move(ret); } + //assumes not empty + value_t &last_inserted() const { + return buffer[(count - 1 + next_read_index) % buffer_len]; + } + }; } -- cgit v1.2.3