sunriseos / SunriseOS

Horizon/NX kernel reimplementation
Apache License 2.0
229 stars 13 forks source link

Keyboard refactor #527

Closed kitlith closed 4 years ago

kitlith commented 4 years ago

My goal here was to try to read from the port in as few places as possible (as well as trying to handle weird edge cases) in preparation for sending commands / receiving responses. In the process, though, I may have made KeyEvent::read_key_event an even more messy function than before...

kitlith commented 4 years ago

It's not exactly something that I directly had in mind, but I'm glad it'll be helpful for that too.

Orycterope commented 4 years ago

Regarding moving key reading to a separate task, I'm not sure what you meant, but I guess a producer-consumer pattern would fit.

One task (producer) waits for interrupts, fills a ring buffer with every byte it can read, and then goes to sleep again. It does not attempt to interpret read bytes in anyway, just bufferize them. Another task (consumer) waits for IPC calls, and tries to interpret the content of the buffer as scancodes, and goes to sleep if it's empty.

This would require locks to synchronize the two tasks, which we don't have yet (or I missed them).

Anyway this is irrelevant to the current PR, which is fine ! Thank you, your contribution is really appreciated ! 😊

roblabla commented 4 years ago

Needs a rebase on master to fix the build failure.

kitlith commented 4 years ago

I wonder if the pattern matching could be simplified with slice patterns nowadays...