mirror of
https://github.com/moonlight-stream/moonlight-ios.git
synced 2026-04-23 08:47:02 +00:00
Plumb trigger rumble and motion sensor callbacks
This commit is contained in:
@@ -27,5 +27,7 @@
|
||||
|
||||
@property (nonatomic) HapticContext* _Nullable lowFreqMotor;
|
||||
@property (nonatomic) HapticContext* _Nullable highFreqMotor;
|
||||
@property (nonatomic) HapticContext* _Nullable leftTriggerMotor;
|
||||
@property (nonatomic) HapticContext* _Nullable rightTriggerMotor;
|
||||
|
||||
@end
|
||||
|
||||
@@ -41,6 +41,8 @@
|
||||
-(void) updateFinished:(Controller*)controller;
|
||||
|
||||
-(void) rumble:(unsigned short)controllerNumber lowFreqMotor:(unsigned short)lowFreqMotor highFreqMotor:(unsigned short)highFreqMotor;
|
||||
-(void) rumbleTriggers:(uint16_t)controllerNumber leftTrigger:(uint16_t)leftTrigger rightTrigger:(uint16_t)rightTrigger;
|
||||
-(void) setMotionEventState:(uint16_t)controllerNumber motionType:(uint8_t)motionType reportRateHz:(uint16_t)reportRateHz;
|
||||
|
||||
+(int) getConnectedGamepadMask:(StreamConfiguration*)streamConfig;
|
||||
|
||||
|
||||
@@ -71,6 +71,27 @@ static const double MOUSE_SPEED_DIVISOR = 1.25;
|
||||
[controller.highFreqMotor setMotorAmplitude:highFreqMotor];
|
||||
}
|
||||
|
||||
-(void) rumbleTriggers:(uint16_t)controllerNumber leftTrigger:(uint16_t)leftTrigger rightTrigger:(uint16_t)rightTrigger
|
||||
{
|
||||
Controller* controller = [_controllers objectForKey:[NSNumber numberWithInteger:controllerNumber]];
|
||||
if (controller == nil && controllerNumber == 0 && _oscEnabled) {
|
||||
// No physical controller, but we have on-screen controls
|
||||
controller = _player0osc;
|
||||
}
|
||||
if (controller == nil) {
|
||||
// No connected controller for this player
|
||||
return;
|
||||
}
|
||||
|
||||
[controller.leftTriggerMotor setMotorAmplitude:leftTrigger];
|
||||
[controller.rightTriggerMotor setMotorAmplitude:rightTrigger];
|
||||
}
|
||||
|
||||
- (void) setMotionEventState:(uint16_t)controllerNumber motionType:(uint8_t)motionType reportRateHz:(uint16_t)reportRateHz
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
-(void) updateLeftStick:(Controller*)controller x:(short)x y:(short)y
|
||||
{
|
||||
@synchronized(controller) {
|
||||
@@ -261,12 +282,17 @@ static const double MOUSE_SPEED_DIVISOR = 1.25;
|
||||
{
|
||||
controller.lowFreqMotor = [HapticContext createContextForLowFreqMotor:controller.gamepad];
|
||||
controller.highFreqMotor = [HapticContext createContextForHighFreqMotor:controller.gamepad];
|
||||
controller.leftTriggerMotor = [HapticContext createContextForLeftTrigger:controller.gamepad];
|
||||
controller.rightTriggerMotor = [HapticContext createContextForRightTrigger:controller.gamepad];
|
||||
}
|
||||
|
||||
-(void) cleanupControllerHaptics:(Controller*) controller
|
||||
{
|
||||
[controller.lowFreqMotor cleanup];
|
||||
[controller.highFreqMotor cleanup];
|
||||
[controller.leftTriggerMotor cleanup];
|
||||
[controller.rightTriggerMotor cleanup];
|
||||
}
|
||||
}
|
||||
|
||||
-(void) registerControllerCallbacks:(GCController*) controller
|
||||
|
||||
@@ -16,5 +16,7 @@
|
||||
|
||||
+(HapticContext*) createContextForHighFreqMotor:(GCController*)gamepad;
|
||||
+(HapticContext*) createContextForLowFreqMotor:(GCController*)gamepad;
|
||||
+(HapticContext*) createContextForLeftTrigger:(GCController*)gamepad;
|
||||
+(HapticContext*) createContextForRightTrigger:(GCController*)gamepad;
|
||||
|
||||
@end
|
||||
|
||||
@@ -89,6 +89,11 @@
|
||||
return nil;
|
||||
}
|
||||
|
||||
if (![[gamepad.haptics supportedLocalities] containsObject:locality]) {
|
||||
Log(LOG_W, @"Controller %d does not support haptic locality: %@", gamepad.playerIndex, locality);
|
||||
return nil;
|
||||
}
|
||||
|
||||
_playerIndex = gamepad.playerIndex;
|
||||
_hapticEngine = [gamepad.haptics createEngineWithLocality:locality];
|
||||
|
||||
@@ -144,4 +149,22 @@
|
||||
}
|
||||
}
|
||||
|
||||
+(HapticContext*) createContextForLeftTrigger:(GCController*)gamepad {
|
||||
if (@available(iOS 14.0, tvOS 14.0, *)) {
|
||||
return [[HapticContext alloc] initWithGamepad:gamepad locality:GCHapticsLocalityLeftTrigger];
|
||||
}
|
||||
else {
|
||||
return nil;
|
||||
}
|
||||
}
|
||||
|
||||
+(HapticContext*) createContextForRightTrigger:(GCController*)gamepad {
|
||||
if (@available(iOS 14.0, tvOS 14.0, *)) {
|
||||
return [[HapticContext alloc] initWithGamepad:gamepad locality:GCHapticsLocalityRightTrigger];
|
||||
}
|
||||
else {
|
||||
return nil;
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user