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/include | |
parent | b1a912a8a6ff472a49b2e0a09cfd433adfc2cb24 (diff) | |
download | hilbert-os-e60fa7740cd7d245d1b22a25fea9df0768d32668.tar.gz |
mouse support (working in qemu, semi-working in virtualbox)
Diffstat (limited to 'kernel/include')
-rw-r--r-- | kernel/include/hilbert/kernel/input.hpp | 21 | ||||
-rw-r--r-- | kernel/include/hilbert/kernel/utility.hpp | 5 |
2 files changed, 25 insertions, 1 deletions
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<uint32_t> *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_packet> *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]; + } + }; } |