block keyboard action initiated by physical gamepad for iOS 26
This commit is contained in:
1 parent
6299401286
commit
42f29074fa
3 files changed
+37
-14
No files matched your search
@@ -73,7 +73,6 @@ static const double MOUSE_SPEED_DIVISOR = 1.25;
|
|||||||
|
|
||||||
OnScreenControls *_osc;
|
OnScreenControls *_osc;
|
||||||
VoidController *_oscController;
|
VoidController *_oscController;
|
||||||
NSMutableSet* _activeGCControllers;
|
|
||||||
TemporarySettings* tempSettings;
|
TemporarySettings* tempSettings;
|
||||||
OSCProfile* oscProfile;
|
OSCProfile* oscProfile;
|
||||||
OSCProfilesManager* oscProfileMan;
|
OSCProfilesManager* oscProfileMan;
|
||||||
@@ -1218,7 +1217,6 @@ double rc_expo(double x, double expo) {
|
|||||||
|
|
||||||
CGFloat rightStickXRaw = gamepad.rightThumbstick.xAxis.value * self->stickMaxOffset;
|
CGFloat rightStickXRaw = gamepad.rightThumbstick.xAxis.value * self->stickMaxOffset;
|
||||||
CGFloat rightStickYRaw = gamepad.rightThumbstick.yAxis.value * self->stickMaxOffset;
|
CGFloat rightStickYRaw = gamepad.rightThumbstick.yAxis.value * self->stickMaxOffset;
|
||||||
|
|
||||||
|
|
||||||
CGVector leftStickOffset = [ControllerUtil compensatedWithOffsetVector:CGVectorMake(leftStickXRaw, leftStickYRaw) minOffset:self->_leftStickMinOffset circulate:false];
|
CGVector leftStickOffset = [ControllerUtil compensatedWithOffsetVector:CGVectorMake(leftStickXRaw, leftStickYRaw) minOffset:self->_leftStickMinOffset circulate:false];
|
||||||
|
|
||||||
@@ -1601,7 +1599,7 @@ double rc_expo(double x, double expo) {
|
|||||||
-(VoidController* )assignController:(GCController*)controller {
|
-(VoidController* )assignController:(GCController*)controller {
|
||||||
NSLog(@"run assignController");
|
NSLog(@"run assignController");
|
||||||
|
|
||||||
bool newGCControllerArrival = ![_activeGCControllers containsObject:controller];
|
bool newGCControllerArrival = ![ControllerUtil.activeGCControllers containsObject:controller];
|
||||||
|
|
||||||
if(!newGCControllerArrival){
|
if(!newGCControllerArrival){
|
||||||
VoidController* voidController = [_voidControllers objectForKey:@(controller.playerIndex)];
|
VoidController* voidController = [_voidControllers objectForKey:@(controller.playerIndex)];
|
||||||
@@ -1623,7 +1621,7 @@ double rc_expo(double x, double expo) {
|
|||||||
VoidController* voidController = [[VoidController alloc] init];
|
VoidController* voidController = [[VoidController alloc] init];
|
||||||
|
|
||||||
|
|
||||||
[_activeGCControllers addObject:controller];
|
[ControllerUtil.activeGCControllers addObject:controller];
|
||||||
controller.playerIndex = i;
|
controller.playerIndex = i;
|
||||||
voidController.playerIndex = i;
|
voidController.playerIndex = i;
|
||||||
[self updateVoidController:voidController withGCController:controller];
|
[self updateVoidController:voidController withGCController:controller];
|
||||||
@@ -1701,9 +1699,9 @@ double rc_expo(double x, double expo) {
|
|||||||
- (void)assignControllers{
|
- (void)assignControllers{
|
||||||
for (GCController* controller in [GCController controllers]) {
|
for (GCController* controller in [GCController controllers]) {
|
||||||
NSLog(@"controller count: iterating");
|
NSLog(@"controller count: iterating");
|
||||||
|
|
||||||
if ([ControllerSupport isSupportedGamepad:controller]) {
|
if ([ControllerSupport isSupportedGamepad:controller]) {
|
||||||
NSLog(@"controller count: is supported,is contained by dict: %d", [_activeGCControllers containsObject:controller]);
|
NSLog(@"controller count: is supported,is contained by dict: %d", [ControllerUtil.activeGCControllers containsObject:controller]);
|
||||||
NSLog(@"controller obj +1 in dic");
|
NSLog(@"controller obj +1 in dic");
|
||||||
[self assignController:controller];
|
[self assignController:controller];
|
||||||
NSLog(@"controller obj num in dict: %lu", (unsigned long)_voidControllers.allValues.count);
|
NSLog(@"controller obj num in dict: %lu", (unsigned long)_voidControllers.allValues.count);
|
||||||
@@ -1820,7 +1818,7 @@ double rc_expo(double x, double expo) {
|
|||||||
_delegate = delegate;
|
_delegate = delegate;
|
||||||
_controllerStreamLock = [[NSLock alloc] init];
|
_controllerStreamLock = [[NSLock alloc] init];
|
||||||
_voidControllers = [[NSMutableDictionary alloc] init];
|
_voidControllers = [[NSMutableDictionary alloc] init];
|
||||||
_activeGCControllers = [[NSMutableSet alloc] init];
|
[ControllerUtil.activeGCControllers removeAllObjects];
|
||||||
_controllerNumbers = 0;
|
_controllerNumbers = 0;
|
||||||
|
|
||||||
_captureMouse = (streamConfig.localMousePointerMode == 0);
|
_captureMouse = (streamConfig.localMousePointerMode == 0);
|
||||||
@@ -1873,8 +1871,8 @@ double rc_expo(double x, double expo) {
|
|||||||
|
|
||||||
[self unregisterControllerCallbacks:controller];
|
[self unregisterControllerCallbacks:controller];
|
||||||
|
|
||||||
if([self->_activeGCControllers containsObject:controller]){
|
if([ControllerUtil.activeGCControllers containsObject:controller]){
|
||||||
[self->_activeGCControllers removeObject:controller];
|
[ControllerUtil.activeGCControllers removeObject:controller];
|
||||||
self->_controllerNumbers &= ~(1 << controller.playerIndex);
|
self->_controllerNumbers &= ~(1 << controller.playerIndex);
|
||||||
}
|
}
|
||||||
Log(LOG_I, @"Unassigning controller index: %ld", (long)controller.playerIndex);
|
Log(LOG_I, @"Unassigning controller index: %ld", (long)controller.playerIndex);
|
||||||
|
|||||||
@@ -53,7 +53,9 @@ import GameController
|
|||||||
@objc class ControllerUtil: NSObject {
|
@objc class ControllerUtil: NSObject {
|
||||||
|
|
||||||
static private let stickMaxOffset:CGFloat = 0x7FFE
|
static private let stickMaxOffset:CGFloat = 0x7FFE
|
||||||
|
@objc static var navigationActionTriggered:Bool = false
|
||||||
|
@objc static private(set) var navigationActionTriggeredPrivate:Bool = false
|
||||||
|
|
||||||
@objc static func listen(
|
@objc static func listen(
|
||||||
controller: GCController,
|
controller: GCController,
|
||||||
swapABXY: Bool,
|
swapABXY: Bool,
|
||||||
@@ -73,6 +75,22 @@ import GameController
|
|||||||
|
|
||||||
// 单一 gamepad.valueChangedHandler
|
// 单一 gamepad.valueChangedHandler
|
||||||
gamepad.valueChangedHandler = { gamepad, element in
|
gamepad.valueChangedHandler = { gamepad, element in
|
||||||
|
navigationActionTriggeredPrivate = (gamepad.dpad.up.isPressed
|
||||||
|
|| gamepad.dpad.down.isPressed
|
||||||
|
|| gamepad.dpad.left.isPressed
|
||||||
|
|| gamepad.dpad.right.isPressed
|
||||||
|
|| gamepad.rightThumbstick.xAxis.value != 0
|
||||||
|
|| gamepad.rightThumbstick.yAxis.value != 0
|
||||||
|
|| gamepad.leftThumbstick.xAxis.value != 0
|
||||||
|
|| gamepad.leftThumbstick.yAxis.value != 0)
|
||||||
|
if navigationActionTriggeredPrivate { navigationActionTriggered = true}
|
||||||
|
else {
|
||||||
|
DispatchQueue.global().asyncAfter(deadline: .now() + 0.02) {
|
||||||
|
if !navigationActionTriggeredPrivate {
|
||||||
|
navigationActionTriggered = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
handler(buttonDict, gamepad, element)
|
handler(buttonDict, gamepad, element)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -156,6 +174,8 @@ import GameController
|
|||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@objc static var activeGCControllers:NSMutableSet = NSMutableSet()
|
||||||
|
|
||||||
@objc static func string(for button: ControllerButton) -> String {
|
@objc static func string(for button: ControllerButton) -> String {
|
||||||
switch button {
|
switch button {
|
||||||
case .a: return "A"
|
case .a: return "A"
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
#import "KeyboardSupport.h"
|
#import "KeyboardSupport.h"
|
||||||
#include <Limelight.h>
|
#include <Limelight.h>
|
||||||
|
#include "VoidLink-Swift.h"
|
||||||
|
|
||||||
@implementation KeyboardSupport
|
@implementation KeyboardSupport
|
||||||
|
|
||||||
@@ -17,7 +18,6 @@
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
short keyCode;
|
short keyCode;
|
||||||
|
|
||||||
switch (press.type) {
|
switch (press.type) {
|
||||||
case UIPressTypeUpArrow:
|
case UIPressTypeUpArrow:
|
||||||
keyCode = 0x26;
|
keyCode = 0x26;
|
||||||
@@ -36,9 +36,14 @@
|
|||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
LiSendKeyboardEvent(0x8000 | keyCode,
|
bool physicalGamepadConnected = ControllerUtil.activeGCControllers.count>0;
|
||||||
down ? KEY_ACTION_DOWN : KEY_ACTION_UP,
|
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, physicalGamepadConnected ? 0.005*NSEC_PER_SEC : 0), dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
||||||
0);
|
if(!physicalGamepadConnected
|
||||||
|
|| !ControllerUtil.navigationActionTriggered)
|
||||||
|
LiSendKeyboardEvent(0x8000 | keyCode,
|
||||||
|
down ? KEY_ACTION_DOWN : KEY_ACTION_UP,
|
||||||
|
0);
|
||||||
|
});
|
||||||
|
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user