aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/emuThird.c10
-rw-r--r--src/evdev.c24
-rw-r--r--src/evdev.h7
3 files changed, 28 insertions, 13 deletions
diff --git a/src/emuThird.c b/src/emuThird.c
index 7461767..5f14d33 100644
--- a/src/emuThird.c
+++ b/src/emuThird.c
@@ -229,8 +229,8 @@ Evdev3BEmuProcessAbsMotion(InputInfoPtr pInfo, ValuatorMask *vals)
{
if (valuator_mask_isset(vals, axis))
{
- int delta = valuator_mask_get(vals, axis) - emu3B->startpos[axis];
- if (abs(delta) > emu3B->threshold)
+ double delta = valuator_mask_get_double(vals, axis) - emu3B->startpos[axis];
+ if (fabs(delta) > emu3B->threshold)
cancel = TRUE;
}
axis++;
@@ -248,7 +248,7 @@ Evdev3BEmuProcessAbsMotion(InputInfoPtr pInfo, ValuatorMask *vals)
* emulation.
*/
void
-Evdev3BEmuProcessRelMotion(InputInfoPtr pInfo, int dx, int dy)
+Evdev3BEmuProcessRelMotion(InputInfoPtr pInfo, double dx, double dy)
{
EvdevPtr pEvdev = pInfo->private;
struct emulate3B *emu3B = &pEvdev->emulate3B;
@@ -260,8 +260,8 @@ Evdev3BEmuProcessRelMotion(InputInfoPtr pInfo, int dx, int dy)
emu3B->delta[1] += dy;
emu3B->flags |= EVDEV_RELATIVE_EVENTS;
- if (abs(emu3B->delta[0]) > emu3B->threshold ||
- abs(emu3B->delta[1]) > emu3B->threshold)
+ if (fabs(emu3B->delta[0]) > emu3B->threshold ||
+ fabs(emu3B->delta[1]) > emu3B->threshold)
{
Evdev3BEmuPostButtonEvent(pInfo, 1, BUTTON_PRESS);
Evdev3BCancel(pInfo);
diff --git a/src/evdev.c b/src/evdev.c
index da25b56..17d9d61 100644
--- a/src/evdev.c
+++ b/src/evdev.c
@@ -25,6 +25,7 @@
* Adam Jackson (ajax@redhat.com)
* Peter Hutterer (peter.hutterer@redhat.com)
* Oliver McFadden (oliver.mcfadden@nokia.com)
+ * Thomas H.P. Andersen (phomes@gmail.com)
*/
#ifdef HAVE_CONFIG_H
@@ -432,31 +433,36 @@ EvdevProcessValuators(InputInfoPtr pInfo)
/* Apply transformations on relative coordinates */
if (pEvdev->rel_queued) {
- int deltaX = 0, deltaY = 0;
+ double deltaX = 0, deltaY = 0;
if (valuator_mask_isset(pEvdev->rel_vals, REL_X))
- deltaX = valuator_mask_get(pEvdev->rel_vals, REL_X);
+ deltaX = valuator_mask_get_double(pEvdev->rel_vals, REL_X);
if (valuator_mask_isset(pEvdev->rel_vals, REL_Y))
- deltaY = valuator_mask_get(pEvdev->rel_vals, REL_Y);
+ deltaY = valuator_mask_get_double(pEvdev->rel_vals, REL_Y);
if (pEvdev->swap_axes) {
- int tmp = deltaX;
+ double tmp = deltaX;
deltaX = deltaY;
deltaY = tmp;
}
+ if (pEvdev->resolution > 0) {
+ deltaX *= DEFAULT_MOUSE_DPI / pEvdev->resolution;
+ deltaY *= DEFAULT_MOUSE_DPI / pEvdev->resolution;
+ }
+
if (pEvdev->invert_x)
deltaX *= -1;
if (pEvdev->invert_y)
deltaY *= -1;
if (deltaX)
- valuator_mask_set(pEvdev->rel_vals, REL_X, deltaX);
+ valuator_mask_set_double(pEvdev->rel_vals, REL_X, deltaX);
else
valuator_mask_unset(pEvdev->rel_vals, REL_X);
if (deltaY)
- valuator_mask_set(pEvdev->rel_vals, REL_Y, deltaY);
+ valuator_mask_set_double(pEvdev->rel_vals, REL_Y, deltaY);
else
valuator_mask_unset(pEvdev->rel_vals, REL_Y);
@@ -2293,6 +2299,12 @@ EvdevProbe(InputInfoPtr pInfo)
pEvdev->invert_y = xf86SetBoolOption(pInfo->options, "InvertY", FALSE);
pEvdev->swap_axes = xf86SetBoolOption(pInfo->options, "SwapAxes", FALSE);
+ pEvdev->resolution = xf86SetIntOption(pInfo->options, "Resolution", 0);
+ if (pEvdev->resolution < 0) {
+ xf86IDrvMsg(pInfo, X_ERROR, "Resolution must be a positive number");
+ pEvdev->resolution = 0;
+ }
+
str = xf86CheckStrOption(pInfo->options, "Calibration", NULL);
if (str) {
num_calibration = sscanf(str, "%d %d %d %d",
diff --git a/src/evdev.h b/src/evdev.h
index 0f71d78..4d44d2b 100644
--- a/src/evdev.h
+++ b/src/evdev.h
@@ -97,6 +97,8 @@
/* Number of longs needed to hold the given number of bits */
#define NLONGS(x) (((x) + LONG_BITS - 1) / LONG_BITS)
+#define DEFAULT_MOUSE_DPI 1000.0
+
/* Function key mode */
enum fkeymode {
FKEYMODE_UNKNOWN = 0,
@@ -170,6 +172,7 @@ typedef struct {
BOOL swap_axes;
BOOL invert_x;
BOOL invert_y;
+ int resolution;
unsigned int abs_queued, rel_queued, prox_queued;
@@ -191,7 +194,7 @@ typedef struct {
int button; /* phys button to emit */
int threshold; /* move threshold in dev coords */
OsTimerPtr timer;
- int delta[2]; /* delta x/y, accumulating */
+ double delta[2]; /* delta x/y, accumulating */
int startpos[2]; /* starting pos for abs devices */
int flags; /* remember if we had rel or abs movement */
} emulate3B;
@@ -269,7 +272,7 @@ BOOL Evdev3BEmuFilterEvent(InputInfoPtr, int, BOOL);
void Evdev3BEmuPreInit(InputInfoPtr pInfo);
void Evdev3BEmuOn(InputInfoPtr);
void Evdev3BEmuFinalize(InputInfoPtr);
-void Evdev3BEmuProcessRelMotion(InputInfoPtr pInfo, int dx, int dy);
+void Evdev3BEmuProcessRelMotion(InputInfoPtr pInfo, double dx, double dy);
void Evdev3BEmuProcessAbsMotion(InputInfoPtr pInfo, ValuatorMask *vals);
/* Mouse Wheel emulation */