mirror of
https://github.com/libretro/RetroArch
synced 2025-04-09 21:45:45 +00:00
Enable option to rumble iOS device instead of controller (#14734).
This commit is contained in:
parent
b98bf2ccf0
commit
ce49bd6dcc
@ -282,10 +282,18 @@ static void frontend_darwin_get_os(char *s, size_t len, int *major, int *minor)
|
|||||||
{
|
{
|
||||||
#if defined(IOS)
|
#if defined(IOS)
|
||||||
get_ios_version(major, minor);
|
get_ios_version(major, minor);
|
||||||
|
#if TARGET_OS_TV
|
||||||
|
s[0] = 't';
|
||||||
|
s[1] = 'v';
|
||||||
|
s[2] = 'O';
|
||||||
|
s[3] = 'S';
|
||||||
|
s[4] = '\0';
|
||||||
|
#else
|
||||||
s[0] = 'i';
|
s[0] = 'i';
|
||||||
s[1] = 'O';
|
s[1] = 'O';
|
||||||
s[2] = 'S';
|
s[2] = 'S';
|
||||||
s[3] = '\0';
|
s[3] = '\0';
|
||||||
|
#endif
|
||||||
#elif defined(OSX)
|
#elif defined(OSX)
|
||||||
|
|
||||||
#if MAC_OS_X_VERSION_MIN_REQUIRED >= 101300 // MAC_OS_X_VERSION_10_13
|
#if MAC_OS_X_VERSION_MIN_REQUIRED >= 101300 // MAC_OS_X_VERSION_10_13
|
||||||
|
@ -31,6 +31,11 @@
|
|||||||
#define MAX_MFI_CONTROLLERS 4
|
#define MAX_MFI_CONTROLLERS 4
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if TARGET_OS_IOS
|
||||||
|
#include "../../configuration.h"
|
||||||
|
static UIImpactFeedbackGenerator *deviceFeedbackGenerator;
|
||||||
|
#endif
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
GCCONTROLLER_PLAYER_INDEX_UNSET = -1,
|
GCCONTROLLER_PLAYER_INDEX_UNSET = -1,
|
||||||
@ -487,6 +492,13 @@ void *apple_gamecontroller_joypad_init(void *data)
|
|||||||
{
|
{
|
||||||
if (mfi_inited)
|
if (mfi_inited)
|
||||||
return (void*)-1;
|
return (void*)-1;
|
||||||
|
|
||||||
|
#if TARGET_OS_IOS
|
||||||
|
if (!deviceFeedbackGenerator)
|
||||||
|
deviceFeedbackGenerator = [[UIImpactFeedbackGenerator alloc] init];
|
||||||
|
[deviceFeedbackGenerator prepare];
|
||||||
|
#endif
|
||||||
|
|
||||||
if (!apple_gamecontroller_available())
|
if (!apple_gamecontroller_available())
|
||||||
return NULL;
|
return NULL;
|
||||||
mfiControllers = [[NSMutableArray alloc] initWithCapacity:MAX_MFI_CONTROLLERS];
|
mfiControllers = [[NSMutableArray alloc] initWithCapacity:MAX_MFI_CONTROLLERS];
|
||||||
@ -588,6 +600,17 @@ static int16_t apple_gamecontroller_joypad_state(
|
|||||||
static bool apple_gamecontroller_joypad_set_rumble(unsigned pad,
|
static bool apple_gamecontroller_joypad_set_rumble(unsigned pad,
|
||||||
enum retro_rumble_effect type, uint16_t strength)
|
enum retro_rumble_effect type, uint16_t strength)
|
||||||
{
|
{
|
||||||
|
#if TARGET_OS_IOS
|
||||||
|
settings_t *settings = config_get_ptr();
|
||||||
|
bool enable_device_vibration = settings->bools.enable_device_vibration;
|
||||||
|
|
||||||
|
if (enable_device_vibration && pad == 0)
|
||||||
|
{
|
||||||
|
[deviceFeedbackGenerator impactOccurredWithIntensity:((float)strength)/65535.0f];
|
||||||
|
[deviceFeedbackGenerator prepare];
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (pad < MAX_MFI_CONTROLLERS)
|
if (pad < MAX_MFI_CONTROLLERS)
|
||||||
{
|
{
|
||||||
if (@available(iOS 14, tvOS 14, macOS 11, *))
|
if (@available(iOS 14, tvOS 14, macOS 11, *))
|
||||||
|
@ -6742,6 +6742,13 @@ unsigned menu_displaylist_build_list(
|
|||||||
{
|
{
|
||||||
input_driver_t *current_input =
|
input_driver_t *current_input =
|
||||||
input_state_get_ptr()->current_driver;
|
input_state_get_ptr()->current_driver;
|
||||||
|
const frontend_ctx_driver_t *frontend =
|
||||||
|
frontend_get_ptr();
|
||||||
|
char os_ver[64] = {0};
|
||||||
|
int major, minor;
|
||||||
|
|
||||||
|
if (frontend && frontend->get_os)
|
||||||
|
frontend->get_os(os_ver, sizeof(os_ver), &major, &minor);
|
||||||
|
|
||||||
if (current_input->keypress_vibrate)
|
if (current_input->keypress_vibrate)
|
||||||
if (MENU_DISPLAYLIST_PARSE_SETTINGS_ENUM(list,
|
if (MENU_DISPLAYLIST_PARSE_SETTINGS_ENUM(list,
|
||||||
@ -6749,7 +6756,8 @@ unsigned menu_displaylist_build_list(
|
|||||||
PARSE_ONLY_BOOL, false) == 0)
|
PARSE_ONLY_BOOL, false) == 0)
|
||||||
count++;
|
count++;
|
||||||
|
|
||||||
if (string_is_equal(current_input->ident, "android"))
|
if (string_is_equal(current_input->ident, "android") ||
|
||||||
|
(string_is_equal(current_input->ident, "cocoa") && string_is_equal(os_ver, "iOS")))
|
||||||
if (MENU_DISPLAYLIST_PARSE_SETTINGS_ENUM(list,
|
if (MENU_DISPLAYLIST_PARSE_SETTINGS_ENUM(list,
|
||||||
MENU_ENUM_LABEL_ENABLE_DEVICE_VIBRATION,
|
MENU_ENUM_LABEL_ENABLE_DEVICE_VIBRATION,
|
||||||
PARSE_ONLY_BOOL, false) == 0)
|
PARSE_ONLY_BOOL, false) == 0)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user