diff options
| author | realtradam <[email protected]> | 2023-04-24 03:58:04 -0400 |
|---|---|---|
| committer | realtradam <[email protected]> | 2023-04-24 03:58:04 -0400 |
| commit | 8f42815db1d3636c3fddc696b626c54ca7896d32 (patch) | |
| tree | c8b691f85704abbe3becd21e6dac5efba17f4028 /src | |
| parent | 92b561030f7f713fc4e2893de05fdc7a06c8a139 (diff) | |
| download | RodeoKit-8f42815db1d3636c3fddc696b626c54ca7896d32.tar.gz RodeoKit-8f42815db1d3636c3fddc696b626c54ca7896d32.zip | |
added unbounded ranges for the input system
Diffstat (limited to 'src')
| -rw-r--r-- | src/input/rodeo_input.c | 75 |
1 files changed, 70 insertions, 5 deletions
diff --git a/src/input/rodeo_input.c b/src/input/rodeo_input.c index a6edfbb..426fda4 100644 --- a/src/input/rodeo_input.c +++ b/src/input/rodeo_input.c @@ -108,13 +108,23 @@ rodeo_input_events_poll(void) { 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, + &command->positional.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, + &command->positional.mouse_position, rodeo_input_positional_mouse_Y - ); + ); + const cset_input_unboundedRange_mouse_value *rel_x_value = + cset_input_unboundedRange_mouse_get( + &command->unbounded_range.mouse_delta, + rodeo_input_unboundedRange_mouse_X + ); + const cset_input_unboundedRange_mouse_value *rel_y_value = + cset_input_unboundedRange_mouse_get( + &command->unbounded_range.mouse_delta, + rodeo_input_unboundedRange_mouse_Y + ); if(x_value != NULL) { @@ -147,6 +157,37 @@ rodeo_input_events_poll(void) (**k.ref)(input_state); } } + if(rel_x_value != NULL) + { + rodeo_input_any_state_t input_state = { + .data.unbounded_range_state = (float)event.motion.xrel, + .input_type = rodeo_input_type_UnboundedRange + }; + c_foreach( + k, + cset_input_callback_functions, + command->callbacks + ) + { + (**k.ref)(input_state); + } + } + + if(rel_y_value != NULL) + { + rodeo_input_any_state_t input_state = { + .data.unbounded_range_state = (float)event.motion.yrel, + .input_type = rodeo_input_type_UnboundedRange + }; + c_foreach( + k, + cset_input_callback_functions, + command->callbacks + ) + { + (**k.ref)(input_state); + } + } } } } @@ -302,7 +343,31 @@ rodeo_input_command_register_positional_mouse( else { cset_input_positional_mouse_insert( - &input_command->unbounded_range.mouse_position, + &input_command->positional.mouse_position, + mouse_axis + ); + return true; + } +} + +bool +rodeo_input_command_register_unboundedRange_mouse( + rodeo_input_command_t *input_command, + rodeo_input_unboundedRange_mouse_t mouse_axis +) +{ + if((rodeo_input_type_UnboundedRange & 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_unboundedRange_mouse_insert( + &input_command->unbounded_range.mouse_delta, mouse_axis ); return true; |
