1 /** 2 * Copyright: Copyright (C) 2018 Gabriel Gheorghe, All Rights Reserved 3 * Authors: $(Gabriel Gheorghe) 4 * License: $(LINK2 https://www.gnu.org/licenses/gpl-3.0.txt, GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007) 5 * Source: $(LINK2 https://github.com/GabyForceQ/LibertyEngine/blob/master/source/liberty/input/profiler/binding.d) 6 * Documentation: 7 * Coverage: 8 **/ 9 module liberty.input.profiler.binding; 10 11 import liberty.input.constants; 12 import liberty.input.impl; 13 import liberty.input.profiler.data; 14 import liberty.input.profiler.impl; 15 import liberty.input.joystick.impl; 16 import liberty.input.keyboard.impl; 17 import liberty.input.mouse.impl; 18 19 /** 20 * 21 **/ 22 final class InputActionBinding { 23 private { 24 string id; 25 InputProfiler parent; 26 } 27 28 /** 29 * 30 **/ 31 InputAction!Keyboard[] keyboard; 32 33 /** 34 * 35 **/ 36 InputAction!Mouse[] mouse; 37 38 /** 39 * 40 **/ 41 InputAction!Joystick[] joystick; 42 43 /** 44 * 45 **/ 46 this(string id, InputProfiler parent) { 47 this.id = id; 48 this.parent = parent; 49 } 50 51 /** 52 * 53 **/ 54 string getId() const { 55 return id; 56 } 57 58 /** 59 * 60 **/ 61 bool isUnfolding() { 62 import std.uni : toLower; 63 import std.traits : EnumMembers; 64 65 static foreach (type; EnumMembers!InputDeviceType) 66 static if (type != "None") 67 foreach (e; mixin(type.toLower())) 68 if (mixin("Input.get" ~ type ~ "().isUnfolding(e.button, e.action)")) { 69 parent.lastDeviceUsed = type; 70 return true; 71 } 72 73 return false; 74 } 75 } 76 77 /** 78 * 79 **/ 80 final class InputAxisBinding { 81 private { 82 string id; 83 } 84 85 /** 86 * 87 **/ 88 InputAxis!Keyboard[] keyboard; 89 90 /** 91 * 92 **/ 93 InputAxis!Mouse[] mouse; 94 95 /** 96 * 97 **/ 98 InputAxis!Joystick[] joystick; 99 100 /** 101 * 102 **/ 103 this(string id) { 104 this.id = id; 105 } 106 107 /** 108 * 109 **/ 110 string getId() const { 111 return id; 112 } 113 }