Repository navigation
Add a USB mouse sample - #965
Open
PS2HomeDeveloper wants to merge 2 commits into
Open
PS2HomeDeveloper wants to merge 2 commits into
PS2HomeDeveloper wants to merge 2 commits into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a sample for the USB mouse library (
libmouseand theps2mouseIRX) inee/rpc/mouse/samples. It is added tosamples/Makefile_sampleasrpc/mouse.The sample draws a square and a mouse pointer, and uses them to try every part of the mouse API: the three buttons, their double clicks, the wheel, both read modes and all the settings of the driver.
What the sample does
Square (button 1, button 2 and the wheel, with the pointer on it):
Anywhere else:
The pointer is only drawn while a mouse is plugged in, and it comes back to its last place when a mouse is plugged in again. The sample works on NTSC and PAL.
API used
PS2MouseInit, PS2MouseGetVersion, PS2MouseEnum, PS2MouseRead, PS2MouseSetReadMode and PS2MouseGetReadMode, PS2MouseSetPosition, PS2MouseReset, PS2MouseSetBoundary and PS2MouseGetBoundary, PS2MouseSetAccel and PS2MouseGetAccel, PS2MouseSetThres and PS2MouseGetThres, PS2MouseSetDblClickTime and PS2MouseGetDblClickTIme.
Files
Only
mouse.ccalls the driver (andsettings.c, for the settings); the other files draw and use what the mouse did in one frame.mouse.c: start, read loop, plug and unplug, reset.gfx.c/gfx.h: screen, rectangles, pointer and text.square.c/square.h: the square.menu.c/menu.h: the menu of sizes.settings.c/settings.h: the settings of the driver.input.h: what the mouse did in one frame.cursor.raw: the pointer image, 16x16 RGBA.Notes
graph_initialize()to show all of it.PS2MouseSetPositionis only used in absolute mode.Testing
Tested on a real PS2 with a USB mouse (plugging it in and out while the sample runs).