mirror of
https://github.com/libretro/RetroArch
synced 2025-04-18 14:42:30 +00:00
Cleanups
This commit is contained in:
parent
23b8f3d97d
commit
2d2d96660a
@ -70,18 +70,16 @@ static void apple_gamecontroller_joypad_poll_internal(GCController *controller)
|
|||||||
/* If we have not assigned a slot to this controller yet, ignore it. */
|
/* If we have not assigned a slot to this controller yet, ignore it. */
|
||||||
if (slot >= MAX_USERS)
|
if (slot >= MAX_USERS)
|
||||||
return;
|
return;
|
||||||
buttons = &mfi_buttons[slot];
|
|
||||||
|
|
||||||
/* retain the values from the paused controller handler and pass them through */
|
/* retain the values from the paused controller handler and pass them through */
|
||||||
if (@available(iOS 13, *))
|
|
||||||
{
|
|
||||||
/* The menu button can be pressed/unpressed
|
/* The menu button can be pressed/unpressed
|
||||||
* like any other button in iOS 13,
|
* like any other button in iOS 13,
|
||||||
* so no need to passthrough anything */
|
* so no need to passthrough anything */
|
||||||
|
if (@available(iOS 13, *))
|
||||||
*buttons = 0;
|
*buttons = 0;
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
buttons = &mfi_buttons[slot];
|
||||||
/* Use the paused controller handler for iOS versions below 13 */
|
/* Use the paused controller handler for iOS versions below 13 */
|
||||||
pause = *buttons & (1 << RETRO_DEVICE_ID_JOYPAD_START);
|
pause = *buttons & (1 << RETRO_DEVICE_ID_JOYPAD_START);
|
||||||
select = *buttons & (1 << RETRO_DEVICE_ID_JOYPAD_SELECT);
|
select = *buttons & (1 << RETRO_DEVICE_ID_JOYPAD_SELECT);
|
||||||
@ -302,13 +300,13 @@ static void mfi_joypad_autodetect_add(unsigned autoconf_pad)
|
|||||||
|
|
||||||
- (void)setupEngine MFI_RUMBLE_AVAIL
|
- (void)setupEngine MFI_RUMBLE_AVAIL
|
||||||
{
|
{
|
||||||
|
NSError *error;
|
||||||
if (self.engine)
|
if (self.engine)
|
||||||
return;
|
return;
|
||||||
if (!self.controller)
|
if (!self.controller)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
CHHapticEngine *engine = [self.controller.haptics createEngineWithLocality:GCHapticsLocalityDefault];
|
CHHapticEngine *engine = [self.controller.haptics createEngineWithLocality:GCHapticsLocalityDefault];
|
||||||
NSError *error;
|
|
||||||
[engine startAndReturnError:&error];
|
[engine startAndReturnError:&error];
|
||||||
if (error)
|
if (error)
|
||||||
return;
|
return;
|
||||||
@ -316,7 +314,8 @@ static void mfi_joypad_autodetect_add(unsigned autoconf_pad)
|
|||||||
self.engine = engine;
|
self.engine = engine;
|
||||||
|
|
||||||
__weak MFIRumbleController *weakSelf = self;
|
__weak MFIRumbleController *weakSelf = self;
|
||||||
self.engine.stoppedHandler = ^(CHHapticEngineStoppedReason stoppedReason) {
|
self.engine.stoppedHandler = ^(CHHapticEngineStoppedReason stoppedReason)
|
||||||
|
{
|
||||||
MFIRumbleController *strongSelf = weakSelf;
|
MFIRumbleController *strongSelf = weakSelf;
|
||||||
if (!strongSelf)
|
if (!strongSelf)
|
||||||
return;
|
return;
|
||||||
@ -386,7 +385,8 @@ static void mfi_joypad_autodetect_add(unsigned autoconf_pad)
|
|||||||
|
|
||||||
- (void)shutdown
|
- (void)shutdown
|
||||||
{
|
{
|
||||||
if (@available(iOS 14, tvOS 14, macOS 11, *)) {
|
if (@available(iOS 14, tvOS 14, macOS 11, *))
|
||||||
|
{
|
||||||
_weakPlayer = nil;
|
_weakPlayer = nil;
|
||||||
_strongPlayer = nil;
|
_strongPlayer = nil;
|
||||||
self.engine = nil;
|
self.engine = nil;
|
||||||
@ -397,24 +397,23 @@ static void mfi_joypad_autodetect_add(unsigned autoconf_pad)
|
|||||||
|
|
||||||
static void apple_gamecontroller_joypad_setup_haptics(GCController *controller)
|
static void apple_gamecontroller_joypad_setup_haptics(GCController *controller)
|
||||||
{
|
{
|
||||||
if (@available(iOS 14, tvOS 14, macOS 11, *)) {
|
if (@available(iOS 14, tvOS 14, macOS 11, *))
|
||||||
mfi_rumblers[controller.playerIndex] = [[MFIRumbleController alloc] initWithController:controller];
|
mfi_rumblers[controller.playerIndex] = [[MFIRumbleController alloc] initWithController:controller];
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void apple_gamecontroller_joypad_connect(GCController *controller)
|
static void apple_gamecontroller_joypad_connect(GCController *controller)
|
||||||
{
|
{
|
||||||
signed desired_index = (int32_t)controller.playerIndex;
|
signed desired_index = (int32_t)controller.playerIndex;
|
||||||
desired_index = (desired_index >= 0 && desired_index < MAX_MFI_CONTROLLERS)
|
if (!(desired_index >= 0 && desired_index < MAX_MFI_CONTROLLERS))
|
||||||
? desired_index : 0;
|
desired_index = 0;
|
||||||
|
|
||||||
/* prevent same controller getting set twice */
|
/* Prevent same controller getting set twice */
|
||||||
if ([mfiControllers containsObject:controller])
|
if ([mfiControllers containsObject:controller])
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (mfi_controllers[desired_index] != (uint32_t)controller.hash)
|
if (mfi_controllers[desired_index] != (uint32_t)controller.hash)
|
||||||
{
|
{
|
||||||
/* desired slot is unused, take it */
|
/* Desired slot is unused, take it */
|
||||||
if (!mfi_controllers[desired_index])
|
if (!mfi_controllers[desired_index])
|
||||||
{
|
{
|
||||||
controller.playerIndex = desired_index;
|
controller.playerIndex = desired_index;
|
||||||
@ -422,7 +421,7 @@ static void apple_gamecontroller_joypad_connect(GCController *controller)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* find a new slot for this controller that's unused */
|
/* Find a new slot for this controller that's unused */
|
||||||
unsigned i;
|
unsigned i;
|
||||||
|
|
||||||
for (i = 0; i < MAX_MFI_CONTROLLERS; ++i)
|
for (i = 0; i < MAX_MFI_CONTROLLERS; ++i)
|
||||||
@ -438,7 +437,7 @@ static void apple_gamecontroller_joypad_connect(GCController *controller)
|
|||||||
|
|
||||||
[mfiControllers addObject:controller];
|
[mfiControllers addObject:controller];
|
||||||
|
|
||||||
/* Move any non-game controllers (like the siri remote) to the end */
|
/* Move any non-game controllers (like the Siri remote) to the end */
|
||||||
if (mfiControllers.count > 1)
|
if (mfiControllers.count > 1)
|
||||||
{
|
{
|
||||||
int newPlayerIndex = 0;
|
int newPlayerIndex = 0;
|
||||||
@ -590,17 +589,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)
|
||||||
{
|
{
|
||||||
NSError *error;
|
if (pad < MAX_MFI_CONTROLLERS)
|
||||||
|
{
|
||||||
if (pad >= MAX_MFI_CONTROLLERS)
|
if (@available(iOS 14, tvOS 14, macOS 11, *))
|
||||||
return false;
|
{
|
||||||
if (@available(iOS 14, tvOS 14, macOS 11, *)) {
|
|
||||||
MFIRumbleController *rumble = mfi_rumblers[pad];
|
MFIRumbleController *rumble = mfi_rumblers[pad];
|
||||||
if (!rumble)
|
if (rumble)
|
||||||
return false;
|
{
|
||||||
|
NSError *error;
|
||||||
id<CHHapticPatternPlayer> player = (type == RETRO_RUMBLE_STRONG ? rumble.strongPlayer : rumble.weakPlayer);
|
id<CHHapticPatternPlayer> player = (type == RETRO_RUMBLE_STRONG ? rumble.strongPlayer : rumble.weakPlayer);
|
||||||
if (!player)
|
if (player)
|
||||||
return false;
|
{
|
||||||
if (strength == 0)
|
if (strength == 0)
|
||||||
[player stopAtTime:0 error:&error];
|
[player stopAtTime:0 error:&error];
|
||||||
else
|
else
|
||||||
@ -615,9 +614,11 @@ static bool apple_gamecontroller_joypad_set_rumble(unsigned pad,
|
|||||||
[player startAtTime:0 error:&error];
|
[player startAtTime:0 error:&error];
|
||||||
}
|
}
|
||||||
return error;
|
return error;
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool apple_gamecontroller_joypad_query_pad(unsigned pad)
|
static bool apple_gamecontroller_joypad_query_pad(unsigned pad)
|
||||||
@ -627,10 +628,9 @@ static bool apple_gamecontroller_joypad_query_pad(unsigned pad)
|
|||||||
|
|
||||||
static const char *apple_gamecontroller_joypad_name(unsigned pad)
|
static const char *apple_gamecontroller_joypad_name(unsigned pad)
|
||||||
{
|
{
|
||||||
if (pad >= MAX_USERS)
|
if (pad < MAX_USERS)
|
||||||
return NULL;
|
|
||||||
|
|
||||||
return "mFi Controller";
|
return "mFi Controller";
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
input_device_driver_t mfi_joypad = {
|
input_device_driver_t mfi_joypad = {
|
||||||
|
@ -27,7 +27,9 @@
|
|||||||
#include "../../tasks/tasks_internal.h"
|
#include "../../tasks/tasks_internal.h"
|
||||||
#include "../../verbosity.h"
|
#include "../../verbosity.h"
|
||||||
|
|
||||||
|
#if 0
|
||||||
#define LERP(p, f, t) ((((p * 10) * (t * 10)) / (f * 10)) / 10)
|
#define LERP(p, f, t) ((((p * 10) * (t * 10)) / (f * 10)) / 10)
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(ORBIS)
|
#if defined(ORBIS)
|
||||||
#include <orbis/orbisPad.h>
|
#include <orbis/orbisPad.h>
|
||||||
@ -242,7 +244,7 @@ static void ps4_joypad_poll(void)
|
|||||||
unsigned j, k;
|
unsigned j, k;
|
||||||
unsigned i = player;
|
unsigned i = player;
|
||||||
|
|
||||||
if (ds_joypad_states[player].connected == false)
|
if (!ds_joypad_states[player].connected)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
ret = scePadReadState(ds_joypad_states[player].handle[0],&buttons);
|
ret = scePadReadState(ds_joypad_states[player].handle[0],&buttons);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user