ok i must clear the things: that link can't help me.
i tried to simplify things so do not relate on the code i just show you what i am doing now after hundreds of changes ;]
i basically made an array of two pointers (becasue i will never use more than two)
what i do for now is:
ACTION_DOWN
touchpad[0].pressed = true;
touchpad[0].pos = getxy...
call_native_on_mousedown(x,y,0);
ACTION_UP
touchpad[0].pressed = false;
touchpad[0].pos = getxy...
call_native_on_mouseup(x,y,0);
ACTION_MOVE
through all pointers (int i)
touchpad[ i ].pos = getxy...
call_native_on_mousemove(x,y, i);
ACTION_POINTER_DOWN
touchpad[1].pressed = true;
touchpad[1].pos = getxy;
call_native_on_mousedown(x,y, 1);
ACTION_POINTER_UP
touchpad[1].pressed = false;
touchpad[1].pos = getxy..
call_native_on_mouseup(x,y, index);
its obviously wrong
now lets say i press topleft part of screen with finger (0 index)
and press center of screen with second finger
when i release first finger second finger index becomes 0 and that craps everything. so i need to (now when second finger is for camera rotation - bool mouse_move; and int mouse_move_index is equal to 1 in this case) index of the finger 2 changes to 0 so ACTION_MOVE when called checks if pointer_index == mouse_move_index then rotatecamera; doesnt work because pointer_index is now 0 so i need to change it from 1 to 0
that additionally craps the movement in one case:
when i press first button and then second and i move camera(rotate) with second finger and release first finger everything works (after changing that to 0) but when i press first finger again which now wil be secondary pointer it craps the rotation (anyway its not the big issue)
the issue is not to change index from 1 to 0 after calling action_pointer_up, but to store somehow those pointers in the array
i think i will come with something but really i dont want to change the spec of java file because i hate that so much that i would steal a X nukes an nuke every person that says that he likes it. + the more i use java the more i will have to change for ios port then. And please dont tell me java is supported by both platforms and works the same everywhere becasue its not.
messing indices ARGH!!!!
i didnt fix it yet and it needs some tweaking but i post a code that i call out of from java now
#ifndef android_pointersH
#define android_pointersH
#include "DxcMath.h"
const int POINTER_COUNT = 25;
struct TPointerInfo
{
textpoint pos;
bool pressed;
TPointerInfo()
{
pressed = false;
}
};
extern void Android_OnMouseDown(float x, float y);
extern void Android_OnMouseMove(float x, float y);
extern void Android_OnMouseUp(float x, float y);
extern int Find_first_free();
extern int Find_By_Coord(float x, float y);
extern TPointerInfo TOUCHPAD[ POINTER_COUNT ];
extern int touchpad_lastindex;
#endif
#include "android_pointers.h"
//#include "logme.h"
TPointerInfo TOUCHPAD[ POINTER_COUNT ];
int touchpad_lastindex;
int Find_first_free()
{
for (int i=0; i < POINTER_COUNT; i++)
if (!TOUCHPAD[i].pressed) return i;
return 0;
}
int Find_By_Coord(float x, float y)
{
float dst = 100000.0; //gazillion
int index = -1;
for (int i=0; i < POINTER_COUNT; i++)
if (TOUCHPAD[i].pressed) {
float adst = n3ddistance( vec3(x,y,0.0), vec3(TOUCHPAD[i].pos));
if ( adst < dst)
{
index = i;
dst = adst;
}
}
if (index != -1) return index;
return 0;
}
void Android_OnMouseDown(float x, float y)
{
int index = Find_first_free();
TOUCHPAD[index].pos = vec2(x, y);
TOUCHPAD[index].pressed = true;
touchpad_lastindex = index;
}
void Android_OnMouseMove(float x, float y)
{
TOUCHPAD [ Find_By_Coord(x,y) ].pos = vec2(x, y);
}
void Android_OnMouseUp(float x, float y)
{
int index = Find_By_Coord(x,y);
TOUCHPAD [ index ].pressed = false;
touchpad_lastindex = index;
}
this guarantees static index for the pointer so if i release pointer that has index 5 it will tell me that i released index 5 pointer. just for someone