diff options
author | Aapo Rantalainen <aapo.rantalainen@gmail.com> | 2011-03-09 21:32:36 +0100 |
---|---|---|
committer | Christoph Brill <egore911@egore911.de> | 2011-03-09 22:27:04 +0100 |
commit | 049d5fb6037b34d94b24cb8300849cf4e3b67437 (patch) | |
tree | b93bdd5fe6e57131309050dca1ae6c83e92cb84c /src/ps2comm.c | |
parent | d6fc5be2969b9eede3c0fdd6e03daec4100a8c9f (diff) |
Add synaptics orientation support
This patch allows usage of "synclient Orientation=0" (values from 0 to
3). It will rotate the touchpad similar to "xrandr -o". Original patch
was extended for alps and ps2.
Signed-off-by: Christoph Brill <egore911@egore911.de>
Diffstat (limited to 'src/ps2comm.c')
-rw-r--r-- | src/ps2comm.c | 36 |
1 files changed, 29 insertions, 7 deletions
diff --git a/src/ps2comm.c b/src/ps2comm.c index 0e9b861..1c2bbc3 100644 --- a/src/ps2comm.c +++ b/src/ps2comm.c @@ -524,7 +524,7 @@ PS2ReadHwStateProto(InputInfoPtr pInfo, SynapticsParameters *para = &priv->synpara; struct PS2SynapticsHwInfo *synhw; int newabs; - int w, i; + int w, i, x, y; synhw = (struct PS2SynapticsHwInfo*)priv->proto_data; if (!synhw) @@ -541,17 +541,17 @@ PS2ReadHwStateProto(InputInfoPtr pInfo, return FALSE; /* Handle normal packets */ - hw->x = hw->y = hw->z = hw->numFingers = hw->fingerWidth = 0; + hw->x = hw->y = hw->z = hw->numFingers = hw->fingerWidth = x = y = 0; hw->left = hw->right = hw->up = hw->down = hw->middle = FALSE; for (i = 0; i < 8; i++) hw->multi[i] = FALSE; if (newabs) { /* newer protos...*/ DBG(7, "using new protocols\n"); - hw->x = (((buf[3] & 0x10) << 8) | + x = (((buf[3] & 0x10) << 8) | ((buf[1] & 0x0f) << 8) | buf[4]); - hw->y = (((buf[3] & 0x20) << 7) | + y = (((buf[3] & 0x20) << 7) | ((buf[1] & 0xf0) << 4) | buf[5]); @@ -598,9 +598,9 @@ PS2ReadHwStateProto(InputInfoPtr pInfo, } } else { /* old proto...*/ DBG(7, "using old protocol\n"); - hw->x = (((buf[1] & 0x1F) << 8) | + x = (((buf[1] & 0x1F) << 8) | buf[2]); - hw->y = (((buf[4] & 0x1F) << 8) | + y = (((buf[4] & 0x1F) << 8) | buf[5]); hw->z = (((buf[0] & 0x30) << 2) | @@ -612,7 +612,29 @@ PS2ReadHwStateProto(InputInfoPtr pInfo, hw->right = (buf[0] & 0x02) ? 1 : 0; } - hw->y = YMAX_NOMINAL + YMIN_NOMINAL - hw->y; + y = YMAX_NOMINAL + YMIN_NOMINAL - y; + + if (para->orientation==0) + hw->x = x; + else if (para->orientation==2) + hw->x = priv->maxx + priv->minx - x; + else if (para->orientation==3) + hw->y = (priv->maxx - x) * (priv->maxy - priv->miny) / (priv->maxx - priv->minx) + priv->miny; + else if (para->orientation==1) + hw->y = (x - priv->minx) * (priv->maxy - priv->miny) / (priv->maxx - priv->minx) + priv->miny; + else + hw->x = x; + + if (para->orientation==0) + hw->y = y; + else if (para->orientation==2) + hw->y = priv->maxy + priv->miny - y; + else if (para->orientation==3) + hw->x = (y - priv->miny) * (priv->maxx - priv->minx) / (priv->maxy - priv->miny) + priv->minx; + else if (para->orientation==1) + hw->x = (priv->maxy - y) * (priv->maxx - priv->minx) / (priv->maxy - priv->miny) + priv->minx; + else + hw->y = y; if (hw->z >= para->finger_high) { int w_ok = 0; |