Skip to content

Latest commit

 

History

History
324 lines (313 loc) · 41.8 KB

GameController.md

File metadata and controls

324 lines (313 loc) · 41.8 KB

GameController

Symbols: 68.7% of Apple's iOS API (609 of 886, exact) · Rows: 18: 12 ✅ 3 🟡 3 ❌ · iOS: 7.0+

Area: Games & 3D · Apple: GameController · Issues: area:games

How isim implements it

  • Passthrough: host gamepads through SDL3 (isim/runtime/host_gamepad.c).
  • Adapted: GCVirtualController is drawn by isim; the keyboard comes from the host.
  • Objective-C: #import <GameController/GameController.h> and -framework GameController (isim/sdk-src/Frameworks/GameController) reach the Swift overlay's classes under their Objective-C names; isim/swift/overlays/GameController/ObjC.swift has the entry points for the Swift-only types (GCKeyCode, the player index, haptic localities, GCDevice) and isim/frameworks/GameController/GameController.m the constants, GCMotion's C structs, and the start of controller discovery when an Objective-C app runs.

API

API / feature Status iOS Notes
GameController's Objective-C interface: GCController (controllers, current, controllerWithExtendedGamepad / MicroGamepad, discovery, playerIndex, profiles, battery, light, haptics, motion), GCExtendedGamepad, GCMicroGamepad, GCDirectionalGamepad, GCXboxGamepad, GCDualShockGamepad, GCDualSenseGamepad / GCDualSenseAdaptiveTrigger, GCPhysicalInputProfile, the elements (GCControllerButtonInput, GCControllerAxisInput, GCControllerDirectionPad, GCControllerTouchpad, GCDeviceCursor), GCKeyboard / GCKeyboardInput and the GCKeyCode… values, GCMouse / GCMouseInput, GCVirtualController and its configurations, GCDeviceHaptics, GCDeviceBattery, GCDeviceLight / GCColor, GCMotion, the GCDevice protocol, the notification, input-name, product-category and haptic-locality constants ✅ ≤17 adapted: as the Swift classes; Swift-only: the iOS 17 physical-input API (GCDevicePhysicalInput and its protocols), GCEventViewController, GCEventInteraction, the DualSense positional strengths; the classes are not subclassable from Objective-C. Tested (tests/games-objc: a snapshot gamepad, the host keyboard, a tapped GCVirtualController)
GCController (controllers(), current, connect / disconnect / current notifications, playerIndex) ✅ ≤17 virtual controller and host gamepads
GCExtendedGamepad, GCMicroGamepad (buttons, d-pad, thumbsticks, triggers, value / pressed / touched handlers) ✅ ≤17 tested with the virtual controller
Physical game controllers on the host ✅ ≤17 SDL3 gamepads (Xbox / PlayStation / Switch / generic via SDL's mapping database) polled at 60 Hz: each becomes a GCController with GCExtendedGamepad (+ micro profile), vendorName from SDL, productCategory from the SDL pad type; ISIM_GAMEPADS=0 disables. Tested through an SDL virtual joystick (gamepad script command), not a physical pad
Gamepad rumble: GCController.haptics, GCDeviceHaptics (supportedLocalities, createEngine(withLocality:)), GCHapticsLocality, GCHapticDurationInfinite ✅ ≤17 adapted: a host pad's haptics make CoreHaptics engines whose haptic events drive its two rumble motors through SDL (intensity split over the low- and high-frequency motors by sharpness); the handles only: trigger localities give no engine; snapshots and the virtual controller have none; tested (HelloSpriteKit2, test_spritekit2: the virtual test pad logs the rumble)
GCKeyboard.coalesced, GCKeyboardInput (button(forKeyCode:), keyChangedHandler, isAnyKeyPressed), GCKeyCode ✅ ≤17 the host keyboard; key presses and releases arrive as USB HID usages (scripts: keydown/keyup)
GCVirtualController (iOS 15) 🟡 ≤17 thumbsticks, d-pad, A/B/X/Y, shoulders, triggers and menu drawn over the key window; element configurations only hide elements (custom paths ignored)
GCController.battery, GCDeviceBattery (batteryLevel, batteryState) ✅ ≤17 passthrough: SDL's power info of a host pad, read when asked (nil for wired pads and snapshots); the gamepad battery script command sets the virtual pad's; tested (HelloSpriteKit2)
GCController.light, GCDeviceLight (color), GCColor ✅ ≤17 passthrough: the colour lights the pad's light bar (DualShock 4 / DualSense; other pads ignore it); tested (HelloSpriteKit2: the virtual pad's LED)
GCController.motion, GCMotion (sensorsActive, sensorsRequireManualActivation, acceleration, rotationRate, gravity / userAcceleration / attitude and their setters, setState(fromMotion:), valueChangedHandler), GCAcceleration, GCRotationRate, GCQuaternion ✅ ≤17 passthrough: a host pad's accelerometer (in g, gravity included) and gyroscope (rad/s), read at 60 Hz while sensorsActive; like iOS for DualShock / DualSense, the sensors need manual activation and there is no gravity / user-acceleration split or attitude; the gamepad motion script command feeds the virtual pad; tested (HelloSpriteKit2)
GCMouse (current, mice(), connect / current notifications), GCMouseInput (mouseMovedHandler, leftButton, rightButton, middleButton, auxiliaryButtons, scroll), GCDeviceCursor ✅ ≤17 adapted: the host pointer over the device window (relative motion in points with y up, buttons, the scroll wheel), connected once it moves; the pointer still taps the device as touches; mouse script commands drive it; tested (HelloSpriteKit2)
Product profiles: GCDualSenseGamepad (touchpadButton, touchpadPrimary, touchpadSecondary, adaptive leftTrigger / rightTrigger), GCDualShockGamepad, GCXboxGamepad (buttonShare, paddleButton1…4), GCDirectionalGamepad, GCControllerTouchpad (button, touchSurface, touchState, touchDown / touchMoved / touchUp), GCPhysicalInputProfile.touchpads / allTouchpads, the GCInput… names ✅ ≤17 passthrough: the profile follows SDL3's pad type (PS5, PS4, Xbox One / 360; others stay GCExtendedGamepad); share, paddles and the touchpad are SDL's buttons and first touchpad (two fingers, -1…1, y up); the Xbox paddles exist only on pads SDL reports them for; host pads are never GCDirectionalGamepad (a micro gamepad with a d-pad); tested (HelloSpriteKit2: gamepad connect … as ps5 / as xbox, touch, share, paddle)
GCDualSenseAdaptiveTrigger (setModeOff(), feedback / weapon / vibration / slope feedback modes, the positional modes, mode, status, armPosition, PositionalAmplitudes, PositionalResistiveStrengths, discretePositionCount) 🟡 ≤17 passthrough: each mode goes to the pad as a DualSense effect report (SDL's DS5 layout); adapted: the positional modes use the first zone with a value and the strongest one (one zone), slope feedback a constant resistance; status is .unknown (SDL does not read it back); tested (the virtual pad logs the effect report)
GCController.input, GCControllerLiveInput (buttons, dpads, elements, subscripts by name, elementValueDidChangeHandler, capture(), inputStateQueueDepth, inputStateAvailableHandler, nextInputState(), queue, unmapped), GCControllerInputState, GCDevicePhysicalInput, GCDevicePhysicalInputState, GCDevicePhysicalInputStateDiff, GCPhysicalInputElementCollection, the element protocols (GCButtonElement, GCDirectionPadElement, GCAxisElement, GCSwitchElement), the input protocols (GCLinearInput, GCPressedStateInput, GCTouchedStateInput, GCAxisInput, GCAxis2DInput, GCRelativeInput, GCSwitchPositionInput), GCPhysicalInputSource, the element names (GCButtonElementName, GCDirectionPadElementName, GCAxisElementName, GCSwitchElementName, GCPhysicalInputElementName) ✅ 17.0 adapted: the elements wrap the controller's profile elements (the same values and timing); every element change queues a state with the elements that changed since the previous one; host pads have no axis or switch elements (axes and switches are empty); sources are empty; latencies are 0; unmapped is the same input (isim does not remap); tested (HelloSpriteKit2: named elements, handlers, the state queue, capture())
GCEventInteraction (handledEventTypes, receivesEventsInView), GCUIEventTypes, GCEventViewController (controllerUserInteractionEnabled) 🟡 17.0 adapted: they keep their settings; isim sends no game controller events to UIKit, so controller input always reaches GameController; tested (HelloSpriteKit2 attaches an interaction)
Types not yet in isim (iOS 17 and earlier) ❌ ≤17 not implemented, found by the 2026-10 sweep: GCPhysicalInputElementTypedName (1 type; with its members under "Not yet in isim")
Types not yet in isim (iOS 26) ❌ 26.2 not implemented, found by the 2026-10 sweep: GCPhysicalInputExtents (1 type; with its members under "Not yet in isim")
Types not yet in isim (iOS 27) ❌ 27.0 not implemented, found by the 2026-10 sweep: GCControllerHomeButtonSettingCustomizationStatus, GCControllerHomeButtonSettingInAppAction, GCControllerHomeButtonSettingsCustomizationActivity, GCControllerHomeButtonSettingsManager, GCControllerHomeButtonSettingSystemAction (5 types; with their members under "Not yet in isim")

Not yet in isim

277 symbols Apple documents for iOS that isim does not have (exact; Apple snapshot 2026-10-14). Each links to Apple's documentation.

List