inputs: Added interfce for detecting action presses
authorLukas Krickl <lukas@krickl.dev>
Sun, 1 Mar 2026 15:28:03 +0000 (16:28 +0100)
committerLukas Krickl <lukas@krickl.dev>
Sun, 1 Mar 2026 15:28:03 +0000 (16:28 +0100)
src/i_input.c
src/i_input.h

index 903d97be1f791700b6dac4e72159fa0a13a71880..d50cc487bcdff99284c70068ad72cc5af2650dfc 100644 (file)
@@ -85,6 +85,22 @@ void i_input_cursor_action_unset(void) {
        i_input_map.inputs[I_INPUT_ACTION_CURSOR_ACTION].held = 0;
 }
 
+
+lrts_bool i_input_just_pressed(enum i_input_actions action) {
+       LRTS_UNUSED(action);
+       return LRTS_FALSE;
+}
+
+lrts_bool i_input_held(enum i_input_actions action) {
+       LRTS_UNUSED(action);
+       return LRTS_FALSE;
+}
+
+lrts_bool i_input_double_press(enum i_input_actions action) {
+       LRTS_UNUSED(action);
+       return LRTS_FALSE;
+}
+
 void i_input_poll(void) {
        p_poll_events();
        i_input_update();
index b9a120480e1aad43afdb4d4f1c71dfa796af7392..3669ddd05dd009f268dea6c9b5e3d4d6ed827f69 100644 (file)
@@ -92,6 +92,16 @@ void i_input_cursor_click_unset(void);
 void i_input_cursor_drag_unset(void);
 void i_input_cursor_action_unset(void);
 
+/* returns true if this action was just performed this frame */
+lrts_bool i_input_just_pressed(enum i_input_actions action);
+
+/* returns true if this action is held for more than 1 frame */
+lrts_bool i_input_held(enum i_input_actions action);
+
+/* returns true if the action was clicked twice within a 
+ * delay window causing a double click */
+lrts_bool i_input_double_press(enum i_input_actions action);
+
 /* polls input from system backend 
  * and translates the input to commands 
  */