A simple mouse packet reader.
This commit is contained in:
parent
cd9219df52
commit
2198dedb96
@ -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
16
apps/mouse.cpp
Normal 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);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user