Skip to content

Add Mouse I/O peripheral with tests and example#454

Open
KuznetsovNick wants to merge 2 commits into
mortbopet:masterfrom
moevm:pr/io-mouse
Open

Add Mouse I/O peripheral with tests and example#454
KuznetsovNick wants to merge 2 commits into
mortbopet:masterfrom
moevm:pr/io-mouse

Conversation

@KuznetsovNick

Copy link
Copy Markdown

Adds a memory-mapped Mouse peripheral, available from the I/O panel
alongside the existing LED Matrix / Switches / D-Pad.

Behavior

The widget reports cursor position, button state and scroll wheel of the
mouse over its drawing area. The reported coordinate range is
configurable via the Width and Height parameters.

Memory map

Name Offset Size R/W Description
X 0x00 32 R Cursor X within [0, Width)
Y 0x04 32 R Cursor Y within [0, Height)
LBUTTON 0x08 1 R 1 while the left mouse button is held
RBUTTON 0x0C 1 R 1 while the right mouse button is held
SCROLL 0x10 32 R/W Accumulated wheel ticks (signed); writeable to reset/seed

Width and Height are also exposed as the assembler symbols
MOUSE_<n>_WIDTH / MOUSE_<n>_HEIGHT.

Example

examples/C/mouseDrawing.c — hold LMB to draw, RMB to erase a small
area, wheel to cycle the color (R → G → B). Coordinates are scaled and
clamped to the LED Matrix size, so the demo works for any combination
of mouse and matrix dimensions.

Tests

test/tst_io_mouse.cpp — covers register layout, values across
synthesized cursor/button/wheel events, and reset.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants