1 /**
2 Input event type for actions.
3 
4 Copyright:
5 Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur.  
6 Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md)  
7 Copyright (c) 2017-2018 Godot-D contributors  
8 
9 License: $(LINK2 https://opensource.org/licenses/MIT, MIT License)
10 
11 
12 */
13 module godot.inputeventaction;
14 import std.meta : AliasSeq, staticIndexOf;
15 import std.traits : Unqual;
16 import godot.d.traits;
17 import godot.core;
18 import godot.c;
19 import godot.d.bind;
20 import godot.d.reference;
21 import godot.globalenums;
22 import godot.object;
23 import godot.classdb;
24 import godot.inputevent;
25 import godot.resource;
26 /**
27 Input event type for actions.
28 
29 Contains a generic action which can be targeted from several types of inputs. Actions can be created from the $(B Input Map) tab in the $(B Project > Project Settings) menu. See $(D Node._input).
30 */
31 @GodotBaseClass struct InputEventAction
32 {
33 	package(godot) enum string _GODOT_internal_name = "InputEventAction";
34 public:
35 @nogc nothrow:
36 	union { /** */ godot_object _godot_object; /** */ InputEvent _GODOT_base; }
37 	alias _GODOT_base this;
38 	alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses);
39 	package(godot) __gshared bool _classBindingInitialized = false;
40 	package(godot) static struct GDNativeClassBinding
41 	{
42 		__gshared:
43 		@GodotName("get_action") GodotMethod!(String) getAction;
44 		@GodotName("get_strength") GodotMethod!(double) getStrength;
45 		@GodotName("set_action") GodotMethod!(void, String) setAction;
46 		@GodotName("set_pressed") GodotMethod!(void, bool) setPressed;
47 		@GodotName("set_strength") GodotMethod!(void, double) setStrength;
48 	}
49 	/// 
50 	pragma(inline, true) bool opEquals(in InputEventAction other) const
51 	{ return _godot_object.ptr is other._godot_object.ptr; }
52 	/// 
53 	pragma(inline, true) typeof(null) opAssign(typeof(null) n)
54 	{ _godot_object.ptr = n; return null; }
55 	/// 
56 	pragma(inline, true) bool opEquals(typeof(null) n) const
57 	{ return _godot_object.ptr is n; }
58 	/// 
59 	size_t toHash() const @trusted { return cast(size_t)_godot_object.ptr; }
60 	mixin baseCasts;
61 	/// Construct a new instance of InputEventAction.
62 	/// Note: use `memnew!InputEventAction` instead.
63 	static InputEventAction _new()
64 	{
65 		static godot_class_constructor constructor;
66 		if(constructor is null) constructor = _godot_api.godot_get_class_constructor("InputEventAction");
67 		if(constructor is null) return typeof(this).init;
68 		return cast(InputEventAction)(constructor());
69 	}
70 	@disable new(size_t s);
71 	/**
72 	
73 	*/
74 	String getAction() const
75 	{
76 		checkClassBinding!(typeof(this))();
77 		return ptrcall!(String)(GDNativeClassBinding.getAction, _godot_object);
78 	}
79 	/**
80 	
81 	*/
82 	double getStrength() const
83 	{
84 		checkClassBinding!(typeof(this))();
85 		return ptrcall!(double)(GDNativeClassBinding.getStrength, _godot_object);
86 	}
87 	/**
88 	
89 	*/
90 	void setAction(in String action)
91 	{
92 		checkClassBinding!(typeof(this))();
93 		ptrcall!(void)(GDNativeClassBinding.setAction, _godot_object, action);
94 	}
95 	/**
96 	
97 	*/
98 	void setPressed(in bool pressed)
99 	{
100 		checkClassBinding!(typeof(this))();
101 		ptrcall!(void)(GDNativeClassBinding.setPressed, _godot_object, pressed);
102 	}
103 	/**
104 	
105 	*/
106 	void setStrength(in double strength)
107 	{
108 		checkClassBinding!(typeof(this))();
109 		ptrcall!(void)(GDNativeClassBinding.setStrength, _godot_object, strength);
110 	}
111 	/**
112 	The action's name. Actions are accessed via this $(D String).
113 	*/
114 	@property String action()
115 	{
116 		return getAction();
117 	}
118 	/// ditto
119 	@property void action(String v)
120 	{
121 		setAction(v);
122 	}
123 	/**
124 	If `true`, the action's state is pressed. If `false`, the action's state is released.
125 	*/
126 	@property bool pressed()
127 	{
128 		return isPressed();
129 	}
130 	/// ditto
131 	@property void pressed(bool v)
132 	{
133 		setPressed(v);
134 	}
135 	/**
136 	The action's strength between 0 and 1. This value is considered as equal to 0 if pressed is `false`. The event strength allows faking analog joypad motion events, by specifying how strongly the joypad axis is bent or pressed.
137 	*/
138 	@property double strength()
139 	{
140 		return getStrength();
141 	}
142 	/// ditto
143 	@property void strength(double v)
144 	{
145 		setStrength(v);
146 	}
147 }