Fix support of touchscreens for RPI (#1586)
-Checks for absolute pressure in absolute events to simulate a touch or a left mouse click. -Updates touch position on absolute events.
This commit is contained in:
parent
f3df64210b
commit
c7476f0aa5
1 changed files with 33 additions and 4 deletions
35
src/core.c
35
src/core.c
|
@ -5753,7 +5753,8 @@ static void *EventThread(void *arg)
|
||||||
// Basic movement
|
// Basic movement
|
||||||
if (event.code == ABS_X)
|
if (event.code == ABS_X)
|
||||||
{
|
{
|
||||||
CORE.Input.Mouse.position.x = (event.value - worker->absRange.x)*CORE.Window.screen.width/worker->absRange.width; // Scale acording to absRange
|
CORE.Input.Mouse.position.x = (event.value - worker->absRange.x)*CORE.Window.screen.width/worker->absRange.width; // Scale acording to absRange
|
||||||
|
CORE.Input.Touch.position[0].x = (event.value - worker->absRange.x)*CORE.Window.screen.width/worker->absRange.width; // Scale acording to absRange
|
||||||
|
|
||||||
#if defined(SUPPORT_GESTURES_SYSTEM)
|
#if defined(SUPPORT_GESTURES_SYSTEM)
|
||||||
touchAction = TOUCH_MOVE;
|
touchAction = TOUCH_MOVE;
|
||||||
|
@ -5763,7 +5764,8 @@ static void *EventThread(void *arg)
|
||||||
|
|
||||||
if (event.code == ABS_Y)
|
if (event.code == ABS_Y)
|
||||||
{
|
{
|
||||||
CORE.Input.Mouse.position.y = (event.value - worker->absRange.y)*CORE.Window.screen.height/worker->absRange.height; // Scale acording to absRange
|
CORE.Input.Mouse.position.y = (event.value - worker->absRange.y)*CORE.Window.screen.height/worker->absRange.height; // Scale acording to absRange
|
||||||
|
CORE.Input.Touch.position[0].y = (event.value - worker->absRange.y)*CORE.Window.screen.height/worker->absRange.height; // Scale acording to absRange
|
||||||
|
|
||||||
#if defined(SUPPORT_GESTURES_SYSTEM)
|
#if defined(SUPPORT_GESTURES_SYSTEM)
|
||||||
touchAction = TOUCH_MOVE;
|
touchAction = TOUCH_MOVE;
|
||||||
|
@ -5772,7 +5774,7 @@ static void *EventThread(void *arg)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Multitouch movement
|
// Multitouch movement
|
||||||
if (event.code == ABS_MT_SLOT) worker->touchSlot = event.value; // Remeber the slot number for the folowing events
|
if (event.code == ABS_MT_SLOT) worker->touchSlot = event.value; // Remember the slot number for the folowing events
|
||||||
|
|
||||||
if (event.code == ABS_MT_POSITION_X)
|
if (event.code == ABS_MT_POSITION_X)
|
||||||
{
|
{
|
||||||
|
@ -5793,6 +5795,33 @@ static void *EventThread(void *arg)
|
||||||
CORE.Input.Touch.position[worker->touchSlot].y = -1;
|
CORE.Input.Touch.position[worker->touchSlot].y = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Touchscreen tap
|
||||||
|
if(event.code == ABS_PRESSURE)
|
||||||
|
{
|
||||||
|
int previousMouseLeftButtonState = CORE.Input.Mouse.currentButtonStateEvdev[MOUSE_LEFT_BUTTON];
|
||||||
|
|
||||||
|
if(!event.value && previousMouseLeftButtonState)
|
||||||
|
{
|
||||||
|
CORE.Input.Mouse.currentButtonStateEvdev[MOUSE_LEFT_BUTTON] = 0;
|
||||||
|
|
||||||
|
#if defined(SUPPORT_GESTURES_SYSTEM)
|
||||||
|
touchAction = TOUCH_UP;
|
||||||
|
gestureUpdate = true;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
if(event.value && !previousMouseLeftButtonState)
|
||||||
|
{
|
||||||
|
CORE.Input.Mouse.currentButtonStateEvdev[MOUSE_LEFT_BUTTON] = 1;
|
||||||
|
|
||||||
|
#if defined(SUPPORT_GESTURES_SYSTEM)
|
||||||
|
touchAction = TOUCH_DOWN;
|
||||||
|
gestureUpdate = true;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Button parsing
|
// Button parsing
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue