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 release.
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 	 */
38 	public void controllerAdded(uint id);
39 	/**
40 	 * Called if a controller was removed.
41 	 */
42 	public void controllerRemoved(uint id);
43 }
44 /**
45  * Called on text input events.
46  */
47 public interface TextInputListener {
48 	/**
49 	 * Passes the inputted text to the target, alongside with a window ID and a timestamp.
50 	 */
51 	public void textInputEvent(uint timestamp, uint windowID, dstring text);
52 	/**
53 	 * Passes text editing events to the target, alongside with a window ID and a timestamp.
54 	 */
55 	public void textEditingEvent(uint timestamp, uint windowID, dstring text, int start, int length);
56 	/**
57 	 * Passes text input key events to the target, e.g. cursor keys.
58 	 */
59 	public void textInputKeyEvent(uint timestamp, uint windowID, TextInputKey key, ushort modifier);
60 	/**
61 	 * When called, the listener should drop all text input.
62 	 */
63 	public void dropTextInput();
64 	/**
65 	 * Called if text input should be initialized.
66 	 */
67 	public void initTextInput();
68 }
69 /**
70  * Called on mouse events
71  */
72 public interface MouseListener {
73 	/**
74 	 * Called on mouse click events.
75 	 */
76 	public void mouseClickEvent(MouseEventCommons mec, MouseClickEvent mce);
77 	/**
78 	 * Called on mouse wheel events.
79 	 */
80 	public void mouseWheelEvent(MouseEventCommons mec, MouseWheelEvent mwe);
81 	/**
82 	 * Called on mouse motion events.
83 	 */
84 	public void mouseMotionEvent(MouseEventCommons mec, MouseMotionEvent mme);
85 }