1 /** 2 Input event type for gamepad joysticks and other motions. For buttons, see `InputEventJoypadButton`. 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.inputeventjoypadmotion; 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 gamepad joysticks and other motions. For buttons, see `InputEventJoypadButton`. 28 29 Stores information about joystick motions. One $(D InputEventJoypadMotion) represents one axis at a time. 30 */ 31 @GodotBaseClass struct InputEventJoypadMotion 32 { 33 package(godot) enum string _GODOT_internal_name = "InputEventJoypadMotion"; 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_axis") GodotMethod!(long) getAxis; 44 @GodotName("get_axis_value") GodotMethod!(double) getAxisValue; 45 @GodotName("set_axis") GodotMethod!(void, long) setAxis; 46 @GodotName("set_axis_value") GodotMethod!(void, double) setAxisValue; 47 } 48 /// 49 pragma(inline, true) bool opEquals(in InputEventJoypadMotion other) const 50 { return _godot_object.ptr is other._godot_object.ptr; } 51 /// 52 pragma(inline, true) typeof(null) opAssign(typeof(null) n) 53 { _godot_object.ptr = n; return null; } 54 /// 55 pragma(inline, true) bool opEquals(typeof(null) n) const 56 { return _godot_object.ptr is n; } 57 /// 58 size_t toHash() const @trusted { return cast(size_t)_godot_object.ptr; } 59 mixin baseCasts; 60 /// Construct a new instance of InputEventJoypadMotion. 61 /// Note: use `memnew!InputEventJoypadMotion` instead. 62 static InputEventJoypadMotion _new() 63 { 64 static godot_class_constructor constructor; 65 if(constructor is null) constructor = _godot_api.godot_get_class_constructor("InputEventJoypadMotion"); 66 if(constructor is null) return typeof(this).init; 67 return cast(InputEventJoypadMotion)(constructor()); 68 } 69 @disable new(size_t s); 70 /** 71 72 */ 73 long getAxis() const 74 { 75 checkClassBinding!(typeof(this))(); 76 return ptrcall!(long)(GDNativeClassBinding.getAxis, _godot_object); 77 } 78 /** 79 80 */ 81 double getAxisValue() const 82 { 83 checkClassBinding!(typeof(this))(); 84 return ptrcall!(double)(GDNativeClassBinding.getAxisValue, _godot_object); 85 } 86 /** 87 88 */ 89 void setAxis(in long axis) 90 { 91 checkClassBinding!(typeof(this))(); 92 ptrcall!(void)(GDNativeClassBinding.setAxis, _godot_object, axis); 93 } 94 /** 95 96 */ 97 void setAxisValue(in double axis_value) 98 { 99 checkClassBinding!(typeof(this))(); 100 ptrcall!(void)(GDNativeClassBinding.setAxisValue, _godot_object, axis_value); 101 } 102 /** 103 Axis identifier. Use one of the $(D joysticklist) axis constants. 104 */ 105 @property long axis() 106 { 107 return getAxis(); 108 } 109 /// ditto 110 @property void axis(long v) 111 { 112 setAxis(v); 113 } 114 /** 115 Current position of the joystick on the given axis. The value ranges from `-1.0` to `1.0`. A value of `0` means the axis is in its resting position. 116 */ 117 @property double axisValue() 118 { 119 return getAxisValue(); 120 } 121 /// ditto 122 @property void axisValue(double v) 123 { 124 setAxisValue(v); 125 } 126 }