diff --git a/driver.h b/driver.h index b068cec523..56812de5d8 100644 --- a/driver.h +++ b/driver.h @@ -156,6 +156,7 @@ typedef struct video_driver void (*set_swap_block_state)(void *data, bool toggle); // Block swapping from being called in ::frame(). void (*swap)(void *data); // Explicitly swap buffers. Only useful when set_swap_block_state() is set to true. #endif + void (*set_rotation)(void *data, unsigned rotation); } video_driver_t; typedef struct driver @@ -233,6 +234,7 @@ extern const input_driver_t input_xdk360; #define video_alive_func() driver.video->alive(driver.video_data) #define video_focus_func() driver.video->focus(driver.video_data) #define video_xml_shader_func(path) driver.video->xml_shader(driver.video_data, path) +#define video_set_rotation_func(rotate) driver.video->set_rotation(driver.video_data, rotate) #define video_free_func() driver.video->free(driver.video_data) #define input_init_func() driver.input->init() diff --git a/dynamic.c b/dynamic.c index cbf2245b6f..298290a444 100644 --- a/dynamic.c +++ b/dynamic.c @@ -417,6 +417,17 @@ static bool environment_cb(unsigned cmd, void *data) *(snes_audio_sample_batch_t*)data = audio_sample_batch; break; + case SNES_ENVIRONMENT_SET_ROTATION: + { + unsigned rotation = *(const unsigned*)data; + SSNES_LOG("Environ SET_ROTATION: %u\n", rotation); + if (driver.video && driver.video_data && driver.video->set_rotation) + video_set_rotation_func(rotation); + else + return false; + break; + } + default: SSNES_LOG("Environ UNSUPPORTED (#%u).\n", cmd); return false; diff --git a/libsnes.hpp b/libsnes.hpp index dffcaeca02..92f7072962 100755 --- a/libsnes.hpp +++ b/libsnes.hpp @@ -129,8 +129,12 @@ extern "C" { // #define SNES_ENVIRONMENT_GET_AUDIO_BATCH_CB 13 // snes_audio_sample_batch_t * -- // Retrieves callback to a more optimized audio callback. - - + // +#define SNES_ENVIRONMENT_SET_ROTATION 14 // const unsigned * -- + // Sets screen rotation of graphics. + // Is only implemented if rotation can be accelerated by hardware. + // Valid values are 0, 1, 2, 3, which rotates screen by 0, 90, 180, 270 degrees + // counter-clockwise respectively. struct snes_message {