Libpointing
An open-source cross-platform library to get raw events from pointing devices and master transfer functions.
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
pointing::PointingDevice Class Referenceabstract

The PointingDevice class is used to represent Pointing Devices connected to the computer or pseudo-devices. More...

#include <PointingDevice.h>

Inheritance diagram for pointing::PointingDevice:
pointing::DummyPointingDevice pointing::osxHIDPointingDevice pointing::SystemPointingDevice pointing::linuxPointingDevice pointing::osxPointingDevice pointing::winPointingDevice

Public Types

enum  { BUTTON_1 =1, BUTTON_2 =2, BUTTON_3 =4 }
 
typedef void(* PointingCallback )(void *context, TimeStamp::inttime timestamp, int dx, int dy, int buttons)
 

Public Member Functions

virtual bool isActive (void) const
 Indicates whether the current device is active. More...
 
virtual int getVendorID (void) const
 Vendor identifier number. More...
 
virtual std::string getVendor (void) const
 Readable vendor name. More...
 
virtual int getProductID (void) const
 Product identifier number. More...
 
virtual std::string getProduct (void) const
 Readable product name. More...
 
virtual double getResolution (double *defval=0) const =0
 Resolution of the mouse in CPI (counts per inch). More...
 
virtual double getUpdateFrequency (double *defval=0) const =0
 Update frequency of the mouse in Hz. More...
 
virtual URI getURI (bool expanded=false, bool crossplatform=false) const =0
 Constructs the URI according to the parameters of the device. More...
 
virtual void setPointingCallback (PointingCallback callback, void *context=0)=0
 Sets the callback function which is called when device events occur. More...
 
virtual void setDebugLevel (int)
 Sets the level of information for debugging purposes (default = 0).
 
virtual void debug (std::ostream &) const
 Outputs the debug information to the given output stream.
 
int mm2counts (double millimeters) const
 
double counts2mm (int counts) const
 
int in2counts (double inches) const
 
double counts2in (int counts) const
 

Static Public Member Functions

static void idle (int milliseconds)
 The function is used to sleep the current thread. More...
 
static PointingDevicecreate (const char *device_uri=0)
 This static function is used to instantiate a platform-specific object of the class. More...
 
static PointingDevicecreate (std::string device_uri)
 This static function is used to instantiate a platform-specific object of the class. More...
 

Protected Member Functions

void registerTimestamp (TimeStamp::inttime timestamp)
 registerTimestamp Registers the current timestamp to calculate frequency of the device More...
 
double estimatedUpdateFrequency () const
 estimatedUpdateFrequency Estimates the frequency depending on the input timestamps More...
 

Protected Attributes

unsigned long buckets [BUCKETS_SIZE]
 
TimeStamp::inttime lastTime
 

Static Protected Attributes

static const int BUCKETS_SIZE = 5
 

Detailed Description

The PointingDevice class is used to represent Pointing Devices connected to the computer or pseudo-devices.

It is an abstract class which creates an instance using create factory method.

Member Typedef Documentation

typedef void(* pointing::PointingDevice::PointingCallback)(void *context, TimeStamp::inttime timestamp, int dx, int dy, int buttons)

This signature is used when a callback function is created for the Pointing Device. The callback function is called whenever the device is moved or its buttons are pressed.

Parameters
dxHorizontal translation of the device
dyVertical tranlation of the device
buttonsThe state of the buttons (from 0 to 7)

Member Enumeration Documentation

anonymous enum

The enumeration of mouse buttons

Enumerator
BUTTON_1 

Left mouse button

BUTTON_2 

Middle mouse button

BUTTON_3 

Right mouse button

Member Function Documentation

double pointing::PointingDevice::counts2in ( int  counts) const

Not implemented in the current version

double pointing::PointingDevice::counts2mm ( int  counts) const

Not implemented in the current version

PointingDevice * pointing::PointingDevice::create ( const char *  device_uri = 0)
static

This static function is used to instantiate a platform-specific object of the class.

Parameters
device_uriis used to initialize the Device with given parameters. If not given, any supported device is chosen.
Returns
PointingDevice instance with specified parameters.
PointingDevice * pointing::PointingDevice::create ( std::string  device_uri)
static

