瀏覽代碼

comma: detected single frame released events (#8)

pull/5008/head
Maxime Desroches 3 週之前
committed by GitHub
父節點
當前提交
c0753673e6
沒有發現已知的金鑰在資料庫的簽署中 GPG Key ID: B5690EEEBB952194
共有 1 個文件被更改,包括 11 次插入0 次删除
  1. +11
    -0
      src/platforms/rcore_comma.c

+ 11
- 0
src/platforms/rcore_comma.c 查看文件

@ -628,6 +628,8 @@ void PollInputEvents(void) {
CORE.Input.Mouse.previousPosition = CORE.Input.Mouse.currentPosition;
CORE.Input.Touch.pointCount = 0;
int released_detected = 0;
struct input_event event = {0};
while (read(platform.touch.fd, &event, sizeof(struct input_event)) == sizeof(struct input_event)) {
if (event.type == SYN_REPORT) { // synchronization frame. Expose completed events back to the library
@ -647,6 +649,9 @@ void PollInputEvents(void) {
}
} else if (platform.touch.fingers[i].action == TOUCH_ACTION_UP) {
if (CORE.Input.Touch.currentTouchState[i] == 1) {
released_detected = 1;
}
CORE.Input.Touch.position[i].x = -1;
CORE.Input.Touch.position[i].y = -1;
CORE.Input.Touch.currentTouchState[i] = 0;
@ -667,6 +672,12 @@ void PollInputEvents(void) {
}
}
// hack for now to detect gestures in single frame
if (released_detected) {
CORE.Input.Touch.previousTouchState[0] = 1;
CORE.Input.Touch.currentTouchState[0] = 0;
}
// count how many fingers are left on the screen after processing all events
for (int i = 0; i < MAX_TOUCH_POINTS; ++i) {
CORE.Input.Touch.pointCount += platform.touch.fingers[i].action != TOUCH_ACTION_UP;

Loading…
取消
儲存