MasterScan  Lab_Matlab_control Master Branch
List of all members | Properties and Events | Protected Properties | Methods | Protected Methods | Static Methods
dotsReadableHIDMouse Class Reference

Overview

Reads data from a HID mouse device.

dotsReadableHIDMouse extends the dotsReadableHID superclass to manage HID mouse devices. Many integrated and USB pointing devices can be considered HID mouses.

By default, dotsReadableHIDMouse defines "pressed" events for each mouse button. Use getNextEvent() to make sure that no clicks are missed, and that each click is observed only once.

Note that HID mouses report x and y data as position changes, rather than absolute positions. Usually the operating system integrates the changes with some scaling and nonlinearity. dotsReadableHIDMouse automatically sums x and y component values as they arrive, without any scaling or nonlinearity. The latest sums are available in the x and y properties.

Inheritance diagram for dotsReadableHIDMouse:
Inheritance graph
[legend]

Properties and Events

Property x
 the latest x-position of the mouse
 
Property y
 the latest y-position of the mouse
 
Property buttonMatching
 struct of HID parameters to identify mouse button elements More...
 
Property xMatching
 struct of HID parameters to identify mouse x-axis element More...
 
Property yMatching
 struct of HID parameters to identify mouse y-axis element More...
 
Property VendorID
 Matching properties for machine-specific hardware - Vendor.
 
Property ProductID
 Matching properties for machine-specific hardware - Product.
 
Property PrimaryUsage =2
 Matching properties for machine-specific hardware - Usage.
 
- Properties and Events inherited from dotsReadableHID
Property deviceInfo
 struct of info about the HID device
 
Property deviceMatching
 struct of HID parameters for identifying suitable HID devices. More...
 
Property devicePreference
 struct of HID parameters for choosing among suitable devices. More...
 
Property queueDepth = 1024
 size of the mexHID() internal data queue More...
 
Property queueIsOpen = false
 whether or not the internal data queue opened successfully
 
Property isExclusive = false
 whether or not to get exclusive access to device data
 
Property allowMultipleConnections = false
 whether or not to allow multiple objects to access the same device
 
- Properties and Events inherited from dotsReadable
Property isAvailable = false
 

whether or not the object is ready to read() from


 
Property components
 

struct array with details about each component


 
Property state
 

matrix of ID, latest value, and latest time indexed by ID


 
Property history
 

matrix of component ID, value, and time from previous read()


 
Property isAutoRead = true
 

whether or not to to invoke read() during getValue(), etc.


 
Property eventDefinitions
 

struct array defining events of interest, indexed by ID


 
Property initialEventQueueSize = 100
 

initial size of queue for events of interest


 
Property clockFunction
 

any function that returns the current time as a number


 
Property filename
 

name of the data file for devices that store their own data


 
Property filepath
 

where the file is


 
Property recordDuringCalibration = true
 

controls whether or not to stop recording during calibration


 
Property useGUI = false
 Flag to use GUI for feedback, etc.
 
Property useExistingCalibration = false
 Flag to skip calibration routine.
 
Property calibrationUI
 Possibly use a keyboard or other UI to help with calibration.
 
Property deactivateEventsAtStartTrial =false
 Flag to deactivate all events at the beginning of each trial.
 

Protected Properties

Property xID
 ID of the x-axis component.
 
Property yID
 ID of the y-axis component.
 
Property buttonIDs
 ID of button components.
 
- Protected Properties inherited from dotsReadableHID
Property deviceID
 device identifier from mexHID('openMatchingDevice') More...
 
Property queueCallback = @dotsReadableHID.mexHIDQueueCallback
 Callback which mexHID() uses to pass HID data to Matlab. More...
 
Property queueCallbackData
 matrix of recent data passed in from mexHID()
 
- Protected Properties inherited from dotsReadable
Property eventQueue
 

array of queued events (row indices into history)


 
Property queueNext
 

