1 module pixelperfectengine.system.input.interfaces; 2 3 public import pixelperfectengine.system.input.types; 4 5 /** 6 * Listener for keyboard, joystick, etc. events. 7 */ 8 public interface InputListener { 9 /** 10 * Called when a keybinding event is generated. 11 * The `id` should be generated from a string, usually the name of the binding. 12 * `code` is a duplicate of the code used for fast lookup of the binding, which also contains other info (deviceID, etc). 13 * `timestamp` is the time lapsed since the start of the program, can be used to measure time between keypresses. 14 * NOTE: Hat events on joysticks don't generate keyReleased events, instead they generate keyPressed events on getting centered. 15 */ 16 public void keyEvent(uint id, BindingCode code, uint timestamp, bool isPressed); 17 /** 18 * Called when an axis is being operated. 19 * The `id` should be generated from a string, usually the name of the binding. 20 * `code` is a duplicate of the code used for fast lookup of the binding, which also contains other info (deviceID, etc). 21 * `timestamp` is the time lapsed since the start of the program, can be used to measure time between keypresses. 22 * `value` is the current position of the axis normalized between -1.0 and +1.0 for joysticks, and 0.0 and +1.0 for analog 23 * triggers. 24 */ 25 public void axisEvent(uint id, BindingCode code, uint timestamp, float value); 26 } 27 /** 28 * Listener for system events. Controller adding and removal, quiting the application, etc. 29 */ 30 public interface SystemEventListener { 31 /** 32 * Called if the window is being closed. 33 */ 34 public void onQuit(); 35 /** 36 * Called if a controller was added. 37 * The `id` is the ID of the attached controller. 38 */ 39 public void controllerAdded(uint id); 40 /** 41 * Called if a controller was removed. 42 * The `id` is the ID of the removed controller. 43 */ 44 public void controllerRemoved(uint id); 45 } 46 /** 47 * Called on text input events. 48 */ 49 public interface TextInputListener { 50 /** 51 * Passes the inputted text to the target, alongside with a window ID and a timestamp. 52 */ 53 public void textInputEvent(uint timestamp, uint windowID, dstring text); 54 /** 55 * Passes text editing events to the target, alongside with a window ID and a timestamp. 56 */ 57 public void textEditingEvent(uint timestamp, uint windowID, dstring text, int start, int length); 58 /** 59 * Passes text input key events to the target, e.g. cursor keys. 60 */ 61 public void textInputKeyEvent(uint timestamp, uint windowID, TextInputKey key, ushort modifier); 62 /** 63 * When called, the listener should drop all text input. 64 */ 65 public void dropTextInput(); 66 /** 67 * Called if text input should be initialized. 68 */ 69 public void initTextInput(); 70 } 71 /** 72 * Called on mouse events 73 */ 74 public interface MouseListener { 75 /** 76 * Called on mouse click events. 77 */ 78 public void mouseClickEvent(MouseEventCommons mec, MouseClickEvent mce); 79 /** 80 * Called on mouse wheel events. 81 */ 82 public void mouseWheelEvent(MouseEventCommons mec, MouseWheelEvent mwe); 83 /** 84 * Called on mouse motion events. 85 */ 86 public void mouseMotionEvent(MouseEventCommons mec, MouseMotionEvent mme); 87 }