OK, that makes more sense. I think I can fix this solely by modifying Input.hx, which I am doing right now.
Justin, I'm having trouble getting it running. First of all, here's the original code for the onJoyAxisMove function:
private static function onJoyAxisMove(e:JoystickEvent)
{
if(!_joyControllerReady[e.device])
initJoyController(e);
var oldState:Array<Int> = _joyAxisState.get(e.device);
var cur:Int;
var old:Int;
for(i in 0...e.axis.length)
{
if(e.axis[i] < -joySensitivity)
cur = -1;
else if(e.axis[i] > joySensitivity)
cur = 1;
else
cur = 0;
old = oldState[i];
if(cur != old)
{
if(old == -1)
joyRelease(e.device + ", -axis " + i);
else if(old == 1)
joyRelease(e.device + ", +axis " + i);
if(cur == -1)
joyPress(e.device + ", -axis " + i);
else if(cur == 1)
joyPress(e.device + ", +axis " + i);
}
oldState[i] = cur;
}
Now, I tried to change the reference of _joyAxisState to _joyAxisPressure, which contains arrays of Floats instead of Ints, but is not currently used anywhere else. Here's the updated code:
private static function onJoyAxisMove(e:JoystickEvent)
{
if(!_joyControllerReady[e.device])
initJoyController(e);
var oldState:Array<Float> = _joyAxisPressure.get(e.device);
var cur:Float;
var old:Float;
for(i in 0...e.axis.length)
{
if(e.axis[i] < -joySensitivity)
cur = e.axis[i];
else if(e.axis[i] > joySensitivity)
cur = e.axis[i];
else
cur = 0;
old = oldState[i];
if(cur != old)
{
if(old < -joySensitivity && -joySensitivity < cur)
joyRelease(e.device + ", -axis " + i);
else if(old > joySensitivity && joySensitivity > cur)
joyRelease(e.device + ", +axis " + i);
if(old < joySensitivity && joySensitivity < cur)
joyPress(e.device + ", -axis " + i);
else if(old > -joySensitivity && -joySensitivity > cur)
joyPress(e.device + ", +axis " + i);
}
oldState[i] = cur;
}
_joyAxisPressure.set(e.device, e.axis);
}
The problem is, as soon as I use any control on the gamepad, it freezes the game. However, if I change...
var oldState:Array<Float> = _joyAxisPressure.get(e.device);
...to this...
var oldState:Array<Float> = new Array<Float>();
...the game does not freeze, although it doesn't save the position of the axes anymore. Do you have any idea why it freezes?