From 06a3fc95288b8301a3b872ec5b4e906240f76fef Mon Sep 17 00:00:00 2001 From: realtradam Date: Mon, 5 Jun 2023 04:40:58 -0400 Subject: begin rewrite to avoid exposed pointers --- src/audio/irodeo_audio_t.h | 15 ++++ src/audio/rodeo_audio.c | 45 ++++++------ src/audio/rodeo_audio_t.h | 16 ----- src/collision/rodeo_collision.c | 38 +++++----- src/gfx/rodeo_gfx.c | 82 ++++++++++------------ src/input/irodeo_input_t.h | 4 +- src/input/rodeo_input.c | 149 +++++++++++++++++++++------------------- 7 files changed, 170 insertions(+), 179 deletions(-) create mode 100644 src/audio/irodeo_audio_t.h delete mode 100644 src/audio/rodeo_audio_t.h (limited to 'src') diff --git a/src/audio/irodeo_audio_t.h b/src/audio/irodeo_audio_t.h new file mode 100644 index 0000000..e2e247e --- /dev/null +++ b/src/audio/irodeo_audio_t.h @@ -0,0 +1,15 @@ +#pragma once + +// -- external -- +#include "SDL_mixer.h" + +struct +rodeo_audio_sound_data +{ + Mix_Chunk *sdl_sound; +}; +struct +rodeo_audio_music_data +{ + Mix_Music *sdl_music; +}; diff --git a/src/audio/rodeo_audio.c b/src/audio/rodeo_audio.c index f049fa2..485ddfd 100644 --- a/src/audio/rodeo_audio.c +++ b/src/audio/rodeo_audio.c @@ -4,13 +4,13 @@ #include "rodeo/audio.h" #include "rodeo/log.h" // private -#include "audio/rodeo_audio_t.h" +#include "audio/irodeo_audio_t.h" // -- external -- #include "SDL.h" #include "SDL_mixer.h" -static uint32_t **irodeo_audio_channelPool; +//static uint32_t **irodeo_audio_channelPool; //static uint32_t irodeo_audio_channelPool_num; //static uint32_t irodeo_audio_channelPool_size; @@ -92,7 +92,7 @@ rodeo_audio_init(uint32_t channels) void rodeo_audio_deinit(void) { - free(irodeo_audio_channelPool); + //free(irodeo_audio_channelPool); Mix_Quit(); } @@ -147,12 +147,13 @@ rodeo_audio_channelPool_volume_get(uint32_t channel_pool_id) } */ -rodeo_audio_sound_t* +rodeo_audio_sound_t rodeo_audio_sound_create_from_path(cstr path) { - rodeo_audio_sound_t *sample_sound = malloc(sizeof(rodeo_audio_sound_t)); - sample_sound->sdl_sound = Mix_LoadWAV(cstr_str(&path)); - if(NULL == sample_sound->sdl_sound) + rodeo_audio_sound_t sample_sound = {0}; + sample_sound.data = calloc(1, sizeof(*sample_sound.data)); + sample_sound.data->sdl_sound = Mix_LoadWAV(cstr_str(&path)); + if(NULL == sample_sound.data->sdl_sound) { rodeo_log( rodeo_logLevel_error, @@ -164,18 +165,17 @@ rodeo_audio_sound_create_from_path(cstr path) } void -rodeo_audio_sound_destroy(rodeo_audio_sound_t* sound) +rodeo_audio_sound_destroy(rodeo_audio_sound_t sound) { - Mix_FreeChunk(sound->sdl_sound); - free(sound); + Mix_FreeChunk(sound.data->sdl_sound); } -rodeo_audio_music_t* +rodeo_audio_music_t rodeo_audio_music_create_from_path(cstr path) { - rodeo_audio_music_t *sample_music = malloc(sizeof(rodeo_audio_music_t)); - sample_music->sdl_music = Mix_LoadMUS(cstr_str(&path)); - if(NULL == sample_music->sdl_music) + rodeo_audio_music_t sample_music = {0}; + sample_music.data->sdl_music = Mix_LoadMUS(cstr_str(&path)); + if(NULL == sample_music.data->sdl_music) { rodeo_log( rodeo_logLevel_error, @@ -187,31 +187,30 @@ rodeo_audio_music_create_from_path(cstr path) } void -rodeo_audio_music_destroy(rodeo_audio_music_t* music) +rodeo_audio_music_destroy(rodeo_audio_music_t music) { - Mix_FreeMusic(music->sdl_music); - free(music); + Mix_FreeMusic(music.data->sdl_music); } void -rodeo_audio_sound_play(rodeo_audio_sound_t *sound) //, uint32_t channel_pool_id) +rodeo_audio_sound_play(rodeo_audio_sound_t sound) //, uint32_t channel_pool_id) { - Mix_PlayChannel(-1, sound->sdl_sound, 0); + Mix_PlayChannel(-1, sound.data->sdl_sound, 0); } void -rodeo_audio_music_play(rodeo_audio_music_t *music) //, uint32_t channel_pool_id) +rodeo_audio_music_play(rodeo_audio_music_t music) //, uint32_t channel_pool_id) { rodeo_audio_music_stop(); - Mix_PlayMusic(music->sdl_music, 0); + Mix_PlayMusic(music.data->sdl_music, 0); } void -rodeo_audio_music_play_fadeIn(rodeo_audio_music_t *music, uint32_t fade_duration_milliseconds) +rodeo_audio_music_play_fadeIn(rodeo_audio_music_t music, uint32_t fade_duration_milliseconds) { rodeo_audio_music_stop(); - Mix_FadeInMusic(music->sdl_music, 0, (int32_t)fade_duration_milliseconds); + Mix_FadeInMusic(music.data->sdl_music, 0, (int32_t)fade_duration_milliseconds); } void diff --git a/src/audio/rodeo_audio_t.h b/src/audio/rodeo_audio_t.h deleted file mode 100644 index b762cf3..0000000 --- a/src/audio/rodeo_audio_t.h +++ /dev/null @@ -1,16 +0,0 @@ -#pragma once -// -- external -- -#include "SDL.h" -#include "SDL_mixer.h" - -struct -rodeo_audio_sound_t -{ - Mix_Chunk *sdl_sound; -}; - -struct -rodeo_audio_music_t -{ - Mix_Music *sdl_music; -}; diff --git a/src/collision/rodeo_collision.c b/src/collision/rodeo_collision.c index 95fc75c..d529e65 100644 --- a/src/collision/rodeo_collision.c +++ b/src/collision/rodeo_collision.c @@ -3,15 +3,15 @@ #include bool detect_collision( - const rodeo_collision_2d_world_item_t *a, - const rodeo_collision_2d_world_item_t *b + const rodeo_collision_2d_world_item_t a, + const rodeo_collision_2d_world_item_t b ) { - return !(a->id.id == b->id.id || - a->x+a->dx > b->x+b->dx + b->width || - b->x+b->dx > a->x+a->dx + a->width || - a->y+a->dy > b->y+b->dy + b->height || - b->y+b->dy > a->y+a->dy + a->height); + return !(a.id.id == b.id.id || + a.rect.x+a.dx > b.rect.x+b.dx + b.rect.width || + b.rect.x+b.dx > a.rect.x+a.dx + a.rect.width || + a.rect.y+a.dy > b.rect.y+b.dy + b.rect.height || + b.rect.y+b.dy > a.rect.y+a.dy + a.rect.height); } rodeo_collision_2d_world_t @@ -90,7 +90,7 @@ rodeo_collision_2d_world_compare_self( { c_foreach(i, cvec_collision_2d_world_item, *world) { c_foreach(j, cvec_collision_2d_world_item, cvec_collision_2d_world_item_advance(i, 1), cvec_collision_2d_world_item_end(world)) { - if (detect_collision(i.ref, j.ref)) { + if (detect_collision(*i.ref, *j.ref)) { resolve(i.ref, j.ref); } } @@ -109,7 +109,7 @@ rodeo_collision_2d_world_compare_other( { c_foreach(i, cvec_collision_2d_world_item, *world_a) { c_foreach(j, cvec_collision_2d_world_item, *world_b) { - if (detect_collision(i.ref, j.ref)) { + if (detect_collision(*i.ref, *j.ref)) { resolve(i.ref, j.ref); } } @@ -132,20 +132,20 @@ int rodeo_collision_2d_item_cmp( // from raylib GetCollisionRect rodeo_rectangle_t rodeo_collision_2d_get_collision_rect( - rodeo_collision_2d_world_item_t *a, - rodeo_collision_2d_world_item_t *b + rodeo_rectangle_t a, + rodeo_rectangle_t b ) { rodeo_rectangle_t overlap = { 0 }; - float left = (a->x > b->x)? a->x : b->x; - float right1 = a->x + a->width; - float right2 = b->x + b->width; - float right = (right1 < right2)? right1 : right2; - float top = (a->y > b->y)? a->y : b->y; - float bottom1 = a->y + a->height; - float bottom2 = b->y + b->height; - float bottom = (bottom1 < bottom2)? bottom1 : bottom2; + float left = (a.x > b.x)? a.x : b.x; + float right_a = a.x + a.width; + float right_b = b.x + b.width; + float right = (right_a < right_b)? right_a : right_b; + float top = (a.y > b.y)? a.y : b.y; + float bottom_a = a.y + a.height; + float bottom_b = b.y + b.height; + float bottom = (bottom_a < bottom_b)? bottom_a : bottom_b; if ((left < right) && (top < bottom)) { diff --git a/src/gfx/rodeo_gfx.c b/src/gfx/rodeo_gfx.c index eb77b27..04d923f 100644 --- a/src/gfx/rodeo_gfx.c +++ b/src/gfx/rodeo_gfx.c @@ -313,7 +313,7 @@ rodeo_gfx_renderer_flush(void) bgfx_set_texture( 0, irodeo_gfx_state.texture_uniforms[0], - rodeo_gfx_texture_2d_default_get()->internal_texture->texture_bgfx, + rodeo_gfx_texture_2d_default_get().internal_texture->texture_bgfx, UINT32_MAX ); if(irodeo_gfx_state.active_texture_p != NULL) @@ -332,7 +332,7 @@ rodeo_gfx_renderer_flush(void) bgfx_set_texture( 1, irodeo_gfx_state.texture_uniforms[1], - rodeo_gfx_texture_2d_default_get()->internal_texture->texture_bgfx, + rodeo_gfx_texture_2d_default_get().internal_texture->texture_bgfx, UINT32_MAX ); } @@ -375,10 +375,10 @@ rodeo_gfx_renderer_flush(void) irodeo_gfx_state.active_texture_p = NULL; } -const rodeo_gfx_texture_2d_t* +rodeo_gfx_texture_2d_t rodeo_gfx_texture_2d_default_get(void) { - return &irodeo_gfx_state.default_texture; + return irodeo_gfx_state.default_texture; } rodeo_gfx_texture_2d_t @@ -409,49 +409,49 @@ rodeo_gfx_texture_2d_create_from_RGBA8( } void -rodeo_gfx_texture_2d_destroy(rodeo_gfx_texture_2d_t *texture) +rodeo_gfx_texture_2d_destroy(rodeo_gfx_texture_2d_t texture) { - bgfx_destroy_texture(texture->internal_texture->texture_bgfx); - free(texture->internal_texture); + bgfx_destroy_texture(texture.internal_texture->texture_bgfx); + free(texture.internal_texture); } void rodeo_gfx_rectangle_draw( - const rodeo_rectangle_t *rectangle, - const rodeo_color_RGBAFloat_t *color + const rodeo_rectangle_t rectangle, + const rodeo_color_RGBAFloat_t color ) { rodeo_gfx_texture_2d_draw( rectangle, - NULL, + (rodeo_rectangle_t){ 0, 0, (float)rodeo_gfx_texture_2d_default_get().width, (float)rodeo_gfx_texture_2d_default_get().height }, color, - NULL + rodeo_gfx_texture_2d_default_get() ); } void rodeo_gfx_texture_2d_draw( // cant be NULL - const rodeo_rectangle_t *destination, + const rodeo_rectangle_t destination, // default: entire texture - const rodeo_rectangle_t *source, + const rodeo_rectangle_t source, // default: white - const rodeo_color_RGBAFloat_t *color, + const rodeo_color_RGBAFloat_t color, // default: default texture - const rodeo_gfx_texture_2d_t *texture + const rodeo_gfx_texture_2d_t texture ) { // whether to use default or custom texture float texture_uniform_slot = 0.0; rodeo_rectangle_t source_applied; - if(source != NULL && texture != NULL) + if((source.height != 0 || source.width != 0) && texture.internal_texture != NULL) { source_applied = (rodeo_rectangle_t){ - .x = source->x / (float)texture->width, - .y = source->y / (float)texture->height, - .width = source->width / (float)texture->width, - .height = source->height / (float)texture->height, + .x = source.x / (float)texture.width, + .y = source.y / (float)texture.height, + .width = source.width / (float)texture.width, + .height = source.height / (float)texture.height, }; } else @@ -464,33 +464,21 @@ rodeo_gfx_texture_2d_draw( }; } - rodeo_color_RGBAFloat_t color_applied; - if(color != NULL) - { - color_applied = *color; - } - else - { - color_applied = (rodeo_color_RGBAFloat_t){ - { 1.0f, 1.0f, 1.0f, 1.0f } - }; - } - // if not using texture: use default instead // otherwise check what current texture is active // if none or the same: set it // if different: flush and then set it - if(texture != NULL) + if(texture.internal_texture != NULL) { if(irodeo_gfx_state.active_texture_p != NULL) { - if(&texture->internal_texture->texture_bgfx != irodeo_gfx_state.active_texture_p) + if(&texture.internal_texture->texture_bgfx != irodeo_gfx_state.active_texture_p) { rodeo_gfx_renderer_flush(); } } texture_uniform_slot = 1.0; - irodeo_gfx_state.active_texture_p = &texture->internal_texture->texture_bgfx; + irodeo_gfx_state.active_texture_p = &texture.internal_texture->texture_bgfx; } @@ -499,10 +487,10 @@ rodeo_gfx_texture_2d_draw( irodeo_gfx_state.batched_vertices[irodeo_gfx_state.vertex_size] = (rodeo_gfx_vertex_t) { - .x = destination->width + destination->x, - .y = destination->height + destination->y, + .x = destination.width + destination.x, + .y = destination.height + destination.y, //.z = 0.0f, - .color = color_applied, + .color = color, .texture_id = texture_uniform_slot, .texture_x = source_applied.width + source_applied.x, .texture_y = source_applied.height + source_applied.y, @@ -511,10 +499,10 @@ rodeo_gfx_texture_2d_draw( irodeo_gfx_state.batched_vertices[irodeo_gfx_state.vertex_size] = (rodeo_gfx_vertex_t) { - .x = destination->width + destination->x, - .y = destination->y, + .x = destination.width + destination.x, + .y = destination.y, //.z = 0.0f, - .color = color_applied, + .color = color, .texture_id = texture_uniform_slot, .texture_x = source_applied.width + source_applied.x, .texture_y = source_applied.y, @@ -523,10 +511,10 @@ rodeo_gfx_texture_2d_draw( irodeo_gfx_state.batched_vertices[irodeo_gfx_state.vertex_size] = (rodeo_gfx_vertex_t) { - .x = destination->x, - .y = destination->y, + .x = destination.x, + .y = destination.y, //.z = 0.0f, - .color = color_applied, + .color = color, .texture_id = texture_uniform_slot, .texture_x = source_applied.x, .texture_y = source_applied.y, @@ -535,10 +523,10 @@ rodeo_gfx_texture_2d_draw( irodeo_gfx_state.batched_vertices[irodeo_gfx_state.vertex_size] = (rodeo_gfx_vertex_t) { - .x = destination->x, - .y = destination->height + destination->y, + .x = destination.x, + .y = destination.height + destination.y, //.z = 0.0f, - .color = color_applied, + .color = color, .texture_id = texture_uniform_slot, .texture_x = source_applied.x, .texture_y = source_applied.height + source_applied.y, diff --git a/src/input/irodeo_input_t.h b/src/input/irodeo_input_t.h index 77e150e..702e381 100644 --- a/src/input/irodeo_input_t.h +++ b/src/input/irodeo_input_t.h @@ -4,9 +4,9 @@ // public #include "rodeo/input_t.h" -typedef rodeo_input_scene_t *rodeo_input_scene_p; +//typedef rodeo_input_scene_t *rodeo_input_scene_p; #define i_tag input_scene -#define i_key rodeo_input_scene_p +#define i_key rodeo_input_scene_data_t* #include typedef diff --git a/src/input/rodeo_input.c b/src/input/rodeo_input.c index 27b9776..63dc0b1 100644 --- a/src/input/rodeo_input.c +++ b/src/input/rodeo_input.c @@ -54,10 +54,10 @@ rodeo_input_poll(void) { 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_scene_data_t *scene_data = *i.ref; + c_foreach(j, cset_input_commands, scene_data->commands) { - rodeo_input_command_t *command = *j.ref; + rodeo_input_command_data_t *command = *j.ref; const cset_input_binary_scancodes_value *value = cset_input_binary_scancodes_get( &command->binary.scancodes, (rodeo_input_binary_scancode_t)event.key.keysym.scancode @@ -91,10 +91,10 @@ rodeo_input_poll(void) { 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_scene_data_t *scene_data = *i.ref; + c_foreach(j, cset_input_commands, scene_data->commands) { - rodeo_input_command_t *command = *j.ref; + rodeo_input_command_data_t *command = *j.ref; const cset_input_binary_mouseButtons_value *value = cset_input_binary_mouseButtons_get( &command->binary.mouse_buttons, (rodeo_input_binary_mouseButton_t)event.button.button @@ -128,10 +128,10 @@ rodeo_input_poll(void) { 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_scene_data_t *scene_data = *i.ref; + c_foreach(j, cset_input_commands, scene_data->commands) { - rodeo_input_command_t *command = *j.ref; + rodeo_input_command_data_t *command = *j.ref; const cset_input_positional_mouse_value *x_value = cset_input_positional_mouse_get( &command->positional.mouse_axes, rodeo_input_positional_mouse_X @@ -222,11 +222,11 @@ rodeo_input_poll(void) { 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_scene_data_t *scene_data = *i.ref; + c_foreach(j, cset_input_commands, scene_data->commands) { - rodeo_input_command_t *command = *j.ref; - const cset_input_binary_controllerButton_value *value = cset_input_binary_controllerButton_get( + rodeo_input_command_data_t *command = *j.ref; + const cset_input_binary_controllerButtons_value *value = cset_input_binary_controllerButtons_get( &command->binary.controller_buttons, (rodeo_input_binary_controllerButton_t)event.cbutton.button ); @@ -258,11 +258,11 @@ rodeo_input_poll(void) { 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_scene_data_t *scene_data = *i.ref; + c_foreach(j, cset_input_commands, scene_data->commands) { - rodeo_input_command_t *command = *j.ref; - if(cset_input_boundedRange_controllerAxis_contains(&command->bounded_range.controller_axes, event.caxis.axis)) + rodeo_input_command_data_t *command = *j.ref; + if(cset_input_boundedRange_controllerAxes_contains(&command->bounded_range.controller_axes, event.caxis.axis)) { rodeo_input_any_state_t input_state = { .data.bounded_range_state = @@ -308,14 +308,14 @@ rodeo_input_poll(void) void rodeo_input_command_register_callback( - rodeo_input_command_t *command, + rodeo_input_command_t command, rodeo_input_callback_function func ) { - const cset_input_callback_functions_value *callback = cset_input_callback_functions_get(&(command->callbacks), func); + const cset_input_callback_functions_value *callback = cset_input_callback_functions_get(&(command.data->callbacks), func); if(callback == NULL) { - cset_input_callback_functions_insert(&(command->callbacks), func); + cset_input_callback_functions_insert(&(command.data->callbacks), func); return; } else @@ -330,15 +330,15 @@ rodeo_input_command_register_callback( void rodeo_input_command_unregister_callback( - rodeo_input_command_t *command, + rodeo_input_command_t command, rodeo_input_callback_function func ) { cset_input_callback_functions_value *callback = - cset_input_callback_functions_get_mut(&(command->callbacks), func); + cset_input_callback_functions_get_mut(&(command.data->callbacks), func); if(callback != NULL) { - cset_input_callback_functions_erase_entry(&(command->callbacks), callback); + cset_input_callback_functions_erase_entry(&(command.data->callbacks), callback); return; } else @@ -351,49 +351,54 @@ rodeo_input_command_unregister_callback( } } -rodeo_input_scene_t* +rodeo_input_scene_t rodeo_input_scene_create(void) { - rodeo_input_scene_t *result = malloc(sizeof(rodeo_input_scene_t)); - *result = (rodeo_input_scene_t){0}; + rodeo_input_scene_t result = {0}; + result.data = calloc(1, sizeof(cset_input_commands)); + if(result.data == NULL) + { + rodeo_log( + rodeo_logLevel_error, + "Failed to allocate a scene" + ); + } return result; } void -rodeo_input_scene_destroy(rodeo_input_scene_t *scene) +rodeo_input_scene_destroy(rodeo_input_scene_t scene) { rodeo_input_scene_deactivate(scene); - cset_input_commands_drop(&scene->commands); - free(scene); + cset_input_commands_drop(&scene.data->commands); + free(scene.data); } -rodeo_input_command_t* +rodeo_input_command_t rodeo_input_command_create(uint32_t input_types) { - rodeo_input_command_t *result = malloc(sizeof(rodeo_input_command_t)); - *result = (rodeo_input_command_t) - { - .valid_types = input_types - }; + rodeo_input_command_t result = {0}; + result.data = calloc(1, sizeof(rodeo_input_command_data_t)); + result.data->valid_types = input_types; return result; } void -rodeo_input_command_destroy(rodeo_input_command_t *command) +rodeo_input_command_destroy(rodeo_input_command_t command) { - cset_input_binary_scancodes_drop(&command->binary.scancodes); - cset_input_binary_mouseButtons_drop(&command->binary.mouse_buttons); - cset_input_callback_functions_drop(&command->callbacks); - free(command); + cset_input_binary_scancodes_drop(&command.data->binary.scancodes); + cset_input_binary_mouseButtons_drop(&command.data->binary.mouse_buttons); + cset_input_callback_functions_drop(&command.data->callbacks); + free(command.data); } bool rodeo_input_command_register_binary_scancode( - rodeo_input_command_t *input_command, + rodeo_input_command_t input_command, rodeo_input_binary_scancode_t scancode ) { - if((rodeo_input_type_Binary & input_command->valid_types) == 0) + if((rodeo_input_type_Binary & input_command.data->valid_types) == 0) { rodeo_log( rodeo_logLevel_error, @@ -404,7 +409,7 @@ rodeo_input_command_register_binary_scancode( else { cset_input_binary_scancodes_insert( - &input_command->binary.scancodes, + &input_command.data->binary.scancodes, scancode ); return true; @@ -413,11 +418,11 @@ rodeo_input_command_register_binary_scancode( bool rodeo_input_command_register_binary_controllerButton( - rodeo_input_command_t *input_command, + rodeo_input_command_t input_command, rodeo_input_binary_controllerButton_t button ) { - if((rodeo_input_type_Binary & input_command->valid_types) == 0) + if((rodeo_input_type_Binary & input_command.data->valid_types) == 0) { rodeo_log( rodeo_logLevel_error, @@ -427,8 +432,8 @@ rodeo_input_command_register_binary_controllerButton( } else { - cset_input_binary_controllerButton_insert( - &input_command->binary.controller_buttons, + cset_input_binary_controllerButtons_insert( + &input_command.data->binary.controller_buttons, button ); return true; @@ -437,11 +442,11 @@ rodeo_input_command_register_binary_controllerButton( bool rodeo_input_command_register_binary_mouseButton( - rodeo_input_command_t *input_command, + rodeo_input_command_t input_command, rodeo_input_binary_mouseButton_t mouse_button ) { - if((rodeo_input_type_Binary & input_command->valid_types) == 0) + if((rodeo_input_type_Binary & input_command.data->valid_types) == 0) { rodeo_log( rodeo_logLevel_error, @@ -452,7 +457,7 @@ rodeo_input_command_register_binary_mouseButton( else { cset_input_binary_mouseButtons_insert( - &input_command->binary.mouse_buttons, + &input_command.data->binary.mouse_buttons, mouse_button ); return true; @@ -461,11 +466,11 @@ rodeo_input_command_register_binary_mouseButton( bool rodeo_input_command_register_positional_mouse( - rodeo_input_command_t *input_command, + rodeo_input_command_t input_command, rodeo_input_positional_mouse_t mouse_axis ) { - if((rodeo_input_type_Positional & input_command->valid_types) == 0) + if((rodeo_input_type_Positional & input_command.data->valid_types) == 0) { rodeo_log( rodeo_logLevel_error, @@ -476,7 +481,7 @@ rodeo_input_command_register_positional_mouse( else { cset_input_positional_mouse_insert( - &input_command->positional.mouse_axes, + &input_command.data->positional.mouse_axes, mouse_axis ); return true; @@ -485,11 +490,11 @@ rodeo_input_command_register_positional_mouse( bool rodeo_input_command_register_boundedRange_controllerAxis( - rodeo_input_command_t *input_command, + rodeo_input_command_t input_command, rodeo_input_boundedRange_controllerAxis_t controller_axis ) { - if((rodeo_input_type_BoundedRange & input_command->valid_types) == 0) + if((rodeo_input_type_BoundedRange & input_command.data->valid_types) == 0) { rodeo_log( rodeo_logLevel_error, @@ -499,8 +504,8 @@ rodeo_input_command_register_boundedRange_controllerAxis( } else { - cset_input_boundedRange_controllerAxis_insert( - &input_command->bounded_range.controller_axes, + cset_input_boundedRange_controllerAxes_insert( + &input_command.data->bounded_range.controller_axes, controller_axis ); return true; @@ -509,11 +514,11 @@ rodeo_input_command_register_boundedRange_controllerAxis( bool rodeo_input_command_register_unboundedRange_mouse( - rodeo_input_command_t *input_command, + rodeo_input_command_t input_command, rodeo_input_unboundedRange_mouse_t mouse_axis ) { - if((rodeo_input_type_UnboundedRange & input_command->valid_types) == 0) + if((rodeo_input_type_UnboundedRange & input_command.data->valid_types) == 0) { rodeo_log( rodeo_logLevel_error, @@ -524,7 +529,7 @@ rodeo_input_command_register_unboundedRange_mouse( else { cset_input_unboundedRange_mouse_insert( - &input_command->unbounded_range.mouse_axes, + &input_command.data->unbounded_range.mouse_axes, mouse_axis ); return true; @@ -533,38 +538,38 @@ rodeo_input_command_register_unboundedRange_mouse( void rodeo_input_scene_register_command( - rodeo_input_scene_t *scene, - rodeo_input_command_t *command + rodeo_input_scene_t scene, + rodeo_input_command_t command ) { cset_input_commands_insert( - &scene->commands, - command + &scene.data->commands, + command.data ); } void rodeo_input_scene_unregister_command( - rodeo_input_scene_t *scene, - rodeo_input_command_t *command + rodeo_input_scene_t scene, + rodeo_input_command_t command ) { cset_input_commands_erase( - &scene->commands, - command + &scene.data->commands, + command.data ); } void -rodeo_input_scene_activate(rodeo_input_scene_t *scene) +rodeo_input_scene_activate(rodeo_input_scene_t scene) { - cset_input_scene_insert(&istate.active_scenes, scene); + cset_input_scene_insert(&istate.active_scenes, scene.data); } void -rodeo_input_scene_deactivate(rodeo_input_scene_t *scene) +rodeo_input_scene_deactivate(rodeo_input_scene_t scene) { - cset_input_scene_erase(&istate.active_scenes, scene); + cset_input_scene_erase(&istate.active_scenes, scene.data); } #define i_key int32_t -- cgit v1.2.3