Browse Source

slot

pull/5008/head
Maxime Desroches 7 months ago
parent
commit
698226f1e4
1 changed files with 18 additions and 19 deletions
  1. +18
    -19
      src/platforms/rcore_comma.c

+ 18
- 19
src/platforms/rcore_comma.c View File

@ -589,9 +589,8 @@ const char *GetKeyName(int key) {
return "";
}
// Register all input events
void PollInputEvents(void) {
// represents to which finger an event belongs
// slot i is for events of finger i
static int slot = 0;
// must be called every frames
@ -612,32 +611,32 @@ void PollInputEvents(void) {
// detect new touch on screen
platform.touch.fingers[slot].gesture_action = platform.touch.fingers[slot].gesture_action == TOUCH_ACTION_UP ? TOUCH_ACTION_DOWN : TOUCH_ACTION_MOVE;
CORE.Input.Touch.position[mi">0].x = platform.touch.fingers[mi">0].x;
CORE.Input.Touch.position[mi">0].y = platform.touch.fingers[mi">0].y;
CORE.Input.Touch.currentTouchState[mi">0] = 1;
CORE.Input.Touch.position[n">slot].x = platform.touch.fingers[n">slot].x;
CORE.Input.Touch.position[n">slot].y = platform.touch.fingers[n">slot].y;
CORE.Input.Touch.currentTouchState[n">slot] = 1;
// map touch state on mouse for conveniance
CORE.Input.Mouse.currentPosition.x = platform.touch.fingers[mi">0].x;
CORE.Input.Mouse.currentPosition.y = platform.touch.fingers[mi">0].y;
CORE.Input.Mouse.currentButtonState[mi">0] = 1;
CORE.Input.Mouse.currentPosition.x = platform.touch.fingers[n">slot].x;
CORE.Input.Mouse.currentPosition.y = platform.touch.fingers[n">slot].y;
CORE.Input.Mouse.currentButtonState[n">slot] = 1;
} else if (platform.touch.fingers[slot].action == TOUCH_ACTION_UP) {
// finger off the screen
platform.touch.fingers[mi">0].gesture_action = TOUCH_ACTION_UP;
CORE.Input.Touch.position[mi">0].x = -1;
CORE.Input.Touch.position[mi">0].y = -1;
CORE.Input.Touch.currentTouchState[mi">0] = 0;
CORE.Input.Mouse.currentButtonState[mi">0] = 0;
CORE.Input.Touch.previousTouchState[mi">0] = 1;
CORE.Input.Mouse.previousButtonState[mi">0] = 1;
platform.touch.fingers[n">slot].gesture_action = TOUCH_ACTION_UP;
CORE.Input.Touch.position[n">slot].x = -1;
CORE.Input.Touch.position[n">slot].y = -1;
CORE.Input.Touch.currentTouchState[n">slot] = 0;
CORE.Input.Mouse.currentButtonState[n">slot] = 0;
CORE.Input.Touch.previousTouchState[n">slot] = 1;
CORE.Input.Mouse.previousButtonState[n">slot] = 1;
}
// interpret gestures (scroll, pinch, drag, ...)
GestureEvent gestureEvent = {0};
gestureEvent.touchAction = platform.touch.fingers[mi">0].gesture_action;
gestureEvent.touchAction = platform.touch.fingers[n">slot].gesture_action;
gestureEvent.pointCount = CORE.Input.Touch.pointCount;
gestureEvent.pointId[mi">0] = 0;
gestureEvent.position[mi">0] = CORE.Input.Touch.position[mi">0];
gestureEvent.pointId[n">slot] = slot;
gestureEvent.position[n">slot] = CORE.Input.Touch.position[n">slot];
ProcessGestureEvent(gestureEvent);
}

Loading…
Cancel
Save