<p>Why does this need to be a SYNAPTICS property, synclient does not respect XInput properties? Are they changing the same thing on the backend and using the same semantics? (On the last, no, I believe the min/max have to be changed and axes swapped on evdev devices)</p>
<p>--<br>
Timothy Meade<br>
tmzt on freenode</p>
<div class="gmail_quote">On Mar 18, 2011 2:42 AM, "Peter Hutterer" <<a href="mailto:peter.hutterer@who-t.net">peter.hutterer@who-t.net</a>> wrote:<br type="attribution">> Hi Aapo,<br>> <br>> I noticed this patch in the synaptics repo today. Unfortunately, it needs<br>
> a bit more work, so I've reverted it for now. Please find my comments<br>> inline.<br>> <br>> fwiw, patches to synatics should go to the xorg-devel list first for public<br>> review.<br>> <br>> On Fri, Mar 18, 2011 at 04:26:46PM +1000, Peter Hutterer wrote:<br>
>> This patch allows usage of "synclient Orientation=0" (values from 0 to<br>>> 3). It will rotate the touchpad similar to "xrandr -o". Original patch<br>>> was extended for alps and ps2.<br>
>> <br>>> Signed-off-by: Christoph Brill <<a href="mailto:egore911@egore911.de">egore911@egore911.de</a>><br>>> ---<br>>> include/synaptics-properties.h | 3 +++<br>>> man/synaptics.man | 6 ++++++<br>
>> src/alpscomm.c | 29 +++++++++++++++++++++++++----<br>>> src/eventcomm.c | 22 ++++++++++++++++++++--<br>>> src/properties.c | 8 ++++++++<br>>> src/ps2comm.c | 36 +++++++++++++++++++++++++++++-------<br>
>> src/synaptics.c | 2 ++<br>>> src/synapticsstr.h | 1 +<br>>> tools/synclient.c | 1 +<br>>> 9 files changed, 95 insertions(+), 13 deletions(-)<br>
>> <br>>> diff --git a/include/synaptics-properties.h b/include/synaptics-properties.h<br>>> index bdb2112..0b4e570 100644<br>>> --- a/include/synaptics-properties.h<br>>> +++ b/include/synaptics-properties.h<br>
>> @@ -158,4 +158,7 @@<br>>> /* 32 Bit Integer, 2 values, horizontal hysteresis, vertical hysteresis */<br>>> #define SYNAPTICS_PROP_NOISE_CANCELLATION "Synaptics Noise Cancellation"<br>>> <br>
>> +/* 32 bit, 4 values, normal, inverted, left, right */<br>>> +#define SYNAPTICS_ORIENTATION "Synaptics Orientation"<br>> <br>> why not use degrees here?<br>> this opens the way for a unified rotation property for devices that need a<br>
> rotation outside of 90 degree values.<br>> <br>> "left" doesn't have a clear meaning. "90 degrees clockwise" is less<br>> ambiguous<br>> <br>> "orientation" vs "rotation"?<br>
> I'm more of a fan of the latter, but can be convinced otherwise.<br>> <br>> <br>>> +<br>>> #endif /* _SYNAPTICS_PROPERTIES_H_ */<br>>> diff --git a/man/synaptics.man b/man/synaptics.man<br>
>> index 0a35883..44d1c27 100644<br>>> --- a/man/synaptics.man<br>>> +++ b/man/synaptics.man<br>>> @@ -510,6 +510,12 @@ AreaBottomEdge option to any integer value other than zero. If supported by the<br>
>> server (version 1.9 and later), the edge may be specified in percent of<br>>> the total height of the touchpad. Property: "Synaptics Area"<br>>> .<br>>> +.TP<br>>> +.BI "Option \*qOrientation\*q \*q" integer \*q<br>
>> +Rotate the touchpad similar to xrandr -o.<br>>> +.<br>>> +The orientation can be 0 (normal), 1(left), 2 (inverted) or 3(right).<br>>> +.<br>> <br>> same here, just because xrandr uses 0-3 doesn't make it a good idea ;)<br>
> <br>>> <br>>> .SH CONFIGURATION DETAILS<br>>> .SS Area handling<br>>> diff --git a/src/alpscomm.c b/src/alpscomm.c<br>>> index dc76655..7d5cda2 100644<br>>> --- a/src/alpscomm.c<br>
>> +++ b/src/alpscomm.c<br>>> @@ -149,11 +149,12 @@ ALPS_get_packet(struct CommData *comm, InputInfoPtr pInfo)<br>>> * reflects left,right,down,up in lef1,rig1,mid1,up1.<br>>> */<br>>> static void<br>
>> -ALPS_process_packet(unsigned char *packet, struct SynapticsHwState *hw)<br>>> +ALPS_process_packet(SynapticsPrivate *priv, unsigned char *packet, struct SynapticsHwState *hw)<br>>> {<br>>> int x = 0, y = 0, z = 0;<br>
>> int left = 0, right = 0, middle = 0;<br>>> int i;<br>>> + SynapticsParameters *para = &priv->synpara;<br>>> <br>>> x = (packet[1] & 0x7f) | ((packet[2] & 0x78) << (7-3));<br>
>> y = (packet[4] & 0x7f) | ((packet[3] & 0x70) << (7-4));<br>>> @@ -172,8 +173,27 @@ ALPS_process_packet(unsigned char *packet, struct SynapticsHwState *hw)<br>>>         hw->multi[i] = FALSE;<br>
>> <br>>> if (z > 0) {<br>>> -        hw->x = x;<br>>> -        hw->y = y;<br>>> +        if (para->orientation==0)<br>>> +         hw->x = x;<br>>> +        else if (para->orientation==2)<br>
> <br>> self-explanatory enums please, not magic numbers.<br>> else if (para->orientation == ROTATION_90CW)<br>> is much easier to read.<br>> <br>> (also, spaces before/after ==)<br>> <br>>> +         hw->x = priv->maxx + priv->minx - x;<br>
>> +        else if (para->orientation==3)<br>>> +         hw->y = (priv->maxx - x) * (priv->maxy - priv->miny) / (priv->maxx - priv->minx) + priv->miny;<br>>> +        else if (para->orientation==1)<br>
>> +         hw->y = (x - priv->minx) * (priv->maxy - priv->miny) / (priv->maxx - priv->minx) + priv->miny;<br>>> +        else<br>>> +         hw->x = x;<br>>> +<br>>> +        if (para->orientation==0)<br>
>> +         hw->y = y;<br>>> +        else if (para->orientation==2)<br>>> +         hw->y = priv->maxy + priv->miny - y;<br>>> +        else if (para->orientation==3)<br>>> +         hw->x = (y - priv->miny) * (priv->maxx - priv->minx) / (priv->maxy - priv->miny) + priv->minx;<br>
>> +        else if (para->orientation==1)<br>>> +         hw->x = (priv->maxy - y) * (priv->maxx - priv->minx) / (priv->maxy - priv->miny) + priv->minx;<br>>> +        else<br>>> +         hw->y = y;<br>
> <br>> this needs to be done in a function to avoid duplicating the code.<br>> <br>>> }<br>>> hw->z = z;<br>>> hw->numFingers = (z > 0) ? 1 : 0;<br>>> @@ -210,11 +230,12 @@ ALPSReadHwState(InputInfoPtr pInfo,<br>
>> {<br>>> unsigned char *buf = comm->protoBuf;<br>>> struct SynapticsHwState *hw = &(comm->hwState);<br>>> + SynapticsPrivate *priv = (SynapticsPrivate *)pInfo->private;<br>
>> <br>>> if (!ALPS_get_packet(comm, pInfo))<br>>>         return FALSE;<br>>> <br>>> - ALPS_process_packet(buf, hw);<br>>> + ALPS_process_packet(priv, buf, hw);<br>>> <br>
>> *hwRet = *hw;<br>>> return TRUE;<br>>> diff --git a/src/eventcomm.c b/src/eventcomm.c<br>>> index d394d3f..3d550f1 100644<br>>> --- a/src/eventcomm.c<br>>> +++ b/src/eventcomm.c<br>
>> @@ -400,10 +400,28 @@ EventReadHwState(InputInfoPtr pInfo,<br>>>         case EV_ABS:<br>>>          switch (ev.code) {<br>>>          case ABS_X:<br>>> -                hw->x = ev.value;<br>>> +                if (para->orientation==0)<br>
>> +                 hw->x = ev.value;<br>>> +                else if (para->orientation==2)<br>>> +                 hw->x = priv->maxx + priv->minx - ev.value;<br>>> +                else if (para->orientation==3)<br>>> +                 hw->y = (priv->maxx - ev.value) * (priv->maxy - priv->miny) / (priv->maxx - priv->minx) + priv->miny;<br>
>> +                else if (para->orientation==1)<br>>> +                 hw->y = (ev.value - priv->minx) * (priv->maxy - priv->miny) / (priv->maxx - priv->minx) + priv->miny;<br>>> +                else<br>>> +                 hw->x = ev.value;<br>
>>                 break;<br>>>          case ABS_Y:<br>>> -                hw->y = ev.value;<br>>> +                if (para->orientation==0)<br>>> +                 hw->y = ev.value;<br>>> +                else if (para->orientation==2)<br>
>> +                 hw->y = priv->maxy + priv->miny - ev.value;<br>>> +                else if (para->orientation==3)<br>>> +                 hw->x = (ev.value - priv->miny) * (priv->maxx - priv->minx) / (priv->maxy - priv->miny) + priv->minx;<br>
>> +                else if (para->orientation==1)<br>>> +                 hw->x = (priv->maxy - ev.value) * (priv->maxx - priv->minx) / (priv->maxy - priv->miny) + priv->minx;<br>>> +                else<br>>> +                 hw->y = ev.value;<br>
>>                 break;<br>>>          case ABS_PRESSURE:<br>>>                 hw->z = ev.value;<br>>> diff --git a/src/properties.c b/src/properties.c<br>>> index 23b5a6a..06909ed 100644<br>>> --- a/src/properties.c<br>
>> +++ b/src/properties.c<br>>> @@ -83,6 +83,7 @@ Atom prop_capabilities = 0;<br>>> Atom prop_resolution = 0;<br>>> Atom prop_area = 0;<br>>> Atom prop_noise_cancellation = 0;<br>
>> +Atom prop_orientation = 0;<br>>> <br>>> static Atom<br>>> InitAtom(DeviceIntPtr dev, char *name, int format, int nvalues, int *values)<br>>> @@ -285,6 +286,8 @@ InitDeviceProperties(InputInfoPtr pInfo)<br>
>> prop_noise_cancellation = InitAtom(pInfo->dev,<br>>> SYNAPTICS_PROP_NOISE_CANCELLATION, 32, 2, values);<br>>> <br>>> + prop_orientation = InitAtom(pInfo->dev, SYNAPTICS_ORIENTATION, 32, 1, &para->orientation);<br>
>> +<br>>> }<br>>> <br>>> int<br>>> @@ -666,6 +669,11 @@ SetProperty(DeviceIntPtr dev, Atom property, XIPropertyValuePtr prop,<br>>> return BadValue;<br>>> para->hyst_x = hyst[0];<br>
>> para->hyst_y = hyst[1];<br>>> + } else if (property == prop_orientation)<br>>> + {<br>>> + if (prop->size != 1 || prop->format != 32 || prop->type != XA_INTEGER)<br>
>> + return BadMatch;<br>>> + para->orientation = *(INT32*)prop->data;<br>>> }<br>>> <br>>> return Success;<br>>> diff --git a/src/ps2comm.c b/src/ps2comm.c<br>
>> index 0e9b861..1c2bbc3 100644<br>>> --- a/src/ps2comm.c<br>>> +++ b/src/ps2comm.c<br>>> @@ -524,7 +524,7 @@ PS2ReadHwStateProto(InputInfoPtr pInfo,<br>>> SynapticsParameters *para = &priv->synpara;<br>
>> struct PS2SynapticsHwInfo *synhw;<br>>> int newabs;<br>>> - int w, i;<br>>> + int w, i, x, y;<br>>> <br>>> synhw = (struct PS2SynapticsHwInfo*)priv->proto_data;<br>
>> if (!synhw)<br>>> @@ -541,17 +541,17 @@ PS2ReadHwStateProto(InputInfoPtr pInfo,<br>>>         return FALSE;<br>>> <br>>> /* Handle normal packets */<br>>> - hw->x = hw->y = hw->z = hw->numFingers = hw->fingerWidth = 0;<br>
>> + hw->x = hw->y = hw->z = hw->numFingers = hw->fingerWidth = x = y = 0;<br>> <br>> urgh, just add a new line.<br>> <br>>> hw->left = hw->right = hw->up = hw->down = hw->middle = FALSE;<br>
>> for (i = 0; i < 8; i++)<br>>>         hw->multi[i] = FALSE;<br>>> <br>>> if (newabs) {                         /* newer protos...*/<br>>>         DBG(7, "using new protocols\n");<br>>> -        hw->x = (((buf[3] & 0x10) << 8) |<br>
>> +        x = (((buf[3] & 0x10) << 8) |<br>>>                  ((buf[1] & 0x0f) << 8) |<br>>>                  buf[4]);<br>>> -        hw->y = (((buf[3] & 0x20) << 7) |<br>>> +        y = (((buf[3] & 0x20) << 7) |<br>
>>                  ((buf[1] & 0xf0) << 4) |<br>>>                  buf[5]);<br>>> <br>>> @@ -598,9 +598,9 @@ PS2ReadHwStateProto(InputInfoPtr pInfo,<br>>>         }<br>>> } else {                         /* old proto...*/<br>
>>         DBG(7, "using old protocol\n");<br>>> -        hw->x = (((buf[1] & 0x1F) << 8) |<br>>> +        x = (((buf[1] & 0x1F) << 8) |<br>>>                  buf[2]);<br>>> -        hw->y = (((buf[4] & 0x1F) << 8) |<br>
>> +        y = (((buf[4] & 0x1F) << 8) |<br>>>                  buf[5]);<br>>> <br>>>         hw->z = (((buf[0] & 0x30) << 2) |<br>>> @@ -612,7 +612,29 @@ PS2ReadHwStateProto(InputInfoPtr pInfo,<br>
>>         hw->right = (buf[0] & 0x02) ? 1 : 0;<br>>> }<br>>> <br>>> - hw->y = YMAX_NOMINAL + YMIN_NOMINAL - hw->y;<br>>> + y = YMAX_NOMINAL + YMIN_NOMINAL - y;<br>>> +<br>
>> + if (para->orientation==0)<br>>> +        hw->x = x;<br>>> + else if (para->orientation==2)<br>>> +        hw->x = priv->maxx + priv->minx - x;<br>>> + else if (para->orientation==3)<br>
>> +        hw->y = (priv->maxx - x) * (priv->maxy - priv->miny) / (priv->maxx - priv->minx) + priv->miny;<br>>> + else if (para->orientation==1)<br>>> +        hw->y = (x - priv->minx) * (priv->maxy - priv->miny) / (priv->maxx - priv->minx) + priv->miny;<br>
>> + else<br>>> +        hw->x = x;<br>>> +<br>>> + if (para->orientation==0)<br>>> +        hw->y = y;<br>>> + else if (para->orientation==2)<br>>> +        hw->y = priv->maxy + priv->miny - y;<br>
>> + else if (para->orientation==3)<br>>> +        hw->x = (y - priv->miny) * (priv->maxx - priv->minx) / (priv->maxy - priv->miny) + priv->minx;<br>>> + else if (para->orientation==1)<br>
>> +        hw->x = (priv->maxy - y) * (priv->maxx - priv->minx) / (priv->maxy - priv->miny) + priv->minx;<br>>> + else<br>>> +        hw->y = y;<br>> <br>> duplication again, needs abstraction.<br>
> <br>>> <br>>> if (hw->z >= para->finger_high) {<br>>>         int w_ok = 0;<br>>> diff --git a/src/synaptics.c b/src/synaptics.c<br>>> index 1233917..03a9f60 100644<br>>> --- a/src/synaptics.c<br>
>> +++ b/src/synaptics.c<br>>> @@ -574,6 +574,8 @@ static void set_default_parameters(InputInfoPtr pInfo)<br>>> pars->resolution_horiz = xf86SetIntOption(opts, "HorizResolution", horizResolution);<br>
>> pars->resolution_vert = xf86SetIntOption(opts, "VertResolution", vertResolution);<br>>> <br>>> + pars->orientation = xf86SetIntOption(opts, "Orientation", 0);<br>>> +<br>
>> /* Warn about (and fix) incorrectly configured TopEdge/BottomEdge parameters */<br>>> if (pars->top_edge > pars->bottom_edge) {<br>>>         int tmp = pars->top_edge;<br>>> diff --git a/src/synapticsstr.h b/src/synapticsstr.h<br>
>> index 8f6593e..90640f7 100644<br>>> --- a/src/synapticsstr.h<br>>> +++ b/src/synapticsstr.h<br>>> @@ -161,6 +161,7 @@ typedef struct _SynapticsParameters<br>>> unsigned int resolution_vert; /* vertical resolution of touchpad in units/mm */<br>
>> int area_left_edge, area_right_edge, area_top_edge, area_bottom_edge; /* area coordinates absolute */<br>>> int hyst_x, hyst_y; /* x and y width of hysteresis box */<br>>> + int orientation; /* orientation of the touchpad */<br>
>> } SynapticsParameters;<br>>> <br>>> <br>>> diff --git a/tools/synclient.c b/tools/synclient.c<br>>> index 9776d23..1ac5502 100644<br>>> --- a/tools/synclient.c<br>>> +++ b/tools/synclient.c<br>
>> @@ -143,6 +143,7 @@ static struct Parameter params[] = {<br>>> {"AreaRightEdge", PT_INT, 0, 10000, SYNAPTICS_PROP_AREA,        32,        1},<br>>> {"AreaTopEdge", PT_INT, 0, 10000, SYNAPTICS_PROP_AREA,        32,        2},<br>
>> {"AreaBottomEdge", PT_INT, 0, 10000, SYNAPTICS_PROP_AREA,        32,        3},<br>>> + {"Orientation", PT_INT, 0, 3, SYNAPTICS_ORIENTATION, 32, 0},<br>> ^ tab missing?<br>
> <br>> Cheers,<br>> Peter<br>> <br>>> { NULL, 0, 0, 0, 0 }<br>>> };<br>>> <br>>> -- <br>>> 1.7.4<br>> _______________________________________________<br>> <a href="mailto:xorg-devel@lists.x.org">xorg-devel@lists.x.org</a>: X.Org development<br>
> Archives: <a href="http://lists.x.org/archives/xorg-devel">http://lists.x.org/archives/xorg-devel</a><br>> Info: <a href="http://lists.x.org/mailman/listinfo/xorg-devel">http://lists.x.org/mailman/listinfo/xorg-devel</a><br>
</div>