queue index of the next event to be dequeued


 
Property queueLast =0
 

queue index of the last event enqueued


 
Property isRecording =false
 

keep track of whether device is currenly writing to a data file


 
Property didCalibrate = true
 Keep track of whether calibration occurs.
 
Property defaultEventPrefix = 'event'
 Default prefix for event names: <prefix>_<componentName>
 
Property eventSets
 Strutures with different named event definitions, in case we want to quickly swap between them.
 

Methods

self dotsReadableHIDMouse (devicePreference)
 Constructor may take device matching preferences. More...
 
 flushData (self, varargin)
 Flush data and reset the x and y position running sums.
 
- Methods inherited from dotsReadableHID
self dotsReadableHID ()
 Constructor takes no arguments.
 
 flushData (self, varargin)
 Clear data from this object and the mexHID() internal queue. More...
 
components setComponentCalibration (self, namesOrIDs, rawRange, deadRange, calibratedRange, granularity)
 Adjust scaling of raw values from HID components. More...
 
event defineEvent (self, name, varargin)
 Define a calibrated event for given component. More...
 
- Methods inherited from dotsReadable
self dotsReadable ()
 

Constructor takes no arguments.


 
 initialize (self)
 

Locate, acquire, configure, etc. device and component resources.


 
 calibrate (self, varargin)
 

Calibrate the device

More...
 
 record (self, onFlag, filename)
 

Open/close data file associated with the device Arguments: onFlag ...

More...
 
 reset (self, varargin)
 reset device More...
 
 close (self)
 

Release any resources acquired by initialize().


 
 delete (self)
 

Automatically close when Matlab is done with this object.


 
 read (self)
 

Add incoming data to history and detect events of interest.

More...
 
 flushData (self, waitForNoEvents)
 

Delete historical data and reset the current state.

More...
 
 logData (self)
 

Record current and historical data in topsDataLog.

More...
 
stateAtTime getState (self, time)
 

Get the state of device components as of the given time.

More...
 
value data getValue (self, ID)
 

Get the latest value for the given component.

More...
 
event defineEvent (self, name, varargin)
 

Define the event of interest for one of the input components.

More...
 
 defineEventsFromComponents (self, names, varargin)
 defineEventsFromComponents More...
 
 defineEventsFromStruct (self, eventStruct, setName, keepExisting, inactivate)
 defineEventsFromStruct More...
 
 showActiveEvents (self)
 Mostly for debugging.
 
 activateEventSet (self, name)
 Swap in a set of events.
 
 activateEvents (self)
 Activate all events. More...
 
 deactivateEvents (self)
 Deactivate all events. More...
 
activeFlags getActiveFlags (self)
 Get all active flags.
 
 setActiveFlags (self, activeFlags)
 Set all active flags from array.
 
 setEventsActiveFlag (self, activateList, deactivateList)
 Set/unset activeFlag. More...
 
name data getNextEvent (self, isPeek, acceptedEvents)
 

Get the next event that was detected in read().

More...
 
lastName lastID names IDs getHappeningEvent (self, time)
 

Get events that are happening at the current time.

More...
 
name waitTime data waitForEvents (self, eventNames, maxWait)
 Wait for event(s)
 
nEvents getNumberOfEvents (self)
 

Get the number of events in eventQueue.

More...
 
IDs getComponentIDs (self)
 

Get an array of unique integer component IDs.

More...
 
ID getComponentID (self, nameOrID)
 

Get ID of component by name or ID


 
name getComponentName (self, nameOrID)
 

Get name of component by name or ID


 
indices getComponentIndicesByID (self, IDs)
 

Get array of indices for the given component IDs


 
indices getComponentIndicesByName (self, names)
 

Get array of indices for the given component names


 
time getDeviceTime (self)
 

Get the current time from clockFunction.


 
 setDeviceTime (self, val)
 

Set the device time


 
 startTrial (self, varargin)
 

startTrial()

