mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-09 03:10:22 +00:00
IOS7: Register inputs based on capabilities
Instead of register input based on if hardware is connected or not register input based on backend capabilities. Mouse support is default supported through touch events on screen (iOS) or touch on controller (Apple TV), and through connected mouse hardwares. Gamepad controllers are supported from iOS 14 and later. Register mouse and gamepad input based on above capabilities to be able to map actions to buttons on these input devices. Keyboard support is to be added but not in this commit. Remove the "isConnected" methods for each input and change the same method for game controllers to a "isSupported" function to deal with the iOS version support. Remove the sending of the EVENT_INPUT_CHANGED event due to the above reasons. The overide of the isConnected property function is also removed due to this reason. It caused problems that key mappings were reset on connections/disconnections.
This commit is contained in:
parent
7c96a7ff76
commit
8576e9e1f3
@ -50,7 +50,6 @@ enum InputEvent {
|
||||
kInputJoystickAxisMotion,
|
||||
kInputJoystickButtonDown,
|
||||
kInputJoystickButtonUp,
|
||||
kInputChanged,
|
||||
kInputScreenChanged
|
||||
};
|
||||
|
||||
|
@ -44,13 +44,6 @@
|
||||
return self;
|
||||
}
|
||||
|
||||
// Override the setter method
|
||||
- (void)setIsConnected:(BOOL)isConnected {
|
||||
// Inform that input changed
|
||||
_isConnected = isConnected;
|
||||
[view addEvent:InternalEvent(kInputChanged, 0, 0)];
|
||||
}
|
||||
|
||||
- (CGPoint)getLocationInView:(UITouch *)touch; {
|
||||
CGPoint p = [touch locationInView:[self view]];
|
||||
p.x *= [[self view] contentScaleFactor];
|
||||
|
@ -155,12 +155,6 @@ bool OSystem_iOS7::pollEvent(Common::Event &event) {
|
||||
event.joystick.button = internalEvent.value1;
|
||||
break;
|
||||
|
||||
case kInputChanged:
|
||||
event.type = Common::EVENT_INPUT_CHANGED;
|
||||
_queuedInputEvent.type = Common::EVENT_INVALID;
|
||||
_queuedEventTime = getMillis() + kQueuedInputEventDelay;
|
||||
break;
|
||||
|
||||
case kInputScreenChanged:
|
||||
rebuildSurface();
|
||||
dynamic_cast<iOSCommonGraphics *>(_graphicsManager)->notifyResize(getScreenWidth(), getScreenHeight());
|
||||
|
@ -216,13 +216,10 @@ Common::HardwareInputSet *OSystem_iOS7::getHardwareInputSet() {
|
||||
using namespace Common;
|
||||
|
||||
CompositeHardwareInputSet *inputSet = new CompositeHardwareInputSet();
|
||||
// Ask view about connected controllers
|
||||
if ([[iOS7AppDelegate iPhoneView] isTouchControllerConnected] ||
|
||||
[[iOS7AppDelegate iPhoneView] isMouseControllerConnected]) {
|
||||
inputSet->addHardwareInputSet(new MouseHardwareInputSet(defaultMouseButtons));
|
||||
}
|
||||
// Mouse is alwyas supported, either through touch or device
|
||||
inputSet->addHardwareInputSet(new MouseHardwareInputSet(defaultMouseButtons));
|
||||
|
||||
if ([[iOS7AppDelegate iPhoneView] isGamepadControllerConnected]) {
|
||||
if ([[iOS7AppDelegate iPhoneView] isGamepadControllerSupported]) {
|
||||
inputSet->addHardwareInputSet(new JoystickHardwareInputSet(defaultJoystickButtons, defaultJoystickAxes));
|
||||
}
|
||||
|
||||
|
@ -97,9 +97,7 @@ uint getSizeNextPOT(uint size);
|
||||
- (void)addEvent:(InternalEvent)event;
|
||||
- (bool)fetchEvent:(InternalEvent *)event;
|
||||
|
||||
- (BOOL)isTouchControllerConnected;
|
||||
- (BOOL)isMouseControllerConnected;
|
||||
- (BOOL)isGamepadControllerConnected;
|
||||
- (bool)isGamepadControllerSupported;
|
||||
- (void)virtualController:(bool)connect;
|
||||
@end
|
||||
|
||||
|
@ -424,36 +424,12 @@ bool iOS7_fetchEvent(InternalEvent *event) {
|
||||
return true;
|
||||
}
|
||||
|
||||
- (BOOL)isControllerTypeConnected:(Class)controller {
|
||||
for (GameController *c : _controllers) {
|
||||
if ([c isConnected]) {
|
||||
if ([c isKindOfClass:controller]) {
|
||||
return YES;
|
||||
}
|
||||
}
|
||||
}
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (BOOL)isTouchControllerConnected {
|
||||
return [self isControllerTypeConnected:TouchController.class];
|
||||
}
|
||||
|
||||
- (BOOL)isMouseControllerConnected {
|
||||
- (bool)isGamepadControllerSupported {
|
||||
if (@available(iOS 14.0, tvOS 14.0, *)) {
|
||||
return [self isControllerTypeConnected:MouseController.class];
|
||||
// Both virtual and hardware controllers are supported
|
||||
return true;
|
||||
} else {
|
||||
// Fallback on earlier versions
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)isGamepadControllerConnected {
|
||||
if (@available(iOS 14.0, tvOS 14.0, *)) {
|
||||
return [self isControllerTypeConnected:GamepadController.class];
|
||||
} else {
|
||||
// Fallback on earlier versions
|
||||
return NO;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user