mi: ensure chained button mappings from SD -> MD (#19282)
After copying the master event, flip the detail field to the mapped button of the SD, not the physical button. This way if the SD has a mapping 1:3 and the MD has a mapping of 3:4, a press on button 1 on the SD results in a core event on button 4. X.Org Bug 19282 <http://bugs.freedesktop.org/show_bug.cgi?id=19282> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
parent
639f289dcd
commit
d645721170
26
mi/mieq.c
26
mi/mieq.c
|
@ -323,15 +323,32 @@ ChangeDeviceID(DeviceIntPtr dev, xEvent* event)
|
||||||
DebugF("[mi] Unknown event type (%d), cannot change id.\n", type);
|
DebugF("[mi] Unknown event type (%d), cannot change id.\n", type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
FixUpEventForMaster(DeviceIntPtr mdev, DeviceIntPtr sdev, xEvent* original,
|
||||||
|
EventListPtr master, int count)
|
||||||
|
{
|
||||||
|
/* Ensure chained button mappings, i.e. that the detail field is the
|
||||||
|
* value of the mapped button on the SD, not the physical button */
|
||||||
|
if (original->u.u.type == DeviceButtonPress || original->u.u.type == DeviceButtonRelease)
|
||||||
|
{
|
||||||
|
int btn = original->u.u.detail;
|
||||||
|
if (!sdev->button)
|
||||||
|
return; /* Should never happen */
|
||||||
|
|
||||||
|
master->event->u.u.detail = sdev->button->map[btn];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copy the given event into master.
|
* Copy the given event into master.
|
||||||
* @param mdev The master device
|
* @param mdev The master device
|
||||||
|
* @param sdev The slave device the original event comes from
|
||||||
* @param original The event as it came from the EQ
|
* @param original The event as it came from the EQ
|
||||||
* @param master The event after being copied
|
* @param master The event after being copied
|
||||||
* @param count Number of events in original.
|
* @param count Number of events in original.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
CopyGetMasterEvent(DeviceIntPtr mdev, xEvent* original,
|
CopyGetMasterEvent(DeviceIntPtr mdev, DeviceIntPtr sdev, xEvent* original,
|
||||||
EventListPtr master, int count)
|
EventListPtr master, int count)
|
||||||
{
|
{
|
||||||
int len = count * sizeof(xEvent);
|
int len = count * sizeof(xEvent);
|
||||||
|
@ -346,9 +363,14 @@ CopyGetMasterEvent(DeviceIntPtr mdev, xEvent* original,
|
||||||
|
|
||||||
memcpy(master->event, original, len);
|
memcpy(master->event, original, len);
|
||||||
while (count--)
|
while (count--)
|
||||||
|
{
|
||||||
ChangeDeviceID(mdev, &master->event[count]);
|
ChangeDeviceID(mdev, &master->event[count]);
|
||||||
|
FixUpEventForMaster(mdev, sdev, original, master, count);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Call this from ProcessInputEvents(). */
|
/* Call this from ProcessInputEvents(). */
|
||||||
void
|
void
|
||||||
mieqProcessInputEvents(void)
|
mieqProcessInputEvents(void)
|
||||||
|
@ -419,7 +441,7 @@ mieqProcessInputEvents(void)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (master)
|
if (master)
|
||||||
CopyGetMasterEvent(master, event, masterEvents, nevents);
|
CopyGetMasterEvent(master, dev, event, masterEvents, nevents);
|
||||||
|
|
||||||
/* If someone's registered a custom event handler, let them
|
/* If someone's registered a custom event handler, let them
|
||||||
* steal it. */
|
* steal it. */
|
||||||
|
|
|
@ -116,7 +116,7 @@ DeviceIntPtr master = NULL;
|
||||||
if (!IsPointerDevice(master))
|
if (!IsPointerDevice(master))
|
||||||
master = GetPairedDevice(dev->u.master);
|
master = GetPairedDevice(dev->u.master);
|
||||||
|
|
||||||
CopyGetMasterEvent(master, &events, masterEvents, count);
|
CopyGetMasterEvent(master, dev, &events, masterEvents, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
(*dev->public.processInputProc)((xEventPtr)btn, dev, count);
|
(*dev->public.processInputProc)((xEventPtr)btn, dev, count);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user