Make the Touch events more robust
This commit is contained in:
@@ -429,30 +429,28 @@ namespace lime {
|
||||
case SDL_FINGERMOTION:
|
||||
|
||||
touchEvent.type = TOUCH_MOVE;
|
||||
touchEvent.x = event->tfinger.x;
|
||||
touchEvent.y = event->tfinger.y;
|
||||
touchEvent.id = event->tfinger.fingerId;
|
||||
break;
|
||||
|
||||
case SDL_FINGERDOWN:
|
||||
|
||||
touchEvent.type = TOUCH_START;
|
||||
touchEvent.x = event->tfinger.x;
|
||||
touchEvent.y = event->tfinger.y;
|
||||
touchEvent.id = event->tfinger.fingerId;
|
||||
break;
|
||||
|
||||
case SDL_FINGERUP:
|
||||
|
||||
touchEvent.type = TOUCH_END;
|
||||
touchEvent.x = event->tfinger.x;
|
||||
touchEvent.y = event->tfinger.y;
|
||||
touchEvent.id = event->tfinger.fingerId;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
//touchEvent.windowID = event->tfinger.windowID;
|
||||
touchEvent.x = event->tfinger.x;
|
||||
touchEvent.y = event->tfinger.y;
|
||||
touchEvent.id = event->tfinger.fingerId;
|
||||
touchEvent.dx = event->tfinger.dx;
|
||||
touchEvent.dy = event->tfinger.dy;
|
||||
touchEvent.pressure = event->tfinger.pressure;
|
||||
touchEvent.device = event->tfinger.touchId;
|
||||
|
||||
TouchEvent::Dispatch (&touchEvent);
|
||||
|
||||
}
|
||||
|
||||
@@ -8,9 +8,12 @@ namespace lime {
|
||||
AutoGCRoot* TouchEvent::callback = 0;
|
||||
AutoGCRoot* TouchEvent::eventObject = 0;
|
||||
|
||||
static int id_device;
|
||||
static int id_dx;
|
||||
static int id_dy;
|
||||
static int id_id;
|
||||
static int id_pressure;
|
||||
static int id_type;
|
||||
static int id_windowID;
|
||||
static int id_x;
|
||||
static int id_y;
|
||||
static bool init = false;
|
||||
@@ -18,11 +21,14 @@ namespace lime {
|
||||
|
||||
TouchEvent::TouchEvent () {
|
||||
|
||||
id = 0;
|
||||
type = TOUCH_START;
|
||||
windowID = 0;
|
||||
x = 0;
|
||||
y = 0;
|
||||
id = 0;
|
||||
dx = 0;
|
||||
dy = 0;
|
||||
pressure = 0;
|
||||
device = 0;
|
||||
|
||||
}
|
||||
|
||||
@@ -33,9 +39,12 @@ namespace lime {
|
||||
|
||||
if (!init) {
|
||||
|
||||
id_device = val_id ("device");
|
||||
id_dx = val_id ("dx");
|
||||
id_dy = val_id ("dy");
|
||||
id_id = val_id ("id");
|
||||
id_pressure = val_id ("pressure");
|
||||
id_type = val_id ("type");
|
||||
id_windowID = val_id ("windowID");
|
||||
id_x = val_id ("x");
|
||||
id_y = val_id ("y");
|
||||
init = true;
|
||||
@@ -44,9 +53,12 @@ namespace lime {
|
||||
|
||||
value object = (TouchEvent::eventObject ? TouchEvent::eventObject->get () : alloc_empty_object ());
|
||||
|
||||
alloc_field (object, id_device, alloc_int (event->device));
|
||||
alloc_field (object, id_dx, alloc_float (event->dx));
|
||||
alloc_field (object, id_dy, alloc_float (event->dy));
|
||||
alloc_field (object, id_id, alloc_int (event->id));
|
||||
alloc_field (object, id_pressure, alloc_float (event->pressure));
|
||||
alloc_field (object, id_type, alloc_int (event->type));
|
||||
alloc_field (object, id_windowID, alloc_int (event->windowID));
|
||||
alloc_field (object, id_x, alloc_float (event->x));
|
||||
alloc_field (object, id_y, alloc_float (event->y));
|
||||
|
||||
@@ -57,4 +69,4 @@ namespace lime {
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user