1 module libwasm.bindings.Gamepad; 2 3 import libwasm.types; 4 5 import memutils.ct: tuple; 6 import libwasm.bindings.GamepadHapticActuator; 7 import libwasm.bindings.GamepadPose; 8 import libwasm.bindings.Performance; 9 10 @safe: 11 nothrow: 12 13 struct Gamepad { 14 nothrow: 15 JsHandle handle; 16 alias handle this; 17 this(Handle h) { 18 this.handle = JsHandle(h); 19 } 20 string id()() { 21 return Object_Getter__string(this.handle, "id"); 22 } 23 uint index()() { 24 return Object_Getter__uint(this.handle, "index"); 25 } 26 GamepadMappingType mapping()() { 27 return Object_Getter__int(this.handle, "mapping"); 28 } 29 GamepadHand hand()() { 30 return Object_Getter__int(this.handle, "hand"); 31 } 32 uint displayId()() { 33 return Object_Getter__uint(this.handle, "displayId"); 34 } 35 bool connected()() { 36 return Object_Getter__bool(this.handle, "connected"); 37 } 38 auto buttons()() { 39 return Sequence!(GamepadButton)(Object_Getter__Handle(this.handle, "buttons")); 40 } 41 auto axes()() { 42 return Sequence!(double)(Object_Getter__Handle(this.handle, "axes")); 43 } 44 double timestamp()() { 45 return Object_Getter__double(this.handle, "timestamp"); 46 } 47 auto pose()() { 48 return recastOpt!(GamepadPose)(Object_Getter__OptionalHandle(this.handle, "pose")); 49 } 50 auto hapticActuators()() { 51 return Sequence!(GamepadHapticActuator)(Object_Getter__Handle(this.handle, "hapticActuators")); 52 } 53 } 54 struct GamepadButton { 55 nothrow: 56 JsHandle handle; 57 alias handle this; 58 this(Handle h) { 59 this.handle = JsHandle(h); 60 } 61 bool pressed()() { 62 return Object_Getter__bool(this.handle, "pressed"); 63 } 64 bool touched()() { 65 return Object_Getter__bool(this.handle, "touched"); 66 } 67 double value()() { 68 return Object_Getter__double(this.handle, "value"); 69 } 70 } 71 enum GamepadHand { 72 none, 73 left, 74 right 75 } 76 enum GamepadMappingType { 77 none, 78 standard 79 } 80 81