Update rcore_android.c
corrected coding conventions.
This commit is contained in:
parent
5da2d10118
commit
b6daa48a9c
1 changed files with 32 additions and 27 deletions
|
@ -70,6 +70,16 @@ typedef struct {
|
||||||
EGLConfig config; // Graphic config
|
EGLConfig config; // Graphic config
|
||||||
} PlatformData;
|
} PlatformData;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
// Store data for both Hover and Touch events
|
||||||
|
// Used to ignore Hover events which are interpreted as Touch events
|
||||||
|
int32_t pointCount; // Number of touch points active
|
||||||
|
int32_t pointId[MAX_TOUCH_POINTS]; // Point identifiers
|
||||||
|
Vector2 position[MAX_TOUCH_POINTS]; // Touch position on screen
|
||||||
|
|
||||||
|
int32_t hoverPoints[MAX_TOUCH_POINTS]; // Hover Points
|
||||||
|
} TouchRaw;
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
// Global Variables Definition
|
// Global Variables Definition
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
@ -246,16 +256,7 @@ static const KeyboardKey mapKeycode[KEYCODE_MAP_SIZE] = {
|
||||||
KEY_KP_EQUAL // AKEYCODE_NUMPAD_EQUALS
|
KEY_KP_EQUAL // AKEYCODE_NUMPAD_EQUALS
|
||||||
};
|
};
|
||||||
|
|
||||||
// Store data for both Hover and Touch events
|
static TouchRaw touchRaw = { 0 };
|
||||||
// Used to ignore Hover events which are interpreted as Touch events
|
|
||||||
static struct {
|
|
||||||
|
|
||||||
int32_t pointCount; // Number of touch points active
|
|
||||||
int32_t pointId[MAX_TOUCH_POINTS]; // Point identifiers
|
|
||||||
Vector2 position[MAX_TOUCH_POINTS]; // Touch position on screen
|
|
||||||
|
|
||||||
int32_t hoverPoints[MAX_TOUCH_POINTS]; // Hover Points
|
|
||||||
}touchRaw;
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
// Module Internal Functions Declaration
|
// Module Internal Functions Declaration
|
||||||
|
@ -812,10 +813,7 @@ int InitPlatform(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
touchRaw.pointCount = 0;
|
for (int i = 0; i < MAX_TOUCH_POINTS; i++) touchRaw.hoverPoints[i] = -1;
|
||||||
for(int i = 0; i < MAX_TOUCH_POINTS; i++){
|
|
||||||
touchRaw.hoverPoints[i] = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1306,24 +1304,30 @@ static int32_t AndroidInputCallback(struct android_app *app, AInputEvent *event)
|
||||||
unsigned int flags = action & AMOTION_EVENT_ACTION_MASK;
|
unsigned int flags = action & AMOTION_EVENT_ACTION_MASK;
|
||||||
int32_t pointerIndex = (action & AMOTION_EVENT_ACTION_POINTER_INDEX_MASK) >> AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT;
|
int32_t pointerIndex = (action & AMOTION_EVENT_ACTION_POINTER_INDEX_MASK) >> AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT;
|
||||||
|
|
||||||
if(flags == AMOTION_EVENT_ACTION_HOVER_ENTER){
|
if (flags == AMOTION_EVENT_ACTION_HOVER_ENTER)
|
||||||
|
{
|
||||||
// The new pointer is hover
|
// The new pointer is hover
|
||||||
// So add it to hoverPoints
|
// So add it to hoverPoints
|
||||||
for(int i = 0; i < MAX_TOUCH_POINTS; i++){
|
for (int i = 0; i < MAX_TOUCH_POINTS; i++)
|
||||||
if(touchRaw.hoverPoints[i] == -1){
|
{
|
||||||
|
if (touchRaw.hoverPoints[i] == -1)
|
||||||
|
{
|
||||||
touchRaw.hoverPoints[i] = touchRaw.pointId[pointerIndex];
|
touchRaw.hoverPoints[i] = touchRaw.pointId[pointerIndex];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags == AMOTION_EVENT_ACTION_POINTER_UP || flags == AMOTION_EVENT_ACTION_UP || flags == AMOTION_EVENT_ACTION_HOVER_EXIT)
|
if ((flags == AMOTION_EVENT_ACTION_POINTER_UP) || (flags == AMOTION_EVENT_ACTION_UP) || (flags == AMOTION_EVENT_ACTION_HOVER_EXIT))
|
||||||
{
|
{
|
||||||
// One of the touchpoints is released, remove it from touch point arrays
|
// One of the touchpoints is released, remove it from touch point arrays
|
||||||
if(flags == AMOTION_EVENT_ACTION_HOVER_EXIT){
|
if (flags == AMOTION_EVENT_ACTION_HOVER_EXIT)
|
||||||
|
{
|
||||||
// If the touchPoint is hover, remove it from hoverPoints
|
// If the touchPoint is hover, remove it from hoverPoints
|
||||||
for(int i = 0; i < MAX_TOUCH_POINTS; i++){
|
for (int i = 0; i < MAX_TOUCH_POINTS; i++)
|
||||||
if(touchRaw.hoverPoints[i] == touchRaw.pointId[pointerIndex]){
|
{
|
||||||
|
if (touchRaw.hoverPoints[i] == touchRaw.pointId[pointerIndex])
|
||||||
|
{
|
||||||
touchRaw.hoverPoints[i] = -1;
|
touchRaw.hoverPoints[i] = -1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1342,15 +1346,16 @@ static int32_t AndroidInputCallback(struct android_app *app, AInputEvent *event)
|
||||||
{
|
{
|
||||||
// If the touchPoint is hover, Ignore it
|
// If the touchPoint is hover, Ignore it
|
||||||
bool hover = false;
|
bool hover = false;
|
||||||
for(int j = 0; j < MAX_TOUCH_POINTS; j++){
|
for (int j = 0; j < MAX_TOUCH_POINTS; j++)
|
||||||
|
{
|
||||||
// Check if the touchPoint is in hoverPointers
|
// Check if the touchPoint is in hoverPointers
|
||||||
if(touchRaw.hoverPoints[j] == touchRaw.pointId[i]){
|
if (touchRaw.hoverPoints[j] == touchRaw.pointId[i])
|
||||||
|
{
|
||||||
hover = true;
|
hover = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(hover)
|
if (hover) continue;
|
||||||
continue;
|
|
||||||
|
|
||||||
CORE.Input.Touch.pointId[pointCount] = touchRaw.pointId[i];
|
CORE.Input.Touch.pointId[pointCount] = touchRaw.pointId[i];
|
||||||
CORE.Input.Touch.position[pointCount] = touchRaw.position[i];
|
CORE.Input.Touch.position[pointCount] = touchRaw.position[i];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue