The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.
SDL
Simple Directmedia Layer Forums
Android multitouch SDL 1.3 XOOM work HTC Desire not
leanid
Joined: 17 May 2011
Posts: 8
Posted: Wed Aug 17, 2011 8:56 am
Hello,
I start porting game to android and add multitouch to SDL 1.3, but I don't fully understand how works this subsystem in SDL 1.3.
I test my code on motorola XOOM - and it works, and on HTC Desire - no luck. Please sugest any help!
java part
Code:
public boolean onTouch(View v, MotionEvent event) {
{
final int touchDevId = event.getDeviceId();
final int pointerCount = event.getPointerCount();
// touchId, pointerId, action, x, y, pressure
int actionPointerIndex = event.getActionIndex();
int pointerFingerId = event.getPointerId(actionPointerIndex);
int action = event.getActionMasked();
float x = event.getX(actionPointerIndex);
float y = event.getY(actionPointerIndex);
float p = event.getPressure(actionPointerIndex);
if (action == MotionEvent.ACTION_MOVE && pointerCount > 1) {
// TODO send motion to every pointer if it's position has
// changed since prev event.
for (int i = 0; i < pointerCount; i++) {
pointerFingerId = event.getPointerId(i);
x = event.getX(i);
y = event.getY(i);
p = event.getPressure(i);
SDLActivity.onNativeTouch(touchDevId, pointerFingerId,
action, x, y, p);
}
} else {
SDLActivity.onNativeTouch(touchDevId, pointerFingerId, action,
x, y, p);
}
}
return true;
}
c++ part
Code:
void Android_OnTouch(int touch_device_id_in, int pointer_finger_id_in, int action, float x, float y, float p)
{
// SDL_Log(
// "Android_OnTouch touchId=%d, pointerId=%d, action=%d, x=%f, y=%f, p=%f",
// touchId_, pointerId, action, x, y, p); // LEON ADD LINE
if (!Android_Window) {
return;
}