First pass on enabling correct X/Y joystick.onTrackballMove events
This commit is contained in:
@@ -253,17 +253,17 @@ class NativeApplication {
|
||||
case AXIS_MOVE:
|
||||
|
||||
var joystick = Joystick.devices.get (joystickEventInfo.id);
|
||||
if (joystick != null) joystick.onAxisMove.dispatch (joystickEventInfo.index, joystickEventInfo.value);
|
||||
if (joystick != null) joystick.onAxisMove.dispatch (joystickEventInfo.index, joystickEventInfo.x);
|
||||
|
||||
case HAT_MOVE:
|
||||
|
||||
var joystick = Joystick.devices.get (joystickEventInfo.id);
|
||||
if (joystick != null) joystick.onHatMove.dispatch (joystickEventInfo.index, joystickEventInfo.x);
|
||||
if (joystick != null) joystick.onHatMove.dispatch (joystickEventInfo.index, joystickEventInfo.value);
|
||||
|
||||
case TRACKBALL_MOVE:
|
||||
|
||||
var joystick = Joystick.devices.get (joystickEventInfo.id);
|
||||
if (joystick != null) joystick.onTrackballMove.dispatch (joystickEventInfo.index, joystickEventInfo.value);
|
||||
if (joystick != null) joystick.onTrackballMove.dispatch (joystickEventInfo.index, joystickEventInfo.x, joystickEventInfo.y);
|
||||
|
||||
case BUTTON_DOWN:
|
||||
|
||||
|
||||
@@ -273,9 +273,10 @@ class Module implements IModule {
|
||||
* Called when a joystick axis move event is fired
|
||||
* @param joystick The current joystick
|
||||
* @param trackball The trackball that was moved
|
||||
* @param value The trackball value (between 0 and 1)
|
||||
* @param x The x movement of the trackball (between 0 and 1)
|
||||
* @param y The y movement of the trackball (between 0 and 1)
|
||||
*/
|
||||
public function onJoystickTrackballMove (joystick:Joystick, trackball:Int, value:Float):Void { }
|
||||
public function onJoystickTrackballMove (joystick:Joystick, trackball:Int, x:Float, y:Float):Void { }
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -31,7 +31,7 @@ class Joystick {
|
||||
public var onButtonUp = new Event<Int->Void> ();
|
||||
public var onDisconnect = new Event<Void->Void> ();
|
||||
public var onHatMove = new Event<Int->JoystickHatPosition->Void> ();
|
||||
public var onTrackballMove = new Event<Int->Float->Void> ();
|
||||
public var onTrackballMove = new Event<Int->Float->Float->Void> ();
|
||||
|
||||
|
||||
public function new (id:Int) {
|
||||
|
||||
@@ -32,12 +32,12 @@ namespace lime {
|
||||
|
||||
static void Dispatch (JoystickEvent* event);
|
||||
|
||||
double eventValue;
|
||||
int eventValue;
|
||||
int id;
|
||||
int index;
|
||||
JoystickEventType type;
|
||||
int x;
|
||||
int y;
|
||||
double x;
|
||||
double y;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -434,7 +434,7 @@ namespace lime {
|
||||
|
||||
joystickEvent.type = JOYSTICK_AXIS_MOVE;
|
||||
joystickEvent.index = event->jaxis.axis;
|
||||
joystickEvent.eventValue = event->jaxis.value / (event->jaxis.value > 0 ? 32767.0 : 32768.0);
|
||||
joystickEvent.x = event->jaxis.value / (event->jaxis.value > 0 ? 32767.0 : 32768.0);
|
||||
joystickEvent.id = event->jaxis.which;
|
||||
|
||||
JoystickEvent::Dispatch (&joystickEvent);
|
||||
@@ -448,8 +448,8 @@ namespace lime {
|
||||
|
||||
joystickEvent.type = JOYSTICK_TRACKBALL_MOVE;
|
||||
joystickEvent.index = event->jball.ball;
|
||||
joystickEvent.x = event->jball.xrel;
|
||||
joystickEvent.y = event->jball.yrel;
|
||||
joystickEvent.x = event->jball.xrel / (event->jball.xrel > 0 ? 32767.0 : 32768.0);
|
||||
joystickEvent.y = event->jball.yrel / (event->jball.yrel > 0 ? 32767.0 : 32768.0);
|
||||
joystickEvent.id = event->jball.which;
|
||||
|
||||
JoystickEvent::Dispatch (&joystickEvent);
|
||||
@@ -489,7 +489,7 @@ namespace lime {
|
||||
|
||||
joystickEvent.type = JOYSTICK_HAT_MOVE;
|
||||
joystickEvent.index = event->jhat.hat;
|
||||
joystickEvent.x = event->jhat.value;
|
||||
joystickEvent.eventValue = event->jhat.value;
|
||||
joystickEvent.id = event->jhat.which;
|
||||
|
||||
JoystickEvent::Dispatch (&joystickEvent);
|
||||
|
||||
@@ -50,9 +50,9 @@ namespace lime {
|
||||
alloc_field (object, id_id, alloc_int (event->id));
|
||||
alloc_field (object, id_index, alloc_int (event->index));
|
||||
alloc_field (object, id_type, alloc_int (event->type));
|
||||
alloc_field (object, id_value, alloc_float (event->eventValue));
|
||||
alloc_field (object, id_x, alloc_int (event->x));
|
||||
alloc_field (object, id_y, alloc_int (event->y));
|
||||
alloc_field (object, id_value, alloc_int (event->eventValue));
|
||||
alloc_field (object, id_x, alloc_float (event->x));
|
||||
alloc_field (object, id_y, alloc_float (event->y));
|
||||
|
||||
val_call0 (JoystickEvent::callback->get ());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user