diff --git a/input/input_driver.c b/input/input_driver.c index e1ac2324ea..f69a300f5f 100644 --- a/input/input_driver.c +++ b/input/input_driver.c @@ -463,7 +463,7 @@ int16_t input_state(unsigned port, unsigned device, if (bsv_movie_ctl(BSV_MOVIE_CTL_PLAYBACK_ON, NULL)) { int16_t ret; - if (bsv_movie_get_input(&ret)) + if (bsv_movie_ctl(BSV_MOVIE_CTL_GET_INPUT, &ret)) return ret; bsv_movie_ctl(BSV_MOVIE_CTL_SET_END, NULL); @@ -514,7 +514,7 @@ int16_t input_state(unsigned port, unsigned device, } if (bsv_movie_ctl(BSV_MOVIE_CTL_PLAYBACK_OFF, NULL)) - bsv_movie_set_input(res); + bsv_movie_ctl(BSV_MOVIE_CTL_SET_INPUT, &res); return res; } diff --git a/movie.c b/movie.c index b034b29f3e..3e185bef5a 100644 --- a/movie.c +++ b/movie.c @@ -198,24 +198,6 @@ void bsv_movie_free(bsv_movie_t *handle) free(handle); } -bool bsv_movie_get_input(int16_t *input) -{ - bsv_movie_t *handle = bsv_movie_state.movie; - if (fread(input, sizeof(int16_t), 1, handle->file) != 1) - return false; - - *input = swap_if_big16(*input); - return true; -} - -void bsv_movie_set_input(int16_t input) -{ - bsv_movie_t *handle = bsv_movie_state.movie; - - input = swap_if_big16(input); - fwrite(&input, sizeof(int16_t), 1, handle->file); -} - bsv_movie_t *bsv_movie_init(const char *path, enum rarch_movie_type type) { bsv_movie_t *handle = (bsv_movie_t*)calloc(1, sizeof(*handle)); @@ -414,6 +396,26 @@ bool bsv_movie_ctl(enum bsv_ctl_state state, void *data) case BSV_MOVIE_CTL_FRAME_REWIND: bsv_movie_frame_rewind(bsv_movie_state.movie); break; + case BSV_MOVIE_CTL_GET_INPUT: + { + int16_t *bsv_data = (int16_t*)data; + bsv_movie_t *handle = bsv_movie_state.movie; + if (fread(bsv_data, sizeof(int16_t), 1, handle->file) != 1) + return false; + + *bsv_data = swap_if_big16(*bsv_data); + } + break; + case BSV_MOVIE_CTL_SET_INPUT: + { + int16_t *bsv_data = (int16_t*)data; + bsv_movie_t *handle = bsv_movie_state.movie; + + *bsv_data = swap_if_big16(*bsv_data); + fwrite(bsv_data, sizeof(int16_t), 1, handle->file); + } + break; + case BSV_MOVIE_CTL_NONE: default: return false; } diff --git a/movie.h b/movie.h index e405825131..a658c2f28f 100644 --- a/movie.h +++ b/movie.h @@ -42,9 +42,14 @@ enum rarch_movie_type enum bsv_ctl_state { - BSV_MOVIE_CTL_IS_INITED = 0, + BSV_MOVIE_CTL_NONE = 0, + BSV_MOVIE_CTL_IS_INITED, BSV_MOVIE_CTL_PLAYBACK_ON, BSV_MOVIE_CTL_PLAYBACK_OFF, + /* Playback. */ + BSV_MOVIE_CTL_GET_INPUT, + /* Recording. */ + BSV_MOVIE_CTL_SET_INPUT, BSV_MOVIE_CTL_SET_START_RECORDING, BSV_MOVIE_CTL_UNSET_START_RECORDING, BSV_MOVIE_CTL_START_RECORDING, @@ -72,12 +77,6 @@ void bsv_movie_set_start_path(const char *path); bsv_movie_t *bsv_movie_init(const char *path, enum rarch_movie_type type); -/* Playback. */ -bool bsv_movie_get_input(int16_t *input); - -/* Recording. */ -void bsv_movie_set_input(int16_t input); - /* Used for rewinding while playback/record. */ void bsv_movie_set_frame_start(bsv_movie_t *handle);