summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorrealtradam <[email protected]>2023-04-24 02:27:18 -0400
committerrealtradam <[email protected]>2023-04-24 02:27:18 -0400
commit92b561030f7f713fc4e2893de05fdc7a06c8a139 (patch)
treee48f6719d839f12e4a11281d0c29cef25e21b747 /src
parentcb3c2a69576168a3193151f14d6c1f4aeaa30e0b (diff)
downloadRodeoKit-92b561030f7f713fc4e2893de05fdc7a06c8a139.tar.gz
RodeoKit-92b561030f7f713fc4e2893de05fdc7a06c8a139.zip
added positional inputs to input system
Diffstat (limited to 'src')
-rw-r--r--src/input/rodeo_input.c76
-rw-r--r--src/rodeo_input.c23
2 files changed, 76 insertions, 23 deletions
diff --git a/src/input/rodeo_input.c b/src/input/rodeo_input.c
index 02144dc..a6edfbb 100644
--- a/src/input/rodeo_input.c
+++ b/src/input/rodeo_input.c
@@ -99,6 +99,58 @@ rodeo_input_events_poll(void)
}
}
break;
+ case SDL_MOUSEMOTION:
+ {
+ c_foreach(i, cset_input_scene, istate.active_scenes)
+ {
+ rodeo_input_scene_t *scene = *i.ref;
+ c_foreach(j, cset_input_commands, scene->commands)
+ {
+ rodeo_input_command_t *command = *j.ref;
+ const cset_input_positional_mouse_value *x_value = cset_input_positional_mouse_get(
+ &command->unbounded_range.mouse_position,
+ rodeo_input_positional_mouse_X
+ );
+ const cset_input_positional_mouse_value *y_value = cset_input_positional_mouse_get(
+ &command->unbounded_range.mouse_position,
+ rodeo_input_positional_mouse_Y
+ );
+
+ if(x_value != NULL)
+ {
+ rodeo_input_any_state_t input_state = {
+ .data.positional_state = event.motion.x,
+ .input_type = rodeo_input_type_Positional
+ };
+ c_foreach(
+ k,
+ cset_input_callback_functions,
+ command->callbacks
+ )
+ {
+ (**k.ref)(input_state);
+ }
+ }
+
+ if(y_value != NULL)
+ {
+ rodeo_input_any_state_t input_state = {
+ .data.positional_state = event.motion.y,
+ .input_type = rodeo_input_type_Positional
+ };
+ c_foreach(
+ k,
+ cset_input_callback_functions,
+ command->callbacks
+ )
+ {
+ (**k.ref)(input_state);
+ }
+ }
+ }
+ }
+ }
+ break;
}
}
return false;
@@ -233,6 +285,30 @@ rodeo_input_command_register_binary_mouseButton(
}
}
+bool
+rodeo_input_command_register_positional_mouse(
+ rodeo_input_command_t *input_command,
+ rodeo_input_positional_mouse_t mouse_axis
+)
+{
+ if((rodeo_input_type_Positional & input_command->valid_types) == 0)
+ {
+ rodeo_log(
+ rodeo_logLevel_error,
+ "Attempting to register input type which is invalid for this input command, failed to do so"
+ );
+ return false;
+ }
+ else
+ {
+ cset_input_positional_mouse_insert(
+ &input_command->unbounded_range.mouse_position,
+ mouse_axis
+ );
+ return true;
+ }
+}
+
void
rodeo_input_scene_register_command(
rodeo_input_scene_t *scene,
diff --git a/src/rodeo_input.c b/src/rodeo_input.c
deleted file mode 100644
index 3a40b77..0000000
--- a/src/rodeo_input.c
+++ /dev/null
@@ -1,23 +0,0 @@
-
-// public internal
-#include "rodeo_types.h"
-#include "rodeo.h"
-
-// external
-#include "SDL/SDL.h"
-
-int32_t
-rodeo_input_mouse_x_get(void)
-{
- int32_t x, y;
- SDL_GetMouseState(&x, &y);
- return x;
-}
-
-int32_t
-rodeo_input_mouse_y_get(void)
-{
- int32_t x, y;
- SDL_GetMouseState(&x, &y);
- return y;
-}