Add RETRO_ENVIRONMENT_GET_RUMBLE_INTERFACE.

This commit is contained in:
Themaister 2013-09-25 23:21:32 +02:00
parent 7855781cd8
commit a01ef18f80
11 changed files with 53 additions and 14 deletions

View File

@ -309,6 +309,14 @@ void driver_set_nonblock_state(bool nonblock)
g_extern.audio_data.nonblock_chunk_size : g_extern.audio_data.block_chunk_size;
}
bool driver_set_rumble_state(unsigned port, enum retro_rumble_effect effect, bool enable)
{
if (driver.input && driver.input_data)
return driver.input->set_rumble(driver.input_data, port, effect, enable);
else
return false;
}
uintptr_t driver_get_current_framebuffer(void)
{
#ifdef HAVE_FBO

View File

@ -323,12 +323,6 @@ enum keybind_set_id
KEYBINDS_ACTION_LAST
};
enum rarch_rumble_effect
{
RARCH_RUMBLE_STRONG = 0,
RARCH_RUMBLE_WEAK = 1
};
typedef struct input_driver
{
void *(*init)(void);
@ -341,7 +335,7 @@ typedef struct input_driver
const char *ident;
void (*grab_mouse)(void *data, bool state);
bool (*set_rumble)(void *data, unsigned port, enum rarch_rumble_effect effect, bool state);
bool (*set_rumble)(void *data, unsigned port, enum retro_rumble_effect effect, bool state);
} input_driver_t;
struct rarch_viewport;
@ -502,6 +496,9 @@ void driver_set_nonblock_state(bool nonblock);
uintptr_t driver_get_current_framebuffer(void);
retro_proc_address_t driver_get_proc_address(const char *sym);
// Used by RETRO_ENVIRONMENT_GET_RUMBLE_INTERFACE
bool driver_set_rumble_state(unsigned port, enum retro_rumble_effect effect, bool enable);
extern driver_t driver;
//////////////////////////////////////////////// Backends

View File

@ -756,6 +756,15 @@ bool rarch_environment_cb(unsigned cmd, void *data)
break;
}
case RETRO_ENVIRONMENT_GET_RUMBLE_INTERFACE:
{
RARCH_LOG("Environ GET_RUMBLE_INTERFACE.\n");
struct retro_rumble_interface *iface = (struct retro_rumble_interface*)data;
iface->set_rumble_state = driver_set_rumble_state;
break;
}
// Private extensions for internal use, not part of libretro API.
case RETRO_ENVIRONMENT_SET_LIBRETRO_PATH:
RARCH_LOG("Environ (Private) SET_LIBRETRO_PATH.\n");

View File

@ -712,6 +712,7 @@ void rarch_set_fullscreen(bool fullscreen);
void rarch_disk_control_set_eject(bool state, bool log);
void rarch_disk_control_set_index(unsigned index);
void rarch_disk_control_append_image(const char *path);
bool rarch_set_rumble_state(unsigned port, enum retro_rumble_effect effect, bool enable);
void rarch_init_autosave(void);
void rarch_deinit_autosave(void);
void rarch_take_screenshot(void);

View File