More...
 
 finishTrial (self, varargin)
 

finishTrial()

More...
 
 plotData (self)
 

Open a figure with continuously read device data.

More...
 
 startTrialDevice (self, varargin)
 Overloaded methods.
 

Protected Methods

components openComponents (self)
 Locate and enqueue all the buttons and axes of the mouse.
 
 closeComponents (self)
 Unenqueue all the buttons and elements of the mouse.
 
- Protected Methods inherited from dotsReadableHID
isOpen openDevice (self)
 Find the best available HID device with mexHID().
 
 closeDevice (self)
 Release mexHID() resources for this device.
 
isOpen openHIDQueue (self, cookies)
 Open a queue to record value changes for device elements. More...
 
newData readNewData (self)
 Pass any data from the mexHID() internal queue to this object(). More...
 
- Protected Methods inherited from dotsReadable
isOpen openDevice (self)
 

Locate and acquire input device resources (for subclasses).

More...
 
 closeDevice (self)
 

Release input device resources (for subclasses).

More...
 
 resetDevice (self, varargin)
 Reset the device.
 
status calibrateDevice (self, varargin)
 

Calibrate the device (for subclasses).

More...
 
isRecording startRecording (self)
 

Turn on data recording from the device (for subclasses).


 
isRecording stopRecording (self)
 

Turn off data recording from the device (for subclasses).


 
components openComponents (self)
 

Locate and acquire device components (for subclasses).

More...
 
 closeComponents (self)
 

Release device components (for subclasses).

More...
 
newData readNewData (self)
 

Read and format incoming data (for subclasses).

More...
 
isEvent detectEvents (self, data)
 

Use new data to look up events of interest (used internally).

More...
 
newSize resizeEventQueue (self, minSize, doClear)
 

Resize and optionally clear the event queue (used internally).

More...
 
nEvents enqueueEvents (self, eventValues)
 

Add events of interest to the event queue (used internally).

More...
 
eventValue nEvents dequeueEvent (self, isPeek)
 

Remove the next queued event of interest (used internally).

More...
 

Static Methods

static mexHIDMouseQueueCallback (self, newData)
 Pass data from the mexHID() internal queue to Matlab. More...
 
- Static Methods inherited from dotsReadableHID
static mexHIDQueueCallback (self, newData)
 Pass data from the mexHID() internal queue to Matlab. For newData, Rows are inputs Columns are.
 
static time currentHIDTime ()
 Get the current time from the system USB/HID implementation.
 
- Static Methods inherited from dotsReadable
static isHappening data readable isEventHappening (readables, eventName)
 

Is the named event happening now?

More...
 
static didHappen waitTime data readable name waitForEvent (readables, eventName, maxWait)
 

Wait for the named event to happen.

More...
 
static data loadDataFile (filename, varargin)
 Load data from file. More...
 

Constructor

◆ dotsReadableHIDMouse()

Constructor may take device matching preferences.

Parameters
devicePreferencestruct of HID matching parameters

devicePreference is an optional struct of HID parameters for choosing among suitable devices, assigned to the devicePreference property.

Methods

◆ mexHIDMouseQueueCallback()

static mexHIDMouseQueueCallback ( self  ,
newData   
)
static

Pass data from the mexHID() internal queue to Matlab.

Keep running sums of x and y data.

Properties and Events

◆ buttonMatching

Property buttonMatching

struct of HID parameters to identify mouse button elements

See mexHIDUsage() or mexHIDUsage.gui() for lists of valid HID parameters.

◆ xMatching

Property xMatching

struct of HID parameters to identify mouse x-axis element

See mexHIDUsage() or mexHIDUsage.gui() for lists of valid HID parameters.

◆ yMatching

Property yMatching

struct of HID parameters to identify mouse y-axis element

See mexHIDUsage() or mexHIDUsage.gui() for lists of valid HID parameters.


The documentation for this class was generated from the following file: