1 /** 2 Input event for gamepad buttons. 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.inputeventjoypadbutton; 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 for gamepad buttons. 28 29 Input event type for gamepad buttons. For gamepad analog sticks and joysticks, see $(D InputEventJoypadMotion). 30 */ 31 @GodotBaseClass struct InputEventJoypadButton 32 { 33 package(godot) enum string _GODOT_internal_name = "InputEventJoypadButton"; 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_button_index") GodotMethod!(long) getButtonIndex; 44 @GodotName("get_pressure") GodotMethod!(double) getPressure; 45 @GodotName("set_button_index") GodotMethod!(void, long) setButtonIndex; 46 @GodotName("set_pressed") GodotMethod!(void, bool) setPressed; 47 @GodotName("set_pressure") GodotMethod!(void, double) setPressure; 48 } 49 /// 50 pragma(inline, true) bool opEquals(in InputEventJoypadButton 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 InputEventJoypadButton. 62 /// Note: use `memnew!InputEventJoypadButton` instead. 63 static InputEventJoypadButton _new() 64 { 65 static godot_class_constructor constructor; 66 if(constructor is null) constructor = _godot_api.godot_get_class_constructor("InputEventJoypadButton"); 67 if(constructor is null) return typeof(this).init; 68 return cast(InputEventJoypadButton)(constructor()); 69 } 70 @disable new(size_t s); 71 /** 72 73 */ 74 long getButtonIndex() const 75 { 76 checkClassBinding!(typeof(this))(); 77 return ptrcall!(long)(GDNativeClassBinding.getButtonIndex, _godot_object); 78 } 79 /** 80 81 */ 82 double getPressure() const 83 { 84 checkClassBinding!(typeof(this))(); 85 return ptrcall!(double)(GDNativeClassBinding.getPressure, _godot_object); 86 } 87 /** 88 89 */ 90 void setButtonIndex(in long button_index) 91 { 92 checkClassBinding!(typeof(this))(); 93 ptrcall!(void)(GDNativeClassBinding.setButtonIndex, _godot_object, button_index); 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 setPressure(in double pressure) 107 { 108 checkClassBinding!(typeof(this))(); 109 ptrcall!(void)(GDNativeClassBinding.setPressure, _godot_object, pressure); 110 } 111 /** 112 Button identifier. One of the $(D joysticklist) button constants. 113 */ 114 @property long buttonIndex() 115 { 116 return getButtonIndex(); 117 } 118 /// ditto 119 @property void buttonIndex(long v) 120 { 121 setButtonIndex(v); 122 } 123 /** 124 If `true`, the button's state is pressed. If `false`, the button'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 Represents the pressure the user puts on the button with his finger, if the controller supports it. Ranges from `0` to `1`. 137 */ 138 @property double pressure() 139 { 140 return getPressure(); 141 } 142 /// ditto 143 @property void pressure(double v) 144 { 145 setPressure(v); 146 } 147 }