diff options
| author | realtradam <[email protected]> | 2023-04-24 02:27:18 -0400 |
|---|---|---|
| committer | realtradam <[email protected]> | 2023-04-24 02:27:18 -0400 |
| commit | 92b561030f7f713fc4e2893de05fdc7a06c8a139 (patch) | |
| tree | e48f6719d839f12e4a11281d0c29cef25e21b747 /src/input/rodeo_input.c | |
| parent | cb3c2a69576168a3193151f14d6c1f4aeaa30e0b (diff) | |
| download | RodeoKit-92b561030f7f713fc4e2893de05fdc7a06c8a139.tar.gz RodeoKit-92b561030f7f713fc4e2893de05fdc7a06c8a139.zip | |
added positional inputs to input system
Diffstat (limited to 'src/input/rodeo_input.c')
| -rw-r--r-- | src/input/rodeo_input.c | 76 |
1 files changed, 76 insertions, 0 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, |
