|
1 | 1 | //This file was automatically generated by Makefile at https://github.com/cntools/rawdraw |
2 | | -//Generated from files git hash ee3033ea1ad85ef409139067b1f36e35cef8fd4a on Tue Apr 15 12:54:46 AM PDT 2025 (This is not the git hash of this file) |
| 2 | +//Generated from files git hash b1b945260514c1a3b2366b017b1de502b4d78e1c on Mon Jul 21 08:38:02 PM EDT 2025 (This is not the git hash of this file) |
3 | 3 | // Copyright 2010-2021 <>< CNLohr, et. al. (Several other authors, many but not all mentioned) |
4 | 4 | // Licensed under the MIT/x11 or NewBSD License you choose. |
5 | 5 | // |
@@ -3381,7 +3381,7 @@ int CNFGHandleInput() |
3381 | 3381 | { |
3382 | 3382 | //Do nothing. |
3383 | 3383 | //Input is handled on swap frame. |
3384 | | - return 0; |
| 3384 | + return 1; |
3385 | 3385 | } |
3386 | 3386 |
|
3387 | 3387 | #endif |
@@ -5131,44 +5131,54 @@ void CNFGSetupFullscreen( const char * WindowName, int screen_number ) |
5131 | 5131 |
|
5132 | 5132 | int debuga, debugb, debugc; |
5133 | 5133 |
|
| 5134 | +#ifndef MAX_NUM_TOUCHES |
| 5135 | +#define MAX_NUM_TOUCHES 10 |
| 5136 | +#endif |
| 5137 | +bool touch_is_down[MAX_NUM_TOUCHES]; |
| 5138 | + |
5134 | 5139 | int32_t handle_input(struct android_app* app, AInputEvent* event) |
5135 | 5140 | { |
5136 | 5141 | #ifdef ANDROID |
5137 | 5142 | //Potentially do other things here. |
5138 | 5143 |
|
5139 | 5144 | if (AInputEvent_getType(event) == AINPUT_EVENT_TYPE_MOTION) |
5140 | 5145 | { |
5141 | | - int action = AMotionEvent_getAction( event ); |
5142 | | - int whichsource = action >> 8; |
5143 | | - action &= AMOTION_EVENT_ACTION_MASK; |
5144 | | - size_t pointerCount = AMotionEvent_getPointerCount(event); |
| 5146 | + int pointer_count = AMotionEvent_getPointerCount(event); |
| 5147 | + int32_t action = AMotionEvent_getAction(event); |
| 5148 | + int flags = action & AMOTION_EVENT_ACTION_MASK; |
| 5149 | + int id = (action & AMOTION_EVENT_ACTION_POINTER_INDEX_MASK) >> AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT; |
| 5150 | + int pid = AMotionEvent_getPointerId(event, id); |
5145 | 5151 |
|
5146 | | - for (size_t i = 0; i < pointerCount; ++i) |
5147 | | - { |
5148 | | - int x, y, index; |
5149 | | - x = AMotionEvent_getX(event, i); |
5150 | | - y = AMotionEvent_getY(event, i); |
5151 | | - index = AMotionEvent_getPointerId( event, i ); |
| 5152 | + if(pid > 9 || pointer_count > MAX_NUM_TOUCHES){ |
| 5153 | + printf("Pointer id larger than MAX_NUM_TOUCHES\n"); |
| 5154 | + return 0; |
| 5155 | + } |
5152 | 5156 |
|
5153 | | - if( action == AMOTION_EVENT_ACTION_POINTER_DOWN || action == AMOTION_EVENT_ACTION_DOWN ) |
5154 | | - { |
5155 | | - int id = index; |
5156 | | - if( action == AMOTION_EVENT_ACTION_POINTER_DOWN && id != whichsource ) continue; |
5157 | | - HandleButton( x, y, id, 1 ); |
5158 | | - ANativeActivity_showSoftInput( gapp->activity, ANATIVEACTIVITY_SHOW_SOFT_INPUT_FORCED ); |
| 5157 | + switch(flags){ |
| 5158 | + case AMOTION_EVENT_ACTION_POINTER_UP: |
| 5159 | + case AMOTION_EVENT_ACTION_UP:{ |
| 5160 | + touch_is_down[pid] = 0; |
| 5161 | + HandleButton(AMotionEvent_getX(event, id), AMotionEvent_getY(event, id), pid, 0); |
| 5162 | + break; |
5159 | 5163 | } |
5160 | | - else if( action == AMOTION_EVENT_ACTION_POINTER_UP || action == AMOTION_EVENT_ACTION_UP || action == AMOTION_EVENT_ACTION_CANCEL ) |
5161 | | - { |
5162 | | - int id = index; |
5163 | | - if( action == AMOTION_EVENT_ACTION_POINTER_UP && id != whichsource ) continue; |
5164 | | - HandleButton( x, y, id, 0 ); |
| 5164 | + case AMOTION_EVENT_ACTION_POINTER_DOWN: |
| 5165 | + case AMOTION_EVENT_ACTION_DOWN:{ |
| 5166 | + touch_is_down[pid] = 1; |
| 5167 | + HandleButton(AMotionEvent_getX(event, id), AMotionEvent_getY(event, id), pid, 1); |
| 5168 | + break; |
5165 | 5169 | } |
5166 | | - else if( action == AMOTION_EVENT_ACTION_MOVE ) |
5167 | | - { |
5168 | | - HandleMotion( x, y, index ); |
| 5170 | + case AMOTION_EVENT_ACTION_MOVE:{ |
| 5171 | + int off = 0; //number of touches preceeding i that are not down |
| 5172 | + for(int i = 0; i-off < pointer_count && pid+i<MAX_NUM_TOUCHES; i++){ |
| 5173 | + if(touch_is_down[pid+i] == 0){ |
| 5174 | + off++; |
| 5175 | + continue; |
| 5176 | + } |
| 5177 | + HandleMotion(AMotionEvent_getX(event, i-off), AMotionEvent_getY(event, i-off), pid+i); |
| 5178 | + } |
| 5179 | + break; |
5169 | 5180 | } |
5170 | 5181 | } |
5171 | | - return 1; |
5172 | 5182 | } |
5173 | 5183 | else if (AInputEvent_getType(event) == AINPUT_EVENT_TYPE_KEY) |
5174 | 5184 | { |
@@ -8174,4 +8184,3 @@ float tdPerlin2D( float x, float y ) |
8174 | 8184 |
|
8175 | 8185 | #endif |
8176 | 8186 |
|
8177 | | - |
|
0 commit comments