diff --git a/apps/CMakeLists.txt b/apps/CMakeLists.txt index 2b86ec4a..16267f7a 100644 --- a/apps/CMakeLists.txt +++ b/apps/CMakeLists.txt @@ -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) diff --git a/apps/mouse.cpp b/apps/mouse.cpp new file mode 100644 index 00000000..695a8470 --- /dev/null +++ b/apps/mouse.cpp @@ -0,0 +1,16 @@ +#include +#include + +Result 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); + } +}