This static function is used to instantiate a platform-specific object of the class.

Parameters
device_uriis used to initialize the Device with given parameters. If not given, any supported device is chosen.
Returns
PointingDevice instance with specified parameters.
double pointing::PointingDevice::estimatedUpdateFrequency ( ) const
protected

estimatedUpdateFrequency Estimates the frequency depending on the input timestamps

Returns
125, 250, 500, 1000 or -1
virtual std::string pointing::PointingDevice::getProduct ( void  ) const
inlinevirtual

Readable product name.

Returns
Product name

Reimplemented in pointing::osxHIDPointingDevice, and pointing::SystemPointingDevice.

virtual int pointing::PointingDevice::getProductID ( void  ) const
inlinevirtual

Product identifier number.

Returns
Product number associated with the device

Reimplemented in pointing::osxHIDPointingDevice, and pointing::SystemPointingDevice.

virtual double pointing::PointingDevice::getResolution ( double *  defval = 0) const
pure virtual

Resolution of the mouse in CPI (counts per inch).

Parameters
defvalis input variable to define explicitly the resolution.
Returns
Resolution in CPI (if not available 400 cpi).

Implemented in pointing::osxHIDPointingDevice, pointing::SystemPointingDevice, pointing::DummyPointingDevice, and pointing::osxPointingDevice.

virtual double pointing::PointingDevice::getUpdateFrequency ( double *  defval = 0) const
pure virtual

Update frequency of the mouse in Hz.

Parameters
defvalis input variable to define explicitly the update frequency.
Returns
Update frequency in Hz (if not available 125 Hz).

Implemented in pointing::osxHIDPointingDevice, pointing::SystemPointingDevice, pointing::DummyPointingDevice, pointing::osxPointingDevice, and pointing::linuxPointingDevice.

virtual URI pointing::PointingDevice::getURI ( bool  expanded = false,
bool  crossplatform = false 
) const
pure virtual

Constructs the URI according to the parameters of the device.

Parameters
expandedspecifies if additional parameters must be displayed.
crossplatformdefines whether the URI should be crossplatform. if True vendorId and productId are included in the URI
Returns
The corresponding URI of the device.

Implemented in pointing::osxHIDPointingDevice, pointing::SystemPointingDevice, pointing::DummyPointingDevice, pointing::osxPointingDevice, and pointing::linuxPointingDevice.

virtual std::string pointing::PointingDevice::getVendor ( void  ) const
inlinevirtual

Readable vendor name.

Returns
Vendor name

Reimplemented in pointing::osxHIDPointingDevice, and pointing::SystemPointingDevice.

virtual int pointing::PointingDevice::getVendorID ( void  ) const
inlinevirtual

Vendor identifier number.

Returns
integer number associated with vendor of the device

Reimplemented in pointing::osxHIDPointingDevice, and pointing::SystemPointingDevice.

void pointing::PointingDevice::idle ( int  milliseconds)
static

The function is used to sleep the current thread.

Parameters
millisecondsSleep time of the main thread in milliseconds
int pointing::PointingDevice::in2counts ( double  inches) const

Not implemented in the current version

virtual bool pointing::PointingDevice::isActive ( void  ) const
inlinevirtual

Indicates whether the current device is active.

Returns
true if active

Reimplemented in pointing::osxHIDPointingDevice, and pointing::SystemPointingDevice.

int pointing::PointingDevice::mm2counts ( double  millimeters) const

Not implemented in the current version

void pointing::PointingDevice::registerTimestamp ( TimeStamp::inttime  timestamp)
protected

registerTimestamp Registers the current timestamp to calculate frequency of the device

Parameters
timestampCurrent timestamp
virtual void pointing::PointingDevice::setPointingCallback ( PointingCallback  callback,
void *  context = 0 
)
pure virtual

Sets the callback function which is called when device events occur.

Parameters
callbackThe pointer to the callback function.
contextThe pointer to anything that can be used in the callback function.

Implemented in pointing::osxHIDPointingDevice, pointing::SystemPointingDevice, and pointing::DummyPointingDevice.


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