User manual

GHI Electronics,LLC Embedded Master User Manual
Hardware and Software Library
11.14.4 USB Mouse
Embedded Master has direct support for Mice. The user simply connects a USB mouse to
the system. It is found by checking the connection status of system devices. Each
connected Mouse holds information about the current pressed buttons and the current
position.
Scaling
First, the user has to set the scale of the mouse axes. This is the range of reported mouse
movements as the user move the mouse around. For example, let us assume the user has
a screen width of 128 pixels. So a setting a scale with a minimum of -64 and a maximum
of +64 would be appropriate; A a fast mouse movement refers to change of 64 in the
direction.
Here's an example that sets X, Y and Mouse Wheel Movement to values appropriate to an
LCD 128 by 64:
mouse.SetScale(-64, +64, -32, +32, -512, +512);
Position
The position can be obtained as a Delta Position (Relative) or as a Cursor associated with
it (Absolute). The Delta Position changes with a range (min, max) that is the same as the
scale used earlier. The user can associate a cursor with the mouse that updates
automatically. Values taken by the X and Y position in a cursor are in a range specified by
the user. For example, in the earlier example, LCD with width of 128, the user can specify
a cursor to start at 0 and end at 128. With this model, the user is able to use two mice
each moving with a specified cursor in a different region on the LCD.
Getting a mouse position:
mouse.Cursor
mouse.DeltaPosition
An example of setting cursor bounds for X, Y and Wheel position on a LCD 128 by 64:
mouse.SetCursorBounds(0, 128, 0, 64, 0, 64);
Buttons
The Mouse class contains definitions for the current state of Left, Right, Middle, Extended
Button 1 and Extended Button 2.
Events
Position of the mouse or the state of the buttons can be obtained at anytime. Any changes
are sent by events to the user. Each event will have a reference to the originating mouse.
Also, the EventArgs for a mouse button event contains which button is associated with the
event.
Rev. 2.06 TFT Page 82 of 102 www.ghielectronics.com