moonlight-ios/Limelight/Input/Controller.h
Meta Vens 19889385d1
Some checks failed
GameCult iOS 14 IPA / ipa (push) Has been cancelled
Read the Xbox One S BLE controller over IOHID on iOS 14
GameController on iOS 14.4 never exposes the Xbox One S controller on
Microsoft's Bluetooth LE firmware (VID 0x045E, PID 0x0B20) as a
GCController, though iOS connects it as a HID device. ControllerSupport
now matches it with IOHIDManager, parses input report 1 (layout as in
SDL's HIDAPI Xbox One driver) into the existing controller update path,
and drives rumble through output report 3. GCController handling is
unchanged; the IOHID source skips the pad when GameController already
exposes an Xbox gamepad.

Player slot allocation and removal move out of the GCController-specific
code so both sources share them. Arrival events now use the Moonlight
controller's player index rather than the GCController's.

Opening IOHIDLibUserClient needs com.apple.security.iokit-user-client-class;
the IPA workflow embeds it with an ad-hoc signature for TrollStore.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-29 20:39:41 +01:00

56 lines
2.4 KiB
Objective-C

//
// Controller.h
// Moonlight
//
// Created by Cameron Gutman on 2/11/19.
// Copyright © 2019 Moonlight Game Streaming Project. All rights reserved.
//
#import "HapticContext.h"
@import GameController;
@import CoreHaptics;
@interface Controller : NSObject
typedef struct {
float lastX;
float lastY;
} controller_touch_context_t;
@property (nullable, nonatomic, retain) GCController* gamepad;
// IOHIDDeviceRef for a gamepad that GameController doesn't expose (see ControllerSupport.m)
@property (nullable, nonatomic) void* hidDevice;
@property (nullable, nonatomic, retain) NSMutableData* hidReportBuffer;
@property (nonatomic) int playerIndex;
@property (nonatomic) int lastButtonFlags;
@property (nonatomic) int emulatingButtonFlags;
@property (nonatomic) int supportedEmulationFlags;
@property (nonatomic) unsigned char lastLeftTrigger;
@property (nonatomic) unsigned char lastRightTrigger;
@property (nonatomic) short lastLeftStickX;
@property (nonatomic) short lastLeftStickY;
@property (nonatomic) short lastRightStickX;
@property (nonatomic) short lastRightStickY;
@property (nonatomic) controller_touch_context_t primaryTouch;
@property (nonatomic) controller_touch_context_t secondaryTouch;
@property (nonatomic) HapticContext* _Nullable lowFreqMotor;
@property (nonatomic) HapticContext* _Nullable highFreqMotor;
@property (nonatomic) HapticContext* _Nullable leftTriggerMotor;
@property (nonatomic) HapticContext* _Nullable rightTriggerMotor;
@property (nonatomic) NSTimer* _Nullable accelTimer;
@property (nonatomic) GCAcceleration lastAccelSample;
@property (nonatomic) NSTimer* _Nullable gyroTimer;
@property (nonatomic) GCRotationRate lastGyroSample;
@property (nonatomic) NSTimer* _Nullable batteryTimer;
@property (nonatomic) GCDeviceBatteryState lastBatteryState;
@property (nonatomic) float lastBatteryLevel;
@property (nonatomic) BOOL reportedArrival;
@property (nonatomic) Controller* _Nullable mergedWithController;
@end