apps: Add mouse
All checks were successful
continuous-integration/drone/push Build is passing

A simple mouse packet reader.
This commit is contained in:
apio 2023-08-02 11:56:12 +02:00
parent cd9219df52
commit 2198dedb96
Signed by: apio
GPG Key ID: B8A7D06E42258954
2 changed files with 17 additions and 0 deletions

View File

@ -44,3 +44,4 @@ luna_app(gol.cpp gol)
luna_app(buffer-test.cpp buffer-test)
luna_app(socket-test.cpp socket-test)
luna_app(socket-client.cpp socket-client)
luna_app(mouse.cpp mouse)

16
apps/mouse.cpp Normal file
View File

@ -0,0 +1,16 @@
#include <moon/Mouse.h>
#include <os/File.h>
Result<int> luna_main(int, char**)
{
auto mouse = TRY(os::File::open("/dev/mouse", os::File::ReadOnly));
mouse->set_buffer(os::File::NotBuffered);
while (1)
{
moon::MousePacket packet;
TRY(mouse->read_typed(packet));
os::println("Mouse packet: xdelta=%d, ydelta=%d, buttons=%d", packet.xdelta, packet.ydelta, packet.buttons);
}
}