Skip to content
Permalink
Browse files

Implemented mm2counts, counts2mm, in2counts and counts2in

  • Loading branch information...
Géry Casiez
Géry Casiez committed Jul 1, 2019
1 parent a0a1290 commit e7d54e1c5dac4231c3ff070c6b113593522f9545
Showing with 44 additions and 3 deletions.
  1. +22 −0 pointing/input/PointingDevice.cpp
  2. +22 −3 pointing/input/PointingDevice.h
@@ -100,6 +100,28 @@ namespace pointing {
throw std::runtime_error(msg.str()) ;
}

int PointingDevice::mm2counts(double millimeters) const {
return (int)(millimeters * getResolution() / 25.4);
}

double PointingDevice::counts2mm(int counts) const {
if (getResolution() > 0)
return counts * 25.4 / getResolution();
else
return 0;
}

int PointingDevice::in2counts(double inches) const {
return (int)(inches * getResolution());
}

double PointingDevice::counts2in(int counts) const {
if (getResolution() > 0)
return counts / getResolution();
else
return 0;
}

void
PointingDevice::idle(int milliseconds) {
#ifdef _WIN32
@@ -147,15 +147,34 @@ namespace pointing {
*/
virtual URI getURI(bool expanded=false, bool crossplatform=false) const = 0 ;


/**
* Not implemented in the current version
* @brief Converts millimeters to counts, by taking into account device resolution
* @param number of millimeters to convert
* @return number of counts corresponding to the number of millimeters.
*/
//@{
int mm2counts(double millimeters) const ;

/**
* @brief Converts counts to millimeters, by taking into account device resolution
* @param number of counts to convert
* @return number of millimeters corresponding to the number of counts or 0 is device resolution is 0
*/
double counts2mm(int counts) const ;

/**
* @brief Converts inches to counts, by taking into account device resolution
* @param number of inches to convert
* @return number of counts corresponding to the number of inches.
*/
int in2counts(double inches) const ;

/**
* @brief Converts counts to inches, by taking into account device resolution
* @param number of counts to convert
* @return number of inches corresponding to the number of counts or 0 is device resolution is 0
*/
double counts2in(int counts) const ;
//@}

/**
* @brief Sets the callback function which is called when device events occur.

0 comments on commit e7d54e1

Please sign in to comment.
You can’t perform that action at this time.