armory/Sources/armory/logicnode/OnGamepadNode.hx

35 lines
930 B
Haxe
Raw Normal View History

2017-04-10 21:17:17 +02:00
package armory.logicnode;
class OnGamepadNode extends LogicNode {
2019-12-19 23:54:08 +01:00
public var property0: String;
public var property1: String;
2017-04-10 21:17:17 +02:00
@:deprecated("The 'On Gamepad' node is deprecated and will be removed in future SDK versions. Please use 'Gamepad' instead.")
2019-12-19 23:54:08 +01:00
public function new(tree: LogicTree) {
2017-04-10 21:17:17 +02:00
super(tree);
tree.notifyOnUpdate(update);
}
function update() {
2019-12-19 23:54:08 +01:00
var num: Int = inputs[0].get();
2017-11-20 15:16:52 +01:00
var gamepad = iron.system.Input.getGamepad(num);
2017-04-16 14:46:35 +02:00
if (gamepad == null) return;
2017-04-10 21:17:17 +02:00
var b = false;
switch (property0) {
case "Down":
b = gamepad.down(property1) > 0.0;
case "Started":
b = gamepad.started(property1);
case "Released":
b = gamepad.released(property1);
// case "Moved Left":
// b = gamepad.leftStick.movementX != 0 || gamepad.leftStick.movementY != 0;
// case "Moved Right":
// b = gamepad.rightStick.movementX != 0 || gamepad.rightStick.movementY != 0;
}
2018-10-22 10:10:33 +02:00
if (b) runOutput(0);
2017-04-10 21:17:17 +02:00
}
}