@ -334,7 +334,7 @@ static void dinput_grab_mouse(void *data, bool state)
IDirectInputDevice8_Acquire(di->mouse);
}
static bool dinput_set_rumble(void *data, unsigned port, enum rarch_rumble_effect effect, bool state)
static bool dinput_set_rumble(void *data, unsigned port, enum retro_rumble_effect effect, bool state)
{
struct dinput_input *di = (struct dinput_input*)data;
return input_joypad_set_rumble(di->joypad, port, effect, state);

View File

@ -107,7 +107,7 @@ const char *input_joypad_name(const rarch_joypad_driver_t *driver, unsigned joyp
}
bool input_joypad_set_rumble(const rarch_joypad_driver_t *driver,
unsigned port, enum rarch_rumble_effect effect, bool state)
unsigned port, enum retro_rumble_effect effect, bool state)
{
if (!driver)
return false;

View File

@ -66,7 +66,7 @@ typedef struct rarch_joypad_driver
bool (*button)(unsigned, uint16_t);
int16_t (*axis)(unsigned, uint32_t);
void (*poll)(void);
bool (*set_rumble)(unsigned, enum rarch_rumble_effect, bool); // Optional
bool (*set_rumble)(unsigned, enum retro_rumble_effect, bool); // Optional
const char *(*name)(unsigned);
const char *ident;
@ -83,7 +83,7 @@ int16_t input_joypad_analog(const rarch_joypad_driver_t *driver,
unsigned port, unsigned index, unsigned id, const struct retro_keybind *binds);
bool input_joypad_set_rumble(const rarch_joypad_driver_t *driver,
unsigned port, enum rarch_rumble_effect effect, bool state);
unsigned port, enum retro_rumble_effect effect, bool state);
int16_t input_joypad_axis_raw(const rarch_joypad_driver_t *driver,
unsigned joypad, unsigned axis);

View File

@ -285,7 +285,7 @@ static void linuxraw_input_free(void *data)
free(data);
}
static bool linuxraw_set_rumble(void *data, unsigned port, enum rarch_rumble_effect effect, bool state)
static bool linuxraw_set_rumble(void *data, unsigned port, enum retro_rumble_effect effect, bool state)
{
linuxraw_input_t *linuxraw = (linuxraw_input_t*)data;
return input_joypad_set_rumble(linuxraw->joypad, port, effect, state);

View File

@ -214,7 +214,7 @@ static void sdl_input_free(void *data)
free(data);
}
static bool sdl_set_rumble(void *data, unsigned port, enum rarch_rumble_effect effect, bool state)
static bool sdl_set_rumble(void *data, unsigned port, enum retro_rumble_effect effect, bool state)
{
sdl_input_t *sdl = (sdl_input_t*)data;
return input_joypad_set_rumble(sdl->joypad, port, effect, state);

View File

@ -269,7 +269,7 @@ static void x_grab_mouse(void *data, bool state)
x11->grab_mouse = state;
}
static bool x_set_rumble(void *data, unsigned port, enum rarch_rumble_effect effect, bool state)
static bool x_set_rumble(void *data, unsigned port, enum retro_rumble_effect effect, bool state)
{
x11_input_t *x11 = (x11_input_t*)data;
return input_joypad_set_rumble(x11->joypad, port, effect, state);

View File

@ -514,8 +514,32 @@ enum retro_mod
// Lets the core know how much time has passed since last invocation of retro_run().
// The frontend can tamper with the timing to fake fast-forward, slow-motion, frame stepping, etc.
// In this case the delta time will use the reference value in frame_time_callback..
//
#define RETRO_ENVIRONMENT_GET_RUMBLE_INTERFACE (23 | RETRO_ENVIRONMENT_EXPERIMENTAL)
// struct retro_rumble_interface * --
// Gets an interface which is used by a libretro core to set state of rumble motors in controllers.
// A strong and weak motor is supported, and they can be controlled indepedently.
enum retro_rumble_effect
{
RETRO_RUMBLE_STRONG = 0,
RETRO_RUMBLE_WEAK = 1,
RETRO_RUMBLE_DUMMY = INT_MAX
};
// Sets rumble state for joypad plugged in port 'port'. Rumble effects are controlled independently,
// and setting e.g. strong rumble does not override weak rumble.
// Should only be called when rumble state changes.
//
// Returns true if rumble state request was honored. Calling this before first retro_run() is likely to return false.
typedef bool (*retro_set_rumble_state_t)(unsigned port, enum retro_rumble_effect effect, bool enable);
struct retro_rumble_interface
{
retro_set_rumble_state_t set_rumble_state;
};
// Notifies libretro that audio data should be written.
typedef void (*retro_audio_callback_t)(void);