FabGL
ESP32 Display Controller and Graphics Library
|
The PS2 Mouse controller class. More...
#include <mouse.h>
Public Member Functions | |
int | availableStatus () |
Gets the number of available mouse status. More... | |
void | begin (gpio_num_t clkGPIO, gpio_num_t dataGPIO) |
Initializes Mouse specifying CLOCK and DATA GPIOs. More... | |
void | begin (int PS2Port) |
Initializes Mouse without initializing the PS/2 controller. More... | |
bool | deltaAvailable () |
Determines if there is a mouse movement available in the queue. More... | |
void | emptyQueue () |
Empties the mouse status and events queue. More... | |
bool | getNextDelta (MouseDelta *delta, int timeOutMS=-1, bool requestResendOnTimeOut=false) |
Gets a mouse movement from the queue. More... | |
bool | getNextPacket (MousePacket *packet, int timeOutMS=-1, bool requestResendOnTimeOut=false) |
Gets a mouse raw movement (packet) from the queue. More... | |
MouseStatus | getNextStatus (int timeOutMS=-1) |
Gets the next status from the status queue. More... | |
int | getPacketSize () |
Gets mouse packet size. More... | |
PS2DeviceType | identify () |
Identifies the device attached to the PS2 port. More... | |
bool | isMouseAvailable () |
Checks if mouse has been detected and correctly initialized. More... | |
bool | lock (int timeOutMS) |
Gets exclusive access to the device. More... | |
int & | movementAcceleration () |
Gets or set mouse movement acceleration factor. More... | |
bool | packetAvailable () |
Determines if there is a raw mouse movement available in the queue. More... | |
bool | reset () |
Sends a Reset command to the mouse. More... | |
void | resumePort () |
Resumes PS/2 port releasing CLK line. More... | |
void | sendCommand (uint8_t cmd) |
Sends a raw command to the PS/2 device. More... | |
bool | sendCommand (uint8_t cmd, uint8_t expectedReply) |
Sends a raw command to the PS/2 device and wait for reply. More... | |
bool | setResolution (int value) |
Sets the resolution. More... | |
bool | setSampleRate (int value) |
Sets the maximum rate of mouse movements reporting. More... | |
bool | setScaling (int value) |
Sets the scaling. More... | |
void | setUIApp (uiApp *app) |
Sets current UI app. More... | |
void | setupAbsolutePositioner (int width, int height, bool createAbsolutePositionsQueue, BitmappedDisplayController *updateDisplayController=nullptr, uiApp *app=nullptr) |
Initializes absolute position handler. More... | |
MouseStatus & | status () |
Gets or sets current mouse status. More... | |
void | suspendPort () |
Suspends PS/2 port driving the CLK line Low. More... | |
void | terminateAbsolutePositioner () |
Terminates absolute position handler. More... | |
void | unlock () |
Releases device from exclusive access. More... | |
void | updateAbsolutePosition (MouseDelta *delta) |
Updates absolute position from the specified mouse delta event. More... | |
int & | wheelAcceleration () |
Gets or sets wheel acceleration factor. More... | |
Static Public Member Functions | |
static void | quickCheckHardware () |
Disable re-try when a mouse is not found. More... | |
The PS2 Mouse controller class.
Mouse class connects to one port of the PS2 Controller class (fabgl::PS2Controller) to decode and get mouse movements.
At the moment Mouse class supports standard PS/2 mouse (X and Y axis with three buttons) and Microsoft Intellimouse compatible mouse (X and Y axis, scroll wheel with three buttons).
Mouse class allows to set movement parameters, like sample rate, resolution and scaling.
The PS2 controller uses ULP coprocessor and RTC slow memory to communicate with the PS2 device.
Because fabgl::PS2Controller supports up to two PS/2 ports, it is possible to have connected two PS/2 devices. The most common configuration is Keyboard on port 0 and Mouse on port 1. However you may have two mice connected at the same time using the Mouse instance on port 0 and creating a new one on port 1.
Example:
// Setup pins GPIO26 for CLK and GPIO27 for DATA fabgl::Mouse Mouse; Mouse.begin(GPIO_NUM_26, GPIO_NUM_27); if (Mouse.deltaAvailable()) { MouseDelta mouseDelta; Mouse.getNextDelta(&mouseDelta); Serial.printf("deltaX = %d deltaY = %d deltaZ = %d leftBtn = %d midBtn = %d rightBtn = %d\n", mouseDelta.deltaX, mouseDelta.deltaY, mouseDelta.deltaZ, mouseDelta.leftButton, mouseDelta.middleButton, mouseDelta.rightButton); }