Add new input nodes
This commit is contained in:
parent
1ece052aee
commit
a5fa3445d9
33
Sources/armory/logicnode/GetGamepadStartedNode.hx
Normal file
33
Sources/armory/logicnode/GetGamepadStartedNode.hx
Normal file
|
@ -0,0 +1,33 @@
|
|||
package armory.logicnode;
|
||||
|
||||
import iron.system.Input;
|
||||
|
||||
class GetGamepadStartedNode extends LogicNode {
|
||||
|
||||
var buttonStarted: Null<String>;
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
override function run(from: Int) {
|
||||
var g = Input.getGamepad(inputs[0].get());
|
||||
|
||||
buttonStarted = null;
|
||||
|
||||
for (b in Gamepad.buttons) {
|
||||
if (g.started(b)) {
|
||||
buttonStarted = b;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (buttonStarted != null) {
|
||||
runOutput(0);
|
||||
}
|
||||
}
|
||||
|
||||
override function get(from: Int) {
|
||||
return buttonStarted;
|
||||
}
|
||||
}
|
32
Sources/armory/logicnode/GetKeyboardStartedNode.hx
Normal file
32
Sources/armory/logicnode/GetKeyboardStartedNode.hx
Normal file
|
@ -0,0 +1,32 @@
|
|||
package armory.logicnode;
|
||||
|
||||
import iron.system.Input;
|
||||
|
||||
class GetKeyboardStartedNode extends LogicNode {
|
||||
|
||||
var kb = Input.getKeyboard();
|
||||
var keyStarted: Null<String>;
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
override function run(from: Int) {
|
||||
keyStarted = null;
|
||||
|
||||
for (k in Keyboard.keys) {
|
||||
if (kb.started(k)) {
|
||||
keyStarted = k;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (keyStarted != null) {
|
||||
runOutput(0);
|
||||
}
|
||||
}
|
||||
|
||||
override function get(from: Int) {
|
||||
return keyStarted;
|
||||
}
|
||||
}
|
32
Sources/armory/logicnode/GetMouseStartedNode.hx
Normal file
32
Sources/armory/logicnode/GetMouseStartedNode.hx
Normal file
|
@ -0,0 +1,32 @@
|
|||
package armory.logicnode;
|
||||
|
||||
import iron.system.Input;
|
||||
|
||||
class GetKeyboardStartedNode extends LogicNode {
|
||||
|
||||
var m = Input.getMouse();
|
||||
var buttonStarted: Null<String>;
|
||||
|
||||
public function new(tree: LogicTree) {
|
||||
super(tree);
|
||||
}
|
||||
|
||||
override function run(from: Int) {
|
||||
buttonStarted = null;
|
||||
|
||||
for (b in Mouse.buttons) {
|
||||
if (m.started(b)) {
|
||||
buttonStarted = b;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (buttonStarted != null) {
|
||||
runOutput(0);
|
||||
}
|
||||
}
|
||||
|
||||
override function get(from: Int) {
|
||||
return buttonStarted;
|
||||
}
|
||||
}
|
15
blender/arm/logicnode/input/LN_get_gamepad_started.py
Normal file
15
blender/arm/logicnode/input/LN_get_gamepad_started.py
Normal file
|
@ -0,0 +1,15 @@
|
|||
from arm.logicnode.arm_nodes import *
|
||||
|
||||
class GetGamepadStartedNode(ArmLogicTreeNode):
|
||||
"""."""
|
||||
bl_idname = 'LNGetGamepadStartedNode'
|
||||
bl_label = 'Get Gamepad Started'
|
||||
arm_version = 1
|
||||
|
||||
def init(self, context):
|
||||
super(GetGamepadStartedNode, self).init(context)
|
||||
self.add_input('ArmNodeSocketAction', 'In')
|
||||
self.add_input('NodeSocketInt', 'Index')
|
||||
|
||||
self.add_output('ArmNodeSocketAction', 'Out')
|
||||
self.add_output('NodeSocketString', 'Button')
|
14
blender/arm/logicnode/input/LN_get_keyboard_started.py
Normal file
14
blender/arm/logicnode/input/LN_get_keyboard_started.py
Normal file
|
@ -0,0 +1,14 @@
|
|||
from arm.logicnode.arm_nodes import *
|
||||
|
||||
class GetKeyboardStartedNode(ArmLogicTreeNode):
|
||||
"""."""
|
||||
bl_idname = 'LNGetKeyboardStartedNode'
|
||||
bl_label = 'Get Keyboard Started'
|
||||
arm_version = 1
|
||||
|
||||
def init(self, context):
|
||||
super(GetKeyboardStartedNode, self).init(context)
|
||||
self.add_input('ArmNodeSocketAction', 'In')
|
||||
|
||||
self.add_output('ArmNodeSocketAction', 'Out')
|
||||
self.add_output('NodeSocketString', 'Key')
|
14
blender/arm/logicnode/input/LN_get_mouse_started.py
Normal file
14
blender/arm/logicnode/input/LN_get_mouse_started.py
Normal file
|
@ -0,0 +1,14 @@
|
|||
from arm.logicnode.arm_nodes import *
|
||||
|
||||
class GetMouseStartedNode(ArmLogicTreeNode):
|
||||
"""."""
|
||||
bl_idname = 'LNGetMouseStartedNode'
|
||||
bl_label = 'Get Mouse Started'
|
||||
arm_version = 1
|
||||
|
||||
def init(self, context):
|
||||
super(GetMouseStartedNode, self).init(context)
|
||||
self.add_input('ArmNodeSocketAction', 'In')
|
||||
|
||||
self.add_output('ArmNodeSocketAction', 'Out')
|
||||
self.add_output('NodeSocketString', 'Button')
|
Loading…
Reference in a new issue