Re: [AD] submission: linux touchscreen driver for allegro

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


Attached is a patch which corrects the deviceid for linux touchscreen.
Instead of screening for the virtual master deviceid events,
this will ignore them so we only get events from the physical deviceid.
Thanks,
Pho75.

On Sun, Oct 12, 2014 at 5:48 PM, Phelius <project.phelius@xxxxxxxxxx> wrote:
> Attached is a patch for SiegeLord's linux_touch branch that fixes an issue.
>
> 1. The xinput events were appearing twice. Once with the deviceid of
> the touchscreen and another with deviceid for the Virtual core pointer
> (see my xinput output below).
> I fixed it by filtering only for the virtual devices. I don't know the
> pro's or con's of doing this vs. filtering for the physical id's, but
> this works for me.
>
> 2. Since Siege is querying all xinput events I added a filter to
> ignore events that don't belong to the affected display.
> I don't know if this is even necessary, but it seemed appropriate. I
> don't have multiple x11 displays to test with.
>
> P.S.:
> I forgot to mention with my previous patch, but the touchscreen can
> have a higher resolution than the display resolution. It might be
> worth a quick mention in the allegro docs,
> in case someone is expecting only integer values.
>
> Thanks,
> Pho75
>
> u15392@xxxxxxxxxx$ xinput
> ⎡ Virtual core pointer                        id=2    [master pointer  (3)]
> ⎜   ↳ Virtual core XTEST pointer                  id=4    [slave  pointer  (2)]
> ⎜   ↳ SYNAPTICS Synaptics Large Touch Screen      id=11    [slave  pointer  (2)]
> ⎜   ↳ SynPS/2 Synaptics TouchPad                  id=13    [slave  pointer  (2)]
> ⎣ Virtual core keyboard                       id=3    [master keyboard (2)]
>     ↳ Virtual core XTEST keyboard                 id=5    [slave  keyboard (3)]
>     ↳ Power Button                                id=6    [slave  keyboard (3)]
>     ↳ Video Bus                                   id=7    [slave  keyboard (3)]
>     ↳ Video Bus                                   id=8    [slave  keyboard (3)]
>     ↳ Power Button                                id=9    [slave  keyboard (3)]
>     ↳ Integrated_Webcam_HD                        id=10    [slave  keyboard (3)]
>     ↳ AT Translated Set 2 keyboard                id=12    [slave  keyboard (3)]
>     ↳ Dell WMI hotkeys                            id=14    [slave  keyboard (3)]
>
>
> On Tue, Sep 30, 2014 at 8:26 AM, SiegeLordEx <slabode@xxxxxxxxxx> wrote:
>>
>> Heya, I just realized that you might not have gotten this message since you're most likely not subscribed to the mailing list... sorry!
>>
>> -SL
>>
>>
>> -------- Original Message --------
>> Subject: Re: [AD] submission: linux touchscreen driver for allegro
>> Date: Sat, 20 Sep 2014 16:24:06 -0400
>> From: SiegeLordEx <slabode@xxxxxxxxxx>
>> To: alleg-developers@xxxxxxxxxx
>>
>> Ok, I've tried it out on a local branch here:
>> https://github.com/SiegeLord/allegro5/tree/linux_touch
>>
>> I made a whole bunch of refactoring to it (mostly moved most of the
>> logic inside xtouch.c in case XInput2 is too hard a dependency to require).
>>
>> I also made one big change. When you masked the events for the touch
>> input, you specified a single device. This was problematic as
>> ALLEGRO_DISPLAYs created before `al_install_touch_input` was called
>> would never receive those events. So, I made the mask take all touch
>> input devices. I don't know how well that works though, since I don't
>> have a device to test this with...
>>
>> Could you check that branch out and see if it still works for you?
>>
>> Thanks,
>>
>> -SL
>>
>> On 09/14/2014 01:26 PM, Phelius wrote:
>>>
>>> Attached is the updated allegro touchscreen support for linux with
>>> corrections applied.
>>> Thanks so SiegeLord for his feedback.
>>> Cheers,
>>> Pho75
>>>
diff --git a/src/x/xdisplay.c b/src/x/xdisplay.c
index d985964..eacf815 100644
--- a/src/x/xdisplay.c
+++ b/src/x/xdisplay.c
@@ -218,7 +218,7 @@ static bool xdpy_create_display_window(ALLEGRO_SYSTEM_XGLX *system,
 
    /* listen for touchscreen events */
    XIEventMask event_mask;
-   event_mask.deviceid = XIAllMasterDevices;
+   event_mask.deviceid = XIAllDevices;
    event_mask.mask_len = XIMaskLen(XI_TouchEnd);
    event_mask.mask = (unsigned char*)al_calloc(3, sizeof(char));
    XISetMask(event_mask.mask, XI_TouchBegin);
diff --git a/src/x/xtouch.c b/src/x/xtouch.c
index dfdd130..d3370e0 100644
--- a/src/x/xtouch.c
+++ b/src/x/xtouch.c
@@ -427,6 +427,14 @@ void _al_x_handle_touch_event(ALLEGRO_SYSTEM_XGLX *s, ALLEGRO_DISPLAY_XGLX *d, X
          if (devev->display != x11display)
             return;
 
+         /* ignore events from master/virtual devices */
+         int nret= 0, d_use;
+         XIDeviceInfo *dinfo= XIQueryDevice(devev->display, devev->deviceid, &nret);
+         d_use= dinfo->use;
+         XIFreeDeviceInfo(dinfo);
+         if (d_use != XISlavePointer)
+             return;
+
          switch (devev->evtype) {
             case XI_TouchBegin:
                /* the next new touch gets primary flag if it's not set */


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/