Skip to main content

Mouse Class

Namespace: GHIElectronics.TinyCLR.Devices.UsbHost · Assembly: GHIElectronics.TinyCLR.Devices.UsbHost

Allows a usb device to be used a mouse.

public class Mouse : BaseDevice

Constructors

Mouse(uint id, byte interfaceIndex, bool absolutePosition)

public Mouse(uint id, byte interfaceIndex, bool absolutePosition = false) : base(id, interfaceIndex, DeviceType.Mouse)

Creates a new mouse.

ParameterTypeDescription
iduintThe device id.
interfaceIndexbyteThe device interface index.
absolutePositionbool

Properties

LeftButtonState

public ButtonState LeftButtonState { get; }

The current state of the mouse's left button.

RightButtonState

public ButtonState RightButtonState { get; }

The current state of the mouse's right button.

MiddleButtonState

public ButtonState MiddleButtonState { get; }

The current state of the mouse's middle button.

Extended1ButtonState

public ButtonState Extended1ButtonState { get; }

The current state of the mouse's first extended button.

Extended2ButtonState

public ButtonState Extended2ButtonState { get; }

The current state of the mouse's second extended button.

CursorPosition

public Position CursorPosition { get; }

The current position of the cursor.

WheelPosition

public int WheelPosition { get; }

The current position of the mouse wheel.

AbsolutePosition

public bool AbsolutePosition { get; }

Return true for absolute, false for relative mode.

Methods

SetScale(float scale)

public void SetScale(float scale)

Scales the x, y, and wheel delta values.

ParameterTypeDescription
scalefloatThe value by which to scale the data.

SetCursorBounds(Position minimum, Position maximum)

public void SetCursorBounds(Position minimum, Position maximum)

Sets the cursor bounds.

ParameterTypeDescription
minimumPositionThe minimum bound.
maximumPositionThe maximum bound.

SetCursorPosition(Position newPosition)

public void SetCursorPosition(Position newPosition)

Sets the cursor position.

ParameterTypeDescription
newPositionPositionThe new position of the cursor.

Dispose(bool disposing)

protected override void Dispose(bool disposing)

Disposes the mouse.

ParameterTypeDescription
disposingboolWhether or not this is called from Dispose.

CheckEvents(object sender)

protected override void CheckEvents(object sender)

Repeatedly called with a period defined by WorkerInterval. Used to poll the device for data and raise any desired events.

ParameterTypeDescription
senderobjectAlways null.

Events

ButtonChanged

public event ButtonChangedEventHandler ButtonChanged

The event fired when one of the mouse's buttons is pressed or released.

WheelMoved

public event WheelMovedEventHandler WheelMoved

The event fired when the mouse's wheel has moved.

CursorMoved

public event CursorMovedEventHandler CursorMoved

The event fired when the mouse's cursor has moved.