Increase maximum touch points from 8 to 10 and enhance touchscreen prioritization logic
This commit is contained in:
parent
1064590ba7
commit
bffba21ff8
|
|
@ -105,7 +105,7 @@
|
||||||
#define MAX_GAMEPAD_AXES 8 // Maximum number of axes supported (per gamepad)
|
#define MAX_GAMEPAD_AXES 8 // Maximum number of axes supported (per gamepad)
|
||||||
#define MAX_GAMEPAD_BUTTONS 32 // Maximum number of buttons supported (per gamepad)
|
#define MAX_GAMEPAD_BUTTONS 32 // Maximum number of buttons supported (per gamepad)
|
||||||
#define MAX_GAMEPAD_VIBRATION_TIME 2.0f // Maximum vibration time in seconds
|
#define MAX_GAMEPAD_VIBRATION_TIME 2.0f // Maximum vibration time in seconds
|
||||||
#define MAX_TOUCH_POINTS 8 // Maximum number of touch points supported
|
#define MAX_TOUCH_POINTS 10 // Maximum number of touch points supported
|
||||||
#define MAX_KEY_PRESSED_QUEUE 16 // Maximum number of keys in the key input queue
|
#define MAX_KEY_PRESSED_QUEUE 16 // Maximum number of keys in the key input queue
|
||||||
#define MAX_CHAR_PRESSED_QUEUE 16 // Maximum number of characters in the char input queue
|
#define MAX_CHAR_PRESSED_QUEUE 16 // Maximum number of characters in the char input queue
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -135,6 +135,7 @@ typedef struct {
|
||||||
char currentButtonStateEvdev[MAX_MOUSE_BUTTONS]; // Holds the new mouse state for the next polling event to grab
|
char currentButtonStateEvdev[MAX_MOUSE_BUTTONS]; // Holds the new mouse state for the next polling event to grab
|
||||||
bool cursorRelative; // Relative cursor mode
|
bool cursorRelative; // Relative cursor mode
|
||||||
int mouseFd; // File descriptor for the evdev mouse/touch/gestures
|
int mouseFd; // File descriptor for the evdev mouse/touch/gestures
|
||||||
|
bool mouseIsTouch; // Check if the current mouse device is actually a touchscreen
|
||||||
Rectangle absRange; // Range of values for absolute pointing devices (touchscreens)
|
Rectangle absRange; // Range of values for absolute pointing devices (touchscreens)
|
||||||
int touchSlot; // Hold the touch slot number of the currently being sent multitouch block
|
int touchSlot; // Hold the touch slot number of the currently being sent multitouch block
|
||||||
bool touchActive[MAX_TOUCH_POINTS]; // Track which touch points are currently active
|
bool touchActive[MAX_TOUCH_POINTS]; // Track which touch points are currently active
|
||||||
|
|
@ -2054,17 +2055,49 @@ static void ConfigureEvdevDevice(char *device)
|
||||||
const char *deviceKindStr = "unknown";
|
const char *deviceKindStr = "unknown";
|
||||||
if (isMouse || isTouch)
|
if (isMouse || isTouch)
|
||||||
{
|
{
|
||||||
deviceKindStr = "mouse";
|
bool prioritize = false;
|
||||||
if (platform.mouseFd != -1) close(platform.mouseFd);
|
|
||||||
platform.mouseFd = fd;
|
|
||||||
|
|
||||||
if (absAxisCount > 0)
|
// Priority logic: Touchscreens override Mice.
|
||||||
|
// 1. No device set yet? Take it.
|
||||||
|
if (platform.mouseFd == -1) prioritize = true;
|
||||||
|
// 2. Current is Mouse, New is Touch? Upgrade to Touch.
|
||||||
|
else if (isTouch && !platform.mouseIsTouch) prioritize = true;
|
||||||
|
// 3. Current is Touch, New is Touch? Use the new one (Last one found wins, standard behavior).
|
||||||
|
else if (isTouch && platform.mouseIsTouch) prioritize = true;
|
||||||
|
// 4. Current is Mouse, New is Mouse? Use the new one.
|
||||||
|
else if (!isTouch && !platform.mouseIsTouch) prioritize = true;
|
||||||
|
// 5. Current is Touch, New is Mouse? IGNORE the mouse. Keep the touchscreen.
|
||||||
|
else prioritize = false;
|
||||||
|
|
||||||
|
if (prioritize)
|
||||||
{
|
{
|
||||||
platform.absRange.x = absinfo[ABS_X].info.minimum;
|
deviceKindStr = isTouch ? "touchscreen" : "mouse";
|
||||||
platform.absRange.width = absinfo[ABS_X].info.maximum - absinfo[ABS_X].info.minimum;
|
|
||||||
|
if (platform.mouseFd != -1)
|
||||||
|
{
|
||||||
|
TRACELOG(LOG_INFO, "INPUT: Overwriting previous input device with new %s", deviceKindStr);
|
||||||
|
close(platform.mouseFd);
|
||||||
|
}
|
||||||
|
|
||||||
|
platform.mouseFd = fd;
|
||||||
|
platform.mouseIsTouch = isTouch;
|
||||||
|
|
||||||
platform.absRange.y = absinfo[ABS_Y].info.minimum;
|
if (absAxisCount > 0)
|
||||||
platform.absRange.height = absinfo[ABS_Y].info.maximum - absinfo[ABS_Y].info.minimum;
|
{
|
||||||
|
platform.absRange.x = absinfo[ABS_X].info.minimum;
|
||||||
|
platform.absRange.width = absinfo[ABS_X].info.maximum - absinfo[ABS_X].info.minimum;
|
||||||
|
|
||||||
|
platform.absRange.y = absinfo[ABS_Y].info.minimum;
|
||||||
|
platform.absRange.height = absinfo[ABS_Y].info.maximum - absinfo[ABS_Y].info.minimum;
|
||||||
|
}
|
||||||
|
|
||||||
|
TRACELOG(LOG_INFO, "INPUT: Initialized input device %s as %s", device, deviceKindStr);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
TRACELOG(LOG_INFO, "INPUT: Ignoring device %s (keeping higher priority %s device)", device, platform.mouseIsTouch ? "touchscreen" : "mouse");
|
||||||
|
close(fd);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (isGamepad && !isMouse && !isKeyboard && (platform.gamepadCount < MAX_GAMEPADS))
|
else if (isGamepad && !isMouse && !isKeyboard && (platform.gamepadCount < MAX_GAMEPADS))
|
||||||
|
|
@ -2334,8 +2367,13 @@ static void PollMouseEvents(void)
|
||||||
if (event.value >= 0)
|
if (event.value >= 0)
|
||||||
{
|
{
|
||||||
// Touch has started for this point
|
// Touch has started for this point
|
||||||
|
// If it was already active, it means we missed a lift event or the ID changed
|
||||||
|
// We should treat it as a new touch
|
||||||
platform.touchActive[platform.touchSlot] = true;
|
platform.touchActive[platform.touchSlot] = true;
|
||||||
platform.touchId[platform.touchSlot] = event.value;
|
platform.touchId[platform.touchSlot] = event.value;
|
||||||
|
|
||||||
|
// Force DOWN action, even if we previously detected a MOVE or UP in this frame
|
||||||
|
// A new touch is a significant state change that should take priority
|
||||||
touchAction = 1; // TOUCH_ACTION_DOWN
|
touchAction = 1; // TOUCH_ACTION_DOWN
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -2345,7 +2383,10 @@ static void PollMouseEvents(void)
|
||||||
platform.touchPosition[platform.touchSlot].x = -1;
|
platform.touchPosition[platform.touchSlot].x = -1;
|
||||||
platform.touchPosition[platform.touchSlot].y = -1;
|
platform.touchPosition[platform.touchSlot].y = -1;
|
||||||
platform.touchId[platform.touchSlot] = -1;
|
platform.touchId[platform.touchSlot] = -1;
|
||||||
touchAction = 0; // TOUCH_ACTION_UP
|
|
||||||
|
// Force UP action if we haven't already set a DOWN action
|
||||||
|
// (DOWN takes priority over UP if both happen in one frame, though rare)
|
||||||
|
if (touchAction != 1) touchAction = 0; // TOUCH_ACTION_UP
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -2364,7 +2405,7 @@ static void PollMouseEvents(void)
|
||||||
platform.touchPosition[platform.touchSlot].x = -1;
|
platform.touchPosition[platform.touchSlot].x = -1;
|
||||||
platform.touchPosition[platform.touchSlot].y = -1;
|
platform.touchPosition[platform.touchSlot].y = -1;
|
||||||
platform.touchId[platform.touchSlot] = -1;
|
platform.touchId[platform.touchSlot] = -1;
|
||||||
touchAction = 0; // TOUCH_ACTION_UP
|
if (touchAction != 1) touchAction = 0; // TOUCH_ACTION_UP
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -2386,7 +2427,7 @@ static void PollMouseEvents(void)
|
||||||
platform.touchPosition[i].y = -1;
|
platform.touchPosition[i].y = -1;
|
||||||
platform.touchId[i] = -1;
|
platform.touchId[i] = -1;
|
||||||
}
|
}
|
||||||
touchAction = 0; // TOUCH_ACTION_UP
|
if (touchAction != 1) touchAction = 0; // TOUCH_ACTION_UP
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.value && !previousMouseLeftButtonState)
|
if (event.value && !previousMouseLeftButtonState)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user