First Commit

This commit is contained in:
stossy11 2024-10-08 10:25:50 +11:00
commit 3621f4ff19
1839 changed files with 449741 additions and 0 deletions

10
.gitignore vendored Normal file
View File

@ -0,0 +1,10 @@
# User settings
xcuserdata/
# Configuration files
CodeSigning.xcconfig
# macOS files
.DS_Store
Package.resolved

View File

@ -0,0 +1,267 @@
--- !tapi-tbd
tbd-version: 4
targets: [ armv7-ios, armv7s-ios, arm64-ios, arm64e-ios ]
install-name: '/System/Library/Frameworks/CoreBluetooth.framework/CoreBluetooth'
current-version: 180.48.3
exports:
- targets: [ armv7-ios, armv7s-ios ]
objc-classes: [ BTDevicePicker ]
- targets: [ armv7-ios, armv7s-ios, arm64-ios, arm64e-ios ]
symbols: [ _CBATTErrorDomain, _CBAdvOptionInstanceAddress, _CBAdvOptionInstanceRandomAddressBytes,
_CBAdvOptionObjectLocatorOnThisInstance, _CBAdvOptionStopOnAdvertisingAddressChange,
_CBAdvertisementAppleMfgTypeKey, _CBAdvertisementDataAccessoryStatusDecrypted,
_CBAdvertisementDataAppleBeaconKey, _CBAdvertisementDataAppleMfgData,
_CBAdvertisementDataChannel, _CBAdvertisementDataDeviceAddress,
_CBAdvertisementDataDeviceAddressType, _CBAdvertisementDataHostWakeEvent,
_CBAdvertisementDataIsConnectable, _CBAdvertisementDataIsContact,
_CBAdvertisementDataIsExtended, _CBAdvertisementDataIsExtendedConnectable,
_CBAdvertisementDataIsObjectDiscovery, _CBAdvertisementDataIsTDS,
_CBAdvertisementDataLeBluetoothDeviceAddressKey, _CBAdvertisementDataLocalNameKey,
_CBAdvertisementDataManufacturerDataKey, _CBAdvertisementDataNonAppleMfgKey,
_CBAdvertisementDataOverflowServiceUUIDsKey, _CBAdvertisementDataProximityLevelKey,
_CBAdvertisementDataProximityPairingStatusDecrypted, _CBAdvertisementDataSaturated,
_CBAdvertisementDataServiceDataKey, _CBAdvertisementDataServiceUUIDsKey,
_CBAdvertisementDataSolicitedServiceUUIDsKey, _CBAdvertisementDataTDSData,
_CBAdvertisementDataTimestamp, _CBAdvertisementDataTxPowerLevelKey,
_CBAdvertisementDataWlanOn, _CBAdvertisementEnableEPA, _CBAdvertisementRawBytesData,
_CBAdvertisementTDSTypeKey, _CBAssignedL2CAPPSMForNearbyInvitation,
_CBAssignedL2CAPPSMForOysterAutoUnlock, _CBAssignedL2CAPPSMForRapport,
_CBAssignedL2CAPPSMForRemotePairing, _CBAssignedL2CAPPSMForSetupKit,
_CBBluetoothUsageDebuggingMode, _CBBluetoothUsageEnable, _CBBluetoothUsageMaxPercent,
_CBBluetoothUsageMinPercent, _CBCSCreateConfigCSSyncPHY, _CBCSCreateConfigCh3cJump,
_CBCSCreateConfigCh3cShape, _CBCSCreateConfigChannelMap, _CBCSCreateConfigChannelMapRepetition,
_CBCSCreateConfigChannelSelectiontype, _CBCSCreateConfigCompanionSignalEnable,
_CBCSCreateConfigConfigID, _CBCSCreateConfigCreateContext,
_CBCSCreateConfigMainModeMaxSteps, _CBCSCreateConfigMainModeMinSteps,
_CBCSCreateConfigMainModeRepetition, _CBCSCreateConfigMainModeType,
_CBCSCreateConfigMode0Steps, _CBCSCreateConfigRTTTypes, _CBCSCreateConfigRole,
_CBCSCreateConfigSubModeType, _CBCSSNRControlInitiator, _CBCSSNRControlReflector,
_CBCSSetConfigID, _CBCSSetMaxProcedureCount, _CBCSSetMaxProcedureDuration,
_CBCSSetMaxProcedureInterval, _CBCSSetMaxSubeventLen, _CBCSSetMinProcedureInterval,
_CBCSSetMinSubeventLen, _CBCSSetPhy, _CBCSSetPreferredPeerAntenna,
_CBCSSetProcedureEnable, _CBCSSetToneAntennaConfigSelection,
_CBCSSetTxPwrDelta, _CBCSWriteRemoteMaxAntennaPathSupported,
_CBCSWriteRemoteMaxConsecutiveProceduresSupported, _CBCSWriteRemoteNumAntennaSupported,
_CBCSWriteRemoteNumConfigSupported, _CBCSWriteRemoteOptionalCsSyncPhysSupported,
_CBCSWriteRemoteOptionalModeSupported, _CBCSWriteRemoteOptionalNadmRandomCapability,
_CBCSWriteRemoteOptionalNadmSoundingCapability, _CBCSWriteRemoteOptionalSubfeaturesSupported,
_CBCSWriteRemoteOptionalTFCSTimesSupported, _CBCSWriteRemoteOptionalTIP1TimesSupported,
_CBCSWriteRemoteOptionalTIP2TimesSupported, _CBCSWriteRemoteOptionalTPMTimesSupported,
_CBCSWriteRemoteOptionalTxSNRCapability, _CBCSWriteRemoteRTTCapability,
_CBCSWriteRemoteRolesSupported, _CBCSWriteRemoteRttCoarseN,
_CBCSWriteRemoteRttRandomPayloadN, _CBCSWriteRemoteRttSoundingN,
_CBCSWriteRemoteTSWTimesSupported, _CBCancelPeripheralConnectionOptionDoNotAutoConnectBuiltInServices,
_CBCancelPeripheralConnectionOptionForce, _CBCentralManagerControllerBTCLockSeconds,
_CBCentralManagerControllerBTClockEventCounter, _CBCentralManagerControllerBTClockEventType,
_CBCentralManagerControllerBTClockMicroSeconds, _CBCentralManagerControllerBTLocalClock,
_CBCentralManagerControllerBTRemoteClock, _CBCentralManagerEnhancedScanDuration,
_CBCentralManagerEnhancedScanEnable, _CBCentralManagerEnhancedScanPeriod,
_CBCentralManagerEnhancedScanType, _CBCentralManagerMatchActionRuleLocalAddress,
_CBCentralManagerMatchActionRulePeerAddress, _CBCentralManagerOptionDeviceAccessForMedia,
_CBCentralManagerOptionEnableFindMy, _CBCentralManagerOptionInitLeProfilesManagerWithOptions,
_CBCentralManagerOptionPowerModule, _CBCentralManagerOptionReceiveApplicationActivityEvents,
_CBCentralManagerOptionReceiveIncomingObjectDiscoveryData,
_CBCentralManagerOptionReceiveSystemEvents, _CBCentralManagerOptionRestoreIdentifierKey,
_CBCentralManagerOptionShowPowerAlertKey, _CBCentralManagerRemoveMultipleDupFilterEntryPacketType,
_CBCentralManagerRemoveMultipleDupFilterEntryUUIDs, _CBCentralManagerRestoredStatePeripheralsKey,
_CBCentralManagerRestoredStateScanOptionsKey, _CBCentralManagerRestoredStateScanServicesKey,
_CBCentralManagerScanOptionActive, _CBCentralManagerScanOptionAllowDuplicatesKey,
_CBCentralManagerScanOptionAllowedInPaused, _CBCentralManagerScanOptionCacheResults,
_CBCentralManagerScanOptionContactTracing, _CBCentralManagerScanOptionFilterIdentifier,
_CBCentralManagerScanOptionFilterIdentifierString, _CBCentralManagerScanOptionHWObjectDiscovery,
_CBCentralManagerScanOptionHWObjectDiscoveryNearOwner, _CBCentralManagerScanOptionHWObjectDiscoveryWild,
_CBCentralManagerScanOptionIsPrivilegedDaemonKey, _CBCentralManagerScanOptionLatencyCritical,
_CBCentralManagerScanOptionMatchingRuleAddress, _CBCentralManagerScanOptionMatchingRuleAddressType,
_CBCentralManagerScanOptionMatchingRuleBypassFilterDuplicate,
_CBCentralManagerScanOptionMatchingRuleForceDupes, _CBCentralManagerScanOptionMatchingRuleKey,
_CBCentralManagerScanOptionMatchingRuleManufacturerID, _CBCentralManagerScanOptionMatchingRuleMaskKey,
_CBCentralManagerScanOptionMatchingRuleNameMatchOption, _CBCentralManagerScanOptionMatchingRuleNameMatchOptionContains,
_CBCentralManagerScanOptionMatchingRuleNameMatchOptionEndsWith,
_CBCentralManagerScanOptionMatchingRuleNameMatchOptionStartsWith,
_CBCentralManagerScanOptionMatchingRuleNameMatchString, _CBCentralManagerScanOptionMatchingRulePayloadKey,
_CBCentralManagerScanOptionMatchingRuleRSSIKey, _CBCentralManagerScanOptionMatchingRuleRSSIThresholdOrder,
_CBCentralManagerScanOptionMatchingRuleServiceUUID, _CBCentralManagerScanOptionMatchingRuleTargetCore,
_CBCentralManagerScanOptionMatchingRuleTypeKey, _CBCentralManagerScanOptionPeersKey,
_CBCentralManagerScanOptionPriorityCritical, _CBCentralManagerScanOptionProximityThresholdKey,
_CBCentralManagerScanOptionRange, _CBCentralManagerScanOptionReadADVBuffersNow,
_CBCentralManagerScanOptionReceiveDebugScanParamUpdates, _CBCentralManagerScanOptionReloadMigratableItems,
_CBCentralManagerScanOptionReport127dBm, _CBCentralManagerScanOptionReport27dBm,
_CBCentralManagerScanOptionRequiresActive, _CBCentralManagerScanOptionRetainDuplicates,
_CBCentralManagerScanOptionScanInterval, _CBCentralManagerScanOptionScanIntervalBackground,
_CBCentralManagerScanOptionScanRxDuration, _CBCentralManagerScanOptionScanWindow,
_CBCentralManagerScanOptionScanningPhys, _CBCentralManagerScanOptionSolicitedServiceUUIDsKey,
_CBCentralManagerScanOptionTDS, _CBCentralManagerScanOptionUsecase,
_CBCentralManagerScanOptionZonesKey, _CBCentralManagerScanParametersOptionObjectLocator,
_CBCentralManagerScanParametersOptionOwnAddress, _CBCentralManagerScanParametersOptionScanIntervalPHY0,
_CBCentralManagerScanParametersOptionScanIntervalPHY1, _CBCentralManagerScanParametersOptionScanIntervalPHY2,
_CBCentralManagerScanParametersOptionScanIsLegacy, _CBCentralManagerScanParametersOptionScanMaxWindowPHY0,
_CBCentralManagerScanParametersOptionScanMaxWindowPHY1, _CBCentralManagerScanParametersOptionScanMaxWindowPHY2,
_CBCentralManagerScanParametersOptionScanPHY, _CBCentralManagerScanParametersOptionScanTargetCore,
_CBCentralManagerScanParametersOptionScanTypePHY0, _CBCentralManagerScanParametersOptionScanTypePHY1,
_CBCentralManagerScanParametersOptionScanTypePHY2, _CBCentralManagerScanParametersOptionScanWindowPHY0,
_CBCentralManagerScanParametersOptionScanWindowPHY1, _CBCentralManagerScanParametersOptionScanWindowPHY2,
_CBCentralManagerScanParametersOptionScanWithPowerAssertion,
_CBCentralManagerScanParametersOptionScanningFilterPolicy,
_CBCentralManagerSetDataLengthMaxTxOctets, _CBCentralManagerSetDataLengthMaxTxTime,
_CBCentralManagerTrackingOptionEventConfiguration, _CBCentralManagerTrackingOptionInvalidRssiHandling,
_CBCentralManagerTrackingOptionRssiIncreaseScanEnable, _CBCentralManagerTrackingOptionRssiIncreaseScanInterval,
_CBCentralManagerTrackingOptionRssiIncreaseScanThreshold,
_CBCentralManagerTrackingOptionRssiIncreaseScanTimeout, _CBCentralManagerTrackingOptionRssiIncreaseScanWindow,
_CBCentralManagerTrackingOptionRssiPrecision, _CBCentralManagerTrackingOptionRssiThreshold,
_CBCentralManagerTrackingOptionRssiThresholdGone, _CBCentralManagerTrackingOptionSensorTimeoutBetweenIncreaseScan,
_CBCentralManagerTrackingOptionTimeoutValue, _CBCentralManagerTrackingOptionType,
_CBCentralManagerTrackingOptionVseBuffering, _CBConnectPeripheralOptionClientBundleID,
_CBConnectPeripheralOptionClientProcessID, _CBConnectPeripheralOptionConnectionCompleteAfterPoll,
_CBConnectPeripheralOptionConnectionUseCase, _CBConnectPeripheralOptionCtkdTransport,
_CBConnectPeripheralOptionDisableLeGATT, _CBConnectPeripheralOptionDoNotDisconnectOnEncryptionFailure,
_CBConnectPeripheralOptionEnableAutoReconnect, _CBConnectPeripheralOptionEnableControllerBTClockUpdates,
_CBConnectPeripheralOptionEnableScanCore, _CBConnectPeripheralOptionEnableTransportBridgingKey,
_CBConnectPeripheralOptionFirstApproachEnable, _CBConnectPeripheralOptionFixedChannels,
_CBConnectPeripheralOptionHideFromBTSettings, _CBConnectPeripheralOptionInitPHYs,
_CBConnectPeripheralOptionLatencyCritical, _CBConnectPeripheralOptionMaxAllowedConnectionDelay,
_CBConnectPeripheralOptionMinRSSIForConnection, _CBConnectPeripheralOptionNotifyOnConnectionKey,
_CBConnectPeripheralOptionNotifyOnDisconnectionKey, _CBConnectPeripheralOptionNotifyOnNotificationKey,
_CBConnectPeripheralOptionOpportunistic, _CBConnectPeripheralOptionPHYOptions,
_CBConnectPeripheralOptionRequiresANCS, _CBConnectPeripheralOptionResetDisconnectionHistory,
_CBConnectPeripheralOptionSetConnectScanDutyCycle, _CBConnectPeripheralOptionSetScreenOffConnectScanDutyCycle,
_CBConnectPeripheralOptionStartDelayKey, _CBConnectPeripheralOptionTemporaryIRKValue,
_CBConnectPeripheralOptionTemporaryIdentityAddress, _CBConnectPeripheralOptionUseTempLTK,
_CBConnectPeripheralOptionUseWHB, _CBConnectionEventMatchingOptionAllPeripherals,
_CBConnectionEventMatchingOptionPeripheralUUIDs, _CBConnectionEventMatchingOptionServiceUUIDs,
_CBConnectionUseCase, _CBControllerLowPowerModeCompletionTimeoutSeconds,
_CBCoordinatedSetRSIAdv, _CBDeviceFlagsToString, _CBDeviceTypeToNSLocalizedString,
_CBDeviceTypeToString, _CBDiscoveryFlagsToString, _CBDiscoveryTypeFromCString,
_CBDiscoveryTypeNameValues, _CBDiscoveryTypesAddChangedTypes,
_CBDiscoveryTypesAddTypes, _CBDiscoveryTypesAppendString,
_CBDiscoveryTypesBLEScan, _CBDiscoveryTypesBuffer, _CBDiscoveryTypesContainTypes,
_CBDiscoveryTypesEnumToString, _CBDiscoveryTypesNearbyActionNoWake,
_CBDiscoveryTypesNearbyActionV1, _CBDiscoveryTypesNearbyActionV2,
_CBDiscoveryTypesNearbyInfoV2, _CBDiscoveryTypesNeedsAdvertisingAddress,
_CBDiscoveryTypesNeedsIdentify, _CBDiscoveryTypesNeedsObjectLocator,
_CBDiscoveryTypesProximityService, _CBDiscoveryTypesRemoveTypes,
_CBDiscoveryTypesRemoveTypesAndReportChanges, _CBDiscoveryTypesToString,
_CBErrorDomain, _CBErrorF, _CBGenerateObfuscatedSHA256HashedString,
_CBGenerateSHA256HashedString, _CBGetHexString, _CBGetRssiStatisticsDetectionAverage,
_CBGetRssiStatisticsDetectionCoreMotionAndMask, _CBGetRssiStatisticsDetectionCoreMotionAndMask2,
_CBGetRssiStatisticsDetectionCoreMotionXorMask, _CBGetRssiStatisticsDetectionMaximum,
_CBGetRssiStatisticsDetectionMedian, _CBGetRssiStatisticsDetectionMinimum,
_CBGetRssiStatisticsDetectionState, _CBGetRssiStatisticsDetectionVariance,
_CBGetRssiStatisticsRawData, _CBInternalErrorDomain, _CBLESetPhyAllPhys,
_CBLESetPhyPhyOptions, _CBLESetPhyRxPhys, _CBLESetPhyTxPhys,
_CBLTV8GetNext, _CBLTV8GetSInt64, _CBLTV8GetUInt64, _CBLTV8GetWithType,
_CBLeHighHysteresis, _CBLeHighThreshold, _CBLeLowHysteresis,
_CBLeLowThreshold, _CBLeMRCAction, _CBLeMRCEnable, _CBLeMinTimeSpent,
_CBLePHYType, _CBLePathLossReportingEnable, _CBLePowerControlCmd,
_CBLePowerControlLocalEnable, _CBLePowerControlRemoteEnable,
_CBManagerIsIOBluetoothShim, _CBManagerIsPrivilegedDaemonKey,
_CBManagerL2CAPChannelCreditsAckDelta, _CBManagerL2CAPChannelInMPS,
_CBManagerL2CAPChannelInMTU, _CBManagerL2CAPChannelInitialCredits,
_CBManagerListOfClients, _CBManagerNeedsRestrictedStateOperation,
_CBManagerPrivacySupported, _CBManagerReceivesControllerBTClockEvents,
_CBManagerRequiresPlistInspection, _CBManagerResourceADVBufferCount,
_CBManagerResourceConnectionUsecaseCount, _CBMsgArgManagerCustomName,
_CBMsgArgPairingOptionsDisableCTKD, _CBNumberOfConnectionsForUseCase,
_CBOptionUseCase, _CBOptionUseCaseList, _CBOriginalPeerIdentifierErrorKey,
_CBPairingAgentPairingDataOOBTKKey, _CBPairingAgentPairingDataPasskeyKey,
_CBPairingOptionsDistributeIRK, _CBPairingOptionsUseMITMAuthentication,
_CBPeriodicAdvDataAdvHandleKey, _CBPeriodicAdvDataIntervalKey,
_CBPeriodicAdvDataRandomDataKey, _CBPeriodicAdvDataServiceUUIDsKey,
_CBPeripheralFindMyPeripheralAddresses, _CBPeripheralFindMyPeripheralAllowedBundleIDs,
_CBPeripheralFindMyPeripheralEncryptionKeys, _CBPeripheralManagerAdvertisingInterval,
_CBPeripheralManagerAdvertisingWithPowerAssertion, _CBPeripheralManagerOfflineAdvertisingData,
_CBPeripheralManagerOfflineAdvertisingRotationInterval, _CBPeripheralManagerOptionRestoreIdentifierKey,
_CBPeripheralManagerOptionShowPowerAlertKey, _CBPeripheralManagerReceivesOfflineADVPayloadRequests,
_CBPeripheralManagerRestoredStateAdvertisementDataKey, _CBPeripheralManagerRestoredStateServicesKey,
_CBPhyStatsConfigFrequencySubrate, _CBProductIDFromNSString,
_CBRSSIStatisticAndDetectionAverageThresholdCloser, _CBRSSIStatisticAndDetectionAverageThresholdFurther,
_CBRSSIStatisticAndDetectionCMCheckLogic, _CBRSSIStatisticAndDetectionCM_AND_Mask,
_CBRSSIStatisticAndDetectionCM_AND_Mask2, _CBRSSIStatisticAndDetectionCM_XOR_Mask,
_CBRSSIStatisticAndDetectionEnable, _CBRSSIStatisticAndDetectionEnableAOPPath,
_CBRSSIStatisticAndDetectionEnableDebugging, _CBRSSIStatisticAndDetectionMaskDecisionLogic,
_CBRSSIStatisticAndDetectionMaximumThresholdCloser, _CBRSSIStatisticAndDetectionMaximumThresholdFurther,
_CBRSSIStatisticAndDetectionMedianThresholdCloser, _CBRSSIStatisticAndDetectionMedianThresholdFurther,
_CBRSSIStatisticAndDetectionTxPower, _CBRSSIStatisticAndDetectionVarThreshold1,
_CBRSSIStatisticAndDetectionVarThreshold2, _CBRSSIStatisticAndDetectionWindowConfiguration,
_CBRetrieveBTDeviceCacheInfoOptionLastMinutes, _CBRetrieveBTDeviceCacheInfoResultDeviceCount,
_CBScalablePipeOptionDisableBluetoothReliability, _CBScalablePipeOptionRequiresEncryption,
_CBScalablePipeOptionStayConnectedWhenIdle, _CBScalablePipeOptionTrace,
_CBScalablePipeOptionTransport, _CBScalablePipeStatisticsTotalTimeSpentUpgraded,
_CBServiceFlagsToString, _CBSetConnectionEventOptionMatchAllPeripherals,
_CBSetConnectionEventOptionMatchPeripheralsUUIDs, _CBSetConnectionEventOptionMatchServicesUUIDs,
_CBUTF8Truncate, _CBUUIDAMSEntityAttributeCharacteristicString,
_CBUUIDAMSEntityUpdateCharacteristicString, _CBUUIDAMSRemoteCommandCharacteristicString,
_CBUUIDANCSControlPointCharacteristicString, _CBUUIDANCSDataSourceCharacteristicString,
_CBUUIDANCSNotificationSourceCharacteristicString, _CBUUIDASEControlPointCharacteristicString,
_CBUUIDAppearanceString, _CBUUIDAppleAccessoryReconnectServiceString,
_CBUUIDAppleHeadsetPropertyServiceString, _CBUUIDAppleMediaServiceString,
_CBUUIDAppleNotificationCenterServiceString, _CBUUIDAudioStreamControlServiceString,
_CBUUIDAvailableAudioContextsCharacteristicString, _CBUUIDBatteryLevelCharacteristicString,
_CBUUIDBatteryPowerStateCharacteristicString, _CBUUIDBatteryServiceString,
_CBUUIDBloodPressureServiceString, _CBUUIDBodyCompositionServiceString,
_CBUUIDBodySensorLocationCharacteristicString, _CBUUIDBondManagementServiceString,
_CBUUIDBootKeyboardInputReportCharacteristicString, _CBUUIDBootKeyboardOutputReportCharacteristicString,
_CBUUIDBootMouseInputReportCharacteristicString, _CBUUIDCSCFeature,
_CBUUIDCSCMeasurement, _CBUUIDCharacteristicAggregateFormatString,
_CBUUIDCharacteristicExtendedPropertiesString, _CBUUIDCharacteristicFormatString,
_CBUUIDCharacteristicObservationScheduleString, _CBUUIDCharacteristicUserDescriptionString,
_CBUUIDCharacteristicValidRangeString, _CBUUIDClientCharacteristicConfigurationString,
_CBUUIDCommonAudioServiceString, _CBUUIDContinuityCharacteristicString,
_CBUUIDContinuityServiceString, _CBUUIDContinuousGlucoseMonitoringServiceString,
_CBUUIDCurrentElapsedTimeCharacteristicString, _CBUUIDCurrentTimeCharacteristicString,
_CBUUIDCurrentTimeServiceString, _CBUUIDCyclingPowerControlPoint,
_CBUUIDCyclingPowerFeature, _CBUUIDCyclingPowerMeasurement,
_CBUUIDCyclingPowerServiceString, _CBUUIDCyclingPowerVector,
_CBUUIDCyclingSpeedAndCadenceServiceString, _CBUUIDDatabaseChangeIncrementCharacteristicString,
_CBUUIDDeviceInformationServiceString, _CBUUIDDeviceNameString,
_CBUUIDDoAPServiceString, _CBUUIDDosimetrySensitivityCharacteristicString,
_CBUUIDDosimetryVolumeCurveCharacteristicString, _CBUUIDElapsedTimeServiceString,
_CBUUIDEventIndicatorCharacteristicString, _CBUUIDFirmwareRevisionStringCharacteristicString,
_CBUUIDGHSControlPointCharacteristicString, _CBUUIDGenericAccessProfileString,
_CBUUIDGenericAttributeProfileString, _CBUUIDGenericHealthSensorServiceString,
_CBUUIDGlucoseServiceString, _CBUUIDHIDControlPointCharacteristicString,
_CBUUIDHIDInformationCharacteristicString, _CBUUIDHardwareRevisionStringCharacteristicString,
_CBUUIDHealthSensorFeaturesCharacteristicString, _CBUUIDHealthThermometerServiceString,
_CBUUIDHeartRateControlPointCharacteristicString, _CBUUIDHeartRateMeasurementCharacteristicString,
_CBUUIDHeartRateServiceString, _CBUUIDHumanInterfaceDeviceServiceString,
_CBUUIDIEEERegulatoryCertificationDataList, _CBUUIDInsulinDeliveryServiceString,
_CBUUIDL2CAPPSMCharacteristicString, _CBUUIDLECarPlayL2CAPPSMCharacteristicString,
_CBUUIDLECarPlayServiceString, _CBUUIDLiveHealthObservationsCharacteristicString,
_CBUUIDLocalTimeInformationCharacteristicString, _CBUUIDMIDIServiceString,
_CBUUIDManufacturerNameStringCharacteristicString, _CBUUIDModelNumberStringCharacteristicString,
_CBUUIDObservationScheduleChangedCharacteristicString, _CBUUIDPeripheralPreferredConnectionParametersString,
_CBUUIDPeripheralPrivacyFlagString, _CBUUIDPhysicalActivityMonitorServiceString,
_CBUUIDPnPIDCharacteristicString, _CBUUIDProtocolModeCharacteristicString,
_CBUUIDPublishedAudioCapabilitiesServiceString, _CBUUIDPulseOximeterServiceString,
_CBUUIDRACPCharacteristicString, _CBUUIDReconnectionAddressString,
_CBUUIDRegisteredUserCharacteristicString, _CBUUIDReportCharacteristicString,
_CBUUIDReportMapCharacteristicString, _CBUUIDReportReferenceDescriptorString,
_CBUUIDRunningSpeedAndCadenceServiceString, _CBUUIDSelectedCodecCharacteristicString,
_CBUUIDSendDataCharacteristicString, _CBUUIDSensorLocation,
_CBUUIDSerialNumberStringCharacteristicString, _CBUUIDServerCharacteristicConfigurationString,
_CBUUIDServiceChangedString, _CBUUIDSinkASECharacteristicString,
_CBUUIDSinkAudioLocationsCharacteristicString, _CBUUIDSinkPACCharacteristicString,
_CBUUIDSoftwareRevisionStringCharacteristicString, _CBUUIDSourceASECharacteristicString,
_CBUUIDSourceAudioLocationsCharacteristicString, _CBUUIDSourcePACCharacteristicString,
_CBUUIDStartStreamingCharacteristicString, _CBUUIDStopStreamingCharacteristicString,
_CBUUIDStoredHealthObservationsCharacteristicString, _CBUUIDSupportedAudioContextsCharacteristicString,
_CBUUIDSupportedCodecsCharacteristicString, _CBUUIDSystemIDCharacteristicString,
_CBUUIDUARPDataControlPointCharacteristicString, _CBUUIDUDIForMedicalDevicesCharacteristicString,
_CBUUIDUnifiedAccessoryRestoreProtocolServiceString, _CBUUIDUserControlPointCharacteristicString,
_CBUUIDUserDataServiceString, _CBUUIDUserIndexCharacteristicString,
_CBUUIDWeightScaleServiceString, _CBUnpairOptionForceDisconnect,
_CBUseCaseFromString, _CBUserControllerXPCInterface, _CBXPCGetNextClientID,
_CBlePowerControlWait4Result, _gCBDaemonServer ]
objc-classes: [ CBATTRequest, CBAccessoryLogging, CBAdvertiser, CBApplePayloadTypeInfo,
CBAttribute, CBAudioLinkQualityInfo, CBBLEServiceDataInfo,
CBCentral, CBCentralManager, CBCharacteristic, CBConnection,
CBController, CBControllerInfo, CBControllerSettings, CBDescriptor,
CBDevice, CBDeviceIdentity, CBDeviceRequest, CBDeviceResponse,
CBDeviceSettings, CBDiscovery, CBDiscoverySummary, CBHIDPerformanceMonitor,
CBHIDPerformanceSummary, CBL2CAPChannel, CBManager, CBMutableCharacteristic,
CBMutableDescriptor, CBMutableService, CBOOBKeyInfo, CBPacketLoggerClient,
CBPairingAgent, CBPairingInfo, CBPeer, CBPeripheral, CBPeripheralManager,
CBProductInfo, CBReadRequest, CBScalablePipe, CBScalablePipeManager,
CBServer, CBService, CBServiceUUIDParamInfo, CBSpatialInteractionDeviceTimestampInfo,
CBSpatialInteractionSession, CBSpatialMeasurement, CBSystemHealthBluetooth,
CBUUID, CBUserController, CBUtil, CBWriteRequest ]
...

View File

@ -0,0 +1,69 @@
/*
* @file CBATTRequest.h
* @framework CoreBluetooth
*
* @discussion
*
* @copyright 2012 Apple, Inc. All rights reserved.
*/
#ifndef _CORE_BLUETOOTH_H_
#warning Please do not import this header file directly. Use <CoreBluetooth/CoreBluetooth.h> instead.
#endif
#import <CoreBluetooth/CBDefines.h>
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@class CBCentral, CBCharacteristic;
/*!
* @class CBATTRequest
*
* @discussion Represents a read or write request from a central.
*
*/
NS_CLASS_AVAILABLE(10_9, 6_0)
CB_EXTERN_CLASS @interface CBATTRequest : NSObject
- (instancetype)init NS_UNAVAILABLE;
/*!
* @property central
*
* @discussion The central that originated the request.
*
*/
@property(readonly, nonatomic) CBCentral *central;
/*!
* @property characteristic
*
* @discussion The characteristic whose value will be read or written.
*
*/
@property(readonly, nonatomic) CBCharacteristic *characteristic;
/*!
* @property offset
*
* @discussion The zero-based index of the first byte for the read or write.
*
*/
@property(readonly, nonatomic) NSUInteger offset;
/*!
* @property value
*
* @discussion The data being read or written.
* For read requests, <i>value</i> will be nil and should be set before responding via @link respondToRequest:withResult: @/link.
* For write requests, <i>value</i> will contain the data to be written.
*
*/
@property(readwrite, copy, nullable) NSData *value;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,94 @@
/*
* @file CBAdvertisementData.h
* @framework CoreBluetooth
*
* @copyright 2012 Apple, Inc. All rights reserved.
*/
#ifndef _CORE_BLUETOOTH_H_
#warning Please do not import this header file directly. Use <CoreBluetooth/CoreBluetooth.h> instead.
#endif
#import <CoreBluetooth/CBDefines.h>
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
/*!
* @constant CBAdvertisementDataLocalNameKey
*
* @discussion A <code>NSString</code> containing the local name of a peripheral.
*
*/
CB_EXTERN NSString * const CBAdvertisementDataLocalNameKey;
/*!
* @constant CBAdvertisementDataTxPowerLevelKey
*
* @discussion A <code>NSNumber</code> containing the transmit power of a peripheral.
*
*/
CB_EXTERN NSString * const CBAdvertisementDataTxPowerLevelKey;
/*!
* @constant CBAdvertisementDataServiceUUIDsKey
*
* @discussion A list of one or more <code>CBUUID</code> objects, representing <code>CBService</code> UUIDs.
*
*/
CB_EXTERN NSString * const CBAdvertisementDataServiceUUIDsKey;
/*!
* @constant CBAdvertisementDataServiceDataKey
*
* @discussion A dictionary containing service-specific advertisement data. Keys are <code>CBUUID</code> objects, representing
* <code>CBService</code> UUIDs. Values are <code>NSData</code> objects.
*
*/
CB_EXTERN NSString * const CBAdvertisementDataServiceDataKey;
/*!
* @constant CBAdvertisementDataManufacturerDataKey
*
* @discussion A <code>NSData</code> object containing the manufacturer data of a peripheral.
*
*/
CB_EXTERN NSString * const CBAdvertisementDataManufacturerDataKey;
/*!
* @constant CBAdvertisementDataOverflowServiceUUIDsKey
*
* @discussion A list of one or more <code>CBUUID</code> objects, representing <code>CBService</code> UUIDs that were
* found in the "overflow" area of the advertising data. Due to the nature of the data stored in this area,
* UUIDs listed here are "best effort" and may not always be accurate.
*
* @see startAdvertising:
*
*/
CB_EXTERN NSString * const CBAdvertisementDataOverflowServiceUUIDsKey NS_AVAILABLE(10_9, 6_0);
/*!
* @constant CBAdvertisementDataIsConnectable
*
* @discussion An NSNumber (Boolean) indicating whether or not the advertising event type was connectable. This can be used to determine
* whether or not a peripheral is connectable in that instant.
*
*/
CB_EXTERN NSString * const CBAdvertisementDataIsConnectable NS_AVAILABLE(10_9, 7_0);
/*!
* @constant CBAdvertisementDataSolicitedServiceUUIDsKey
*
* @discussion A list of one or more <code>CBUUID</code> objects, representing <code>CBService</code> UUIDs.
*
*/
CB_EXTERN NSString * const CBAdvertisementDataSolicitedServiceUUIDsKey NS_AVAILABLE(10_9, 7_0);
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,34 @@
/*
* @file CBAttribute.h
* @framework CoreBluetooth
*
* @copyright 2014 Apple, Inc. All rights reserved.
*/
#import <CoreBluetooth/CBDefines.h>
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@class CBUUID;
@class CBPeripheral, CBCentral;
@class CBService, CBCharacteristic, CBDescriptor;
NS_CLASS_AVAILABLE(10_13, 8_0)
CB_EXTERN_CLASS @interface CBAttribute : NSObject
- (instancetype)init NS_UNAVAILABLE;
/*!
* @property UUID
*
* @discussion
* The Bluetooth UUID of the attribute.
*
*/
@property(readonly, nonatomic) CBUUID *UUID;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,41 @@
/*
* @file CBCentral.h
* @framework CoreBluetooth
*
* @discussion Representation of a remote central.
*
* @copyright 2012 Apple, Inc. All rights reserved.
*/
#ifndef _CORE_BLUETOOTH_H_
#warning Please do not import this header file directly. Use <CoreBluetooth/CoreBluetooth.h> instead.
#endif
#import <CoreBluetooth/CBDefines.h>
#import <CoreBluetooth/CBPeer.h>
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
/*!
* @class CBCentral
*
* @discussion Represents a remote central.
*
*/
NS_CLASS_AVAILABLE(10_9, 6_0)
CB_EXTERN_CLASS @interface CBCentral : CBPeer
/*!
* @property maximumUpdateValueLength
*
* @discussion The maximum amount of data, in bytes, that can be received by the central in a single notification or indication.
*
* @see updateValue:forCharacteristic:onSubscribedCentrals:
*/
@property(readonly, nonatomic) NSUInteger maximumUpdateValueLength;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,392 @@
/*
* @file CBCentralManager.h
* @framework CoreBluetooth
*
* @discussion Entry point to the central role.
*
* @copyright 2011 Apple, Inc. All rights reserved.
*/
#ifndef _CORE_BLUETOOTH_H_
#warning Please do not import this header file directly. Use <CoreBluetooth/CoreBluetooth.h> instead.
#endif
#import <CoreBluetooth/CBAdvertisementData.h>
#import <CoreBluetooth/CBCentralManagerConstants.h>
#import <CoreBluetooth/CBDefines.h>
#import <CoreBluetooth/CBManager.h>
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
/*!
* @enum CBCentralManagerState
*
* @discussion Represents the current state of a CBCentralManager.
*
* @constant CBCentralManagerStateUnknown State unknown, update imminent.
* @constant CBCentralManagerStateResetting The connection with the system service was momentarily lost, update imminent.
* @constant CBCentralManagerStateUnsupported The platform doesn't support the Bluetooth Low Energy Central/Client role.
* @constant CBCentralManagerStateUnauthorized The application is not authorized to use the Bluetooth Low Energy Central/Client role.
* @constant CBCentralManagerStatePoweredOff Bluetooth is currently powered off.
* @constant CBCentralManagerStatePoweredOn Bluetooth is currently powered on and available to use.
*
*/
typedef NS_ENUM(NSInteger, CBCentralManagerState) {
CBCentralManagerStateUnknown = CBManagerStateUnknown,
CBCentralManagerStateResetting = CBManagerStateResetting,
CBCentralManagerStateUnsupported = CBManagerStateUnsupported,
CBCentralManagerStateUnauthorized = CBManagerStateUnauthorized,
CBCentralManagerStatePoweredOff = CBManagerStatePoweredOff,
CBCentralManagerStatePoweredOn = CBManagerStatePoweredOn,
} NS_DEPRECATED(10_7, 10_13, 5_0, 10_0, "Use CBManagerState instead");
/*!
* @enum CBConnectionEvent
*
* @discussion Represents the connection state of a peer.
*
* @constant CBConnectionEventPeerDisconnected Peer is disconnected.
* @constant CBConnectionEventPeerConnected Peer is connected.
*
*/
typedef NS_ENUM(NSInteger, CBConnectionEvent) {
CBConnectionEventPeerDisconnected = 0,
CBConnectionEventPeerConnected = 1,
};
/*!
* @enum CBCentralManagerFeature
*
* @discussion The set of device specific features.
*
* @constant CBCentralManagerFeatureExtendedScanAndConnect The hardware supports extended scans and enhanced connection creation
*
*/
typedef NS_OPTIONS(NSUInteger, CBCentralManagerFeature) {
CBCentralManagerFeatureExtendedScanAndConnect CB_CM_API_AVAILABLE = 1UL << 0,
} NS_SWIFT_NAME(CBCentralManager.Feature);
@protocol CBCentralManagerDelegate;
@class CBUUID, CBPeripheral;
/*!
* @class CBCentralManager
*
* @discussion Entry point to the central role. Commands should only be issued when its state is <code>CBCentralManagerStatePoweredOn</code>.
*
*/
NS_CLASS_AVAILABLE(10_7, 5_0)
CB_EXTERN_CLASS @interface CBCentralManager : CBManager
/*!
* @property delegate
*
* @discussion The delegate object that will receive central events.
*
*/
@property(nonatomic, weak, nullable) id<CBCentralManagerDelegate> delegate;
/*!
* @property isScanning
*
* @discussion Whether or not the central is currently scanning.
*
*/
@property(nonatomic, assign, readonly) BOOL isScanning NS_AVAILABLE(10_13, 9_0);
/*!
* @method supportsFeatures
*
* @param features One or more features you would like to check if supported.
*
* @discussion Returns a boolean value representing the support for the provided features.
*
*/
+ (BOOL)supportsFeatures:(CBCentralManagerFeature)features CB_CM_API_AVAILABLE NS_SWIFT_NAME(supports(_:));
- (instancetype)init;
/*!
* @method initWithDelegate:queue:
*
* @param delegate The delegate that will receive central role events.
* @param queue The dispatch queue on which the events will be dispatched.
*
* @discussion The initialization call. The events of the central role will be dispatched on the provided queue.
* If <i>nil</i>, the main queue will be used.
*
*/
- (instancetype)initWithDelegate:(nullable id<CBCentralManagerDelegate>)delegate
queue:(nullable dispatch_queue_t)queue;
/*!
* @method initWithDelegate:queue:options:
*
* @param delegate The delegate that will receive central role events.
* @param queue The dispatch queue on which the events will be dispatched.
* @param options An optional dictionary specifying options for the manager.
*
* @discussion The initialization call. The events of the central role will be dispatched on the provided queue.
* If <i>nil</i>, the main queue will be used.
*
* @seealso CBCentralManagerOptionShowPowerAlertKey
* @seealso CBCentralManagerOptionRestoreIdentifierKey
*
*/
- (instancetype)initWithDelegate:(nullable id<CBCentralManagerDelegate>)delegate
queue:(nullable dispatch_queue_t)queue
options:(nullable NSDictionary<NSString *, id> *)options NS_AVAILABLE(10_9, 7_0) NS_DESIGNATED_INITIALIZER;
/*!
* @method retrievePeripheralsWithIdentifiers:
*
* @param identifiers A list of <code>NSUUID</code> objects.
*
* @discussion Attempts to retrieve the <code>CBPeripheral</code> object(s) with the corresponding <i>identifiers</i>.
*
* @return A list of <code>CBPeripheral</code> objects.
*
*/
- (NSArray<CBPeripheral *> *)retrievePeripheralsWithIdentifiers:(NSArray<NSUUID *> *)identifiers NS_AVAILABLE(10_9, 7_0);
/*!
* @method retrieveConnectedPeripheralsWithServices
*
* @discussion Retrieves all peripherals that are connected to the system and implement any of the services listed in <i>serviceUUIDs</i>.
* Note that this set can include peripherals which were connected by other applications, which will need to be connected locally
* via {@link connectPeripheral:options:} before they can be used.
*
* @return A list of <code>CBPeripheral</code> objects.
*
*/
- (NSArray<CBPeripheral *> *)retrieveConnectedPeripheralsWithServices:(NSArray<CBUUID *> *)serviceUUIDs NS_AVAILABLE(10_9, 7_0);
/*!
* @method scanForPeripheralsWithServices:options:
*
* @param serviceUUIDs A list of <code>CBUUID</code> objects representing the service(s) to scan for.
* @param options An optional dictionary specifying options for the scan.
*
* @discussion Starts scanning for peripherals that are advertising any of the services listed in <i>serviceUUIDs</i>. Although strongly discouraged,
* if <i>serviceUUIDs</i> is <i>nil</i> all discovered peripherals will be returned. If the central is already scanning with different
* <i>serviceUUIDs</i> or <i>options</i>, the provided parameters will replace them.
* Applications that have specified the <code>bluetooth-central</code> background mode are allowed to scan while backgrounded, with two
* caveats: the scan must specify one or more service types in <i>serviceUUIDs</i>, and the <code>CBCentralManagerScanOptionAllowDuplicatesKey</code>
* scan option will be ignored.
*
* @see centralManager:didDiscoverPeripheral:advertisementData:RSSI:
* @seealso CBCentralManagerScanOptionAllowDuplicatesKey
* @seealso CBCentralManagerScanOptionSolicitedServiceUUIDsKey
*
*/
- (void)scanForPeripheralsWithServices:(nullable NSArray<CBUUID *> *)serviceUUIDs options:(nullable NSDictionary<NSString *, id> *)options;
/*!
* @method stopScan:
*
* @discussion Stops scanning for peripherals.
*
*/
- (void)stopScan;
/*!
* @method connectPeripheral:options:
*
* @param peripheral The <code>CBPeripheral</code> to be connected.
* @param options An optional dictionary specifying connection behavior options.
*
* @discussion Initiates a connection to <i>peripheral</i>. Connection attempts never time out and, depending on the outcome, will result
* in a call to either {@link centralManager:didConnectPeripheral:} or {@link centralManager:didFailToConnectPeripheral:error:}.
* Pending attempts are cancelled automatically upon deallocation of <i>peripheral</i>, and explicitly via {@link cancelPeripheralConnection}.
*
* @see centralManager:didConnectPeripheral:
* @see centralManager:didFailToConnectPeripheral:error:
* @seealso CBConnectPeripheralOptionNotifyOnConnectionKey
* @seealso CBConnectPeripheralOptionNotifyOnDisconnectionKey
* @seealso CBConnectPeripheralOptionNotifyOnNotificationKey
* @seealso CBConnectPeripheralOptionEnableTransportBridgingKey
* @seealso CBConnectPeripheralOptionRequiresANCS
* @seealso CBConnectPeripheralOptionEnableAutoReconnect
*
*/
- (void)connectPeripheral:(CBPeripheral *)peripheral options:(nullable NSDictionary<NSString *, id> *)options;
/*!
* @method cancelPeripheralConnection:
*
* @param peripheral A <code>CBPeripheral</code>.
*
* @discussion Cancels an active or pending connection to <i>peripheral</i>. Note that this is non-blocking, and any <code>CBPeripheral</code>
* commands that are still pending to <i>peripheral</i> may or may not complete.
*
* @see centralManager:didDisconnectPeripheral:error:
*
*/
- (void)cancelPeripheralConnection:(CBPeripheral *)peripheral;
/*!
* @method registerForConnectionEventsWithOptions:
*
* @param options A dictionary specifying connection event options.
*
* @discussion Calls {@link centralManager:connectionEventDidOccur:forPeripheral:} when a connection event occurs matching any of the given options.
* Passing nil in the option parameter clears any prior registered matching options.
*
* @see centralManager:connectionEventDidOccur:forPeripheral:
* @seealso CBConnectionEventMatchingOptionServiceUUIDs
* @seealso CBConnectionEventMatchingOptionPeripheralUUIDs
*/
- (void)registerForConnectionEventsWithOptions:(nullable NSDictionary<CBConnectionEventMatchingOption, id> *)options CB_CM_API_AVAILABLE;
@end
/*!
* @protocol CBCentralManagerDelegate
*
* @discussion The delegate of a {@link CBCentralManager} object must adopt the <code>CBCentralManagerDelegate</code> protocol. The
* single required method indicates the availability of the central manager, while the optional methods allow for the discovery and
* connection of peripherals.
*
*/
@protocol CBCentralManagerDelegate <NSObject>
@required
/*!
* @method centralManagerDidUpdateState:
*
* @param central The central manager whose state has changed.
*
* @discussion Invoked whenever the central manager's state has been updated. Commands should only be issued when the state is
* <code>CBCentralManagerStatePoweredOn</code>. A state below <code>CBCentralManagerStatePoweredOn</code>
* implies that scanning has stopped and any connected peripherals have been disconnected. If the state moves below
* <code>CBCentralManagerStatePoweredOff</code>, all <code>CBPeripheral</code> objects obtained from this central
* manager become invalid and must be retrieved or discovered again.
*
* @see state
*
*/
- (void)centralManagerDidUpdateState:(CBCentralManager *)central;
@optional
/*!
* @method centralManager:willRestoreState:
*
* @param central The central manager providing this information.
* @param dict A dictionary containing information about <i>central</i> that was preserved by the system at the time the app was terminated.
*
* @discussion For apps that opt-in to state preservation and restoration, this is the first method invoked when your app is relaunched into
* the background to complete some Bluetooth-related task. Use this method to synchronize your app's state with the state of the
* Bluetooth system.
*
* @seealso CBCentralManagerRestoredStatePeripheralsKey;
* @seealso CBCentralManagerRestoredStateScanServicesKey;
* @seealso CBCentralManagerRestoredStateScanOptionsKey;
*
*/
- (void)centralManager:(CBCentralManager *)central willRestoreState:(NSDictionary<NSString *, id> *)dict;
/*!
* @method centralManager:didDiscoverPeripheral:advertisementData:RSSI:
*
* @param central The central manager providing this update.
* @param peripheral A <code>CBPeripheral</code> object.
* @param advertisementData A dictionary containing any advertisement and scan response data.
* @param RSSI The current RSSI of <i>peripheral</i>, in dBm. A value of <code>127</code> is reserved and indicates the RSSI
* was not available.
*
* @discussion This method is invoked while scanning, upon the discovery of <i>peripheral</i> by <i>central</i>. A discovered peripheral must
* be retained in order to use it; otherwise, it is assumed to not be of interest and will be cleaned up by the central manager. For
* a list of <i>advertisementData</i> keys, see {@link CBAdvertisementDataLocalNameKey} and other similar constants.
*
* @seealso CBAdvertisementData.h
*
*/
- (void)centralManager:(CBCentralManager *)central didDiscoverPeripheral:(CBPeripheral *)peripheral advertisementData:(NSDictionary<NSString *, id> *)advertisementData RSSI:(NSNumber *)RSSI;
/*!
* @method centralManager:didConnectPeripheral:
*
* @param central The central manager providing this information.
* @param peripheral The <code>CBPeripheral</code> that has connected.
*
* @discussion This method is invoked when a connection initiated by {@link connectPeripheral:options:} has succeeded.
*
*/
- (void)centralManager:(CBCentralManager *)central didConnectPeripheral:(CBPeripheral *)peripheral;
/*!
* @method centralManager:didFailToConnectPeripheral:error:
*
* @param central The central manager providing this information.
* @param peripheral The <code>CBPeripheral</code> that has failed to connect.
* @param error The cause of the failure.
*
* @discussion This method is invoked when a connection initiated by {@link connectPeripheral:options:} has failed to complete. As connection attempts do not
* timeout, the failure of a connection is atypical and usually indicative of a transient issue.
*
*/
- (void)centralManager:(CBCentralManager *)central didFailToConnectPeripheral:(CBPeripheral *)peripheral error:(nullable NSError *)error;
/*!
* @method centralManager:didDisconnectPeripheral:error:
*
* @param central The central manager providing this information.
* @param peripheral The <code>CBPeripheral</code> that has disconnected.
* @param error If an error occurred, the cause of the failure.
*
* @discussion This method is invoked upon the disconnection of a peripheral that was connected by {@link connectPeripheral:options:}. If the disconnection
* was not initiated by {@link cancelPeripheralConnection}, the cause will be detailed in the <i>error</i> parameter. Once this method has been
* called, no more methods will be invoked on <i>peripheral</i>'s <code>CBPeripheralDelegate</code>.
*
*/
- (void)centralManager:(CBCentralManager *)central didDisconnectPeripheral:(CBPeripheral *)peripheral error:(nullable NSError *)error;
/*!
* @method centralManager:didDisconnectPeripheral:timestamp:isReconnecting:error
*
* @param central The central manager providing this information.
* @param peripheral The <code>CBPeripheral</code> that has disconnected.
* @param timestamp Timestamp of the disconnection, it can be now or a few seconds ago.
* @param isReconnecting If reconnect was triggered upon disconnection.
* @param error If an error occurred, the cause of the failure.
*
* @discussion This method is invoked upon the disconnection of a peripheral that was connected by {@link connectPeripheral:options:}. If perihperal is
* connected with connect option {@link CBConnectPeripheralOptionEnableAutoReconnect}, once this method has been called, the system
* will automatically invoke connect to the peripheral. And if connection is established with the peripheral afterwards,
* {@link centralManager:didConnectPeripheral:} can be invoked. If perihperal is connected without option
* CBConnectPeripheralOptionEnableAutoReconnect, once this method has been called, no more methods will be invoked on
* <i>peripheral</i>'s <code>CBPeripheralDelegate</code> .
*
*/
- (void)centralManager:(CBCentralManager *)central didDisconnectPeripheral:(CBPeripheral *)peripheral timestamp:(CFAbsoluteTime)timestamp isReconnecting:(BOOL)isReconnecting error:(nullable NSError *)error;
/*!
* @method centralManager:connectionEventDidOccur:forPeripheral:
*
* @param central The central manager providing this information.
* @param event The <code>CBConnectionEvent</code> that has occurred.
* @param peripheral The <code>CBPeripheral</code> that caused the event.
*
* @discussion This method is invoked upon the connection or disconnection of a peripheral that matches any of the options provided in {@link registerForConnectionEventsWithOptions:}.
*
*/
- (void)centralManager:(CBCentralManager *)central connectionEventDidOccur:(CBConnectionEvent)event forPeripheral:(CBPeripheral *)peripheral CB_CM_API_AVAILABLE;
/*!
* @method centralManager:didUpdateANCSAuthorizationForPeripheral:
*
* @param central The central manager providing this information.
* @param peripheral The <code>CBPeripheral</code> that caused the event.
*
* @discussion This method is invoked when the authorization status changes for a peripheral connected with {@link connectPeripheral:} option {@link CBConnectPeripheralOptionRequiresANCS}.
*
*/
- (void)centralManager:(CBCentralManager *)central didUpdateANCSAuthorizationForPeripheral:(CBPeripheral *)peripheral NS_AVAILABLE_IOS(13_0);
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,224 @@
/*
* @file CBCentralManagerConstants.h
* @framework CoreBluetooth
*
* @copyright 2013 Apple, Inc. All rights reserved.
*/
#import <CoreBluetooth/CBDefines.h>
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
#define CB_CM_API_AVAILABLE API_AVAILABLE( ios( 13.0 ), tvos( 13.0 ), watchos( 6.0 ) ) API_UNAVAILABLE(macos)
/*!
* @const CBCentralManagerOptionShowPowerAlertKey
*
* @discussion An NSNumber (Boolean) indicating that the system should, if Bluetooth is powered off when <code>CBCentralManager</code> is instantiated, display
* a warning dialog to the user.
*
* @see initWithDelegate:queue:options:
*
*/
CB_EXTERN NSString * const CBCentralManagerOptionShowPowerAlertKey NS_AVAILABLE(10_9, 7_0);
/*!
* @const CBCentralManagerOptionRestoreIdentifierKey
*
* @discussion An NSString containing a unique identifier (UID) for the <code>CBCentralManager</code> that is being instantiated. This UID is used
* by the system to identify a specific <code>CBCentralManager</code> instance for restoration and, therefore, must remain the same for
* subsequent application executions in order for the manager to be restored.
*
* @see initWithDelegate:queue:options:
* @seealso centralManager:willRestoreState:
*
*/
CB_EXTERN NSString * const CBCentralManagerOptionRestoreIdentifierKey NS_AVAILABLE(10_13, 7_0);
/*!
* @const CBCentralManagerOptionDeviceAccessForMedia
*
* @discussion A Boolean representing the CBCentralManager init purpose is for DeviceAccess for media only. This will limit the functionality of this
* manager and only allow media device access without prompting the user for Bluetooth generic TCC.
*
* @see initWithDelegate:queue:options:
*
*/
CB_EXTERN NSString * const CBCentralManagerOptionDeviceAccessForMedia NS_AVAILABLE_IOS(16_0);
/*!
* @const CBCentralManagerScanOptionAllowDuplicatesKey
*
* @discussion An NSNumber (Boolean) indicating that the scan should run without duplicate filtering. By default, multiple discoveries of the
* same peripheral are coalesced into a single discovery event. Specifying this option will cause a discovery event to be generated
* every time the peripheral is seen, which may be many times per second. This can be useful in specific situations, such as making
* a connection based on a peripheral's RSSI, but may have an adverse affect on battery-life and application performance.
*
* @see scanForPeripheralsWithServices:options:
*
*/
CB_EXTERN NSString * const CBCentralManagerScanOptionAllowDuplicatesKey;
/*!
* @const CBCentralManagerScanOptionSolicitedServiceUUIDsKey
*
* @discussion An NSArray of <code>CBUUID</code> objects respresenting service UUIDs. Causes the scan to also look for peripherals soliciting
* any of the services contained in the list.
*
* @see scanForPeripheralsWithServices:options:
*
*/
CB_EXTERN NSString * const CBCentralManagerScanOptionSolicitedServiceUUIDsKey NS_AVAILABLE(10_9, 7_0);
/*!
* @const CBConnectPeripheralOptionNotifyOnConnectionKey
*
* @discussion An NSNumber (Boolean) indicating that the system should display a connection alert for a given peripheral, if the application is suspended
* when a successful connection is made.
* This is useful for applications that have not specified the <code>bluetooth-central</code> background mode and cannot display their
* own alert. If more than one application has requested notification for a given peripheral, the one that was most recently in the foreground
* will receive the alert.
*
* @see connectPeripheral:
*
*/
CB_EXTERN NSString * const CBConnectPeripheralOptionNotifyOnConnectionKey NS_AVAILABLE(10_13, 6_0);
/*!
* @const CBConnectPeripheralOptionNotifyOnDisconnectionKey
*
* @discussion An NSNumber (Boolean) indicating that the system should display a disconnection alert for a given peripheral, if the application
* is suspended at the time of the disconnection.
* This is useful for applications that have not specified the <code>bluetooth-central</code> background mode and cannot display their
* own alert. If more than one application has requested notification for a given peripheral, the one that was most recently in the foreground
* will receive the alert.
*
* @see connectPeripheral:
*
*/
CB_EXTERN NSString * const CBConnectPeripheralOptionNotifyOnDisconnectionKey;
/*!
* @const CBConnectPeripheralOptionNotifyOnNotificationKey
*
* @discussion An NSNumber (Boolean) indicating that the system should display an alert for all notifications received from a given peripheral, if
* the application is suspended at the time.
* This is useful for applications that have not specified the <code>bluetooth-central</code> background mode and cannot display their
* own alert. If more than one application has requested notification for a given peripheral, the one that was most recently in the foreground
* will receive the alert.
*
* @see connectPeripheral:
*
*/
CB_EXTERN NSString * const CBConnectPeripheralOptionNotifyOnNotificationKey NS_AVAILABLE(10_13, 6_0);
/*!
* @const CBConnectPeripheralOptionStartDelayKey
*
* @discussion An NSNumber indicating the number of seconds for the system to wait before starting a connection.
*
* @see connectPeripheral:
*
*/
CB_EXTERN NSString * const CBConnectPeripheralOptionStartDelayKey NS_AVAILABLE(10_13, 6_0);
/*!
* @const CBConnectPeripheralOptionEnableTransportBridgingKey
*
* @discussion An NSNumber (Boolean) indicating that the system will bring up classic transport profiles when low energy transport for peripheral is connected.
*
* @see connectPeripheral:
*
*/
CB_EXTERN NSString * const CBConnectPeripheralOptionEnableTransportBridgingKey NS_AVAILABLE_IOS(13_0);
/*!
* @const CBConnectPeripheralOptionRequiresANCS
*
* @discussion An NSNumber (Boolean) indicating that the ANCS (Apple Notification Center Service) is required for the peripheral is connected.
*
* @see connectPeripheral:
*
*/
CB_EXTERN NSString * const CBConnectPeripheralOptionRequiresANCS NS_AVAILABLE_IOS(13_0);
/*!
* @const CBCentralManagerRestoredStatePeripheralsKey
*
* @discussion An NSArray of <code>CBPeripheral</code> objects containing all peripherals that were connected or pending connection at the time the
* application was terminated by the system. When possible, all known information for each peripheral will be restored, including any discovered
* services, characteristics and descriptors, as well as characteristic notification states.
*
* @see centralManager:willRestoreState:
* @seealso connectPeripheral:options:
*
*/
CB_EXTERN NSString * const CBCentralManagerRestoredStatePeripheralsKey NS_AVAILABLE(10_13, 7_0);
/*!
* @const CBCentralManagerRestoredStateScanServicesKey
*
* @discussion An NSArray of <code>CBUUID</code> objects containing the service(s) being scanned for at the time the application was terminated by the system.
*
* @see centralManager:willRestoreState:
* @seealso scanForPeripheralsWithServices:options:
*
*/
CB_EXTERN NSString * const CBCentralManagerRestoredStateScanServicesKey NS_AVAILABLE(10_13, 7_0);
/*!
* @const CBCentralManagerRestoredStateScanOptionsKey
*
* @discussion An NSDictionary containing the scan options at the time the application was terminated by the system.
*
* @see centralManager:willRestoreState:
* @seealso scanForPeripheralsWithServices:options:
*
*/
CB_EXTERN NSString * const CBCentralManagerRestoredStateScanOptionsKey NS_AVAILABLE(10_13, 7_0);
typedef NSString * CBConnectionEventMatchingOption NS_TYPED_ENUM;
/*!
* @const CBConnectionEventMatchingOptionServiceUUIDs
*
* @discussion An NSArray of <code>CBUUID</code> objects respresenting service UUIDs. A connected peer with any matching service UUIDs will result
* in a call to {@link centralManager:connectionEventDidOccur:}.
* A maximum of 4 services can be registered.
*
* @see centralManager:connectionEventDidOccur:forPeripheral:
* @seealso registerForConnectionEventsWithOptions:
*
*/
CB_EXTERN CBConnectionEventMatchingOption const CBConnectionEventMatchingOptionServiceUUIDs CB_CM_API_AVAILABLE;
/*!
* @const CBConnectionEventMatchingOptionPeripheralUUIDs
*
* @discussion An NSArray of <code>NSUUID</code> objects respresenting <i>peripheral</i> identifiers. A connected peer with any matching identifier(s) will result
* in a call to {@link centralManager:connectionEventDidOccur:}.
*
* @see centralManager:connectionEventDidOccur:forPeripheral:
* @seealso registerForConnectionEventsWithOptions:
*
*/
CB_EXTERN CBConnectionEventMatchingOption const CBConnectionEventMatchingOptionPeripheralUUIDs CB_CM_API_AVAILABLE;
/*!
* @const CBConnectPeripheralOptionEnableAutoReconnect
*
* @discussion An NSNumber (Boolean) indicating that the AutoReconnect is enabled for the peripheral is connected. After peripheral device is connected, this will allow
* the system to initiate connect to the peer device automatically when link is dropped. Caller will get notified about the disconnection with potential delay via
* {@link centralManager:didDisconnectPeripheral:timestamp:isReconnecting:error:}
*
* @see connectPeripheral:
*
*/
CB_EXTERN NSString * const CBConnectPeripheralOptionEnableAutoReconnect NS_AVAILABLE(14_0, 17_0);
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,187 @@
/*
* @file CBCharacteristic.h
* @framework CoreBluetooth
*
* @copyright 2011 Apple, Inc. All rights reserved.
*/
#ifndef _CORE_BLUETOOTH_H_
#warning Please do not import this header file directly. Use <CoreBluetooth/CoreBluetooth.h> instead.
#endif
#import <CoreBluetooth/CBAttribute.h>
NS_ASSUME_NONNULL_BEGIN
/*!
* @enum CBCharacteristicProperties
*
* @discussion Characteristic properties determine how the characteristic value can be used, or how the descriptor(s) can be accessed. Can be combined. Unless
* otherwise specified, properties are valid for local characteristics published via @link CBPeripheralManager @/link.
*
* @constant CBCharacteristicPropertyBroadcast Permits broadcasts of the characteristic value using a characteristic configuration descriptor. Not allowed for local characteristics.
* @constant CBCharacteristicPropertyRead Permits reads of the characteristic value.
* @constant CBCharacteristicPropertyWriteWithoutResponse Permits writes of the characteristic value, without a response.
* @constant CBCharacteristicPropertyWrite Permits writes of the characteristic value.
* @constant CBCharacteristicPropertyNotify Permits notifications of the characteristic value, without a response.
* @constant CBCharacteristicPropertyIndicate Permits indications of the characteristic value.
* @constant CBCharacteristicPropertyAuthenticatedSignedWrites Permits signed writes of the characteristic value
* @constant CBCharacteristicPropertyExtendedProperties If set, additional characteristic properties are defined in the characteristic extended properties descriptor. Not allowed for local characteristics.
* @constant CBCharacteristicPropertyNotifyEncryptionRequired If set, only trusted devices can enable notifications of the characteristic value.
* @constant CBCharacteristicPropertyIndicateEncryptionRequired If set, only trusted devices can enable indications of the characteristic value.
*
*/
typedef NS_OPTIONS(NSUInteger, CBCharacteristicProperties) {
CBCharacteristicPropertyBroadcast = 0x01,
CBCharacteristicPropertyRead = 0x02,
CBCharacteristicPropertyWriteWithoutResponse = 0x04,
CBCharacteristicPropertyWrite = 0x08,
CBCharacteristicPropertyNotify = 0x10,
CBCharacteristicPropertyIndicate = 0x20,
CBCharacteristicPropertyAuthenticatedSignedWrites = 0x40,
CBCharacteristicPropertyExtendedProperties = 0x80,
CBCharacteristicPropertyNotifyEncryptionRequired NS_ENUM_AVAILABLE(10_9, 6_0) = 0x100,
CBCharacteristicPropertyIndicateEncryptionRequired NS_ENUM_AVAILABLE(10_9, 6_0) = 0x200
};
/*!
* @class CBCharacteristic
*
* @discussion
* Represents a service's characteristic.
*
*/
NS_CLASS_AVAILABLE(10_7, 5_0)
CB_EXTERN_CLASS @interface CBCharacteristic : CBAttribute
/*!
* @property service
*
* @discussion
* A back-pointer to the service this characteristic belongs to.
*
*/
@property(weak, readonly, nonatomic) CBService *service;
/*!
* @property properties
*
* @discussion
* The properties of the characteristic.
*
*/
@property(readonly, nonatomic) CBCharacteristicProperties properties;
/*!
* @property value
*
* @discussion
* The value of the characteristic.
*
*/
@property(retain, readonly, nullable) NSData *value;
/*!
* @property descriptors
*
* @discussion
* A list of the CBDescriptors that have so far been discovered in this characteristic.
*
*/
@property(retain, readonly, nullable) NSArray<CBDescriptor *> *descriptors;
/*!
* @property isBroadcasted
*
* @discussion
* Whether the characteristic is currently broadcasted or not.
*
*/
@property(readonly) BOOL isBroadcasted NS_DEPRECATED(10_9, 10_13, 5_0, 8_0);
/*!
* @property isNotifying
*
* @discussion
* Whether the characteristic is currently notifying or not.
*
*/
@property(readonly) BOOL isNotifying;
@end
/*!
* @enum CBAttributePermissions
*
* @discussion Read, write, and encryption permissions for an ATT attribute. Can be combined.
*
* @constant CBAttributePermissionsReadable Read-only.
* @constant CBAttributePermissionsWriteable Write-only.
* @constant CBAttributePermissionsReadEncryptionRequired Readable by trusted devices.
* @constant CBAttributePermissionsWriteEncryptionRequired Writeable by trusted devices.
*
*/
typedef NS_OPTIONS(NSUInteger, CBAttributePermissions) {
CBAttributePermissionsReadable = 0x01,
CBAttributePermissionsWriteable = 0x02,
CBAttributePermissionsReadEncryptionRequired = 0x04,
CBAttributePermissionsWriteEncryptionRequired = 0x08
} NS_ENUM_AVAILABLE(10_9, 6_0);
/*!
* @class CBMutableCharacteristic
*
* @discussion Used to create a local characteristic, which can be added to the local database via <code>CBPeripheralManager</code>. Once a characteristic
* is published, it is cached and can no longer be changed.
* If a characteristic value is specified, it will be cached and marked <code>CBCharacteristicPropertyRead</code> and
* <code>CBAttributePermissionsReadable</code>. If a characteristic value needs to be writeable, or may change during the lifetime of the
* published <code>CBService</code>, it is considered a dynamic value and will be requested on-demand. Dynamic values are identified by a
* <i>value</i> of <i>nil</i>.
*
*/
NS_CLASS_AVAILABLE(10_9, 6_0)
CB_EXTERN_CLASS @interface CBMutableCharacteristic : CBCharacteristic
/*!
* @property permissions
*
* @discussion The permissions of the characteristic value.
*
* @see CBAttributePermissions
*/
@property(assign, readwrite, nonatomic) CBAttributePermissions permissions;
/*!
* @property subscribedCentrals
*
* @discussion For notifying characteristics, the set of currently subscribed centrals.
*/
@property(retain, readonly, nullable) NSArray<CBCentral *> *subscribedCentrals NS_AVAILABLE(10_9, 7_0);
@property(assign, readwrite, nonatomic) CBCharacteristicProperties properties;
@property(retain, readwrite, nullable) NSData *value;
@property(retain, readwrite, nullable) NSArray<CBDescriptor *> *descriptors;
/*!
* @method initWithType:properties:value:permissions
*
* @param UUID The Bluetooth UUID of the characteristic.
* @param properties The properties of the characteristic.
* @param value The characteristic value to be cached. If <i>nil</i>, the value will be dynamic and requested on-demand.
* @param permissions The permissions of the characteristic value.
*
* @discussion Returns an initialized characteristic.
*
*/
- (instancetype)initWithType:(CBUUID *)UUID properties:(CBCharacteristicProperties)properties value:(nullable NSData *)value permissions:(CBAttributePermissions)permissions API_AVAILABLE(ios(6.0), macos(10.9)) API_UNAVAILABLE(watchos, tvos) NS_DESIGNATED_INITIALIZER
#if TARGET_OS_VISION
API_UNAVAILABLE(visionos)
#endif
;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,16 @@
/*
* CBDefines.h
* CoreBluetooth
*
* Copyright 2011 Apple, Inc. All rights reserved.
*/
#ifndef CB_EXTERN
#ifdef __cplusplus
#define CB_EXTERN extern "C" __attribute__((visibility ("default")))
#else
#define CB_EXTERN extern __attribute__((visibility ("default")))
#endif
#endif
#define CB_EXTERN_CLASS __attribute__((visibility("default")))

View File

@ -0,0 +1,78 @@
/*
* @file CBDescriptor.h
* @framework CoreBluetooth
*
* @copyright 2011 Apple, Inc. All rights reserved.
*/
#ifndef _CORE_BLUETOOTH_H_
#warning Please do not import this header file directly. Use <CoreBluetooth/CoreBluetooth.h> instead.
#endif
#import <CoreBluetooth/CBAttribute.h>
NS_ASSUME_NONNULL_BEGIN
/*!
* @class CBDescriptor
*
* @discussion
* Represents a characteristic's descriptor.
*
*/
NS_CLASS_AVAILABLE(10_7, 5_0)
CB_EXTERN_CLASS @interface CBDescriptor : CBAttribute
/*!
* @property characteristic
*
* @discussion
* A back-pointer to the characteristic this descriptor belongs to.
*
*/
@property(weak, readonly, nonatomic) CBCharacteristic *characteristic;
/*!
* @property value
*
* @discussion
* The value of the descriptor. The corresponding value types for the various descriptors are detailed in @link CBUUID.h @/link.
*
*/
@property(retain, readonly, nullable) id value;
@end
/*!
* @class CBMutableDescriptor
*
* @discussion
* Used to create a local characteristic descriptor, which can be added to the local database via <code>CBPeripheralManager</code>.
* Once a descriptor is published, it is cached and can no longer be changed.
* Descriptor types are detailed in @link CBUUID.h @/link, but only the <code>Characteristic User Description</code> and <code>Characteristic Presentation
* Format</code> descriptors are currently supported. The <code>Characteristic Extended Properties</code> and <code>Client Characteristic
* Configuration</code> descriptors will be created automatically upon publication of the parent service, depending on the properties of the characteristic itself.
*/
NS_CLASS_AVAILABLE(10_9, 6_0)
CB_EXTERN_CLASS @interface CBMutableDescriptor : CBDescriptor
/*!
* @method initWithType:value:
*
* @param UUID The Bluetooth UUID of the descriptor.
* @param value The value of the descriptor.
*
* @discussion Returns a decriptor, initialized with a service type and value. The <i>value</i> is required and cannot be updated dynamically
* once the parent service has been published.
*
*/
- (instancetype)initWithType:(CBUUID *)UUID value:(nullable id)value API_AVAILABLE(ios(6.0), macos(10.9)) API_UNAVAILABLE(watchos, tvos) NS_DESIGNATED_INITIALIZER
#if TARGET_OS_VISION
API_UNAVAILABLE(visionos)
#endif
;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,73 @@
/*
* @file CBError.h
* @framework CoreBluetooth
*
* @discussion The possible errors returned during LE transactions.
*
* @copyright 2011 Apple, Inc. All rights reserved.
*/
#ifndef _CORE_BLUETOOTH_H_
#warning Please do not import this header file directly. Use <CoreBluetooth/CoreBluetooth.h> instead.
#endif
#import <CoreBluetooth/CBDefines.h>
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
CB_EXTERN NSString * const CBErrorDomain;
/*!
* @enum CBError
*
* @discussion The possible errors returned during LE transactions.
*/
typedef NS_ENUM(NSInteger, CBError) {
CBErrorUnknown = 0,
CBErrorInvalidParameters NS_ENUM_AVAILABLE(10_9, 6_0) = 1,
CBErrorInvalidHandle NS_ENUM_AVAILABLE(10_9, 6_0) = 2,
CBErrorNotConnected NS_ENUM_AVAILABLE(10_9, 6_0) = 3,
CBErrorOutOfSpace NS_ENUM_AVAILABLE(10_9, 6_0) = 4,
CBErrorOperationCancelled NS_ENUM_AVAILABLE(10_9, 6_0) = 5,
CBErrorConnectionTimeout NS_ENUM_AVAILABLE(10_9, 6_0) = 6,
CBErrorPeripheralDisconnected NS_ENUM_AVAILABLE(10_9, 6_0) = 7,
CBErrorUUIDNotAllowed NS_ENUM_AVAILABLE(10_9, 6_0) = 8,
CBErrorAlreadyAdvertising NS_ENUM_AVAILABLE(10_9, 6_0) = 9,
CBErrorConnectionFailed NS_ENUM_AVAILABLE(10_13, 7_1) = 10,
CBErrorConnectionLimitReached NS_ENUM_AVAILABLE(10_13, 9_0) = 11,
CBErrorUnkownDevice NS_ENUM_DEPRECATED(10_13, 10_15, 9_0, 13_0, "Use CBErrorUnknownDevice instead") = 12,
CBErrorUnknownDevice NS_ENUM_AVAILABLE(10_14, 12_0) = 12,
CBErrorOperationNotSupported NS_ENUM_AVAILABLE(10_14, 12_0) = 13,
CBErrorPeerRemovedPairingInformation NS_ENUM_AVAILABLE(10_15, 13_4) = 14,
CBErrorEncryptionTimedOut NS_ENUM_AVAILABLE(10_15, 13_4) = 15,
CBErrorTooManyLEPairedDevices NS_ENUM_AVAILABLE(11_0, 14_0) = 16,
CBErrorLeGattExceededBackgroundNotificationLimit API_AVAILABLE(watchos(9.0)) API_UNAVAILABLE(macos,ios, tvos) = 17,
CBErrorLeGattNearBackgroundNotificationLimit API_AVAILABLE(watchos(9.0)) API_UNAVAILABLE(macos,ios, tvos) = 18,
};
CB_EXTERN NSString * const CBATTErrorDomain;
typedef NS_ENUM(NSInteger, CBATTError) {
CBATTErrorSuccess NS_ENUM_AVAILABLE(10_9, 6_0) = 0x00,
CBATTErrorInvalidHandle = 0x01,
CBATTErrorReadNotPermitted = 0x02,
CBATTErrorWriteNotPermitted = 0x03,
CBATTErrorInvalidPdu = 0x04,
CBATTErrorInsufficientAuthentication = 0x05,
CBATTErrorRequestNotSupported = 0x06,
CBATTErrorInvalidOffset = 0x07,
CBATTErrorInsufficientAuthorization = 0x08,
CBATTErrorPrepareQueueFull = 0x09,
CBATTErrorAttributeNotFound = 0x0A,
CBATTErrorAttributeNotLong = 0x0B,
CBATTErrorInsufficientEncryptionKeySize = 0x0C,
CBATTErrorInvalidAttributeValueLength = 0x0D,
CBATTErrorUnlikelyError = 0x0E,
CBATTErrorInsufficientEncryption = 0x0F,
CBATTErrorUnsupportedGroupType = 0x10,
CBATTErrorInsufficientResources = 0x11
};
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,50 @@
/*
* @file CBL2CAPChannel.h
* @framework CoreBluetooth
*
* @discussion
*
* @copyright 2017 Apple, Inc. All rights reserved.
*/
#import <CoreBluetooth/CBPeer.h>
#import <Foundation/Foundation.h>
typedef uint16_t CBL2CAPPSM;
/*!
* @class CBL2CAPChannel
*
* @discussion A CBL2CAPChannel represents a live L2CAP connection to a remote device
*/
NS_CLASS_AVAILABLE(10_13, 11_0)
CB_EXTERN_CLASS @interface CBL2CAPChannel : NSObject
/*!
* @property peer
*
* @discussion The peer connected to the channel
*/
@property(readonly, nonatomic) CBPeer *peer;
/*!
* @property inputStream
*
* @discussion An NSStream used for reading data from the remote peer
*/
@property(readonly, nonatomic) NSInputStream *inputStream;
/*!
* @property outputStream
*
* @discussion An NSStream used for writing data to the peer
*/
@property(readonly, nonatomic) NSOutputStream *outputStream;
/*!
* @property PSM
*
* @discussion The PSM (Protocol/Service Multiplexer) of the channel
*/
@property(readonly, nonatomic) CBL2CAPPSM PSM;
@end

View File

@ -0,0 +1,88 @@
/*
* @file CBManager.h
* @framework CoreBluetooth
*
* @discussion Entry point to the central role.
*
* @copyright 2016 Apple, Inc. All rights reserved.
*/
#import <CoreBluetooth/CBDefines.h>
#import <Foundation/Foundation.h>
NS_CLASS_AVAILABLE(10_13, 10_0)
CB_EXTERN_CLASS @interface CBManager : NSObject
- (instancetype)init NS_UNAVAILABLE;
/*!
* @enum CBManagerState
*
* @discussion Represents the current state of a CBManager.
*
* @constant CBManagerStateUnknown State unknown, update imminent.
* @constant CBManagerStateResetting The connection with the system service was momentarily lost, update imminent.
* @constant CBManagerStateUnsupported The platform doesn't support the Bluetooth Low Energy Central/Client role.
* @constant CBManagerStateUnauthorized The application is not authorized to use the Bluetooth Low Energy role.
* @constant CBManagerStatePoweredOff Bluetooth is currently powered off.
* @constant CBManagerStatePoweredOn Bluetooth is currently powered on and available to use.
*
* @seealso authorization
*/
typedef NS_ENUM(NSInteger, CBManagerState) {
CBManagerStateUnknown = 0,
CBManagerStateResetting,
CBManagerStateUnsupported,
CBManagerStateUnauthorized,
CBManagerStatePoweredOff,
CBManagerStatePoweredOn,
} NS_ENUM_AVAILABLE(10_13, 10_0);
/*!
* @property state
*
* @discussion The current state of the manager, initially set to <code>CBManagerStateUnknown</code>.
* Updates are provided by required delegate method {@link managerDidUpdateState:}.
*
*/
@property(nonatomic, assign, readonly) CBManagerState state;
/*!
* @enum CBManagerAuthorization
*
* @discussion Represents the current authorization state of a CBManager.
*
* @constant CBManagerAuthorizationStatusNotDetermined User has not yet made a choice with regards to this application.
* @constant CBManagerAuthorizationStatusRestricted This application is not authorized to use bluetooth. The user cannot change this applications status,
* possibly due to active restrictions such as parental controls being in place.
* @constant CBManagerAuthorizationStatusDenied User has explicitly denied this application from using bluetooth.
* @constant CBManagerAuthorizationStatusAuthorizedAlways User has authorized this application to use bluetooth always.
*
*/
typedef NS_ENUM(NSInteger, CBManagerAuthorization) {
CBManagerAuthorizationNotDetermined = 0,
CBManagerAuthorizationRestricted,
CBManagerAuthorizationDenied,
CBManagerAuthorizationAllowedAlways
} NS_ENUM_AVAILABLE(10_15, 13_0);
/*!
* @property authorization
*
* @discussion The current authorization of the manager, initially set to <code>CBManagerAuthorizationNotDetermined</code>.
* Updates are provided by required delegate method {@link managerDidUpdateState:}.
* @seealso state
*/
@property(nonatomic, assign, readonly) CBManagerAuthorization authorization API_DEPRECATED_WITH_REPLACEMENT("CBManager.authorization", ios(13.0,13.1));
/*!
* @property authorization
*
* @discussion The current authorization of the manager, initially set to <code>CBManagerAuthorizationNotDetermined</code>.
* You can check this in your implementation of required delegate method {@link managerDidUpdateState:}. You can also use it to check authorization status before allocating CBManager.
* @seealso state
*/
@property(class, nonatomic, assign, readonly) CBManagerAuthorization authorization API_AVAILABLE(macos(10.15), ios(13.1), watchos(6.0), tvos(13.0));
@end

View File

@ -0,0 +1,28 @@
/*
* @file CBPeer.h
* @framework CoreBluetooth
*
* @copyright 2014 Apple, Inc. All rights reserved.
*/
#import <CoreBluetooth/CBDefines.h>
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
NS_CLASS_AVAILABLE(10_13, 8_0)
CB_EXTERN_CLASS @interface CBPeer : NSObject <NSCopying>
- (instancetype)init NS_UNAVAILABLE;
/*!
* @property identifier
*
* @discussion The unique, persistent identifier associated with the peer.
*/
@property(readonly, nonatomic) NSUUID *identifier NS_AVAILABLE(10_13, 7_0);
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,447 @@
/*
* @file CBPeripheral.h
* @framework CoreBluetooth
*
* @discussion Representation of a remote peripheral.
*
* @copyright 2011 Apple, Inc. All rights reserved.
*/
#ifndef _CORE_BLUETOOTH_H_
#warning Please do not import this header file directly. Use <CoreBluetooth/CoreBluetooth.h> instead.
#endif
#import <CoreBluetooth/CBDefines.h>
#import <CoreBluetooth/CBPeer.h>
#import <CoreBluetooth/CBL2CAPChannel.h>
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
/*!
* @enum CBPeripheralState
*
* @discussion Represents the current connection state of a CBPeripheral.
*
*/
typedef NS_ENUM(NSInteger, CBPeripheralState) {
CBPeripheralStateDisconnected = 0,
CBPeripheralStateConnecting,
CBPeripheralStateConnected,
CBPeripheralStateDisconnecting NS_AVAILABLE(10_13, 9_0),
} NS_AVAILABLE(10_9, 7_0);
/*!
* @enum CBCharacteristicWriteType
*
* @discussion Specifies which type of write is to be performed on a CBCharacteristic.
*
*/
typedef NS_ENUM(NSInteger, CBCharacteristicWriteType) {
CBCharacteristicWriteWithResponse = 0,
CBCharacteristicWriteWithoutResponse,
};
@protocol CBPeripheralDelegate;
@class CBService, CBCharacteristic, CBDescriptor, CBUUID;
/*!
* @class CBPeripheral
*
* @discussion Represents a peripheral.
*/
NS_CLASS_AVAILABLE(10_7, 5_0)
CB_EXTERN_CLASS @interface CBPeripheral : CBPeer
/*!
* @property delegate
*
* @discussion The delegate object that will receive peripheral events.
*/
@property(weak, nonatomic, nullable) id<CBPeripheralDelegate> delegate;
/*!
* @property name
*
* @discussion The name of the peripheral.
*/
@property(retain, readonly, nullable) NSString *name;
/*!
* @property RSSI
*
* @discussion The most recently read RSSI, in decibels.
*
* @deprecated Use {@link peripheral:didReadRSSI:error:} instead.
*/
@property(retain, readonly, nullable) NSNumber *RSSI NS_DEPRECATED(10_7, 10_13, 5_0, 8_0);
/*!
* @property state
*
* @discussion The current connection state of the peripheral.
*/
@property(readonly) CBPeripheralState state;
/*!
* @property services
*
* @discussion A list of <code>CBService</code> objects that have been discovered on the peripheral.
*/
@property(retain, readonly, nullable) NSArray<CBService *> *services;
/*!
* @property canSendWriteWithoutResponse
*
* @discussion YES if the remote device has space to send a write without response. If this value is NO,
* the value will be set to YES after the current writes have been flushed, and
* <link>peripheralIsReadyToSendWriteWithoutResponse:</link> will be called.
*/
@property(readonly) BOOL canSendWriteWithoutResponse NS_AVAILABLE(10_13, 11_0);
/*!
* @property ancsAuthorized
*
* @discussion YES if the remote device has been authorized to receive data over ANCS (Apple Notification Service Center) protocol. If this value is NO,
* the value will be set to YES after a user authorization occurs and
* <link>didUpdateANCSAuthorizationForPeripheral:</link> will be called.
*/
@property(readonly) BOOL ancsAuthorized NS_AVAILABLE_IOS(13_0);
/*!
* @method readRSSI
*
* @discussion While connected, retrieves the current RSSI of the link.
*
* @see peripheral:didReadRSSI:error:
*/
- (void)readRSSI;
/*!
* @method discoverServices:
*
* @param serviceUUIDs A list of <code>CBUUID</code> objects representing the service types to be discovered. If <i>nil</i>,
* all services will be discovered.
*
* @discussion Discovers available service(s) on the peripheral.
*
* @see peripheral:didDiscoverServices:
*/
- (void)discoverServices:(nullable NSArray<CBUUID *> *)serviceUUIDs;
/*!
* @method discoverIncludedServices:forService:
*
* @param includedServiceUUIDs A list of <code>CBUUID</code> objects representing the included service types to be discovered. If <i>nil</i>,
* all of <i>service</i>s included services will be discovered, which is considerably slower and not recommended.
* @param service A GATT service.
*
* @discussion Discovers the specified included service(s) of <i>service</i>.
*
* @see peripheral:didDiscoverIncludedServicesForService:error:
*/
- (void)discoverIncludedServices:(nullable NSArray<CBUUID *> *)includedServiceUUIDs forService:(CBService *)service;
/*!
* @method discoverCharacteristics:forService:
*
* @param characteristicUUIDs A list of <code>CBUUID</code> objects representing the characteristic types to be discovered. If <i>nil</i>,
* all characteristics of <i>service</i> will be discovered.
* @param service A GATT service.
*
* @discussion Discovers the specified characteristic(s) of <i>service</i>.
*
* @see peripheral:didDiscoverCharacteristicsForService:error:
*/
- (void)discoverCharacteristics:(nullable NSArray<CBUUID *> *)characteristicUUIDs forService:(CBService *)service;
/*!
* @method readValueForCharacteristic:
*
* @param characteristic A GATT characteristic.
*
* @discussion Reads the characteristic value for <i>characteristic</i>.
*
* @see peripheral:didUpdateValueForCharacteristic:error:
*/
- (void)readValueForCharacteristic:(CBCharacteristic *)characteristic;
/*!
* @method maximumWriteValueLengthForType:
*
* @discussion The maximum amount of data, in bytes, that can be sent to a characteristic in a single write type.
*
* @see writeValue:forCharacteristic:type:
*/
- (NSUInteger)maximumWriteValueLengthForType:(CBCharacteristicWriteType)type NS_AVAILABLE(10_12, 9_0);
/*!
* @method writeValue:forCharacteristic:type:
*
* @param data The value to write.
* @param characteristic The characteristic whose characteristic value will be written.
* @param type The type of write to be executed.
*
* @discussion Writes <i>value</i> to <i>characteristic</i>'s characteristic value.
* If the <code>CBCharacteristicWriteWithResponse</code> type is specified, {@link peripheral:didWriteValueForCharacteristic:error:}
* is called with the result of the write request.
* If the <code>CBCharacteristicWriteWithoutResponse</code> type is specified, and canSendWriteWithoutResponse is false, the delivery
* of the data is best-effort and may not be guaranteed.
*
* @see peripheral:didWriteValueForCharacteristic:error:
* @see peripheralIsReadyToSendWriteWithoutResponse:
* @see canSendWriteWithoutResponse
* @see CBCharacteristicWriteType
*/
- (void)writeValue:(NSData *)data forCharacteristic:(CBCharacteristic *)characteristic type:(CBCharacteristicWriteType)type;
/*!
* @method setNotifyValue:forCharacteristic:
*
* @param enabled Whether or not notifications/indications should be enabled.
* @param characteristic The characteristic containing the client characteristic configuration descriptor.
*
* @discussion Enables or disables notifications/indications for the characteristic value of <i>characteristic</i>. If <i>characteristic</i>
* allows both, notifications will be used.
* When notifications/indications are enabled, updates to the characteristic value will be received via delegate method
* @link peripheral:didUpdateValueForCharacteristic:error: @/link. Since it is the peripheral that chooses when to send an update,
* the application should be prepared to handle them as long as notifications/indications remain enabled.
*
* @see peripheral:didUpdateNotificationStateForCharacteristic:error:
* @seealso CBConnectPeripheralOptionNotifyOnNotificationKey
*/
- (void)setNotifyValue:(BOOL)enabled forCharacteristic:(CBCharacteristic *)characteristic;
/*!
* @method discoverDescriptorsForCharacteristic:
*
* @param characteristic A GATT characteristic.
*
* @discussion Discovers the characteristic descriptor(s) of <i>characteristic</i>.
*
* @see peripheral:didDiscoverDescriptorsForCharacteristic:error:
*/
- (void)discoverDescriptorsForCharacteristic:(CBCharacteristic *)characteristic;
/*!
* @method readValueForDescriptor:
*
* @param descriptor A GATT characteristic descriptor.
*
* @discussion Reads the value of <i>descriptor</i>.
*
* @see peripheral:didUpdateValueForDescriptor:error:
*/
- (void)readValueForDescriptor:(CBDescriptor *)descriptor;
/*!
* @method writeValue:forDescriptor:
*
* @param data The value to write.
* @param descriptor A GATT characteristic descriptor.
*
* @discussion Writes <i>data</i> to <i>descriptor</i>'s value. Client characteristic configuration descriptors cannot be written using
* this method, and should instead use @link setNotifyValue:forCharacteristic: @/link.
*
* @see peripheral:didWriteValueForCharacteristic:error:
*/
- (void)writeValue:(NSData *)data forDescriptor:(CBDescriptor *)descriptor;
/*!
* @method openL2CAPChannel:
*
* @param PSM The PSM of the channel to open
*
* @discussion Attempt to open an L2CAP channel to the peripheral using the supplied PSM.
*
* @see peripheral:didWriteValueForCharacteristic:error:
*/
- (void)openL2CAPChannel:(CBL2CAPPSM)PSM NS_AVAILABLE(10_14, 11_0);
@end
/*!
* @protocol CBPeripheralDelegate
*
* @discussion Delegate for CBPeripheral.
*
*/
@protocol CBPeripheralDelegate <NSObject>
@optional
/*!
* @method peripheralDidUpdateName:
*
* @param peripheral The peripheral providing this update.
*
* @discussion This method is invoked when the @link name @/link of <i>peripheral</i> changes.
*/
- (void)peripheralDidUpdateName:(CBPeripheral *)peripheral NS_AVAILABLE(10_9, 6_0);
/*!
* @method peripheral:didModifyServices:
*
* @param peripheral The peripheral providing this update.
* @param invalidatedServices The services that have been invalidated
*
* @discussion This method is invoked when the @link services @/link of <i>peripheral</i> have been changed.
* At this point, the designated <code>CBService</code> objects have been invalidated.
* Services can be re-discovered via @link discoverServices: @/link.
*/
- (void)peripheral:(CBPeripheral *)peripheral didModifyServices:(NSArray<CBService *> *)invalidatedServices NS_AVAILABLE(10_9, 7_0);
/*!
* @method peripheralDidUpdateRSSI:error:
*
* @param peripheral The peripheral providing this update.
* @param error If an error occurred, the cause of the failure.
*
* @discussion This method returns the result of a @link readRSSI: @/link call.
*
* @deprecated Use {@link peripheral:didReadRSSI:error:} instead.
*/
- (void)peripheralDidUpdateRSSI:(CBPeripheral *)peripheral error:(nullable NSError *)error NS_DEPRECATED(10_7, 10_13, 5_0, 8_0);
/*!
* @method peripheral:didReadRSSI:error:
*
* @param peripheral The peripheral providing this update.
* @param RSSI The current RSSI of the link.
* @param error If an error occurred, the cause of the failure.
*
* @discussion This method returns the result of a @link readRSSI: @/link call.
*/
- (void)peripheral:(CBPeripheral *)peripheral didReadRSSI:(NSNumber *)RSSI error:(nullable NSError *)error NS_AVAILABLE(10_13, 8_0);
/*!
* @method peripheral:didDiscoverServices:
*
* @param peripheral The peripheral providing this information.
* @param error If an error occurred, the cause of the failure.
*
* @discussion This method returns the result of a @link discoverServices: @/link call. If the service(s) were read successfully, they can be retrieved via
* <i>peripheral</i>'s @link services @/link property.
*
*/
- (void)peripheral:(CBPeripheral *)peripheral didDiscoverServices:(nullable NSError *)error;
/*!
* @method peripheral:didDiscoverIncludedServicesForService:error:
*
* @param peripheral The peripheral providing this information.
* @param service The <code>CBService</code> object containing the included services.
* @param error If an error occurred, the cause of the failure.
*
* @discussion This method returns the result of a @link discoverIncludedServices:forService: @/link call. If the included service(s) were read successfully,
* they can be retrieved via <i>service</i>'s <code>includedServices</code> property.
*/
- (void)peripheral:(CBPeripheral *)peripheral didDiscoverIncludedServicesForService:(CBService *)service error:(nullable NSError *)error;
/*!
* @method peripheral:didDiscoverCharacteristicsForService:error:
*
* @param peripheral The peripheral providing this information.
* @param service The <code>CBService</code> object containing the characteristic(s).
* @param error If an error occurred, the cause of the failure.
*
* @discussion This method returns the result of a @link discoverCharacteristics:forService: @/link call. If the characteristic(s) were read successfully,
* they can be retrieved via <i>service</i>'s <code>characteristics</code> property.
*/
- (void)peripheral:(CBPeripheral *)peripheral didDiscoverCharacteristicsForService:(CBService *)service error:(nullable NSError *)error;
/*!
* @method peripheral:didUpdateValueForCharacteristic:error:
*
* @param peripheral The peripheral providing this information.
* @param characteristic A <code>CBCharacteristic</code> object.
* @param error If an error occurred, the cause of the failure.
*
* @discussion This method is invoked after a @link readValueForCharacteristic: @/link call, or upon receipt of a notification/indication.
*/
- (void)peripheral:(CBPeripheral *)peripheral didUpdateValueForCharacteristic:(CBCharacteristic *)characteristic error:(nullable NSError *)error;
/*!
* @method peripheral:didWriteValueForCharacteristic:error:
*
* @param peripheral The peripheral providing this information.
* @param characteristic A <code>CBCharacteristic</code> object.
* @param error If an error occurred, the cause of the failure.
*
* @discussion This method returns the result of a {@link writeValue:forCharacteristic:type:} call, when the <code>CBCharacteristicWriteWithResponse</code> type is used.
*/
- (void)peripheral:(CBPeripheral *)peripheral didWriteValueForCharacteristic:(CBCharacteristic *)characteristic error:(nullable NSError *)error;
/*!
* @method peripheral:didUpdateNotificationStateForCharacteristic:error:
*
* @param peripheral The peripheral providing this information.
* @param characteristic A <code>CBCharacteristic</code> object.
* @param error If an error occurred, the cause of the failure.
*
* @discussion This method returns the result of a @link setNotifyValue:forCharacteristic: @/link call.
*/
- (void)peripheral:(CBPeripheral *)peripheral didUpdateNotificationStateForCharacteristic:(CBCharacteristic *)characteristic error:(nullable NSError *)error;
/*!
* @method peripheral:didDiscoverDescriptorsForCharacteristic:error:
*
* @param peripheral The peripheral providing this information.
* @param characteristic A <code>CBCharacteristic</code> object.
* @param error If an error occurred, the cause of the failure.
*
* @discussion This method returns the result of a @link discoverDescriptorsForCharacteristic: @/link call. If the descriptors were read successfully,
* they can be retrieved via <i>characteristic</i>'s <code>descriptors</code> property.
*/
- (void)peripheral:(CBPeripheral *)peripheral didDiscoverDescriptorsForCharacteristic:(CBCharacteristic *)characteristic error:(nullable NSError *)error;
/*!
* @method peripheral:didUpdateValueForDescriptor:error:
*
* @param peripheral The peripheral providing this information.
* @param descriptor A <code>CBDescriptor</code> object.
* @param error If an error occurred, the cause of the failure.
*
* @discussion This method returns the result of a @link readValueForDescriptor: @/link call.
*/
- (void)peripheral:(CBPeripheral *)peripheral didUpdateValueForDescriptor:(CBDescriptor *)descriptor error:(nullable NSError *)error;
/*!
* @method peripheral:didWriteValueForDescriptor:error:
*
* @param peripheral The peripheral providing this information.
* @param descriptor A <code>CBDescriptor</code> object.
* @param error If an error occurred, the cause of the failure.
*
* @discussion This method returns the result of a @link writeValue:forDescriptor: @/link call.
*/
- (void)peripheral:(CBPeripheral *)peripheral didWriteValueForDescriptor:(CBDescriptor *)descriptor error:(nullable NSError *)error;
/*!
* @method peripheralIsReadyToSendWriteWithoutResponse:
*
* @param peripheral The peripheral providing this update.
*
* @discussion This method is invoked after a failed call to @link writeValue:forCharacteristic:type: @/link, when <i>peripheral</i> is again
* ready to send characteristic value updates.
*
*/
- (void)peripheralIsReadyToSendWriteWithoutResponse:(CBPeripheral *)peripheral;
/*!
* @method peripheral:didOpenL2CAPChannel:error:
*
* @param peripheral The peripheral providing this information.
* @param channel A <code>CBL2CAPChannel</code> object.
* @param error If an error occurred, the cause of the failure.
*
* @discussion This method returns the result of a @link openL2CAPChannel: @link call.
*/
- (void)peripheral:(CBPeripheral *)peripheral didOpenL2CAPChannel:(nullable CBL2CAPChannel *)channel error:(nullable NSError *)error;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,489 @@
/*
* @file CBPeripheralManager.h
* @framework CoreBluetooth
*
* @discussion Entry point to the peripheral role.
*
* @copyright 2012 Apple, Inc. All rights reserved.
*/
#ifndef _CORE_BLUETOOTH_H_
#warning Please do not import this header file directly. Use <CoreBluetooth/CoreBluetooth.h> instead.
#endif
#import <Foundation/Foundation.h>
#import <CoreBluetooth/CBDefines.h>
#import <CoreBluetooth/CBError.h>
#import <CoreBluetooth/CBManager.h>
#import <CoreBluetooth/CBL2CAPChannel.h>
#import <CoreBluetooth/CBPeripheralManagerConstants.h>
NS_ASSUME_NONNULL_BEGIN
/*!
* @enum CBPeripheralManagerAuthorizationStatus
*
* @discussion Represents the current state of a CBPeripheralManager.
*
* @constant CBPeripheralManagerAuthorizationStatusNotDetermined User has not yet made a choice with regards to this application.
* @constant CBPeripheralManagerAuthorizationStatusRestricted This application is not authorized to share data while backgrounded. The user cannot change this applications status, possibly due to active restrictions such as parental controls being in place.
* @constant CBPeripheralManagerAuthorizationStatusDenied User has explicitly denied this application from sharing data while backgrounded.
* @constant CBPeripheralManagerAuthorizationStatusAuthorized User has authorized this application to share data while backgrounded.
*
*/
typedef NS_ENUM(NSInteger, CBPeripheralManagerAuthorizationStatus) {
CBPeripheralManagerAuthorizationStatusNotDetermined = 0,
CBPeripheralManagerAuthorizationStatusRestricted,
CBPeripheralManagerAuthorizationStatusDenied,
CBPeripheralManagerAuthorizationStatusAuthorized,
} NS_DEPRECATED(10_9, 10_15, 7_0, 13_0, "Use CBManagerAuthorization instead");
/*!
* @enum CBPeripheralManagerState
*
* @discussion Represents the current state of a CBPeripheralManager.
*
* @constant CBPeripheralManagerStateUnknown State unknown, update imminent.
* @constant CBPeripheralManagerStateResetting The connection with the system service was momentarily lost, update imminent.
* @constant CBPeripheralManagerStateUnsupported The platform doesn't support the Bluetooth Low Energy Peripheral/Server role.
* @constant CBPeripheralManagerStateUnauthorized The application is not authorized to use the Bluetooth Low Energy Peripheral/Server role.
* @constant CBPeripheralManagerStatePoweredOff Bluetooth is currently powered off.
* @constant CBPeripheralManagerStatePoweredOn Bluetooth is currently powered on and available to use.
*
*/
typedef NS_ENUM(NSInteger, CBPeripheralManagerState) {
CBPeripheralManagerStateUnknown = CBManagerStateUnknown,
CBPeripheralManagerStateResetting = CBManagerStateResetting,
CBPeripheralManagerStateUnsupported = CBManagerStateUnsupported,
CBPeripheralManagerStateUnauthorized = CBManagerStateUnauthorized,
CBPeripheralManagerStatePoweredOff = CBManagerStatePoweredOff,
CBPeripheralManagerStatePoweredOn = CBManagerStatePoweredOn,
} NS_DEPRECATED(10_9, 10_13, 6_0, 10_0, "Use CBManagerState instead");
/*!
* @enum CBPeripheralManagerConnectionLatency
*
* @discussion The latency of a peripheral-central connection controls how frequently messages can be exchanged.
*
* @constant CBPeripheralManagerConnectionLatencyLow Prioritizes rapid communication over battery life.
* @constant CBPeripheralManagerConnectionLatencyMedium A balance between communication frequency and battery life.
* @constant CBPeripheralManagerConnectionLatencyHigh Prioritizes extending battery life over rapid communication.
*
*/
typedef NS_ENUM(NSInteger, CBPeripheralManagerConnectionLatency) {
CBPeripheralManagerConnectionLatencyLow = 0,
CBPeripheralManagerConnectionLatencyMedium,
CBPeripheralManagerConnectionLatencyHigh
} NS_ENUM_AVAILABLE(10_9, 6_0);
@class CBCentral, CBService, CBMutableService, CBCharacteristic, CBMutableCharacteristic, CBATTRequest;
@protocol CBPeripheralManagerDelegate;
/*!
* @class CBPeripheralManager
*
* @discussion The <code>CBPeripheralManager</code> class is an abstraction of the Peripheral and Broadcaster GAP roles, and the GATT Server
* role. Its primary function is to allow you to manage published services within the GATT database, and to advertise these services
* to other devices.
* Each application has sandboxed access to the shared GATT database. You can add services to the database by calling {@link addService:};
* they can be removed via {@link removeService:} and {@link removeAllServices}, as appropriate. While a service is in the database,
* it is visible to and can be accessed by any connected GATT Client. However, applications that have not specified the "bluetooth-peripheral"
* background mode will have the contents of their service(s) "disabled" when in the background. Any remote device trying to access
* characteristic values or descriptors during this time will receive an error response.
* Once you've published services that you want to share, you can ask to advertise their availability and allow other devices to connect
* to you by calling {@link startAdvertising:}. Like the GATT database, advertisement is managed at the system level and shared by all
* applications. This means that even if you aren't advertising at the moment, someone else might be!
*
*/
NS_CLASS_AVAILABLE(10_9, 6_0)
CB_EXTERN_CLASS @interface CBPeripheralManager : CBManager
/*!
* @property delegate
*
* @discussion The delegate object that will receive peripheral events.
*
*/
@property(nonatomic, weak, nullable) id<CBPeripheralManagerDelegate> delegate;
/*!
* @property isAdvertising
*
* @discussion Whether or not the peripheral is currently advertising data.
*
*/
@property(nonatomic, assign, readonly) BOOL isAdvertising;
/*!
* @method authorizationStatus
*
* @discussion This method does not prompt the user for access. You can use it to detect restricted access and simply hide UI instead of
* prompting for access.
*
* @return The current authorization status for sharing data while backgrounded. For the constants returned, see {@link CBPeripheralManagerAuthorizationStatus}.
*
* @see CBPeripheralManagerAuthorizationStatus
*/
+ (CBPeripheralManagerAuthorizationStatus)authorizationStatus NS_DEPRECATED(10_9, 10_15, 7_0, 13_0, "Use CBManagerAuthorization instead");
- (instancetype)init;
/*!
* @method initWithDelegate:queue:
*
* @param delegate The delegate that will receive peripheral role events.
* @param queue The dispatch queue on which the events will be dispatched.
*
* @discussion The initialization call. The events of the peripheral role will be dispatched on the provided queue.
* If <i>nil</i>, the main queue will be used.
*
*/
- (instancetype)initWithDelegate:(nullable id<CBPeripheralManagerDelegate>)delegate
queue:(nullable dispatch_queue_t)queue API_AVAILABLE(ios(6.0), macos(10.9)) API_UNAVAILABLE(watchos, tvos)
#if TARGET_OS_VISION
API_UNAVAILABLE(visionos)
#endif
;
/*!
* @method initWithDelegate:queue:options:
*
* @param delegate The delegate that will receive peripheral role events.
* @param queue The dispatch queue on which the events will be dispatched.
* @param options An optional dictionary specifying options for the manager.
*
* @discussion The initialization call. The events of the peripheral role will be dispatched on the provided queue.
* If <i>nil</i>, the main queue will be used.
*
* @seealso CBPeripheralManagerOptionShowPowerAlertKey
* @seealso CBPeripheralManagerOptionRestoreIdentifierKey
*
*/
- (instancetype)initWithDelegate:(nullable id<CBPeripheralManagerDelegate>)delegate
queue:(nullable dispatch_queue_t)queue
options:(nullable NSDictionary<NSString *, id> *)options API_AVAILABLE(ios(7.0), macos(10.9)) API_UNAVAILABLE(watchos, tvos) NS_DESIGNATED_INITIALIZER
#if TARGET_OS_VISION
API_UNAVAILABLE(visionos)
#endif
;
/*!
* @method startAdvertising:
*
* @param advertisementData An optional dictionary containing the data to be advertised.
*
* @discussion Starts advertising. Supported advertising data types are <code>CBAdvertisementDataLocalNameKey</code>
* and <code>CBAdvertisementDataServiceUUIDsKey</code>.
* When in the foreground, an application can utilize up to 28 bytes of space in the initial advertisement data for
* any combination of the supported advertising data types. If this space is used up, there are an additional 10 bytes of
* space in the scan response that can be used only for the local name. Note that these sizes do not include the 2 bytes
* of header information that are required for each new data type. Any service UUIDs that do not fit in the allotted space
* will be added to a special "overflow" area, and can only be discovered by an iOS device that is explicitly scanning
* for them.
* While an application is in the background, the local name will not be used and all service UUIDs will be placed in the
* "overflow" area. However, applications that have not specified the "bluetooth-peripheral" background mode will not be able
* to advertise anything while in the background.
*
* @see peripheralManagerDidStartAdvertising:error:
* @seealso CBAdvertisementData.h
*
*/
- (void)startAdvertising:(nullable NSDictionary<NSString *, id> *)advertisementData;
/*!
* @method stopAdvertising
*
* @discussion Stops advertising.
*
*/
- (void)stopAdvertising;
/*!
* @method setDesiredConnectionLatency:forCentral:
*
* @param latency The desired connection latency.
* @param central A connected central.
*
* @discussion Sets the desired connection latency for an existing connection to <i>central</i>. Connection latency changes are not guaranteed, so the
* resultant latency may vary. If a desired latency is not set, the latency chosen by <i>central</i> at the time of connection establishment
* will be used. Typically, it is not necessary to change the latency.
*
* @see CBPeripheralManagerConnectionLatency
*
*/
- (void)setDesiredConnectionLatency:(CBPeripheralManagerConnectionLatency)latency forCentral:(CBCentral *)central;
/*!
* @method addService:
*
* @param service A GATT service.
*
* @discussion Publishes a service and its associated characteristic(s) to the local database. If the service contains included services,
* they must be published first.
*
* @see peripheralManager:didAddService:error:
*/
- (void)addService:(CBMutableService *)service;
/*!
* @method removeService:
*
* @param service A GATT service.
*
* @discussion Removes a published service from the local database. If the service is included by other service(s), they must be removed
* first.
*
*/
- (void)removeService:(CBMutableService *)service;
/*!
* @method removeAllServices
*
* @discussion Removes all published services from the local database.
*
*/
- (void)removeAllServices;
/*!
* @method respondToRequest:withResult:
*
* @param request The original request that was received from the central.
* @param result The result of attempting to fulfill <i>request</i>.
*
* @discussion Used to respond to request(s) received via the @link peripheralManager:didReceiveReadRequest: @/link or
* @link peripheralManager:didReceiveWriteRequests: @/link delegate methods.
*
* @see peripheralManager:didReceiveReadRequest:
* @see peripheralManager:didReceiveWriteRequests:
*/
- (void)respondToRequest:(CBATTRequest *)request withResult:(CBATTError)result;
/*!
* @method updateValue:forCharacteristic:onSubscribedCentrals:
*
* @param value The value to be sent via a notification/indication.
* @param characteristic The characteristic whose value has changed.
* @param centrals A list of <code>CBCentral</code> objects to receive the update. Note that centrals which have not subscribed to
* <i>characteristic</i> will be ignored. If <i>nil</i>, all centrals that are subscribed to <i>characteristic</i> will be updated.
*
* @discussion Sends an updated characteristic value to one or more centrals, via a notification or indication. If <i>value</i> exceeds
* {@link maximumUpdateValueLength}, it will be truncated to fit.
*
* @return <i>YES</i> if the update could be sent, or <i>NO</i> if the underlying transmit queue is full. If <i>NO</i> was returned,
* the delegate method @link peripheralManagerIsReadyToUpdateSubscribers: @/link will be called once space has become
* available, and the update should be re-sent if so desired.
*
* @see peripheralManager:central:didSubscribeToCharacteristic:
* @see peripheralManager:central:didUnsubscribeFromCharacteristic:
* @see peripheralManagerIsReadyToUpdateSubscribers:
* @seealso maximumUpdateValueLength
*/
- (BOOL)updateValue:(NSData *)value forCharacteristic:(CBMutableCharacteristic *)characteristic onSubscribedCentrals:(nullable NSArray<CBCentral *> *)centrals;
/*!
* @method publishL2CAPChannelWithEncryption:
*
* @param encryptionRequired YES if the service requires the link to be encrypted before a stream can be established. NO if the service can be used over
* an unsecured link.
*
* @discussion Create a listener for incoming L2CAP Channel connections. The system will determine an unused PSM at the time of publishing, which will be returned
* with @link peripheralManager:didPublishL2CAPChannel:error: @/link. L2CAP Channels are not discoverable by themselves, so it is the application's
* responsibility to handle PSM discovery on the client.
*
*/
- (void)publishL2CAPChannelWithEncryption:(BOOL)encryptionRequired NS_AVAILABLE(10_14, 11_0);
/*!
* @method unpublishL2CAPChannel:
*
* @param PSM The service PSM to be removed from the system.
*
* @discussion Removes a published service from the local system. No new connections for this PSM will be accepted, and any existing L2CAP channels
* using this PSM will be closed.
*
*/
- (void)unpublishL2CAPChannel:(CBL2CAPPSM)PSM NS_AVAILABLE(10_14, 11_0);
@end
/*!
* @protocol CBPeripheralManagerDelegate
*
* @discussion The delegate of a @link CBPeripheralManager @/link object must adopt the <code>CBPeripheralManagerDelegate</code> protocol. The
* single required method indicates the availability of the peripheral manager, while the optional methods provide information about
* centrals, which can connect and access the local database.
*
*/
@protocol CBPeripheralManagerDelegate <NSObject>
@required
/*!
* @method peripheralManagerDidUpdateState:
*
* @param peripheral The peripheral manager whose state has changed.
*
* @discussion Invoked whenever the peripheral manager's state has been updated. Commands should only be issued when the state is
* <code>CBPeripheralManagerStatePoweredOn</code>. A state below <code>CBPeripheralManagerStatePoweredOn</code>
* implies that advertisement has paused and any connected centrals have been disconnected. If the state moves below
* <code>CBPeripheralManagerStatePoweredOff</code>, advertisement is stopped and must be explicitly restarted, and the
* local database is cleared and all services must be re-added.
*
* @see state
*
*/
- (void)peripheralManagerDidUpdateState:(CBPeripheralManager *)peripheral;
@optional
/*!
* @method peripheralManager:willRestoreState:
*
* @param peripheral The peripheral manager providing this information.
* @param dict A dictionary containing information about <i>peripheral</i> that was preserved by the system at the time the app was terminated.
*
* @discussion For apps that opt-in to state preservation and restoration, this is the first method invoked when your app is relaunched into
* the background to complete some Bluetooth-related task. Use this method to synchronize your app's state with the state of the
* Bluetooth system.
*
* @seealso CBPeripheralManagerRestoredStateServicesKey;
* @seealso CBPeripheralManagerRestoredStateAdvertisementDataKey;
*
*/
- (void)peripheralManager:(CBPeripheralManager *)peripheral willRestoreState:(NSDictionary<NSString *, id> *)dict;
/*!
* @method peripheralManagerDidStartAdvertising:error:
*
* @param peripheral The peripheral manager providing this information.
* @param error If an error occurred, the cause of the failure.
*
* @discussion This method returns the result of a @link startAdvertising: @/link call. If advertisement could
* not be started, the cause will be detailed in the <i>error</i> parameter.
*
*/
- (void)peripheralManagerDidStartAdvertising:(CBPeripheralManager *)peripheral error:(nullable NSError *)error;
/*!
* @method peripheralManager:didAddService:error:
*
* @param peripheral The peripheral manager providing this information.
* @param service The service that was added to the local database.
* @param error If an error occurred, the cause of the failure.
*
* @discussion This method returns the result of an @link addService: @/link call. If the service could
* not be published to the local database, the cause will be detailed in the <i>error</i> parameter.
*
*/
- (void)peripheralManager:(CBPeripheralManager *)peripheral didAddService:(CBService *)service error:(nullable NSError *)error;
/*!
* @method peripheralManager:central:didSubscribeToCharacteristic:
*
* @param peripheral The peripheral manager providing this update.
* @param central The central that issued the command.
* @param characteristic The characteristic on which notifications or indications were enabled.
*
* @discussion This method is invoked when a central configures <i>characteristic</i> to notify or indicate.
* It should be used as a cue to start sending updates as the characteristic value changes.
*
*/
- (void)peripheralManager:(CBPeripheralManager *)peripheral central:(CBCentral *)central didSubscribeToCharacteristic:(CBCharacteristic *)characteristic;
/*!
* @method peripheralManager:central:didUnsubscribeFromCharacteristic:
*
* @param peripheral The peripheral manager providing this update.
* @param central The central that issued the command.
* @param characteristic The characteristic on which notifications or indications were disabled.
*
* @discussion This method is invoked when a central removes notifications/indications from <i>characteristic</i>.
*
*/
- (void)peripheralManager:(CBPeripheralManager *)peripheral central:(CBCentral *)central didUnsubscribeFromCharacteristic:(CBCharacteristic *)characteristic;
/*!
* @method peripheralManager:didReceiveReadRequest:
*
* @param peripheral The peripheral manager requesting this information.
* @param request A <code>CBATTRequest</code> object.
*
* @discussion This method is invoked when <i>peripheral</i> receives an ATT request for a characteristic with a dynamic value.
* For every invocation of this method, @link respondToRequest:withResult: @/link must be called.
*
* @see CBATTRequest
*
*/
- (void)peripheralManager:(CBPeripheralManager *)peripheral didReceiveReadRequest:(CBATTRequest *)request;
/*!
* @method peripheralManager:didReceiveWriteRequests:
*
* @param peripheral The peripheral manager requesting this information.
* @param requests A list of one or more <code>CBATTRequest</code> objects.
*
* @discussion This method is invoked when <i>peripheral</i> receives an ATT request or command for one or more characteristics with a dynamic value.
* For every invocation of this method, @link respondToRequest:withResult: @/link should be called exactly once. If <i>requests</i> contains
* multiple requests, they must be treated as an atomic unit. If the execution of one of the requests would cause a failure, the request
* and error reason should be provided to <code>respondToRequest:withResult:</code> and none of the requests should be executed.
*
* @see CBATTRequest
*
*/
- (void)peripheralManager:(CBPeripheralManager *)peripheral didReceiveWriteRequests:(NSArray<CBATTRequest *> *)requests;
/*!
* @method peripheralManagerIsReadyToUpdateSubscribers:
*
* @param peripheral The peripheral manager providing this update.
*
* @discussion This method is invoked after a failed call to @link updateValue:forCharacteristic:onSubscribedCentrals: @/link, when <i>peripheral</i> is again
* ready to send characteristic value updates.
*
*/
- (void)peripheralManagerIsReadyToUpdateSubscribers:(CBPeripheralManager *)peripheral;
/*!
* @method peripheralManager:didPublishL2CAPChannel:error:
*
* @param peripheral The peripheral manager requesting this information.
* @param PSM The PSM of the channel that was published.
* @param error If an error occurred, the cause of the failure.
*
* @discussion This method is the response to a @link publishL2CAPChannel: @/link call. The PSM will contain the PSM that was assigned for the published
* channel
*
*/
- (void)peripheralManager:(CBPeripheralManager *)peripheral didPublishL2CAPChannel:(CBL2CAPPSM)PSM error:(nullable NSError *)error;
/*!
* @method peripheralManager:didUnublishL2CAPChannel:error:
*
* @param peripheral The peripheral manager requesting this information.
* @param PSM The PSM of the channel that was published.
* @param error If an error occurred, the cause of the failure.
*
* @discussion This method is the response to a @link unpublishL2CAPChannel: @/link call.
*
*/
- (void)peripheralManager:(CBPeripheralManager *)peripheral didUnpublishL2CAPChannel:(CBL2CAPPSM)PSM error:(nullable NSError *)error;
/*!
* @method peripheralManager:didOpenL2CAPChannel:error:
*
* @param peripheral The peripheral manager requesting this information.
* @param channel A <code>CBL2CAPChannel</code> object.
* @param error If an error occurred, the cause of the failure.
*
* @discussion This method returns the result of establishing an incoming L2CAP channel , following publishing a channel using @link publishL2CAPChannel: @link call.
*
*/
- (void)peripheralManager:(CBPeripheralManager *)peripheral didOpenL2CAPChannel:(nullable CBL2CAPChannel *)channel error:(nullable NSError *)error;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,63 @@
/*
* @file CBPeripheralManagerConstants.h
* @framework CoreBluetooth
*
* @copyright 2013 Apple, Inc. All rights reserved.
*/
#import <CoreBluetooth/CBDefines.h>
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
#define CB_PM_API_AVAILABLE API_AVAILABLE( ios( 13.0 ), tvos( 13.0 ), watchos( 6.0 ) ) API_UNAVAILABLE(macos)
/*!
* @const CBPeripheralManagerOptionShowPowerAlertKey
*
* @discussion An NSNumber (Boolean) indicating that the system should, if Bluetooth is powered off when <code>CBPeripheralManager</code> is instantiated, display
* a warning dialog to the user.
*
* @see initWithDelegate:queue:options:
*
*/
CB_EXTERN NSString * const CBPeripheralManagerOptionShowPowerAlertKey NS_AVAILABLE(10_9, 7_0);
/*!
* @const CBPeripheralManagerOptionRestoreIdentifierKey
*
* @discussion An NSString containing a unique identifier (UID) for the <code>CBPeripheralManager</code> that is being instantiated. This UID is used
* by the system to identify a specific <code>CBPeripheralManager</code> instance for restoration and, therefore, must remain the same for
* subsequent application executions in order for the manager to be restored.
*
* @see initWithDelegate:queue:options:
* @seealso centralManager:willRestoreState:
*
*/
CB_EXTERN NSString * const CBPeripheralManagerOptionRestoreIdentifierKey NS_AVAILABLE(10_9, 7_0);
/*!
* @const CBPeripheralManagerRestoredStateServicesKey
*
* @discussion An NSArray of <code>CBMutableService</code> objects containing all services that were published to the local database at the time the
* application was terminated by the system. All information for each service will be restored, including all discovered
* services, characteristics and descriptors, as well as characteristic notification states.
*
* @see peripheralManager:willRestoreState:
* @seealso addService:
*
*/
CB_EXTERN NSString * const CBPeripheralManagerRestoredStateServicesKey NS_AVAILABLE(10_9, 7_0);
/*!
* @const CBPeripheralManagerRestoredStateAdvertisementDataKey
*
* @discussion An NSDictionary containing the data being advertised at the time the application was terminated by the system.
*
* @see peripheralManager:willRestoreState:
* @seealso startAdvertising:
*
*/
CB_EXTERN NSString * const CBPeripheralManagerRestoredStateAdvertisementDataKey NS_AVAILABLE(10_9, 7_0);
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,100 @@
/*
* @file CBService.h
* @framework CoreBluetooth
*
* @discussion A Bluetooth LE service representation. A LE Service provides a number of
* characteristics and may also reference other services.
*
* @copyright 2011 Apple, Inc. All rights reserved.
*/
#ifndef _CORE_BLUETOOTH_H_
#warning Please do not import this header file directly. Use <CoreBluetooth/CoreBluetooth.h> instead.
#endif
#import <CoreBluetooth/CBAttribute.h>
NS_ASSUME_NONNULL_BEGIN
/*!
* @class CBService
*
* @discussion
* Represents a peripheral's service or a service's included service.
*
*/
NS_CLASS_AVAILABLE(10_7, 5_0)
CB_EXTERN_CLASS @interface CBService : CBAttribute
/*!
* @property peripheral
*
* @discussion
* A back-pointer to the peripheral this service belongs to.
*
*/
@property(weak, readonly, nonatomic) CBPeripheral *peripheral;
/*!
* @property isPrimary
*
* @discussion
* The type of the service (primary or secondary).
*
*/
@property(readonly, nonatomic) BOOL isPrimary;
/*!
* @property includedServices
*
* @discussion
* A list of included CBServices that have so far been discovered in this service.
*
*/
@property(retain, readonly, nullable) NSArray<CBService *> *includedServices;
/*!
* @property characteristics
*
* @discussion
* A list of CBCharacteristics that have so far been discovered in this service.
*
*/
@property(retain, readonly, nullable) NSArray<CBCharacteristic *> *characteristics;
@end
/*!
* @class CBMutableService
*
* @discussion
* Used to create a local service or included service, which can be added to the local database via <code>CBPeripheralManager</code>.
* Once a service is published, it is cached and can no longer be changed. This class adds write access to all properties in the
* @link CBService @/link class.
*
*/
NS_CLASS_AVAILABLE(10_9, 6_0)
CB_EXTERN_CLASS @interface CBMutableService : CBService
@property(retain, readwrite, nullable) NSArray<CBService *> *includedServices;
@property(retain, readwrite, nullable) NSArray<CBCharacteristic *> *characteristics;
/*!
* @method initWithType:primary:
*
* @param UUID The Bluetooth UUID of the service.
* @param isPrimary The type of the service (primary or secondary).
*
* @discussion Returns a service, initialized with a service type and UUID.
*
*/
- (instancetype)initWithType:(CBUUID *)UUID primary:(BOOL)isPrimary API_AVAILABLE(ios(6.0), macos(10.9)) API_UNAVAILABLE(watchos, tvos) NS_DESIGNATED_INITIALIZER
#if TARGET_OS_VISION
API_UNAVAILABLE(visionos)
#endif
;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,144 @@
/*
* @file CBUUID.h
* @framework CoreBluetooth
*
* @discussion The CBUUID class represents bluetooth LE UUIDs. It automatically handles
* transformations of 16 and 32 bit UUIDs into 128 bit UUIDs.
*
* @copyright 2011 Apple, Inc. All rights reserved.
*/
#ifndef _CORE_BLUETOOTH_H_
#warning Please do not import this header file directly. Use <CoreBluetooth/CoreBluetooth.h> instead.
#endif
#import <CoreBluetooth/CBDefines.h>
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
/*!
* @const CBUUIDCharacteristicExtendedPropertiesString
* @discussion The string representation of the UUID for the extended properties descriptor.
* The corresponding value for this descriptor is an <code>NSNumber</code> object.
*/
CB_EXTERN NSString * const CBUUIDCharacteristicExtendedPropertiesString;
/*!
* @const CBUUIDCharacteristicUserDescriptionString
* @discussion The string representation of the UUID for the user description descriptor.
* The corresponding value for this descriptor is an <code>NSString</code> object.
*/
CB_EXTERN NSString * const CBUUIDCharacteristicUserDescriptionString;
/*!
* @const CBUUIDClientCharacteristicConfigurationString
* @discussion The string representation of the UUID for the client configuration descriptor.
* The corresponding value for this descriptor is an <code>NSNumber</code> object.
*/
CB_EXTERN NSString * const CBUUIDClientCharacteristicConfigurationString;
/*!
* @const CBUUIDServerCharacteristicConfigurationString
* @discussion The string representation of the UUID for the server configuration descriptor.
* The corresponding value for this descriptor is an <code>NSNumber</code> object.
*/
CB_EXTERN NSString * const CBUUIDServerCharacteristicConfigurationString;
/*!
* @const CBUUIDCharacteristicFormatString
* @discussion The string representation of the UUID for the presentation format descriptor.
* The corresponding value for this descriptor is an <code>NSData</code> object.
*/
CB_EXTERN NSString * const CBUUIDCharacteristicFormatString;
/*!
* @const CBUUIDCharacteristicAggregateFormatString
* @discussion The string representation of the UUID for the aggregate descriptor.
*/
CB_EXTERN NSString * const CBUUIDCharacteristicAggregateFormatString;
/*!
* @const CBUUIDCharacteristicValidRangeString
* @discussion Data representing the valid min/max values accepted for a characteristic.
*/
CB_EXTERN NSString * const CBUUIDCharacteristicValidRangeString;
/*!
* @const CBUUIDCharacteristicObservationScheduleString
* @discussion Data representing the observation schedule for a characteristic.
*/
CB_EXTERN NSString * const CBUUIDCharacteristicObservationScheduleString;
/*!
* @const CBUUIDL2CAPPSMCharacteristicString
* @discussion The PSM (a little endian uint16_t) of an L2CAP Channel associated with the GATT service
* containing this characteristic. Servers can publish this characteristic with the UUID
* ABDD3056-28FA-441D-A470-55A75A52553A
*/
CB_EXTERN NSString * const CBUUIDL2CAPPSMCharacteristicString NS_AVAILABLE(10_13, 11_0);
/*!
* @class CBUUID
*
* @discussion
* A 16-bit, 32-bit, or 128-bit Bluetooth UUID.
* 16-bit and 32-bit UUIDs are implicitly pre-filled with the Bluetooth Base UUID.
*
*/
NS_CLASS_AVAILABLE(10_7, 5_0)
CB_EXTERN_CLASS @interface CBUUID : NSObject <NSCopying>
/*!
* @property data
*
* @discussion
* The UUID as NSData.
*
*/
@property(nonatomic, readonly) NSData *data;
/*!
* @property UUIDString
*
* @discussion
* The UUID as NSString.
*
*/
@property(nonatomic, readonly) NSString *UUIDString NS_AVAILABLE(10_10, 7_1);
/*!
* @method UUIDWithString:
*
* @discussion
* Creates a CBUUID with a 16-bit, 32-bit, or 128-bit UUID string representation.
* The expected format for 128-bit UUIDs is a string punctuated by hyphens, for example 68753A44-4D6F-1226-9C60-0050E4C00067.
*
*/
+ (CBUUID *)UUIDWithString:(NSString *)theString;
/*!
* @method UUIDWithData:
*
* @discussion
* Creates a CBUUID with a 16-bit, 32-bit, or 128-bit UUID data container.
*
*/
+ (CBUUID *)UUIDWithData:(NSData *)theData;
/*!
* @method UUIDWithCFUUID:
*
* @discussion
* Creates a CBUUID with a CFUUIDRef.
*
*/
+ (CBUUID *)UUIDWithCFUUID:(CFUUIDRef)theUUID NS_DEPRECATED(10_7, 10_13, 5_0, 9_0);
/*!
* @method UUIDWithNSUUID:
*
* @discussion
* Creates a CBUUID with an NSUUID.
*
*/
+ (CBUUID *)UUIDWithNSUUID:(NSUUID *)theUUID NS_AVAILABLE(10_9, 7_0);
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,7 @@
---
Name: CoreBluetooth
Tags:
- Name: CBError
NSErrorDomain: CBErrorDomain
- Name: CBATTError
NSErrorDomain: CBATTErrorDomain

View File

@ -0,0 +1,32 @@
/*!
* @header
* @file CoreBluetooth.h
* @framework CoreBluetooth
*
* @discussion Bluetooth Low Energy framework
*
* @copyright 2011 Apple, Inc. All rights reserved.
*/
#ifndef _CORE_BLUETOOTH_H_
#define _CORE_BLUETOOTH_H_
#endif
#import <CoreBluetooth/CBDefines.h>
#if __OBJC__
#import <CoreBluetooth/CBCentralManager.h>
#import <CoreBluetooth/CBPeripheralManager.h>
#import <CoreBluetooth/CBPeripheral.h>
#import <CoreBluetooth/CBCentral.h>
#import <CoreBluetooth/CBService.h>
#import <CoreBluetooth/CBCharacteristic.h>
#import <CoreBluetooth/CBDescriptor.h>
#import <CoreBluetooth/CBError.h>
#import <CoreBluetooth/CBUUID.h>
#import <CoreBluetooth/CBAdvertisementData.h>
#import <CoreBluetooth/CBATTRequest.h>
#endif

View File

@ -0,0 +1,5 @@
framework module CoreBluetooth [extern_c] {
umbrella header "CoreBluetooth.h"
export *
module * { export * }
}

View File

@ -0,0 +1,328 @@
--- !tapi-tbd
tbd-version: 4
targets: [ armv7-ios, armv7s-ios, arm64-ios, arm64e-ios ]
install-name: '/System/Library/Frameworks/GameController.framework/GameController'
current-version: 12.0.31
swift-abi-version: 7
exports:
- targets: [ armv7-ios, armv7s-ios ]
symbols: [ _GCApplicationSupportsBackgroundInput, _GCCommonGetPreferencesBooleanValue,
_GCControllerManagerInit, _GCControllerManagerInitXPC, __GCHIDEventCallback,
_kGCCommonFullPreferencesPath, _kGCCommonPreferencesUser,
_threadRunLoopSourceCallback ]
objc-classes: [ GCControllerCBDelegate, GCControllerMBDelegate, GCControllerSFDelegate,
_GCCControllerHIDServiceInfo, _GCMicroGamepadSnapshot ]
objc-ivars: [ GCControllerCBDelegate._centralManager, GCControllerCBDelegate._completionHandler,
GCControllerCBDelegate._connectedPeripherals, GCControllerCBDelegate._foundPeripherals,
GCControllerMBDelegate._discoveryAgent, GCControllerMBDelegate._pairingAgent,
GCControllerMBDelegate._session, GCControllerMBDelegate._timer,
GCControllerSFDelegate._activity ]
- targets: [ armv7-ios, armv7s-ios, arm64-ios, arm64e-ios ]
symbols: [ '_$s14GameController17GCAxisElementNameV13steeringWheelACvgZ',
'_$s14GameController17GCAxisElementNameV8rawValueACSS_tcfC',
'_$s14GameController17GCAxisElementNameV8rawValueSSvg', '_$s14GameController17GCAxisElementNameV8rawValueSSvpMV',
'_$s14GameController17GCAxisElementNameVAA015GCPhysicalInputd5TypedE0AAMc',
'_$s14GameController17GCAxisElementNameVAA015GCPhysicalInputd5TypedE0AAWP',
'_$s14GameController17GCAxisElementNameVMa', '_$s14GameController17GCAxisElementNameVMn',
'_$s14GameController17GCAxisElementNameVN', '_$s14GameController17GCAxisElementNameVSHAAMc',
'_$s14GameController17GCAxisElementNameVSQAAMc', '_$s14GameController17GCAxisElementNameVSYAAMc',
'_$s14GameController19GCButtonElementNameV10leftBumperACvgZ',
'_$s14GameController19GCButtonElementNameV10leftPaddleACvgZ',
'_$s14GameController19GCButtonElementNameV10pedalBrakeACvgZ',
'_$s14GameController19GCButtonElementNameV11leftTriggerACvgZ',
'_$s14GameController19GCButtonElementNameV11pedalClutchACvgZ',
'_$s14GameController19GCButtonElementNameV11rightBumperACvgZ',
'_$s14GameController19GCButtonElementNameV11rightPaddleACvgZ',
'_$s14GameController19GCButtonElementNameV12arcadeButton3row6columnACSi_SitFZ',
'_$s14GameController19GCButtonElementNameV12leftShoulderACvgZ',
'_$s14GameController19GCButtonElementNameV12rightTriggerACvgZ',
'_$s14GameController19GCButtonElementNameV13rightShoulderACvgZ',
'_$s14GameController19GCButtonElementNameV14backLeftButton8positionACSi_tFZ',
'_$s14GameController19GCButtonElementNameV15backRightButton8positionACSi_tFZ',
'_$s14GameController19GCButtonElementNameV16pedalAcceleratorACvgZ',
'_$s14GameController19GCButtonElementNameV1aACvgZ', '_$s14GameController19GCButtonElementNameV1bACvgZ',
'_$s14GameController19GCButtonElementNameV1xACvgZ', '_$s14GameController19GCButtonElementNameV1yACvgZ',
'_$s14GameController19GCButtonElementNameV20leftThumbstickButtonACvgZ',
'_$s14GameController19GCButtonElementNameV21rightThumbstickButtonACvgZ',
'_$s14GameController19GCButtonElementNameV4homeACvgZ', '_$s14GameController19GCButtonElementNameV4menuACvgZ',
'_$s14GameController19GCButtonElementNameV5shareACvgZ', '_$s14GameController19GCButtonElementNameV7optionsACvgZ',
'_$s14GameController19GCButtonElementNameV8rawValueACSS_tcfC',
'_$s14GameController19GCButtonElementNameV8rawValueSSvg',
'_$s14GameController19GCButtonElementNameV8rawValueSSvpMV',
'_$s14GameController19GCButtonElementNameVAA015GCPhysicalInputd5TypedE0AAMc',
'_$s14GameController19GCButtonElementNameVAA015GCPhysicalInputd5TypedE0AAWP',
'_$s14GameController19GCButtonElementNameVMa', '_$s14GameController19GCButtonElementNameVMn',
'_$s14GameController19GCButtonElementNameVN', '_$s14GameController19GCButtonElementNameVSHAAMc',
'_$s14GameController19GCButtonElementNameVSQAAMc', '_$s14GameController19GCButtonElementNameVSYAAMc',
'_$s14GameController19GCSwitchElementNameV8rawValueACSS_tcfC',
'_$s14GameController19GCSwitchElementNameV8rawValueSSvg',
'_$s14GameController19GCSwitchElementNameV8rawValueSSvpMV',
'_$s14GameController19GCSwitchElementNameVAA015GCPhysicalInputd5TypedE0AAMc',
'_$s14GameController19GCSwitchElementNameVAA015GCPhysicalInputd5TypedE0AAWP',
'_$s14GameController19GCSwitchElementNameVMa', '_$s14GameController19GCSwitchElementNameVMn',
'_$s14GameController19GCSwitchElementNameVN', '_$s14GameController19GCSwitchElementNameVSHAAMc',
'_$s14GameController19GCSwitchElementNameVSQAAMc', '_$s14GameController19GCSwitchElementNameVSYAAMc',
'_$s14GameController25GCDirectionPadElementNameV09directionD0ACvgZ',
'_$s14GameController25GCDirectionPadElementNameV14leftThumbstickACvgZ',
'_$s14GameController25GCDirectionPadElementNameV15rightThumbstickACvgZ',
'_$s14GameController25GCDirectionPadElementNameV8rawValueACSS_tcfC',
'_$s14GameController25GCDirectionPadElementNameV8rawValueSSvg',
'_$s14GameController25GCDirectionPadElementNameV8rawValueSSvpMV',
'_$s14GameController25GCDirectionPadElementNameVAA015GCPhysicalInpute5TypedF0AAMc',
'_$s14GameController25GCDirectionPadElementNameVAA015GCPhysicalInpute5TypedF0AAWP',
'_$s14GameController25GCDirectionPadElementNameVMa', '_$s14GameController25GCDirectionPadElementNameVMn',
'_$s14GameController25GCDirectionPadElementNameVN', '_$s14GameController25GCDirectionPadElementNameVSHAAMc',
'_$s14GameController25GCDirectionPadElementNameVSQAAMc', '_$s14GameController25GCDirectionPadElementNameVSYAAMc',
'_$s14GameController26GCPhysicalInputElementNameV7shifterACvgZ',
'_$s14GameController26GCPhysicalInputElementNameV8rawValueACSS_tcfC',
'_$s14GameController26GCPhysicalInputElementNameV8rawValueSSvg',
'_$s14GameController26GCPhysicalInputElementNameV8rawValueSSvpMV',
'_$s14GameController26GCPhysicalInputElementNameVAA0cde5TypedF0AAMc',
'_$s14GameController26GCPhysicalInputElementNameVAA0cde5TypedF0AAWP',
'_$s14GameController26GCPhysicalInputElementNameVMa', '_$s14GameController26GCPhysicalInputElementNameVMn',
'_$s14GameController26GCPhysicalInputElementNameVN', '_$s14GameController26GCPhysicalInputElementNameVSHAAMc',
'_$s14GameController26GCPhysicalInputElementNameVSQAAMc',
'_$s14GameController26GCPhysicalInputElementNameVSYAAMc',
'_$s14GameController31GCPhysicalInputElementTypedNameMp',
'_$s14GameController31GCPhysicalInputElementTypedNamePSHTb',
'_$s14GameController31GCPhysicalInputElementTypedNamePSYTb',
'_$s14GameController31GCPhysicalInputElementTypedNameTL',
'_$s14GameController32GCPhysicalInputElementCollectionV10startIndexAC0H0Vyx_Gvg',
'_$s14GameController32GCPhysicalInputElementCollectionV10startIndexAC0H0Vyx_GvpMV',
'_$s14GameController32GCPhysicalInputElementCollectionV5IndexV1loiySbAEyx_G_AGtFZ',
'_$s14GameController32GCPhysicalInputElementCollectionV5IndexV2eeoiySbAEyx_G_AGtFZ',
'_$s14GameController32GCPhysicalInputElementCollectionV5IndexVMa',
'_$s14GameController32GCPhysicalInputElementCollectionV5IndexVMn',
'_$s14GameController32GCPhysicalInputElementCollectionV5IndexVyx_GSLAAMc',
'_$s14GameController32GCPhysicalInputElementCollectionV5IndexVyx_GSQAAMc',
'_$s14GameController32GCPhysicalInputElementCollectionV5index5afterAC5IndexVyx_GAH_tF',
'_$s14GameController32GCPhysicalInputElementCollectionV8endIndexAC0H0Vyx_Gvg',
'_$s14GameController32GCPhysicalInputElementCollectionV8endIndexAC0H0Vyx_GvpMV',
'_$s14GameController32GCPhysicalInputElementCollectionVAASo014GCDirectionPadE0_pRszrlEySoAD_pSgAA0ghE4NameVcig',
'_$s14GameController32GCPhysicalInputElementCollectionVAASo014GCDirectionPadE0_pRszrlEySoAD_pSgAA0ghE4NameVcipMV',
'_$s14GameController32GCPhysicalInputElementCollectionVAASo06GCAxisE0_pRszrlEySoAD_pSgAA0gE4NameVcig',
'_$s14GameController32GCPhysicalInputElementCollectionVAASo06GCAxisE0_pRszrlEySoAD_pSgAA0gE4NameVcipMV',
'_$s14GameController32GCPhysicalInputElementCollectionVAASo08GCButtonE0_pRszrlEySoAD_pSgAA0gE4NameVcig',
'_$s14GameController32GCPhysicalInputElementCollectionVAASo08GCButtonE0_pRszrlEySoAD_pSgAA0gE4NameVcipMV',
'_$s14GameController32GCPhysicalInputElementCollectionVAASo08GCSwitchE0_pRszrlEySoAD_pSgAA0gE4NameVcig',
'_$s14GameController32GCPhysicalInputElementCollectionVAASo08GCSwitchE0_pRszrlEySoAD_pSgAA0gE4NameVcipMV',
'_$s14GameController32GCPhysicalInputElementCollectionVAASo0cdE0_pRszrlEySoAD_pSgAA0cdE4NameVcig',
'_$s14GameController32GCPhysicalInputElementCollectionVAASo0cdE0_pRszrlEySoAD_pSgAA0cdE4NameVcipMV',
'_$s14GameController32GCPhysicalInputElementCollectionVMa',
'_$s14GameController32GCPhysicalInputElementCollectionVMn',
'_$s14GameController32GCPhysicalInputElementCollectionVy08PhysicaldE0Qyd__Sgqd__cAA0cdE9TypedNameRd__luig',
'_$s14GameController32GCPhysicalInputElementCollectionVy08PhysicaldE0Qyd__Sgqd__cAA0cdE9TypedNameRd__luipMV',
'_$s14GameController32GCPhysicalInputElementCollectionVySo0cdE0_pSgqd__cSoAD_pRszAA0cdE9TypedNameRd__luig',
'_$s14GameController32GCPhysicalInputElementCollectionVySo0cdE0_pSgqd__cSoAD_pRszAA0cdE9TypedNameRd__luipMV',
'_$s14GameController32GCPhysicalInputElementCollectionVyxAC5IndexVyx_Gcig',
'_$s14GameController32GCPhysicalInputElementCollectionVyxAC5IndexVyx_GcipMV',
'_$s14GameController32GCPhysicalInputElementCollectionVyxGSTAAMc',
'_$s14GameController32GCPhysicalInputElementCollectionVyxGSlAAMc',
'_$s14GameController32GCPhysicalInputElementCollectionVyxSgSScig',
'_$s14GameController32GCPhysicalInputElementCollectionVyxSgSScipMV',
'_$s20PhysicalInputElement14GameController010GCPhysicalbC9TypedNamePTl',
'_$sSo26GCDevicePhysicalInputStateP14GameControllerE4axesAC010GCPhysicalC17ElementCollectionVySo06GCAxisI0_pGvg',
'_$sSo26GCDevicePhysicalInputStateP14GameControllerE4axesAC010GCPhysicalC17ElementCollectionVySo06GCAxisI0_pGvpMV',
'_$sSo26GCDevicePhysicalInputStateP14GameControllerE5dpadsAC010GCPhysicalC17ElementCollectionVySo014GCDirectionPadI0_pGvg',
'_$sSo26GCDevicePhysicalInputStateP14GameControllerE5dpadsAC010GCPhysicalC17ElementCollectionVySo014GCDirectionPadI0_pGvpMV',
'_$sSo26GCDevicePhysicalInputStateP14GameControllerE7buttonsAC010GCPhysicalC17ElementCollectionVySo08GCButtonI0_pGvg',
'_$sSo26GCDevicePhysicalInputStateP14GameControllerE7buttonsAC010GCPhysicalC17ElementCollectionVySo08GCButtonI0_pGvpMV',
'_$sSo26GCDevicePhysicalInputStateP14GameControllerE8elementsAC010GCPhysicalC17ElementCollectionVySo0hcI0_pGvg',
'_$sSo26GCDevicePhysicalInputStateP14GameControllerE8elementsAC010GCPhysicalC17ElementCollectionVySo0hcI0_pGvpMV',
'_$sSo26GCDevicePhysicalInputStateP14GameControllerE8switchesAC010GCPhysicalC17ElementCollectionVySo08GCSwitchI0_pGvg',
'_$sSo26GCDevicePhysicalInputStateP14GameControllerE8switchesAC010GCPhysicalC17ElementCollectionVySo08GCSwitchI0_pGvpMV',
'_$sSo30GCDevicePhysicalInputStateDiffP14GameControllerE15changedElementsQrSgyF',
'_$sSo30GCDevicePhysicalInputStateDiffP14GameControllerE15changedElementsQrSgyFQOMQ',
'_$sSo30GCDevicePhysicalInputStateDiffP14GameControllerE15changedElementsSo12NSEnumeratorCSgyF',
_ControllerClassForService, _GCAgentClientInterface, _GCAgentServerInterface,
_GCAppClientInterface, _GCAppServerInterface, _GCApplicationIsAlmond,
_GCApplicationIsMacCatalyst, _GCBundleWithPID, _GCBypassMFiAuthentication,
_GCControllerButtonInputPressedThreshold, _GCControllerComponent_Classes,
_GCControllerDidBecomeCurrentNotification, _GCControllerDidConnectNotification,
_GCControllerDidDisconnectNotification, _GCControllerDidStopBeingCurrentNotification,
_GCControllerUserCustomizationsDidChangeNotification, _GCCurrentExtendedGamepadSnapshotDataVersion,
_GCCurrentMicroGamepadSnapshotDataVersion, _GCCurrentProcessLinkedOnAfter,
_GCExecutablePathWithPID, _GCExtendedGamepadDidBecomeCurrentNotification,
_GCExtendedGamepadDidStopBeingCurrentNotification, _GCExtendedGamepadInitInfoMake,
_GCExtendedGamepadInitInfoPopulateNames, _GCExtendedGamepadSnapShotDataV100FromNSData,
_GCExtendedGamepadSnapshotDataFromNSData, _GCFrameworkBundle,
_GCFrameworkInitializationReasonToString, _GCFrameworkStaticInitializer,
_GCGameIntentBlocklist, _GCGamepadSnapShotDataV100FromNSData,
_GCHandSkeletonAny, _GCHandSkeletonLeft, _GCHandSkeletonRight,
_GCHapticDurationInfinite, _GCHapticsLocalityAll, _GCHapticsLocalityDefault,
_GCHapticsLocalityHandles, _GCHapticsLocalityLeftHandle, _GCHapticsLocalityLeftTrigger,
_GCHapticsLocalityRightHandle, _GCHapticsLocalityRightTrigger,
_GCHapticsLocalityTriggers, _GCIPCObjectIdentifier_Classes,
_GCInputArcadeButtonName, _GCInputAuxiliaryMouseButtonName,
_GCInputBackLeftButton, _GCInputBackLeftPrimaryButton, _GCInputBackLeftSecondaryButton,
_GCInputBackRightButton, _GCInputBackRightPrimaryButton, _GCInputBackRightSecondaryButton,
_GCInputButtonA, _GCInputButtonB, _GCInputButtonHome, _GCInputButtonMenu,
_GCInputButtonOptions, _GCInputButtonShare, _GCInputButtonX,
_GCInputButtonY, _GCInputDirectionPad, _GCInputDirectionalCardinalDpad,
_GCInputDirectionalCenterButton, _GCInputDirectionalDpad,
_GCInputDirectionalTouchSurfaceButton, _GCInputDualShockTouchpadButton,
_GCInputDualShockTouchpadOne, _GCInputDualShockTouchpadTwo,
_GCInputLeftBumper, _GCInputLeftPaddle, _GCInputLeftShoulder,
_GCInputLeftThumbstick, _GCInputLeftThumbstickButton, _GCInputLeftTrigger,
_GCInputMicroGamepadButtonA, _GCInputMicroGamepadButtonMenu,
_GCInputMicroGamepadButtonX, _GCInputMicroGamepadDpad, _GCInputMouseCursor,
_GCInputMouseScrollWheel, _GCInputPedalAccelerator, _GCInputPedalBrake,
_GCInputPedalClutch, _GCInputPrimaryMouseButton, _GCInputRightBumper,
_GCInputRightPaddle, _GCInputRightShoulder, _GCInputRightThumbstick,
_GCInputRightThumbstickButton, _GCInputRightTrigger, _GCInputSecondaryMouseButton,
_GCInputShifter, _GCInputSteeringWheel, _GCInputThirdMouseButton,
_GCInputXboxPaddleFour, _GCInputXboxPaddleOne, _GCInputXboxPaddleThree,
_GCInputXboxPaddleTwo, _GCKeyA, _GCKeyApplication, _GCKeyB,
_GCKeyBackslash, _GCKeyC, _GCKeyCapsLock, _GCKeyCloseBracket,
_GCKeyCodeApplication, _GCKeyCodeBackslash, _GCKeyCodeCapsLock,
_GCKeyCodeCloseBracket, _GCKeyCodeComma, _GCKeyCodeDeleteForward,
_GCKeyCodeDeleteOrBackspace, _GCKeyCodeDownArrow, _GCKeyCodeEight,
_GCKeyCodeEnd, _GCKeyCodeEqualSign, _GCKeyCodeEscape, _GCKeyCodeF1,
_GCKeyCodeF10, _GCKeyCodeF11, _GCKeyCodeF12, _GCKeyCodeF13,
_GCKeyCodeF14, _GCKeyCodeF15, _GCKeyCodeF16, _GCKeyCodeF17,
_GCKeyCodeF18, _GCKeyCodeF19, _GCKeyCodeF2, _GCKeyCodeF20,
_GCKeyCodeF3, _GCKeyCodeF4, _GCKeyCodeF5, _GCKeyCodeF6, _GCKeyCodeF7,
_GCKeyCodeF8, _GCKeyCodeF9, _GCKeyCodeFive, _GCKeyCodeFour,
_GCKeyCodeGraveAccentAndTilde, _GCKeyCodeHome, _GCKeyCodeHyphen,
_GCKeyCodeInsert, _GCKeyCodeInternational1, _GCKeyCodeInternational2,
_GCKeyCodeInternational3, _GCKeyCodeInternational4, _GCKeyCodeInternational5,
_GCKeyCodeInternational6, _GCKeyCodeInternational7, _GCKeyCodeInternational8,
_GCKeyCodeInternational9, _GCKeyCodeKeyA, _GCKeyCodeKeyB,
_GCKeyCodeKeyC, _GCKeyCodeKeyD, _GCKeyCodeKeyE, _GCKeyCodeKeyF,
_GCKeyCodeKeyG, _GCKeyCodeKeyH, _GCKeyCodeKeyI, _GCKeyCodeKeyJ,
_GCKeyCodeKeyK, _GCKeyCodeKeyL, _GCKeyCodeKeyM, _GCKeyCodeKeyN,
_GCKeyCodeKeyO, _GCKeyCodeKeyP, _GCKeyCodeKeyQ, _GCKeyCodeKeyR,
_GCKeyCodeKeyS, _GCKeyCodeKeyT, _GCKeyCodeKeyU, _GCKeyCodeKeyV,
_GCKeyCodeKeyW, _GCKeyCodeKeyX, _GCKeyCodeKeyY, _GCKeyCodeKeyZ,
_GCKeyCodeKeypad0, _GCKeyCodeKeypad1, _GCKeyCodeKeypad2, _GCKeyCodeKeypad3,
_GCKeyCodeKeypad4, _GCKeyCodeKeypad5, _GCKeyCodeKeypad6, _GCKeyCodeKeypad7,
_GCKeyCodeKeypad8, _GCKeyCodeKeypad9, _GCKeyCodeKeypadAsterisk,
_GCKeyCodeKeypadEnter, _GCKeyCodeKeypadEqualSign, _GCKeyCodeKeypadHyphen,
_GCKeyCodeKeypadNumLock, _GCKeyCodeKeypadPeriod, _GCKeyCodeKeypadPlus,
_GCKeyCodeKeypadSlash, _GCKeyCodeLANG1, _GCKeyCodeLANG2, _GCKeyCodeLANG3,
_GCKeyCodeLANG4, _GCKeyCodeLANG5, _GCKeyCodeLANG6, _GCKeyCodeLANG7,
_GCKeyCodeLANG8, _GCKeyCodeLANG9, _GCKeyCodeLeftAlt, _GCKeyCodeLeftArrow,
_GCKeyCodeLeftControl, _GCKeyCodeLeftGUI, _GCKeyCodeLeftShift,
_GCKeyCodeNine, _GCKeyCodeNonUSBackslash, _GCKeyCodeNonUSPound,
_GCKeyCodeOne, _GCKeyCodeOpenBracket, _GCKeyCodePageDown,
_GCKeyCodePageUp, _GCKeyCodePause, _GCKeyCodePeriod, _GCKeyCodePower,
_GCKeyCodePrintScreen, _GCKeyCodeQuote, _GCKeyCodeReturnOrEnter,
_GCKeyCodeRightAlt, _GCKeyCodeRightArrow, _GCKeyCodeRightControl,
_GCKeyCodeRightGUI, _GCKeyCodeRightShift, _GCKeyCodeScrollLock,
_GCKeyCodeSemicolon, _GCKeyCodeSeven, _GCKeyCodeSix, _GCKeyCodeSlash,
_GCKeyCodeSpacebar, _GCKeyCodeTab, _GCKeyCodeThree, _GCKeyCodeTwo,
_GCKeyCodeUpArrow, _GCKeyCodeZero, _GCKeyComma, _GCKeyD, _GCKeyDeleteForward,
_GCKeyDeleteOrBackspace, _GCKeyDownArrow, _GCKeyE, _GCKeyEight,
_GCKeyEnd, _GCKeyEqualSign, _GCKeyEscape, _GCKeyF, _GCKeyF1,
_GCKeyF10, _GCKeyF11, _GCKeyF12, _GCKeyF13, _GCKeyF14, _GCKeyF15,
_GCKeyF16, _GCKeyF17, _GCKeyF18, _GCKeyF19, _GCKeyF2, _GCKeyF20,
_GCKeyF3, _GCKeyF4, _GCKeyF5, _GCKeyF6, _GCKeyF7, _GCKeyF8,
_GCKeyF9, _GCKeyFive, _GCKeyFour, _GCKeyG, _GCKeyGraveAccentAndTilde,
_GCKeyH, _GCKeyHome, _GCKeyHyphen, _GCKeyI, _GCKeyInsert,
_GCKeyInternational1, _GCKeyInternational2, _GCKeyInternational3,
_GCKeyInternational4, _GCKeyInternational5, _GCKeyInternational6,
_GCKeyInternational7, _GCKeyInternational8, _GCKeyInternational9,
_GCKeyJ, _GCKeyK, _GCKeyKeypad0, _GCKeyKeypad1, _GCKeyKeypad2,
_GCKeyKeypad3, _GCKeyKeypad4, _GCKeyKeypad5, _GCKeyKeypad6,
_GCKeyKeypad7, _GCKeyKeypad8, _GCKeyKeypad9, _GCKeyKeypadAsterisk,
_GCKeyKeypadEnter, _GCKeyKeypadEqualSign, _GCKeyKeypadHyphen,
_GCKeyKeypadNumLock, _GCKeyKeypadPeriod, _GCKeyKeypadPlus,
_GCKeyKeypadSlash, _GCKeyL, _GCKeyLANG1, _GCKeyLANG2, _GCKeyLANG3,
_GCKeyLANG4, _GCKeyLANG5, _GCKeyLANG6, _GCKeyLANG7, _GCKeyLANG8,
_GCKeyLANG9, _GCKeyLeftAlt, _GCKeyLeftArrow, _GCKeyLeftControl,
_GCKeyLeftGUI, _GCKeyLeftShift, _GCKeyM, _GCKeyN, _GCKeyNine,
_GCKeyNonUSBackslash, _GCKeyNonUSPound, _GCKeyO, _GCKeyOne,
_GCKeyOpenBracket, _GCKeyP, _GCKeyPageDown, _GCKeyPageUp,
_GCKeyPause, _GCKeyPeriod, _GCKeyPower, _GCKeyPrintScreen,
_GCKeyQ, _GCKeyQuote, _GCKeyR, _GCKeyReturnOrEnter, _GCKeyRightAlt,
_GCKeyRightArrow, _GCKeyRightControl, _GCKeyRightGUI, _GCKeyRightShift,
_GCKeyS, _GCKeyScrollLock, _GCKeySemicolon, _GCKeySeven, _GCKeySix,
_GCKeySlash, _GCKeySpacebar, _GCKeyT, _GCKeyTab, _GCKeyThree,
_GCKeyTwo, _GCKeyU, _GCKeyUpArrow, _GCKeyV, _GCKeyW, _GCKeyX,
_GCKeyY, _GCKeyZ, _GCKeyZero, _GCKeyboardDidConnectNotification,
_GCKeyboardDidDisconnectNotification, _GCLogicalDeviceWasRegisteredNotification,
_GCLogicalDeviceWasUnregisteredNotification, _GCMicroGamepadDidBecomeCurrentNotification,
_GCMicroGamepadDidStopBeingCurrentNotification, _GCMicroGamepadSnapShotDataV100FromNSData,
_GCMicroGamepadSnapshotDataFromNSData, _GCMouseDidBecomeCurrentNotification,
_GCMouseDidConnectNotification, _GCMouseDidDisconnectNotification,
_GCMouseDidStopBeingCurrentNotification, _GCOverrideCurrentProcessLinkedOn,
_GCPhysicalDeviceWasRegisteredNotification, _GCPhysicalDeviceWasUnregisteredNotification,
_GCPoint2Zero, _GCProductCategoryArcadeStick, _GCProductCategoryCoalescedRemote,
_GCProductCategoryControlCenterRemote, _GCProductCategoryDualSense,
_GCProductCategoryDualShock4, _GCProductCategoryHID, _GCProductCategoryKeyboard,
_GCProductCategoryMFi, _GCProductCategoryMouse, _GCProductCategorySiriRemote1stGen,
_GCProductCategorySiriRemote2ndGen, _GCProductCategoryUniversalElectronicsRemote,
_GCProductCategoryXboxOne, _GCPropertyValueHandedness, _GCRacingWheelDidConnectNotification,
_GCRacingWheelDidDisconnectNotification, _GCRefreshPhysicalDeviceConfigurationNotification,
_GCSystemGestureModeToString, _GCXRPropertyButtonFingerIndex,
_GCXRPropertyButtonFingerMiddle, _GCXRPropertyButtonFingerPinky,
_GCXRPropertyButtonFingerRing, _GCXRPropertyButtonFingerThumb,
_NSDataFromGCExtendedGamepadSnapShotDataV100, _NSDataFromGCExtendedGamepadSnapshotData,
_NSDataFromGCGamepadSnapShotDataV100, _NSDataFromGCMicroGamepadSnapShotDataV100,
_NSDataFromGCMicroGamepadSnapshotData, _NSStringFromGCPoint2,
_VendorNameForATVProfile, __GCControllerComponentDescription_Classes,
__GCGamepadEventSourceDescription_Classes, __GCHIDEventSourceDescription_Classes,
__GCKeyboardEventSourceDescription_Classes, __GCMotionEventSourceDescription_Classes,
__publishCustomController, __unpublishCustomController, _allCodes,
_batchInputData, _clamp, _convertToDict, _currentProcessBundleIdentifier,
_currentProcessHasEntitlement, _currentProcessIsGameControllerDaemon,
_dataFromController, _deviceMatchesUsageAndUsagePage, _doesDescriptorConformToSpec,
_dqAdd, _dqConjugate, _dqDLB, _dqGetMatrix, _dqGetRotation,
_dqGetTranslation, _dqIdentity, _dqMakeDualQuaternion, _dqMul,
_dqMulConst, _dqNormalize, _dqScLERP, _elementRangesMatch,
_getElementCapability, _getElementTimePressed, _hexStringFromByteArray,
_isDeviceAppleControlCenterRemote, _isDeviceAppleDirectionalRemote,
_isDeviceAppleEmbeddedBluetoothButtons, _isDeviceAppleMultiPointDigitizer,
_isDeviceAppleSiriRemote, _isDeviceAppleTouchpad, _isDeviceDualSense,
_isDeviceDualSenseEdge, _isDeviceDualShock4, _isDeviceKeyboard,
_isDeviceLuna, _isDeviceMFiGamepadCompliantForDeviceRef, _isDeviceMotionLite,
_isDeviceMouse, _isDeviceParentAuthenticated, _isDeviceSwitchJoyCon,
_isDeviceSwitchN64Controller, _isDeviceSwitchProController,
_isDeviceSwitchSuperFamicomController, _isDeviceXbox, _isPartnerSupportEnabled,
_kGCControllerSettingsMetaSettingsExistKey, _kGCSettingsCustomizedElementsKey,
_kGCSettingsDefaultBundleIdentifier, _kGCSettingsElementInvertHorizontallyKey,
_kGCSettingsElementInvertSwapAxesKey, _kGCSettingsElementInvertVerticallyKey,
_kGCSettingsElementMappingKeyKey, _kGCSettingsMetaSettingsExistKey,
_kGCSettingsMetaSuiteSuffix, _loadNSDictionaryFromJSON, _mapToAnalytics,
_nameForKeyCode, _numberFromInt, _serviceMatchesUsageAndUsagePage,
_stringFromState ]
objc-classes: [ GCAnalytics, GCApplicationStateMonitor, GCColor, GCController,
GCControllerAxisInput, GCControllerButtonInput, GCControllerDirectionPad,
GCControllerElement, GCControllerElementSettings, GCControllerInputState,
GCControllerLiveInput, GCControllerSettings, GCControllerTouchpad,
GCCursorElement, GCDeviceAdaptiveTriggersPayload, GCDeviceAdaptiveTriggersStatusPayload,
GCDeviceBattery, GCDeviceButtonInputDescription, GCDeviceCursor,
GCDeviceDirectionPadDescription, GCDeviceElementDescription,
GCDeviceHaptics, GCDeviceLight, GCDirectionalGamepad, GCDualSenseAdaptiveTrigger,
GCDualSenseGamepad, GCDualShockGamepad, GCEAAccessoryManagerWrapper,
GCEventInteraction, GCEventViewController, GCExtendedGamepad,
GCExtendedGamepadSnapshot, GCFrontmostApplicationObserver,
GCGameControllerActivationContext, GCGameIntentSettings, GCGamepad,
GCGamepadSnapshot, GCGearShifterElement, GCHIDInformation,
GCHapticActuator, GCHapticCapabilities, GCHapticCapabilityGraph,
GCHapticCapabilityGraphNode, GCKeyboard, GCKeyboardAndMouseEmulatedController,
GCKeyboardAndMouseManager, GCKeyboardInput, GCLocalPlayerIndicator,
GCLogicalDeviceAnalytics, GCMicroGamepad, GCMicroGamepadSnapshot,
GCMotion, GCMouse, GCMouseInput, GCMouseInputState, GCMouseLiveInput,
GCNotificationManager, GCNotificationOptions, GCPhysicalInputElementCollection,
GCPhysicalInputProfile, GCProductInformation, GCRacingWheel,
GCRacingWheelInput, GCRacingWheelInputState, GCRemoteUserDefaultsProxy,
GCReplayKitGestureSettings, GCReplayNotificationOptions, GCSceneComponent,
GCSteeringWheelElement, GCSyntheticDeviceManager, GCSystemGesturesState,
GCVirtualController, GCVirtualControllerConfiguration, GCVirtualControllerElementConfiguration,
GCXboxGamepad, _GCAgentClientConnection, _GCAgentClientProxy,
_GCAgentServerConnection, _GCAppAgentConnection, _GCAppClientConnection,
_GCAppClientProxy, _GCAppServerConnection, _GCButtonEventImpl,
_GCCControllerHIDServiceInfoDescription, _GCCControllerManagerDescription,
_GCController, _GCControllerComponentDescription, _GCControllerDescription,
_GCControllerGestureAwareButtonInput, _GCControllerManager,
_GCControllerManagerAppClient, _GCControllerManagerServer,
_GCDefaultLogicalDevice, _GCDeviceExtendedGamepadComponentDescription,
_GCDeviceGamepadComponentDescription, _GCDevicePhysicalInputComponentDescription,
_GCDigitizerEventImpl, _GCDriverClientConnection, _GCGamepadEventGamepadHIDAdapterDescription,
_GCGamepadEventImpl, _GCHIDEventSubject, _GCHandSkeleton,
_GCHapticEvent, _GCHapticServerManager, _GCIPCRemoteProcess,
_GCImplicitIPCObjectDescription, _GCKeyboardEventFusion, _GCKeyboardEventHIDAdapter,
_GCKeyboardEventImpl, _GCObservation, _GCPointerEventImpl,
_GCScrollEventImpl, _GCXRComponent ]
...

View File

@ -0,0 +1,89 @@
//
// GCAxis2DInput.h
// GameController
//
// Copyright © 2021 Apple Inc. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <GameController/GCTypes.h>
@protocol GCPhysicalInputElement;
@protocol GCPhysicalInputSource;
NS_ASSUME_NONNULL_BEGIN
/**
An object conforming to \c GCAxis2DInput represents an input that produces a
pair of normalized values - between [-1, 1] - along two axes with fixed origin.
The origin - a value of 0 - corresponds the neutral state of the input.
*/
API_AVAILABLE(macos(14.3), ios(17.4), tvos(17.4), visionos(1.1))
@protocol GCAxis2DInput <NSObject>
/**
Set this block to be notified when the value of the axis input changes.
@param element the element that has been modified.
@param input the input that has been modified.
@param value the value the axis was set to at the time the valueChangedHandler fired.
*/
@property (atomic, copy, nullable) void (^valueDidChangeHandler)(__kindof id<GCPhysicalInputElement> element, id<GCAxis2DInput> input, GCPoint2 value);
/**
A pair of x,y normalized values for the axis input, each between -1 and 1
(inclusive). The values are deadzoned and saturated before they are returned
so there is no value outside the range. Deadzoning does not remove values
from the range; the full 0 to 1 magnitude of values are possible from the input.
As an axis is often used in a digital sense, you can rely on a value of 0
meaning the axis is inside the deadzone. Any value greater than or less than
zero is not in the deadzone.
*/
@property (readonly) GCPoint2 value;
/**
Check if the axis can support more than just digital values.
Defaults to \c YES for most axis inputs.
*/
@property (readonly, getter = isAnalog) BOOL analog;
/**
Check if the axis input value "rolls over" when reaching either the extreme
high or low value. For example, some dials can be rotated past the position
that represents their maximum value causing the reported value to roll over.
Defaults to \c NO for most axis elements.
*/
@property (readonly) BOOL canWrap;
/**
The timestamp of the last value.
This time interval is not relative to any specific point in time. You can
subtract a previous timestamp from the current timestamp to determine the time
(in seconds) between changes to the value.
*/
@property (readonly) NSTimeInterval lastValueTimestamp;
/**
The interval (in seconds) between the timestamp of the last event and the
current time.
This should be treated as a lower bound of the event latency. It may not
include (wired or wireless) transmission latency, or latency accrued on
the device before the event was transmitted to the host.
*/
@property (readonly) NSTimeInterval lastValueLatency;
/**
An object describing the physical action(s) the user performs to manipulate
this input.
*/
@property (copy, readonly) NSSet<id<GCPhysicalInputSource>> *sources;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,36 @@
//
// GCPhysicalInputElement.h
// GameController
//
// Copyright © 2021 Apple Inc. All rights reserved.
//
#import <GameController/GCPhysicalInputElement.h>
#import <GameController/GCAxisInput.h>
#import <GameController/GCRelativeInput.h>
NS_ASSUME_NONNULL_BEGIN
API_AVAILABLE(macos(13.0), ios(16.0), tvos(16.0))
@protocol GCAxisElement <GCPhysicalInputElement>
/**
The input reporting the value of the axis as the position between a lower and
upper bound, if available.
*/
@property (readonly, nullable) id<GCAxisInput> absoluteInput;
/**
The input reporting axis values as the change (delta) since the last event.
Certain kinds of axis elements are only able to report relative values. The
tracking of a computer mouse, for example, has no fixed origin - only the
change in position since the last event is reported. Some freely-rotating
dials may also only report a value indicating which direction the dial was
turned.
*/
@property (readonly) id<GCRelativeInput> relativeInput;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,88 @@
//
// GCAxisInput.h
// GameController
//
// Copyright © 2021 Apple Inc. All rights reserved.
//
#import <Foundation/Foundation.h>
@protocol GCPhysicalInputElement;
@protocol GCPhysicalInputSource;
NS_ASSUME_NONNULL_BEGIN
/**
An object conforming to \c GCAxisInput represents an input that produces
normalized values - between [-1, 1] - along an axis with a fixed origin.
The origin - a value of 0 - corresponds the neutral state of the input.
*/
API_AVAILABLE(macos(13.0), ios(16.0), tvos(16.0))
@protocol GCAxisInput <NSObject>
/**
Set this block to be notified when the value of the axis input changes.
@param element the element that has been modified.
@param input the input that has been modified.
@param value the value the axis was set to at the time the valueChangedHandler fired.
*/
@property (atomic, copy, nullable) void (^valueDidChangeHandler)(__kindof id<GCPhysicalInputElement> element, id<GCAxisInput> input, float value);
/**
A normalized value for the axis input, between -1 and 1 (inclusive). The values
are deadzoned and saturated before they are returned so there is no value
outside the range. Deadzoning does not remove values from the range, the full
0 to 1 magnitude of values are possible from the input.
As an axis is often used in a digital sense, you can rely on a value of 0
meaning the axis is inside the deadzone. Any value greater than or less than
zero is not in the deadzone.
*/
@property (readonly) float value;
/**
Check if the axis can support more than just digital values.
Defaults to \c YES for most axis inputs.
*/
@property (readonly, getter = isAnalog) BOOL analog;
/**
Check if the axis input value "rolls over" when reaching either the extreme
high or low value. For example, some dials can be rotated past the position
that represents their maximum value causing the reported value to roll over.
Defaults to \c NO for most axis elements.
*/
@property (readonly) BOOL canWrap;
/**
The timestamp of the last value.
This time interval is not relative to any specific point in time. You can
subtract a previous timestamp from the current timestamp to determine the time
(in seconds) between changes to the value.
*/
@property (readonly) NSTimeInterval lastValueTimestamp;
/**
The interval (in seconds) between the timestamp of the last event and the
current time.
This should be treated as a lower bound of the event latency. It may not
include (wired or wireless) transmission latency, or latency accrued on
the device before the event was transmitted to the host.
*/
@property (readonly) NSTimeInterval lastValueLatency;
/**
An object describing the physical action(s) the user performs to manipulate
this input.
*/
@property (copy, readonly) NSSet<id<GCPhysicalInputSource>> *sources API_AVAILABLE(macos(14.0), ios(17.0), tvos(17.0));
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,40 @@
//
// GCButtonElement.h
// GameController
//
// Copyright © 2021 Apple Inc. All rights reserved.
//
#import <GameController/GCPhysicalInputElement.h>
#import <GameController/GCLinearInput.h>
#import <GameController/GCPressedStateInput.h>
#import <GameController/GCTouchedStateInput.h>
NS_ASSUME_NONNULL_BEGIN
/**
An object conforming to \c GCButtonElement represents a momentary switch,
such as a push button. A button's input only asserts while the user is
interacting with it, and then returns to a preferred state (not pressed, not
touched).
*/
API_AVAILABLE(macos(13.0), ios(16.0), tvos(16.0))
@protocol GCButtonElement <GCPhysicalInputElement>
/**
Get the input containing the pressed state of the button.
*/
@property (readonly) id<GCPressedStateInput, GCLinearInput> pressedInput;
/**
Get the input containing the touched state of the button.
Some buttons feature capacitive touch capabilities where the user can touch the
button without pressing it.
*/
@property (readonly, nullable) id<GCTouchedStateInput> touchedInput;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,29 @@
//
// GCColor.h
// GameController
//
// Copyright © 2020 Apple Inc. All rights reserved.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
/**
Represents a color used by a GCDeviceLight.
@see GCDeviceLight
*/
API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0))
@interface GCColor : NSObject<NSCopying, NSSecureCoding>
- (instancetype)init NS_UNAVAILABLE;
- (instancetype)initWithRed:(float)red green:(float)green blue:(float)blue;
@property (readonly) float red;
@property (readonly) float green;
@property (readonly) float blue;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,341 @@
//
// GCController.h
// GameController
//
// Copyright (c) 2012 Apple Inc. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <GameController/GCExtern.h>
#import <GameController/GCDevice.h>
#import <GameController/GCControllerInput.h>
#import <GameController/GCPhysicalInputProfile.h>
#import <GameController/GCControllerElement.h>
#import <GameController/GCColor.h>
@class GCMotion;
@class CHHapticEngine;
@class GCDeviceHaptics;
@class GCDeviceLight;
@class GCDeviceBattery;
@class GCGamepad;
@class GCMicroGamepad;
@class GCExtendedGamepad;
NS_ASSUME_NONNULL_BEGIN
/**
Use these constants with NSNotificationCenter to listen to connection and disconnection events.
Use GCControllerDidConnectNotification for observing connections of controllers.
Use GCControllerDidDisconnectNotification for observing disconnections of controllers.
Connections and disconnections of controllers will also be reflected in the controllers array
of the GCController class.
The 'object' property of the notification will contain the GCController that was connected or disconnected.
For example:
- (void)controllerDidConnect:(NSNotification *)note {
GCController *controller = note.object;
....
}
@see NSNotificationCenter
@see GCController.controllers
*/
GAMECONTROLLER_EXTERN NSString *const GCControllerDidConnectNotification API_AVAILABLE(macos(10.9), ios(7.0), tvos(7.0));
GAMECONTROLLER_EXTERN NSString *const GCControllerDidDisconnectNotification API_AVAILABLE(macos(10.9), ios(7.0), tvos(7.0));
/**
Use these constants with NSNotificationCenter to listen to a controller becoming the most recently used controller.
This is a good time to swap out UI to match the new current controller, and unregister any handlers with
the old current controller.
The 'object' property of the notification will contain the GCController that became the current controller.
For example:
- (void)controllerDidBecomeCurrent:(NSNotification *)note {
GCController *controller = note.object;
...
}
@see NSNotificationCenter
@see GCController.controllers
*/
GAMECONTROLLER_EXTERN NSString *const GCControllerDidBecomeCurrentNotification API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
GAMECONTROLLER_EXTERN NSString *const GCControllerDidStopBeingCurrentNotification API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
/**
Use this constant with NSNotificationCenter to listen to controller user customization events.
When a user customizes the button mappings or other settings of a controller this notification will be
posted. This is a good time to swap out UI to match the new user settings. Users can modify game
controller settings through the Settings app on iOS, tvOS, and macOS.
The 'object' property of the notification will contain the GCController that was customized.
For example:
- (void)controllerDidConnect:(NSNotification *)note {
GCController *controller = note.object;
....
}
@see NSNotificationCenter
@see GCController.controllers
*/
GAMECONTROLLER_EXTERN NSString *const GCControllerUserCustomizationsDidChangeNotification API_AVAILABLE(macos(13.0), ios(16.0), tvos(16.0));
/**
This is the player index that a connected controller will have if it has never been assigned a player index on the current system.
Controllers retain the player index they have been assigned between game sessions, so if you wish to unset the player index of a
controller set it back to this value.
*/
typedef NS_ENUM(NSInteger, GCControllerPlayerIndex) {
GCControllerPlayerIndexUnset = -1,
GCControllerPlayerIndex1 = 0,
GCControllerPlayerIndex2,
GCControllerPlayerIndex3,
GCControllerPlayerIndex4,
};
/**
Controllers are available to an application that links to GameController.framework. There are 2 ways to access controllers
paired to the system, adopt both to ensure the best user experience:
1: Querying for the the current array or controllers using [GCController controllers].
2: Registering for Connection/Disconnection notifications from NSNotificationCenter.
Only controllers that support one of the allowed profiles, such as GCExtendedGamepad, will be enumerated. Check for the profile
supported before using a controller in your application. Ignore a controller that doesn't support a profile that suits
your application, as the user will expect their controller to either be fully supported or not supported at all.
*/
API_AVAILABLE(macos(10.9), ios(7.0), tvos(7.0))
@interface GCController : NSObject<GCDevice>
/**
Set this block to be notified when a user intends to suspend or resume the current game state. A controller will have a button
dedicated to suspending and resuming play and invoking context sensitive actions. During event handling the system will
notify the application using this block such that the application can handle the suspension and resumption from the given controller.
Use this to implement your canonical transition to a pause menu for example if that is your application's desired handling
of suspension in play. You may pause and resume based on game state as well so the event is only called each time the
pause/resume button is pressed.
@note This handler has been deprecated in favor of the Menu button found on GCMicroGamepad and GCExtendedGamepad.
@see microGamepad
@see extendedGamepad
*/
@property (nonatomic, copy, nullable) void (^controllerPausedHandler)(GCController *controller) API_DEPRECATED("controllerPausedHandler has been deprecated. Use the Menu button found on the controller's profile, if it exists.", macos(10.9, 10.15), ios(7.0, 13.0), tvos(9.0, 13.0));
/**
The most recently used game controller. If a user actuates a game controller input, that controller will become the current one.
@note This is useful for single player games where you only care about whether an input is pressed, and not where it came from. You
will still need to register for changes to GCController.current so that your UI can remain up-to-date with the current controller.
*/
@property (class, atomic, strong, readonly, nullable) GCController *current API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
/**
Whether the current application should monitor and respond to game controller events when it is not the frontmost application.
@example If shouldMonitorBackgroundEvents is NO, and the application is not the frontmost application, any inputs from a game controller will
not be forwarded to the application. Once the application becomes the frontmost application, game controller events will be forwarded.
@note Starting with macOS Big Sur 11.3, shouldMonitorBackgroundEvents will be NO by default. For applications built prior to macOS Big Sur 11.3,
(or running on devices with an earlier version of macOS), shouldMonitorBackgroundEvents will be YES by default. On iOS and tvOS, this property is ignored.
*/
@property (class, nonatomic, readwrite) BOOL shouldMonitorBackgroundEvents API_AVAILABLE(macos(11.3), ios(14.5), tvos(14.5));
/**
A controller may be form fitting or otherwise closely attached to the device. This closeness to other inputs on the device
may suggest that interaction with the device may use other inputs easily. This is presented to developers to allow them to
make informed decisions about UI and interactions to choose for their game in this situation.
*/
@property (nonatomic, readonly, getter = isAttachedToDevice) BOOL attachedToDevice;
/**
A controller may represent a real device managed by the operating system, or a virtual snapshot created by the developer.
If a controller is directly created by the developer, it is considered to be a snapshot, allowing direct writes to any
GCControllerElement of its profiles. If the controller is not snapshot, the system will reject any write requests to GCControllerElement.
@see controllerWithMicroGamepad
@see controllerWithExtendedGamepad
@see capture
*/
@property (atomic, readonly, getter = isSnapshot) BOOL snapshot API_AVAILABLE(macos(10.15), ios(13.0), tvos(13.0));
/**
A player index for the controller, defaults to GCControllerPlayerIndexUnset.
This can be set both for the application to keep track of controllers and as a signal to make a controller display a player
index on a set of LEDs or some other mechanism.
A controller is not guaranteed to have a visual display of the playerIndex, playerIndex does not persist for a controller
with regards to a system.
Negative values less than GCControllerPlayerIndexUnset will just map back to GCControllerPlayerIndexUnset when read back.
*/
@property (nonatomic) GCControllerPlayerIndex playerIndex;
/**
Gets the input profile for the controller.
*/
@property (nonatomic, strong, readonly) GCControllerLiveInput *input API_AVAILABLE(macos(14.0), ios(17.0), tvos(17.0));
/**
Gets the battery information if controller supports one
This property is useful when you try to notify your user to change or charge controller before it runs out of battery life
or simply display the current battery level and status.
*/
@property (nonatomic, copy, readonly, nullable) GCDeviceBattery *battery API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
/**
Gets the physical input profile for the controller.
@note This is equivalent to the controller's microGamepad, or extendedGamepad instance.
@see microGamepad
@see extendedGamepad
*/
@property (nonatomic, strong, readonly) GCPhysicalInputProfile *physicalInputProfile API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
/**
Gets the profile for the controller that suits current application.
There are several supported profiles, with an additional optional profile for motion as well.
Each controller may be able to map its inputs into all profiles or just one kind of profile. Query for the controller
profile that suits your game, the simplest kind will be supported by the broadest variety
of controllers. A controller supporting the Extended Gamepad profile for example supports the Gamepad profile and more.
As such it can always be used just in the Gamepad profile if that suits the game.
A physical controller that supports a profile must support it completely. That means that all buttons and axis inputs must
be valid inputs that a developer can utilize.
If a controller does not support the given profile the returned value will be nil. Use this to filter controllers if the
application requires a specific kind of profile.
@see motion
*/
@property (nonatomic, strong, readonly, nullable) GCGamepad *gamepad API_DEPRECATED_WITH_REPLACEMENT("extendedGamepad", macos(10.9, 10.12), ios(7.0, 10.0), tvos(7.0, 10.0));
@property (nonatomic, strong, readonly, nullable) GCMicroGamepad *microGamepad;
@property (nonatomic, strong, readonly, nullable) GCExtendedGamepad *extendedGamepad;
/**
Gets the motion input profile. This profile is optional and may be available if the controller is attached to a device that supports motion.
If this is nil the controller does not support motion input and only the gamepad & extendedGamepad profiles are available.
@see gamepad
@see extendedGamepad
*/
@property (nonatomic, strong, readonly, nullable) GCMotion *motion API_AVAILABLE(macos(10.10), ios(8.0), tvos(8.0));
/**
Gets the light for the controller, if one exists.
A controller's light can be used to signal information to the player, such as using different light colors based on the player
index. It can also be used to react to in-game events and enhance user immersion.
*/
@property (nonatomic, retain, readonly, nullable) GCDeviceLight *light API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
/**
Gets the haptics for the controller, if one exists.
Use this property to create CHHapticEngine instances according to your needs.
@note Haptics are a drain on the controller's battery, and can be distracting when used excessively.
*/
@property (nonatomic, retain, readonly, nullable) GCDeviceHaptics *haptics API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
/**
Polls the state vector of the controller and saves it to a new and writable instance of GCController.
If your application is heavily multithreaded this may also be useful to guarantee atomicity of input handling as
a snapshot will not change based on user input once it is taken.
@see snapshot
@return A new controller with the duplicated state vector of the current controller
*/
- (GCController *)capture API_AVAILABLE(macos(10.15), ios(13.0), tvos(13.0));
/**
Get a list of controllers currently attached to the system.
@see GCControllerDidConnectNotification
@see GCControllerDidDisconnectNotification
*/
+ (NSArray<GCController *> *)controllers;
/**
Start discovery of new wireless controllers that are discoverable. This is an asynchronous and the supplied completionHandler
will get called once no more devices can be found. If there are already multiple controllers available for use, there
may be little reason to automatically start discovery of new wireless controllers. In this situation it may be best to
allow the user to start discovery manually via in-game UI.
Once discovery has started new controllers will notify themselves as connected via GCControllerDidConnectNotification.
As the notification arrives the controller is also available in the controllers array.
The completionHandler could be used to update UI and/or game state to indicate that no more controllers will be found
and the current set of controllers is what is available for use in the game.
If a completionHandler was provided, it will be called once when discovery stops. Either from an explicit call to
stopWirelessControllerDiscovery or from timing out or stopping in its natural course of operation. Thus the
completionHandler will at most be called once per call to startWirelessControllerDiscoveryWithCompletionHandler:.
The completionHandler may also not get called at all, if for example startWirelessControllerDiscoveryWithCompletionHandler:
is called multiple times during dicovery. For this case the net effect is that the completionHandler is replaced with each call
and only the last one set before discovery stops will be called.
@param completionHandler an optional handler that is called when discovery stops. (may be nil, in which case you will not be notified when discovery stops)
@see stopWirelessControllerDiscovery
@see controllers
*/
+ (void)startWirelessControllerDiscoveryWithCompletionHandler:(nullable void (^)(void))completionHandler;
/**
If no more controllers are needed, depending on game state or number of controllers supported by a game, the discovery
process can be stopped. Calling stopWirelessControllerDiscovery when no discovery is currently in progress will return
immediately without any effect, thus it is safe to call even if the completionHandler of
startWirelessControllerDiscoveryWithCompletionHandler: has been called.
@see startWirelessControllerDiscoveryWithCompletionHandler:
*/
+ (void)stopWirelessControllerDiscovery;
/**
Creates a controller with a micro gamepad profile.
This controller will be considered a snapshot, allowing developers to write to any GCControllerElement of its profiles.
@see snapshot
@return A new controller with a micro gamepad profile
*/
+ (GCController *)controllerWithMicroGamepad API_AVAILABLE(macos(10.15), ios(13.0), tvos(13.0));
/**
Creates a controller with an extended gamepad profile.
This controller will be considered a snapshot, allowing developers to write to any GCControllerElement of its profiles.
@see snapshot
@return A new controller with an extended gamepad profile
*/
+ (GCController *)controllerWithExtendedGamepad API_AVAILABLE(macos(10.15), ios(13.0), tvos(13.0));
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,46 @@
//
// GCControllerAxisInput.h
// GameController
//
// Copyright (c) 2012 Apple Inc. All rights reserved.
//
#import <GameController/GCControllerElement.h>
NS_ASSUME_NONNULL_BEGIN
API_AVAILABLE(macos(10.9), ios(7.0), tvos(7.0))
@interface GCControllerAxisInput : GCControllerElement
/**
Set this block if you want to be notified when the value on this axis changes.
@param axis the element that has been modified.
@param value the value the axis was set to at the time the valueChangedHandler fired.
*/
typedef void (^GCControllerAxisValueChangedHandler)(GCControllerAxisInput *axis, float value);
@property (nonatomic, copy, nullable) GCControllerAxisValueChangedHandler valueChangedHandler;
/**
A normalized value for the input, between -1 and 1 for axis inputs. The values are deadzoned and saturated before they are returned
so there is no value ouside the range. Deadzoning does not remove values from the range, the full 0 to 1 magnitude of values
are possible from the input.
As an axis is often used in a digital sense, you can rely on a value of 0 meaning the axis is inside the deadzone.
Any value greater than or less than zero is not in the deadzone.
*/
@property (nonatomic, readonly) float value;
/**
Sets the normalized value for the input.
@param value the value to set the input to.
@note If the controller's snapshot flag is set to NO, this method has no effect.
@see value
*/
- (void)setValue:(float)value API_AVAILABLE(macos(10.15), ios(13.0), tvos(13.0));
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,92 @@
//
// GCControllerButtonInput.h
// GameController
//
// Copyright (c) 2012 Apple Inc. All rights reserved.
//
#import <GameController/GCControllerElement.h>
NS_ASSUME_NONNULL_BEGIN
API_AVAILABLE(macos(10.9), ios(7.0), tvos(7.0))
@interface GCControllerButtonInput : GCControllerElement
/**
Set this block if you want to be notified when the value on this button changes.
@param button the element that has been modified.
@param value the value the button was set to at the time the valueChangedHandler fired.
@param pressed the pressed state of the button at the time the valueChangedHandler fired.
@see value
@see pressed
*/
typedef void (^GCControllerButtonValueChangedHandler)(GCControllerButtonInput *button, float value, BOOL pressed);
@property (nonatomic, copy, nullable) GCControllerButtonValueChangedHandler valueChangedHandler;
/**
Set this block if you want to be notified when only the pressed state on this button changes. This
will get called less often than the valueChangedHandler with the additional feature of the pressed state
being different to the last time it was called.
*/
@property (nonatomic, copy, nullable) GCControllerButtonValueChangedHandler pressedChangedHandler API_AVAILABLE(macos(10.10), ios(8.0), tvos(8.0));
/**
Set this block if you want to be notified when the touched state on this button changes.
@param button the element that has been modified.
@param value the value the button was set to at the time the valueChangedHandler fired.
@param pressed the pressed state of the button at the time the valueChangedHandler fired.
@param touched the touched state of the button at the time the valueChangedHandler fired.
@see value
@see pressed
*/
typedef void (^GCControllerButtonTouchedChangedHandler)(GCControllerButtonInput *button, float value, BOOL pressed, BOOL touched);
@property (nonatomic, copy, nullable) GCControllerButtonTouchedChangedHandler touchedChangedHandler API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
/**
A normalized value for the input. Between 0 and 1 for button inputs. Values are saturated and thus never exceed the range of [0, 1].
@see valueChangedHandler
@see pressed
*/
@property (nonatomic, readonly) float value;
/**
Buttons are mostly used in a digital sense, thus we have a recommended method for checking for pressed state instead of
interpreting the value.
As a general guideline a button is pressed if the value exceeds 0. However there may be hysterisis applied
to counter noisy input values, thus incidental values around the threshold value may not trigger a change
in pressed state.
Others buttons may support two-stage actuation, where the button reports a value between 0 and 1 but is only considered
pressed when its value is greater than some threshold other than 0.
@see pressedChangedHandler
@see value
*/
@property (nonatomic, readonly, getter = isPressed) BOOL pressed;
/**
Some buttons feature capacitive touch capabilities where the user can touch the button
without pressing it. In such cases, a button will be touched before it is pressed.
For buttons without capacitive sensing, the touched state is true if the value exceeds 0.
@see touchChangedHandler
@see pressed
*/
@property (nonatomic, readonly, getter = isTouched) BOOL touched;
/**
Sets the normalized value for the button input. Will update the pressed state of the button.
@param value the value to set the input to.
@note If the controller's snapshot flag is set to NO, this method has no effect.
@see value
*/
- (void)setValue:(float)value API_AVAILABLE(macos(10.15), ios(13.0), tvos(13.0));
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,54 @@
//
// GCControllerDirectionPad.h
// GameController
//
// Copyright (c) 2012 Apple Inc. All rights reserved.
//
#import <GameController/GCControllerElement.h>
@class GCControllerAxisInput;
@class GCControllerButtonInput;
NS_ASSUME_NONNULL_BEGIN
/**
A direction pad is a common grouping of 2 axis inputs where the input can also be interpreted as 2 sets of mutually exclusive button pairs.
Only one button in each pair, {up, down} and {left, right}, can be pressed at any one time.
*/
API_AVAILABLE(macos(10.9), ios(7.0), tvos(7.0))
@interface GCControllerDirectionPad : GCControllerElement
/**
Set this block if you want to be notified when the value on this axis changes.
@param dpad the direction pad collection whose axis have been modified.
@param xValue the value the x axis was set to at the time the valueChangedHandler fired.
@param yValue the value the y axis was set to at the time the valueChangedHandler fired.
*/
typedef void (^GCControllerDirectionPadValueChangedHandler)(GCControllerDirectionPad *dpad, float xValue, float yValue);
@property (nonatomic, copy, nullable) GCControllerDirectionPadValueChangedHandler valueChangedHandler;
@property (nonatomic, readonly) GCControllerAxisInput *xAxis;
@property (nonatomic, readonly) GCControllerAxisInput *yAxis;
@property (nonatomic, readonly) GCControllerButtonInput *up;
@property (nonatomic, readonly) GCControllerButtonInput *down;
@property (nonatomic, readonly) GCControllerButtonInput *left;
@property (nonatomic, readonly) GCControllerButtonInput *right;
/**
Sets the normalized value for the direction pad's axis inputs. Will update the states of the direction pad's button inputs as well.
@param xAxis the value to set the xAxis of the touchpad to.
@param yAxis the value to set the yAxis of the touchpad to.
@note If the controller's snapshot flag is set to NO, this method has no effect.
@see value
@see pressed
*/
- (void)setValueForXAxis:(float)xAxis yAxis:(float)yAxis API_AVAILABLE(macos(10.15), ios(13.0), tvos(13.0));
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,116 @@
//
// GCControllerElement.h
// GameController
//
// Copyright (c) 2012 Apple Inc. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <GameController/GCExtern.h>
NS_ASSUME_NONNULL_BEGIN
/**
Elements on a GCDevice can be used for system gestures. The system gesture state represents how input is handled in the app
for a controller element that is bound to a system gesture.
@example The Options button on an extended gamepad can be bound to take a screenshot with a long press. This occurs outside of
the control of the app. If a user presses the Options button, the system gesture recognizer will run by default. If a long press is detected,
input will not be forwarded to your app (your application won't see the Options button was pressed at all). If a long press is not detected,
input will be forwared to your app, with a delay.
If you do not want any delay in receiving input for this element, you have two options
- Set the preferred state of the element to GCSystemGestureStateAlwaysReceive. The system gesture recognize will run
concurrently with input being sent to your app. This removes input delay, but can lead to system gestures being triggered
simulatenously with in-app actions.
- Set the preferred state of the element to GCSystemGestureStateDisabled. This will disable the system gesture recognizer - your app
will receive full control of the input for this element.
@see GCControllerElement.boundToSystemGesture
@see GCControllerElement.preferredSystemGestureState
*/
API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0))
typedef NS_ENUM(NSInteger, GCSystemGestureState) {
/** System gesture recognizers will run before input is sent to app, this is the default state */
GCSystemGestureStateEnabled = 0,
/** Input is sent to app and processed by system gesture recognizers simultaneously */
GCSystemGestureStateAlwaysReceive,
/** System gesture recognizers will not run at all. Input is passed directly to app */
GCSystemGestureStateDisabled
} NS_SWIFT_NAME(GCControllerElement.SystemGestureState);
/**
Every controller element knows which collection it belongs to and whether its input value is analog or digital.
*/
API_AVAILABLE(macos(10.9), ios(7.0), tvos(7.0))
@interface GCControllerElement : NSObject
/**
Each element can be part of a wider collection of inputs that map to a single logical element. A directional pad (dpad)
is a logical collection of two axis inputs and thus each axis belongs to the same collection element - the dpad.
*/
@property (nonatomic, weak, readonly, nullable) GCControllerElement *collection;
/**
Check if the element can support more than just digital values, such as decimal ranges between 0 and 1.
Defaults to YES for most elements.
*/
@property (nonatomic, readonly, getter = isAnalog) BOOL analog;
/**
Check if the element is bound to a system gesture.
Defaults to NO for most elements.
@see preferredSystemGestureState
@see GCSystemGestureState
*/
@property (nonatomic, readonly, getter = isBoundToSystemGesture) BOOL boundToSystemGesture API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
/**
The preferred system gesture state for this element.
Defaults to GCSystemGestureStateEnabled for most elements
@note This is merely the preferred system gesture state - it is not guaranteed to be respected by the system.
@note It is highly recommended to leave this set to the default value, however there may be situations (for example, game
streaming apps) where it is preferrable to disable system gestures.
@see boundToSystemGesture
*/
@property (nonatomic, readwrite) GCSystemGestureState preferredSystemGestureState API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
/**
The element's SF Symbols name, taking input remapping into account.
@note In almost all instances, you should use this over unmappedSfSymbolsName in your UI.
*/
@property (nonatomic, strong, nullable) NSString *sfSymbolsName API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
/**
The element's localized name, taking input remapping into account.
@note In almost all instances, you should use this over unmappedLocalizedName in your UI.
*/
@property (nonatomic, strong, nullable) NSString *localizedName API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
/**
The element's SF Symbols name, not taking any input remapping into account.
@note Use this in your games own remapping UI, or when you need to prompt a user that a given button has no mapping (sfSymbolsName is nil).
*/
@property (nonatomic, strong, nullable) NSString *unmappedSfSymbolsName API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
/**
The element's localized name, not taking any input remapping into account.
@note Use this in your games own remapping UI, or when you need to prompt a user that a given button has no mapping (localizedName is nil).
*/
@property (nonatomic, strong, nullable) NSString *unmappedLocalizedName API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
/**
A set of aliases that can be used to access this element with keyed subscript notation.
*/
@property (nonatomic, copy, readonly) NSSet<NSString *> *aliases API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,39 @@
//
// GCControllerInput.h
// GameController
//
// Copyright © 2022 Apple Inc. All rights reserved.
//
#import <GameController/GCDevicePhysicalInput.h>
NS_ASSUME_NONNULL_BEGIN
API_AVAILABLE(macos(14.0), ios(17.0), tvos(17.0))
@interface GCControllerInputState : NSObject <GCDevicePhysicalInputState>
@end
API_AVAILABLE(macos(14.0), ios(17.0), tvos(17.0))
@interface GCControllerLiveInput : GCControllerInputState <GCDevicePhysicalInput>
/**
* Get a view of the controller's input without any system-level control
* remapping applied.
*
* Developers should avoid implementing their own control remapping
* functionality and to instead direct users to the system game controller
* settings to remap controls. If you choose to implement your own
* control remapping functionality, or if your app streams controller input
* to a remote device that implements control remapping functionality, you
* should access controller physical input through this interface.
*/
@property (readonly, nullable) GCControllerLiveInput *unmappedInput;
/* GCDevicePhysicalInput re-declarations with better type information. */
- (GCControllerInputState *)capture;
- (nullable GCControllerInputState<GCDevicePhysicalInputStateDiff> *)nextInputState;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,101 @@
//
// GCControllerTouchpad.h
// GameController
//
// Copyright © 2019 Apple Inc. All rights reserved.
//
#import <GameController/GCControllerElement.h>
@class GCControllerDirectionPad;
@class GCControllerButtonInput;
NS_ASSUME_NONNULL_BEGIN
/**
Represents the current state of a touch event on a touchpad.
*/
typedef NS_ENUM(NSInteger, GCTouchState) {
GCTouchStateUp,
GCTouchStateDown,
GCTouchStateMoving
} NS_SWIFT_NAME(GCControllerTouchpad.TouchState);
/**
A touchpad is a touch-based two axis input with a notion of "touch state". It keeps track of
whether the touchpad is actively being touched, and generates events based on a
change in touch state.
*/
API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0))
@interface GCControllerTouchpad : GCControllerElement
/**
Button is the button built into the touch surface.
*/
@property (nonatomic, readonly) GCControllerButtonInput *button;
/**
Set this block if you want to be notified when an axis or the touch state changes.
@param touchpad the touchpad collection whose axes or touch state has been modified.
@param xValue the value x axis was set to at the time the handler fired.
@param yValue the value y axis was set to at the time the handler fired.
@param buttonValue the value of the touch surface button at the time the handler fired.
@param buttonPressed the pressed state of the touch surface button at the time the handler fired.
*/
typedef void (^GCControllerTouchpadHandler)(GCControllerTouchpad *touchpad, float xValue, float yValue, float buttonValue, BOOL buttonPressed);
/**
Called when a touch event begins on the touchpad.
*/
@property (nonatomic, copy, nullable) GCControllerTouchpadHandler touchDown;
/**
Called when a touch event continues on the touchpad, but not when it begins or ends.
*/
@property (nonatomic, copy, nullable) GCControllerTouchpadHandler touchMoved;
/**
Called when a touch event ends on the touchpad.
*/
@property (nonatomic, copy, nullable) GCControllerTouchpadHandler touchUp;
/**
The touch surface is a 2-axis control that represents the position of a touch event on the touchpad.
The axes will indicate the most recent touch position - a non-zero value does not indicate that the
surface is being touched, and a value of (0, 0) does not indicate the surface is not being touched.
@see touchState - Should be polled in conjunction with touchSurface to determine if values are valid
*/
@property (nonatomic, readonly) GCControllerDirectionPad *touchSurface;
/**
Indicates the current state of the touch event on the touchpad.
*/
@property (nonatomic, readonly) GCTouchState touchState;
/**
The touchpad can use the raw position values of its surface as D-pad values, or it can create a virtual dpad centered around the first contact point with the surface.
If NO; a smaller sliding window is created around the initial touch point and subsequent movement is relative to that center. Movement outside the window will slide the window with it to re-center it. This is great for surfaces where there is no clear sense of a middle and drift over time is an issue.
If YES; the absolute values are used and any drift will have to managed manually either through user traning or by a developer using the dpad.
The default value for this property is YES, meaning the touch surface's raw positional values are reported.
*/
@property (nonatomic) BOOL reportsAbsoluteTouchSurfaceValues;
/**
Sets the normalized value for the touchpad's axes, as well as its current touch and button state.
@note If the controller's snapshot flag is set to NO, this method has no effect.
@see touchSurface
@see touchState
*/
- (void)setValueForXAxis:(float)xAxis yAxis:(float)yAxis touchDown:(BOOL)touchDown buttonValue:(float)buttonValue;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,55 @@
//
// GCDevice.h
// GameController
//
// Copyright © 2020 Apple Inc. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <GameController/GCProductCategories.h>
@class GCPhysicalInputProfile;
NS_ASSUME_NONNULL_BEGIN
API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0))
@protocol GCDevice <NSObject>
/**
The dispatch queue that element value change handlers are submitted on. The default queue is main, and setting this to any
other queue will make value change handlers dispatch async on the given queue. This is useful if the main game loop
of the application is not on main, or if input logic is handled on another thread from the main game loop.
@see GCControllerAxisInput.valueChangedHandler
@see GCControllerButtonInput.valueChangedHandler
@see GCControllerButtonInput.pressedChangedHandler
@see GCControllerDirectionPad.valueChangedHandler
@see GCMotion.valueChangedHandler
*/
@property (nonatomic, strong) dispatch_queue_t handlerQueue API_AVAILABLE(macos(10.9), ios(7.0), tvos(7.0));
/**
A vendor supplied name. May be nil, and is not guaranteed to be unique. This should not be used as a key in a dictionary,
but simply as a way to present some basic information about the device in testing or to the user.
*/
@property (nonatomic, readonly, copy, nullable) NSString *vendorName API_AVAILABLE(macos(10.9), ios(7.0), tvos(7.0));
/**
The product category the device belongs to. This is useful for setting appropriate UI elements based on what type of device is connected.
@see GCProductCategories.h
*/
@property (nonatomic, readonly) NSString *productCategory API_AVAILABLE(macos(10.15), ios(13.0), tvos(13.0));
/**
Gets the physical input profile for the device.
@note This is equivalent to the controller's gamepad, microGamepad, or extendedGamepad instance.
@see GCController.microGamepad
@see GCController.extendedGamepad
*/
@property (nonatomic, strong, readonly) GCPhysicalInputProfile *physicalInputProfile API_DEPRECATED("Use the physicalInputProfile property on GCController instead. For GCKeyboard, use the keyboardInput property. For GCMouse, use the mouseInput property.", macos(11.0, 13.0), ios(14.0, 16.0), tvos(14.0, 16.0));
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,51 @@
//
// GCDeviceBattery.h
// GameController
//
// Copyright © 2020 Apple Inc. All rights reserved.
//
#import <GameController/GCExtern.h>
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
/**
This is the battery status and it's represented by one of the following values:
GCControllerBatteryStateUnknown means that the current state of battery is unknown or cannot be determined
GCControllerBatteryStateDischarging means that controller is on battery and discharging at this moment
GCControllerBatteryStateCharging means that controller is plugged in, but it's battery level is less than 100%
GCControllerBatteryStateFull means that controller is plugged in and it's battery level is 100%
*/
typedef NS_ENUM(NSInteger, GCDeviceBatteryState) {
GCDeviceBatteryStateUnknown = -1,
GCDeviceBatteryStateDischarging,
GCDeviceBatteryStateCharging,
GCDeviceBatteryStateFull
} NS_SWIFT_NAME(GCDeviceBattery.State);
/**
A controller battery is an abstract representation of the battery level and battery status of a GCController instance.
*/
API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0))
@interface GCDeviceBattery : NSObject
/**
This is the battery level for controller.
Battery level ranges from 0.0 (fully discharged) to 1.0 (100% charged) and defaults to 0
*/
@property(nonatomic, readonly) float batteryLevel;
/**
A battery state for controller, defaults to GCControllerBatteryStateUnknown
@note This property might be useful if you display the information about currently connected controller for player's convenience
*/
@property(nonatomic, readonly) GCDeviceBatteryState batteryState;
- (instancetype)init NS_UNAVAILABLE;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,22 @@
//
// GCControllerCursor.h
// GameController
//
// Copyright © 2020 Apple Inc. All rights reserved.
//
#import <GameController/GCControllerDirectionPad.h>
NS_ASSUME_NONNULL_BEGIN
/**
A cursor is a Direction Pad that has its axis extended from [-1; 1] to [width; height] range
Up, down, left, right allows to use mouse to simulate DirectionaPad or Thumbstick since values are normalized for these elements
*/
API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0))
@interface GCDeviceCursor : GCControllerDirectionPad
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,68 @@
//
// GCDeviceHaptics.h
// GameController
//
// Copyright © 2020 Apple Inc. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <GameController/GCExtern.h>
@class CHHapticEngine;
NS_ASSUME_NONNULL_BEGIN
/**
A GCHapticsLocality represents the locations of haptic actuators on a controller. You can create a haptic engine with a given
GCHapticsLocality, and any patterns you send to that engine will play on all specified actuators.
```
CHHapticEngine *engine = [controller.haptics createEngineWithLocality:GCHapticsLocalityDefault];
```
@see GCDeviceHaptics
*/
typedef NSString* GCHapticsLocality NS_TYPED_ENUM API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
GAMECONTROLLER_EXTERN GCHapticsLocality const GCHapticsLocalityDefault API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); // guaranteed to be supported
GAMECONTROLLER_EXTERN GCHapticsLocality const GCHapticsLocalityAll API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); // guaranteed to be supported
GAMECONTROLLER_EXTERN GCHapticsLocality const GCHapticsLocalityHandles API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
GAMECONTROLLER_EXTERN GCHapticsLocality const GCHapticsLocalityLeftHandle API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
GAMECONTROLLER_EXTERN GCHapticsLocality const GCHapticsLocalityRightHandle API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
GAMECONTROLLER_EXTERN GCHapticsLocality const GCHapticsLocalityTriggers API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
GAMECONTROLLER_EXTERN GCHapticsLocality const GCHapticsLocalityLeftTrigger API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
GAMECONTROLLER_EXTERN GCHapticsLocality const GCHapticsLocalityRightTrigger API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
GAMECONTROLLER_EXTERN const float GCHapticDurationInfinite API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0))
@interface GCDeviceHaptics : NSObject
/**
The set of supported haptic localities for this device - representing the locations of its haptic actuators.
@note GCHapticsLocalityDefault and GCHapticsLocalityAll are guaranteed to be supported - and they may be equivalent.
@see GCHapticsLocality
*/
@property (nonatomic, strong, readonly) NSSet<GCHapticsLocality> *supportedLocalities;
- (instancetype)init NS_UNAVAILABLE;
/**
Creates and returns a new instance of CHHapticEngine with a given GCHapticsLocality. Any patterns you send to this engine will play on
all specified actuators.
@note Often times, it is best to use GCHapticsLocalityDefault. Engines created with the default locality will give users an expected
haptic experience. On most game controllers, this will cause your haptic patterns to play on the handles. If you want to play different
experiences on different actuators (for example, using the left handle actuator as a woofer and the right actuator as a tweeter), you can
create multiple engines (for example, one with a GCHapticsLocalityLeftHandle locality and another with a GCHapticsLocalityRightHandle
locality).
@see CHHapticEngine
@see GCHapticsLocality
*/
- (CHHapticEngine * _Nullable)createEngineWithLocality:(GCHapticsLocality)locality;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,27 @@
//
// GCDeviceLight.h
// GameController
//
// Copyright © 2020 Apple Inc. All rights reserved.
//
#import <GameController/GCExtern.h>
#import <GameController/GCColor.h>
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
/**
A controller light is an abstract representation of the light-emitting capabilities of a GCController instance.
*/
API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0))
@interface GCDeviceLight : NSObject
@property (nonatomic, copy) GCColor *color;
- (instancetype)init NS_UNAVAILABLE;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,123 @@
//
// GCDevicePhysicalInput.h
// GameController
//
// Copyright © 2021 Apple Inc. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <GameController/GCDevicePhysicalInputState.h>
#import <GameController/GCDevicePhysicalInputStateDiff.h>
@protocol GCDevice;
NS_ASSUME_NONNULL_BEGIN
/**
An objecting conforming to \c GCDevicePhysicalInput provides properties and
methods for accessing common physical elements - buttons, thumbsticks, dpads,
etc - of a device.
*/
API_AVAILABLE(macos(13.0), ios(16.0), tvos(16.0))
@protocol GCDevicePhysicalInput <GCDevicePhysicalInputState>
/**
The device that this profile is mapping input from.
*/
@property (weak, readonly) id<GCDevice> device;
/**
The dispatch queue that element value change handlers and other callbacks are
submitted on.
The default queue is the \c handlerQueue of the associated \c device. Set
this property if your application wants to receive input callbacks on a
different queue. You should set this property before configuring other
callbacks.
*/
@property (atomic, strong, nullable) dispatch_queue_t queue API_AVAILABLE(macos(14.0), ios(17.0), tvos(17.0));
#pragma mark Immediate Input
/**
Set this block to be notified when a value on a element changed. If multiple
elements change this block will be called for each element that changed.
The block is called on the \c queue configured for the physical input.
@param element
The element that has been modified.
*/
@property (atomic, copy, nullable) void (^elementValueDidChangeHandler)(__kindof id<GCDevicePhysicalInput> physicalInput, __kindof id<GCPhysicalInputElement> element);
/**
Polls the current state vector of the physical input and saves it to a new
instance.
If your application is heavily multithreaded this may also be useful to
guarantee atomicity of input handling as a snapshot will not change based on
further device input once it is taken.
@return An input state with the duplicated state vector of the current input.
*/
- (__kindof id<GCDevicePhysicalInputState>)capture;
#pragma mark Buffered Input
/**
Set this block to be notified when a new input state is available. Your
handler should repeatedly call \c -nextInputState until it returns \c nil to
drain the pending input states from the queue.
physicalInput.inputStateQueueDepth = 20;
physicalInput.inputStateAvailableHandler = ^(__kindof id<GCDevicePhysicalInput> physicalInput) {
id<GCDevicePhysicalInputState, GCDevicePhysicalInputStateDiff> nextInputState;
while ((nextInputState = [physicalInput nextInputState])) {
// You can grab the individual states of all elements that your app
// is interested in.
id<GCButtonElement> buttonA = nextInputState.buttons[GCInputButtonA];
BOOL buttonAPressed = buttonA.pressedInput.pressed;
if (buttonAPressed) {
// Handle button A pressed
}
// Your code can first query whether an element's input value changed
// from the prior input state.
GCDevicePhysicalInputElementChange buttonAChange = [nextInputState changeForElement:buttonA];
if (buttonAChange == GCDevicePhysicalInputElementChanged) {
// Handle button A input changed
}
// Or, your code can request an enumerator of elements with input
// values that changed from the prior input state
for (id<GCPhysicalInputElement> changedElement in nextInputState.changedElements) {
}
}
};
*/
@property (atomic, copy, nullable) void (^inputStateAvailableHandler)(__kindof id<GCDevicePhysicalInput> physicalInput);
/**
The maximum number of input states to buffer. If your application does not
drain the pending input states in the queue before this limit is reached, older
input states will be discarded - resulting in your application "missing" input
state changes.
The default value is \c one (no buffering). Smaller values are ignored. A
value of \c 20 should be more than enough to ensure no input state changes
are missed.
*/
@property (atomic, readwrite) NSInteger inputStateQueueDepth;
/**
Pop the oldest pending input state from the queue. This method returns \c nil
when there are no more input states pending.
*/
- (nullable __kindof id<GCDevicePhysicalInputState, GCDevicePhysicalInputStateDiff>)nextInputState;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,85 @@
//
// GCDevicePhysicalInputState.h
// GameController
//
// Copyright © 2022 Apple Inc. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <GameController/GCInputNames.h>
#import <GameController/GCPhysicalInputElement.h>
#import <GameController/GCButtonElement.h>
#import <GameController/GCAxisElement.h>
#import <GameController/GCSwitchElement.h>
#import <GameController/GCDirectionPadElement.h>
@protocol GCDevice;
NS_ASSUME_NONNULL_BEGIN
/**
An object conforming to \c GCDevicePhysicalInputState contains the state of
a device's physical inputs. This may be either the "live" physical input
state if the same object also conforms to \c GCDevicePhysicalInput, or a
snapshot of the physical input state.
*/
API_AVAILABLE(macos(13.0), ios(16.0), tvos(16.0))
@protocol GCDevicePhysicalInputState <NSObject>
/**
The device that this profile is mapping input from.
*/
@property (weak, readonly) id<GCDevice> device;
/**
The internal time stamp of the last event.
This time interval is not relative to any specific point in time. Your
application can subtract a previous timestamp from the returned timestamp to
determine the time (in seconds) between events. The \c lastEventTimestamp of
the inputs from two different devices can be compared to determine which event
occurred first.
*/
@property (readonly) NSTimeInterval lastEventTimestamp;
/**
The interval (in seconds) between the timestamp of the last event and the
current time.
This value should be treated as a lower bound of the event latency. It may
not include (wired or wireless) transmission latency, or latency accrued on
the device before the event was transmitted to the host.
@note
If the system has gone to sleep between when the event occurred and when this
property is read, the returned value may not reflect the true latency.
*/
@property (readonly) NSTimeInterval lastEventLatency;
/**
The following properties allow for runtime lookup of any input element on a
profile, when provided with a valid alias.
@example input.elements[GCInputButtonA]
@example input.dpads[GCInputLeftThumbstick]
@example input.dpads[GCInputButtonB] // fails, "Button B" is not a DirectionPad
*/
@property (readonly) GCPhysicalInputElementCollection<GCInputElementName, id<GCPhysicalInputElement>> *elements NS_REFINED_FOR_SWIFT;
@property (readonly) GCPhysicalInputElementCollection<GCInputButtonName, id<GCButtonElement>> *buttons NS_REFINED_FOR_SWIFT;
@property (readonly) GCPhysicalInputElementCollection<GCInputAxisName, id<GCAxisElement>> *axes NS_REFINED_FOR_SWIFT;
@property (readonly) GCPhysicalInputElementCollection<GCInputSwitchName, id<GCSwitchElement>> *switches NS_REFINED_FOR_SWIFT;
@property (readonly) GCPhysicalInputElementCollection<GCInputDirectionPadName, id<GCDirectionPadElement>> *dpads NS_REFINED_FOR_SWIFT;
/**
Profile elements can be accessed using keyed subscript notation, with a valid alias of its inputs.
@example physicalInput[GCInputButtonA]
@example physicalInput[GCInputButtonX]
@note Equivalent to -elements
*/
- (__kindof id<GCPhysicalInputElement> _Nullable)objectForKeyedSubscript:(NSString *)key;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,57 @@
//
// GCDevicePhysicalInputStateDiff.h
// GameController
//
// Copyright © 2022 Apple Inc. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <GameController/GCPhysicalInputElement.h>
NS_ASSUME_NONNULL_BEGIN
typedef NS_ENUM(NSInteger, GCDevicePhysicalInputElementChange) {
/** Indicates that a change could not be determined. This is typically
* because the input state queue filled up and older input state snapshots
* were dropped. */
GCDevicePhysicalInputElementUnknownChange = -1,
/** Indicates that no value of the element changed. */
GCDevicePhysicalInputElementNoChange = 0,
/** Indicates that a value of the element changed. */
GCDevicePhysicalInputElementChanged = 1,
};
/**
An object conforming to the \c GCDevicePhysicalInputStateDiff protocol
contains the input state differences between the current and previous
\c GCDevicePhysicalInputState objects returned from the \c -nextInputState
method of \c GCDevicePhysicalInput.
*/
API_AVAILABLE(macos(13.0), ios(16.0), tvos(16.0))
@protocol GCDevicePhysicalInputStateDiff <NSObject>
/**
Check if a value of \a element changed, compared the previous input state.
@param element
The element to check. This may be a pointer to either the "live" element
from the device's physical input, or a pointer to an element from any input
state "snapshot" of the device's physical input.
*/
- (GCDevicePhysicalInputElementChange)changeForElement:(id<GCPhysicalInputElement>)element;
/**
Gets an enumerator that iterates over the elements that have changed, compared
the previous input state.
This method returns \c nil if the changed elements could not be determined -
typically because the input state queue filled up and older input state
snapshots were dropped.
*/
- (nullable NSEnumerator<id<GCPhysicalInputElement>> *)changedElements NS_REFINED_FOR_SWIFT;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,47 @@
//
// GCDirectionPadElement.h
// GameController
//
// Copyright © 2021 Apple Inc. All rights reserved.
//
#import <GameController/GCPhysicalInputElement.h>
#import <GameController/GCLinearInput.h>
#import <GameController/GCAxisInput.h>
#import <GameController/GCAxis2DInput.h>
#import <GameController/GCPressedStateInput.h>
NS_ASSUME_NONNULL_BEGIN
/**
An object conforming to \c GCDirectionPadElement represents a four-way
directional control element.
A direction pad element contains a common grouping of 2 axis inputs, which can
also be interpreted as 2 sets of mutually exclusive button pairs. Only one
button in each pair, {up, down} and {left, right}, can be pressed at any
given time.
*/
API_AVAILABLE(macos(13.0), ios(16.0), tvos(16.0))
@protocol GCDirectionPadElement <GCPhysicalInputElement>
/** The x,y position of the dpad input. */
@property (readonly) id<GCAxis2DInput> xyAxes API_AVAILABLE(macos(14.3), ios(17.4), tvos(17.4), visionos(1.1));
/** The horizontal/x-component of the dpad input. */
@property (readonly) id<GCAxisInput> xAxis;
/** The vertical/y-component of the dpad input. */
@property (readonly) id<GCAxisInput> yAxis;
/** The positive y-component of the dpad input. */
@property (readonly) id<GCLinearInput, GCPressedStateInput> up;
/** The negative y-component of the dpad input. */
@property (readonly) id<GCLinearInput, GCPressedStateInput> down;
/** The negative x-component of the dpad input. */
@property (readonly) id<GCLinearInput, GCPressedStateInput> left;
/** The positive x-component of the dpad input. */
@property (readonly) id<GCLinearInput, GCPressedStateInput> right;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,73 @@
//
// GCDirectionalGamepad.h
// GameController
//
// Copyright © 2020 Apple Inc. All rights reserved.
//
#import <GameController/GCMicroGamepad.h>
NS_ASSUME_NONNULL_BEGIN
/**
The primary directional input surface for the directional gamepad
@note Equivalent to microgamepad.dpad
@note For the 2021 2nd generation Siri Remote, this represents touching anywhere on the entire touch surface - including the inner and outer rings.
*/
GAMECONTROLLER_EXTERN NSString *const GCInputDirectionalDpad API_AVAILABLE(macos(11.3), ios(14.5), tvos(14.5));
/**
The button corresponding to pressing anywhere on the primary directional input surface for the directional gamepad
@note Equivalent to microgamepad.buttonA
@note For the 2021 2nd generation Siri Remote, this represents pressing anywhere the entire touch surface - including the inner and outer rings.
*/
GAMECONTROLLER_EXTERN NSString *const GCInputDirectionalTouchSurfaceButton API_AVAILABLE(macos(12.0), ios(15.0), tvos(15.0));
/**
An optional secondary directional input surface for the directional gamepad. This input is guaranteed to be an 8-way digital dpad with physical Up, Down, Left, Right butttons.
@note For the 2021 2nd generation Siri Remote, this represents pressing on the outer ring of the touch surface.
*/
GAMECONTROLLER_EXTERN NSString *const GCInputDirectionalCardinalDpad API_AVAILABLE(macos(11.3), ios(14.5), tvos(14.5));
/**
An optional button for the directional gamepad. This input represents the center button of the cardinal dpad.
@note For the 2021 2nd generation Siri Remote, this represents pressing anywhere on the inner ring of the touch surface.
*/
GAMECONTROLLER_EXTERN NSString *const GCInputDirectionalCenterButton API_AVAILABLE(macos(12.0), ios(15.0), tvos(15.0));
/**
Directional Gamepad profile.
All controller profiles provide a base level of information about the controller they belong to. A directional gamepad
features a subset of the possible inputs on a micro gamepad. It guarantees:
- The gamepad does not support motion, meaning
- -[GCController motion] is always nil
- -[GCDirectionalGamepad allowsRotation] is always NO
Additionally, the gamepad may have a digital or analog dpad.
- -[GCDirectionalGamepad dpad].analog may be YES or NO
- If -[GCDirectionalGamepad dpad].analog is NO, then -[GCDirectionalGamepad reportsAbsoluteDpadValues] is always YES
A profile maps the hardware notion of a controller into a logical controller. One that a developer can design for
and depend on, no matter the underlying hardware. If your game supports GCMicroGamepad, but does not need
the motion and analog dpad functionality of GCMicroGamepad, be sure to add Directional Gamepad to your project's
supported Game Controller capabilities.
@see GCMicroGamepad
@note If you want to use the additional functionality of GCDirectionalGamepad, you should set GCSupportsMultipleMicroGamepads to YES and handle microgamepad connections separately.
@note This profile represents the 2021 2nd generation Siri Remote. Make sure you set GCSupportsMultipleMicroGamepads to YES to properly support the remote.
*/
API_AVAILABLE(macos(11.1), ios(14.3), tvos(14.3))
@interface GCDirectionalGamepad : GCMicroGamepad
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,161 @@
//
// GCDualSenseAdaptiveTrigger.h
// GameController
//
// Copyright © 2020 Apple Inc. All rights reserved.
//
#import <GameController/GCControllerButtonInput.h>
NS_ASSUME_NONNULL_BEGIN
enum {
/** The number of discrete control positions supported by the DualSense adaptive triggers. Each of these positions can be configured separately in multi-position feedback and multi-position vibration modes. */
GCDualSenseAdaptiveTriggerDiscretePositionCount NS_SWIFT_NAME(GCDualSenseAdaptiveTrigger.discretePositionCount) = 10,
};
typedef NS_ENUM(NSInteger, GCDualSenseAdaptiveTriggerMode) {
/** The adaptive trigger effect is disabled. */
GCDualSenseAdaptiveTriggerModeOff = 0,
/** The adaptive trigger effect provides constant feedback from the start position onwards. */
GCDualSenseAdaptiveTriggerModeFeedback = 1,
/** The adaptive trigger effect provides feedback from the start position to the end position, emulating the feeling of pulling the trigger on a weapon. */
GCDualSenseAdaptiveTriggerModeWeapon = 2,
/** The adaptive trigger effect provides a constant vibration effect from the start position onwards. */
GCDualSenseAdaptiveTriggerModeVibration = 3,
/** The adaptive trigger effect provides feedback from the start position to the end position, linearly interpolated between the start and end strengths. */
GCDualSenseAdaptiveTriggerModeSlopeFeedback API_AVAILABLE(macos(12.3), ios(15.4), tvos(15.4)) = 4
} NS_SWIFT_NAME(GCDualSenseAdaptiveTrigger.Mode) API_AVAILABLE(macos(11.3), ios(14.5), tvos(14.5));
typedef NS_ENUM(NSInteger, GCDualSenseAdaptiveTriggerStatus) {
/** The adaptive trigger status cannot be determined. */
GCDualSenseAdaptiveTriggerStatusUnknown = -1,
/** The adaptive trigger is in feedback mode, and a resistive load has not been applied yet. */
GCDualSenseAdaptiveTriggerStatusFeedbackNoLoad,
/** The adaptive trigger is in feedback mode, and a resistive load is applied. */
GCDualSenseAdaptiveTriggerStatusFeedbackLoadApplied,
/** The adaptive trigger is in weapon mode, the trigger is ready to fire, and a resistive load has not been applied yet. */
GCDualSenseAdaptiveTriggerStatusWeaponReady,
/** The adaptive trigger is in weapon mode, the trigger is firing, and a resistive load is currently being applied. */
GCDualSenseAdaptiveTriggerStatusWeaponFiring,
/** The adaptive trigger is in weapon mode, the trigger has fired, and a resistive load is no longer being applied. */
GCDualSenseAdaptiveTriggerStatusWeaponFired,
/** The adaptive trigger is in vibration mode, and the trigger is not vibrating. */
GCDualSenseAdaptiveTriggerStatusVibrationNotVibrating,
/** The adaptive trigger is in vibration mode, and the trigger is currently vibrating. */
GCDualSenseAdaptiveTriggerStatusVibrationIsVibrating,
/** The adaptive trigger is in slope feedback mode, the trigger is ready to apply a resistive load, but a resistive load has not been applied yet. */
GCDualSenseAdaptiveTriggerStatusSlopeFeedbackReady API_AVAILABLE(macos(11.3), ios(14.5), tvos(14.5)),
/** The adaptive trigger is in slope feedback mode, and a resistive load is currently being applied to the trigger. */
GCDualSenseAdaptiveTriggerStatusSlopeFeedbackApplyingLoad API_AVAILABLE(macos(11.3), ios(14.5), tvos(14.5)),
/** The adaptive trigger is in slope feedback mode, a resistive load has previously been applied, but is no longer being applied. */
GCDualSenseAdaptiveTriggerStatusSlopeFeedbackFinished API_AVAILABLE(macos(11.3), ios(14.5), tvos(14.5)),
} NS_SWIFT_NAME(GCDualSenseAdaptiveTrigger.Status) API_AVAILABLE(macos(11.3), ios(14.5), tvos(14.5));
typedef struct {
/** An array of amplitudes associated with the GCDualSenseAdaptiveTriggerDiscretePositionCount control positions supported by the DualSense adaptive triggers. */
float values[GCDualSenseAdaptiveTriggerDiscretePositionCount];
} GCDualSenseAdaptiveTriggerPositionalAmplitudes NS_SWIFT_NAME(GCDualSenseAdaptiveTrigger.PositionalAmplitudes) API_AVAILABLE(macos(12.3), ios(15.4), tvos(15.4));
typedef struct {
/** An array of resistive strengths associated with the GCDualSenseAdaptiveTriggerDiscretePositionCount control positions supported by the DualSense adaptive triggers. */
float values[GCDualSenseAdaptiveTriggerDiscretePositionCount];
} GCDualSenseAdaptiveTriggerPositionalResistiveStrengths NS_SWIFT_NAME(GCDualSenseAdaptiveTrigger.PositionalResistiveStrengths) API_AVAILABLE(macos(12.3), ios(15.4), tvos(15.4));
/**
DualSense triggers are required to be analog inputs. Common uses would be acceleration and decelleration in a driving game for example.
GCDualSenseAdaptiveTrigger represents an adaptive trigger on the Sony DualSense controller, allowing you to specify a dynamic resistance force
that is applied when pulling the trigger. This can, for example, be used to emulate the feeling of pulling back a bow string, firing a weapon, or pulling a lever.
@see GCDualSenseGamepad
*/
API_AVAILABLE(macos(11.3), ios(14.5), tvos(14.5))
@interface GCDualSenseAdaptiveTrigger : GCControllerButtonInput
/**
The mode that the adaptive trigger is currently in. This property reflects the physical state of the triggers - and requires a response from the controller.
It does not update immediately after calling -[GCDualSenseAdaptiveTrigger setMode...].
@see GCDualSenseAdaptiveTriggerMode
*/
@property (nonatomic, readonly) GCDualSenseAdaptiveTriggerMode mode;
/**
The current status of the adaptive trigger - whether it is ready to apply a load, is currently applying a load, or has finished applying a load.
@see GCDualSenseAdaptiveTriggerStatus
*/
@property (nonatomic, readonly) GCDualSenseAdaptiveTriggerStatus status;
/**
A normalized float from [0-1], with 0 representing the lowest possible trigger arm position and 1 representing the maximum trigger arm position.
@see GCDualSenseAdaptiveTriggerStatus
*/
@property (nonatomic, readonly) float armPosition;
/**
Sets the adaptive trigger to slope feedback mode. The start position, end position, start strength, and end strength of the effect can be set arbitrarily; however the end position must be larger than the start position.
The trigger arm will provide a linearly interpolated degree of feedback whenever it is depressed between the start and end positions based on the starting and ending strengths.
@param startPosition - A normalized float from [0-1], with 0 representing the smallest possible trigger depression and 1 representing the maximum trigger depression. The effect will begin once the trigger is depressed beyond this point.
@param endPosition - A normalized float from [0-1], with 0 representing the smallest possible depression and 1 representing the maximum trigger depression. Must be greater than startPosition. The effect will end once the trigger is depressed beyond this point.
@param startStrength - A normalized float from [0-1], with 0 representing the minimum effect strength (off entirely) and 1 representing the maximum effect strength. The effect will begin at startStrength once the trigger is depressed beyond startPosition.
@param endStrength - A normalized float from [0-1], with 0 representing the minimum effect strength (off entirely) and 1 representing the maximum effect strength. The effect will end at endStrength once the trigger is depressed to endPosition.
*/
- (void)setModeSlopeFeedbackWithStartPosition:(float)startPosition endPosition:(float)endPosition startStrength:(float)startStrength endStrength:(float)endStrength API_AVAILABLE(macos(12.3), ios(15.4), tvos(15.4)) NS_SWIFT_NAME(setModeSlopeFeedback(startPosition:endPosition:startStrength:endStrength:));
/**
Sets the adaptive trigger to feedback mode. The start position and strength of the effect can be set arbitrarily. The trigger arm will continue to provide a
constant degree of feedback whenever it is depressed further than the start position.
@param startPosition - A normalized float from [0-1], with 0 representing the smallest possible trigger depression and 1 representing the maximum trigger depression.
@param resistiveStrength - A normalized float from [0-1], with 0 representing the minimum effect strength (off entirely) and 1 representing the maximum effect strength.
*/
- (void)setModeFeedbackWithStartPosition:(float)startPosition resistiveStrength:(float)resistiveStrength;
/**
Sets the adaptive trigger to feedback mode. The strength of the effect can be set for each possible trigger position. The trigger arm will provide a degree of feedback based on the resistive strength for a given position.
@param positionalResistiveStrengths - Positional normalized floats from [0-1], with 0 representing the minimum effect strength (off entirely) and 1 representing the maximum effect strength.
*/
- (void)setModeFeedbackWithResistiveStrengths:(GCDualSenseAdaptiveTriggerPositionalResistiveStrengths)positionalResistiveStrengths API_AVAILABLE(macos(12.3), ios(15.4), tvos(15.4)) NS_SWIFT_NAME(setModeFeedback(resistiveStrengths:));
/**
Sets the adaptive trigger to weapon mode. The start position, end position, and strength of the effect can be set arbitrarily; however the end position must be larger than the start position.
The trigger arm will continue to provide a constant degree of feedback whenever it is depressed further than the start position. Once the trigger arm has been depressed past the end
position, the strength of the effect will immediately fall to zero, providing a "sense of release" similar to that provided by pulling the trigger of a weapon.
@param startPosition - A normalized float from [0-1], with 0 representing the smallest possible depression and 1 representing the maximum trigger depression. The effect will begin once the trigger is depressed beyond this point.
@param endPosition - A normalized float from [0-1], with 0 representing the smallest possible depression and 1 representing the maximum trigger depression. Must be greater than startPosition. The effect will end once the trigger is depressed beyond this point.
@param resistiveStrength - A normalized float from [0-1], with 0 representing the minimum effect strength (off entirely) and 1 representing the maximum effect strength.
*/
- (void)setModeWeaponWithStartPosition:(float)startPosition endPosition:(float)endPosition resistiveStrength:(float)resistiveStrength;
/**
Sets the adaptive trigger to vibration mode. The start position, amplitude, and frequency of the effect can be set arbitrarily. The trigger arm will continue to strike against
the trigger whenever it is depressed further than the start position, providing a "sense of vibration".
@param startPosition - A normalized float from [0-1], with 0 representing the smallest possible depression and 1 representing the maximum trigger depression. The effect will begin once the trigger is depressed beyond this point.
@param amplitude - A normalized float from [0-1], with 0 representing the minimum effect strength (off entirely) and 1 representing the maximum effect strength.
@param frequency - A normalized float from [0-1], with 0 representing the minimum frequency and 1 representing the maximum frequency of the vibration effect.
*/
- (void)setModeVibrationWithStartPosition:(float)startPosition amplitude:(float)amplitude frequency:(float)frequency;
/**
Sets the adaptive trigger to vibration mode. The amplitude of the effect can be set for each possible trigger position. The trigger arm will provide a degree of feedback based on the amplitude for a given position. The trigger arm will continue to strike against the trigger, providing a "sense of vibration".
@param positionalAmplitudes - Positional normalized floats from [0-1], with 0 representing the minimum effect strength (off entirely) and 1 representing the maximum effect strength.
@param frequency - A normalized float from [0-1], with 0 representing the minimum frequency and 1 representing the maximum frequency of the vibration effect.
*/
- (void)setModeVibrationWithAmplitudes:(GCDualSenseAdaptiveTriggerPositionalAmplitudes)positionalAmplitudes frequency:(float)frequency API_AVAILABLE(macos(12.3), ios(15.4), tvos(15.4)) NS_SWIFT_NAME(setModeVibration(amplitudes:frequency:));
/**
Sets the adaptive trigger to off mode. This turns off the adaptive trigger effect.
*/
- (void)setModeOff;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,40 @@
//
// GCDualSenseGamepad.h
// GameController
//
// Copyright © 2020 Apple Inc. All rights reserved.
//
#import <GameController/GCExtendedGamepad.h>
#import <GameController/GCDualSenseAdaptiveTrigger.h>
NS_ASSUME_NONNULL_BEGIN
/**
The GCDualSenseGamepad profile represents any supported DualSense controller.
@see GCExtendedGamepad
@see GCMotion
*/
API_AVAILABLE(macos(11.3), ios(14.5), tvos(14.5))
@interface GCDualSenseGamepad : GCExtendedGamepad
/**
DualSense controllers have a touchpad with a button and two-finger tracking.
*/
@property (nonatomic, readonly) GCControllerButtonInput *touchpadButton;
@property (nonatomic, readonly) GCControllerDirectionPad *touchpadPrimary;
@property (nonatomic, readonly) GCControllerDirectionPad *touchpadSecondary;
/**
Triggers are required to be analog inputs. Common uses would be acceleration and decelleration in a driving game for example.
The DualSense has adaptive triggers, allowing you to specify a dynamic resistance force that is applied when pulling the trigger. This can,
for example, be used to emulate the feeling of pulling back a bow string, firing a weapon, or pulling a lever.
*/
@property (nonatomic, readonly) GCDualSenseAdaptiveTrigger *leftTrigger;
@property (nonatomic, readonly) GCDualSenseAdaptiveTrigger *rightTrigger;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,26 @@
//
// GCDualShockGamepad.h
// GameController
//
// Copyright © 2019 Apple Inc. All rights reserved.
//
#import <GameController/GCExtendedGamepad.h>
/**
The GCDualShockGamepad profile represents any supported DualShock 4 controller.
@see GCExtendedGamepad
@see GCMotion
*/
API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0))
@interface GCDualShockGamepad : GCExtendedGamepad
/**
DualShock controllers have a touchpad with a button and two-finger tracking.
*/
@property (nonatomic, readonly) GCControllerButtonInput *touchpadButton;
@property (nonatomic, readonly) GCControllerDirectionPad *touchpadPrimary;
@property (nonatomic, readonly) GCControllerDirectionPad *touchpadSecondary;
@end

View File

@ -0,0 +1,54 @@
//
// GCEventInteraction.h
// GameController
//
// Copyright © 2024 Apple Inc. All rights reserved.
//
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
typedef NS_OPTIONS(NSUInteger, GCUIEventTypes) {
GCUIEventTypeNone = (0U),
GCUIEventTypeGamepad = (1U << 0),
};
/**
* An interaction that indicates your views's intent to receive game controller
* events through the GameController framework.
*
* @discussion
* On some platforms controllers can be used to control the general UIKit user
* interface and for many views that is the default behavior. By attaching a
* \c GCEventInteraction to one or more of your app's views you get fine
* grained control over whether the controller events go through the UIEvent &
* UIResponder chain, or if they are decoupled from the UI and all incoming
* data is served via Game Controller framework.
*
* On visionOS, while the user is gazing a view with the \c GCEventInteraction,
* or one of its subviews, the interaction's \c handledEventTypes property
* determines whether the system will deliver game controller events through
* the Game Controller framework instead of through the UIEvent & UIResponder
* chain.
*
* On iOS, iPadOS, and tvOS, while a view with the \c GCEventInteraction, is
* the first responder, or is part of the current responder chain, the
* interaction's \c handledEventTypes property determines whether the system
* will deliver game controller events through the Game Controller framework
* instead of through the UIEvent & UIResponder chain.
*/
API_AVAILABLE(macCatalyst(18.0), ios(18.0), visionos(2.0)) API_UNAVAILABLE(tvos) API_UNAVAILABLE(macos)
@interface GCEventInteraction : NSObject <UIInteraction>
- (instancetype)init NS_DESIGNATED_INITIALIZER;
/**
* The types of game controller events that should be delivered through
* the Game Controller framework.
*/
@property (nonatomic, readwrite) GCUIEventTypes handledEventTypes;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,43 @@
//
// GCEventViewController.h
// GameController
//
// Copyright © 2018 Apple Inc. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <UIKit/UIViewController.h>
/**
A view controller subclass that allows fine grained control of the user interface system's handling
of game controller events. Set an instance of this class as your root view controller if you intend
to use GCController APIs for handling game controllers.
*/
API_AVAILABLE(macos(10.11), ios(9.0), tvos(9.0))
@interface GCEventViewController : UIViewController
/**
Controllers can be used to control the general UIKit user interface and for many views that is
the default behavior. By using a controller event view controller you get fine grained control
over whether the controller events go trough the UIEvent & UIResponder chain, or if they are
decoupled from the UI and all incoming data is served via GCController.
Defaults to NO - suppressing UIEvents from game controllers and presenting them via the GCController
API whilst this controller's view or any of it's subviews are the first responders. If you are not
using any UIView components or UIEvents in your application you should leave this as NO and process
your game controller events via the normal GCController API.
If set to YES the controller input will start flowing through UIEvent and the UIResponder
chain will be used. This gives you fine grained control over the event handling of the
controlled view and its subviews. You should stop using GCController instances and the corresponding
profiles if you no longer need to read input from them.
Note that unlike UIView.userInteractionEnabled this only controls the flow of game controller events.
@see GCController
@see UIView.userInteractionEnabled
*/
@property (nonatomic) BOOL controllerUserInteractionEnabled;
@end

View File

@ -0,0 +1,139 @@
//
// GCExtendedGamepad.h
// GameController
//
// Copyright (c) 2012 Apple Inc. All rights reserved.
//
#import <GameController/GCPhysicalInputProfile.h>
NS_ASSUME_NONNULL_BEGIN
@class GCController;
@class GCExtendedGamepadSnapshot;
/**
Extended Gamepad profile. Has all the physical features of a Standard Gamepad and more.
In comparison to the Standard gamepad, The directional pad on an Extended gamepad is optionally analog
as the two thumbsticks provided are required to be analog.
All controller profiles provide a base level of information about the controller they belong to.
A profile maps the hardware notion of a controller into a logical controller. One that a developer can
design for and depend on, no matter the underlying hardware.
*/
API_AVAILABLE(macos(10.9), ios(7.0), tvos(7.0))
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunguarded-availability"
@interface GCExtendedGamepad : GCPhysicalInputProfile
#pragma clang diagnostic pop
/**
A profile keeps a reference to the controller that this profile is mapping input from.
*/
#if !__has_feature(objc_arc)
@property (nonatomic, readonly, assign) GCController *controller;
#else
@property (nonatomic, readonly, weak) GCController *controller;
#endif
/**
Set this block if you want to be notified when a value on a element changed. If multiple elements have changed this block will be called
for each element that changed. As elements in a collection, such as the axis in a dpad, tend to change at the same time and thus
will only call this once with the collection as the element.
@param gamepad this gamepad that is being used to map the raw input data into logical values on controller elements such as the dpad or the buttons.
@param element the element that has been modified.
*/
typedef void (^GCExtendedGamepadValueChangedHandler)(GCExtendedGamepad *gamepad, GCControllerElement *element);
@property (nonatomic, copy, nullable) GCExtendedGamepadValueChangedHandler valueChangedHandler;
/**
Polls the state vector of the controller and saves it to a snapshot. The snapshot is stored in a device independent
format that can be serialized and used at a later date. This is useful for features such as quality assurance,
save game or replay functionality among many.
If your application is heavily multithreaded this may also be useful to guarantee atomicity of input handling as
a snapshot will not change based on user input once it is taken.
*/
- (GCExtendedGamepadSnapshot *)saveSnapshot API_DEPRECATED("GCExtendedGamepadSnapshot has been deprecated, use [GCController capture] instead", macos(10.9, 10.15), ios(7.0, 13.0), tvos(7.0, 13.0));
/**
Required to be analog in the Extended profile. All the elements of this directional input are thus analog.
*/
@property (nonatomic, readonly) GCControllerDirectionPad *dpad;
/**
All face buttons are required to be analog in the Extended profile. These must be arranged
in the diamond pattern given below:
Y
/ \
X B
\ /
A
*/
@property (nonatomic, readonly) GCControllerButtonInput *buttonA;
@property (nonatomic, readonly) GCControllerButtonInput *buttonB;
@property (nonatomic, readonly) GCControllerButtonInput *buttonX;
@property (nonatomic, readonly) GCControllerButtonInput *buttonY;
/**
Button menu is the primary menu button, and should be used to enter the main menu and pause the game.
*/
@property (nonatomic, readonly) GCControllerButtonInput *buttonMenu API_AVAILABLE(macos(10.15), ios(13.0), tvos(13.0));
/**
Button options is the secondary menu button. It should be used to enter a secondary menu, such as graphics and sound configuration, and pause the game.
*/
@property (nonatomic, readonly, nullable) GCControllerButtonInput *buttonOptions API_AVAILABLE(macos(10.15), ios(13.0), tvos(13.0));
/**
Button home is a special menu button. If the system does not consume button home events, they will be passed to your application and should be used to enter a secondary menu, and pause the game.
*/
@property (nonatomic, readonly, nullable) GCControllerButtonInput *buttonHome API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
/**
A thumbstick is a 2-axis control that is physically required to be analog. All the elements of this directional input are thus analog.
*/
@property (nonatomic, readonly) GCControllerDirectionPad *leftThumbstick;
/**
A thumbstick is a 2-axis control that is physically required to be analog. All the elements of this directional input are thus analog.
*/
@property (nonatomic, readonly) GCControllerDirectionPad *rightThumbstick;
/**
Shoulder buttons are required to be analog inputs.
*/
@property (nonatomic, readonly) GCControllerButtonInput *leftShoulder;
/**
Shoulder buttons are required to be analog inputs.
*/
@property (nonatomic, readonly) GCControllerButtonInput *rightShoulder;
/**
Triggers are required to be analog inputs. Common uses would be acceleration and decelleration in a driving game for example.
*/
@property (nonatomic, readonly) GCControllerButtonInput *leftTrigger;
@property (nonatomic, readonly) GCControllerButtonInput *rightTrigger;
/**
A thumbstick may also have a clickable component, which is treated as a non-analog button.
*/
@property (nonatomic, readonly, nullable) GCControllerButtonInput *leftThumbstickButton API_AVAILABLE(macos(10.14.1), ios(12.1), tvos(12.1));
@property (nonatomic, readonly, nullable) GCControllerButtonInput *rightThumbstickButton API_AVAILABLE(macos(10.14.1), ios(12.1), tvos(12.1));
/**
Sets the state vector of the extended gamepad to a copy of the input extended gamepad's state vector.
@note If the controller's snapshot flag is set to NO, this method has no effect.
@see GCController.snapshot
*/
- (void) setStateFromExtendedGamepad:(GCExtendedGamepad *)extendedGamepad API_AVAILABLE(macos(10.15), ios(13.0), tvos(13.0));
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,140 @@
//
// GCExtendedGamepadSnapshot.h
// GameController
//
// Copyright (c) 2012 Apple Inc. All rights reserved.
//
#import <GameController/GCExtendedGamepad.h>
NS_ASSUME_NONNULL_BEGIN
/**
A GCExtendedGamepadSnapshot snapshot is a concrete GCExtendedGamepad implementation. It can be used directly in an
application to implement controller input replays. It is also returned as the result of polling a controller.
The current snapshotData is readily available to access as NSData. A developer can serialize this to any
destination necessary using the NSData API.
The data contains some version of a GCExtendedGamepadSnapShotData structure.
@see -[GCExtendedGamepad saveSnapshot]
*/
API_DEPRECATED("GCExtendedGamepadSnapshot has been deprecated, use [GCController controllerWithExtendedGamepad] instead", macos(10.11, 10.15), ios(9.0, 13.0), tvos(9.0, 13.0))
@interface GCExtendedGamepadSnapshot : GCExtendedGamepad
@property (atomic, copy) NSData *snapshotData;
- (instancetype)initWithSnapshotData:(NSData *)data;
- (instancetype)initWithController:(GCController *)controller snapshotData:(NSData *)data;
@end
typedef NS_ENUM(NSInteger, GCExtendedGamepadSnapshotDataVersion) {
GCExtendedGamepadSnapshotDataVersion1 = 0x0100,
GCExtendedGamepadSnapshotDataVersion2 = 0x0101
} API_DEPRECATED("GCExtendedGamepadSnapshot has been deprecated, use [GCController controllerWithExtendedGamepad] instead", macos(10.11, 10.15), ios(9.0, 13.0), tvos(9.0, 13.0));
extern const GCExtendedGamepadSnapshotDataVersion GCCurrentExtendedGamepadSnapshotDataVersion API_DEPRECATED("GCExtendedGamepadSnapshot has been deprecated, use [GCController controllerWithExtendedGamepad] instead", macos(10.11, 10.15), ios(9.0, 13.0), tvos(9.0, 13.0));
#pragma pack(push, 1)
typedef struct {
#pragma mark - GCExtendedGamepadSnapshotDataVersion1+
uint16_t version;
uint16_t size;
// Extended gamepad data
// Axes in the range [-1.0, 1.0]
float dpadX;
float dpadY;
// Buttons in the range [0.0, 1.0]
float buttonA;
float buttonB;
float buttonX;
float buttonY;
float leftShoulder;
float rightShoulder;
// Axes in the range [-1.0, 1.0]
float leftThumbstickX;
float leftThumbstickY;
float rightThumbstickX;
float rightThumbstickY;
// Buttons in the range [0.0, 1.0]
float leftTrigger;
float rightTrigger;
#pragma mark - GCExtendedGamepadSnapshotDataVersion2+
// Boolean indicating whether the controller supports clickable thumbsticks (1) or not (0)
BOOL supportsClickableThumbsticks API_AVAILABLE(macos(10.14.1), ios(12.1), tvos(12.1));
// Left and right thumbstick clickable values (0, 1)
BOOL leftThumbstickButton API_AVAILABLE(macos(10.14.1), ios(12.1), tvos(12.1));
BOOL rightThumbstickButton API_AVAILABLE(macos(10.14.1), ios(12.1), tvos(12.1));
} GCExtendedGamepadSnapshotData API_DEPRECATED("GCExtendedGamepadSnapshot has been deprecated, use [GCController controllerWithExtendedGamepad] instead", macos(10.11, 10.15), ios(9.0, 13.0), tvos(9.0, 13.0));
#pragma pack(pop)
/**Fills out a snapshot from any compatible NSData source
@return NO if data is nil, snapshotData is nil or the contents of data does not contain a compatible snapshot. YES for all other cases.
*/
BOOL GCExtendedGamepadSnapshotDataFromNSData(GCExtendedGamepadSnapshotData *__nullable snapshotData, NSData *__nullable data) API_DEPRECATED("GCExtendedGamepadSnapshot has been deprecated, use [GCController controllerWithExtendedGamepad] instead", macos(10.11, 10.15), ios(9.0, 13.0), tvos(9.0, 13.0));
/**Creates an NSData object from a snapshot.
If the version and size is not set in the snapshot the data will automatically have the version GCCurrentExtendedGamepadSnapshotDataVersion and sizeof(GCExtendedGamepadSnapshotData) set as the values implicitly.
@return nil if the snapshot is NULL, otherwise an NSData instance compatible with GCExtendedGamepadSnapshot.snapshotData
*/
NSData *__nullable NSDataFromGCExtendedGamepadSnapshotData(GCExtendedGamepadSnapshotData *__nullable snapshotData) API_DEPRECATED("GCExtendedGamepadSnapshot has been deprecated, use [GCController controllerWithExtendedGamepad] instead", macos(10.11, 10.15), ios(9.0, 13.0), tvos(9.0, 13.0));
#pragma mark - Deprecated Versioning System
#pragma pack(push)
typedef struct {
// Standard information
uint16_t version; // 0x0100
uint16_t size; //sizeof(GCExtendedGamepadSnapShotDataV100) or larger
// Extended gamepad data
// Axes in the range [-1.0, 1.0]
float dpadX;
float dpadY;
// Buttons in the range [0.0, 1.0]
float buttonA;
float buttonB;
float buttonX;
float buttonY;
float leftShoulder;
float rightShoulder;
// Axes in the range [-1.0, 1.0]
float leftThumbstickX;
float leftThumbstickY;
float rightThumbstickX;
float rightThumbstickY;
// Buttons in the range [0.0, 1.0]
float leftTrigger;
float rightTrigger;
} GCExtendedGamepadSnapShotDataV100 API_DEPRECATED("GCExtendedGamepadSnapshot has been deprecated, use [GCController controllerWithExtendedGamepad] instead", macos(10.11, 10.15), ios(9.0, 13.0), tvos(9.0, 13.0));
#pragma pack(pop)
/**Fills out a v100 snapshot from any compatible NSData source
@return NO if data is nil, snapshotData is nil or the contents of data does not contain a compatible snapshot. YES for all other cases.
*/
BOOL GCExtendedGamepadSnapShotDataV100FromNSData(GCExtendedGamepadSnapShotDataV100 *__nullable snapshotData, NSData *__nullable data) API_DEPRECATED("GCExtendedGamepadSnapshot has been deprecated, use [GCController controllerWithExtendedGamepad] instead", macos(10.11, 10.15), ios(9.0, 13.0), tvos(9.0, 13.0));
/**Creates an NSData object from a v100 snapshot.
If the version and size is not set in the snapshot the data will automatically have version 0x100 and sizeof(GCExtendedGamepadSnapShotDataV100) set as the values implicitly.
@return nil if the snapshot is NULL, otherwise an NSData instance compatible with GCExtendedGamepadSnapshot.snapshotData
*/
NSData *__nullable NSDataFromGCExtendedGamepadSnapShotDataV100(GCExtendedGamepadSnapShotDataV100 *__nullable snapshotData) API_DEPRECATED("GCExtendedGamepadSnapshot has been deprecated, use [GCController controllerWithExtendedGamepad] instead", macos(10.11, 10.15), ios(9.0, 13.0), tvos(9.0, 13.0));
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,14 @@
//
// GCExtern.h
// GameController
//
// Copyright (c) 2017 Apple Inc. All rights reserved.
//
#ifdef __cplusplus
#define GAMECONTROLLER_EXTERN extern "C" __attribute__((visibility ("default")))
#else
#define GAMECONTROLLER_EXTERN extern __attribute__((visibility ("default")))
#endif

View File

@ -0,0 +1,26 @@
//
// GCGameControllerActivationContext.h
// GameController
//
// Copyright © 2024 Apple Inc. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <GameController/GCExtern.h>
NS_HEADER_AUDIT_BEGIN(nullability, sendability)
API_AVAILABLE(ios(18.0))
API_UNAVAILABLE(macCatalyst, tvos, visionos)
API_UNAVAILABLE(macos)
@interface GCGameControllerActivationContext : NSObject
- (instancetype)init NS_UNAVAILABLE;
/** The bundle identifier of the previously active application, if any. */
@property (nonatomic, nullable, readonly) NSString *previousApplicationBundleID;
@end
NS_HEADER_AUDIT_END(nullability, sendability)

View File

@ -0,0 +1,48 @@
//
// GCGameControllerSceneDelegate.h
// GameControllerFramework
//
// Created by Chris Donegan on 1/26/24.
//
#import <Foundation/Foundation.h>
#import <GameController/GCExtern.h>
#import <GameController/GCGameControllerActivationContext.h>
NS_HEADER_AUDIT_BEGIN(nullability, sendability)
GAMECONTROLLER_EXTERN
API_AVAILABLE(ios(18.0))
API_UNAVAILABLE(macCatalyst, tvos, visionos)
API_UNAVAILABLE(macos)
@protocol GCGameControllerSceneDelegate <NSObject>
/**
* The scene has activated in response to a game controller event.
*
* @param scene
* The activated scene
*
* @param context
* The game controller activation context
*/
- (void)scene:(UIScene *)scene didActivateGameControllerWithContext:(GCGameControllerActivationContext *)context;
@end
GAMECONTROLLER_EXTERN
API_AVAILABLE(ios(18.0))
API_UNAVAILABLE(macCatalyst, tvos, visionos)
API_UNAVAILABLE(macos)
@interface UISceneConnectionOptions (GameController)
/**
* The activation context if the scene is being connected in response to a
* game controller.
*/
@property (nonatomic, nullable, readonly) GCGameControllerActivationContext *gameControllerActivationContext;
@end
NS_HEADER_AUDIT_END(nullability, sendability)

View File

@ -0,0 +1,93 @@
//
// GCGamepad.h
// GameController
//
// Copyright (c) 2012 Apple Inc. All rights reserved.
//
#import <GameController/GCPhysicalInputProfile.h>
NS_ASSUME_NONNULL_BEGIN
@class GCController;
@class GCGamepadSnapshot;
/**
Standard Gamepad profile.
All controller profiles provide a base level of information about the controller they belong to.
A profile maps the hardware notion of a controller into a logical controller. One that a developer can design for
and depend on, no matter the underlying hardware.
*/
API_DEPRECATED_WITH_REPLACEMENT("GCExtendedGamepad", macos(10.9, 10.12), ios(7.0, 10.0), tvos(7.0, 10.0))
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunguarded-availability"
@interface GCGamepad : GCPhysicalInputProfile
#pragma clang diagnostic pop
/**
A profile keeps a reference to the controller that this profile is mapping input from.
*/
#if !__has_feature(objc_arc)
@property (nonatomic, readonly, assign) GCController *controller;
#else
@property (nonatomic, readonly, weak) GCController *controller;
#endif
/**
Set this block if you want to be notified when a value on a element changed. If multiple elements have changed this block will be called
for each element that changed. As elements in a collection, such as the axis in a dpad, tend to change at the same time and thus
will only call this once with the collection as the element.
@param gamepad this gamepad that is being used to map the raw input data into logical values on controller elements such as the dpad or the buttons.
@param element the element that has been modified.
*/
API_DEPRECATED("GCGamepad has been deprecated", macos(10.9, 10.12), ios(7.0, 10.0), tvos(7.0, 10.0))
typedef void (^GCGamepadValueChangedHandler)(GCGamepad *gamepad, GCControllerElement *element);
@property (nonatomic, copy, nullable) GCGamepadValueChangedHandler valueChangedHandler;
/**
Polls the state vector of the controller and saves it to a snapshot. The snapshot is stored in a device independent
format that can be serialized and used at a later date. This is useful for features such as quality assurance,
save game or replay functionality among many.
If your application is heavily multithreaded this may also be useful to guarantee atomicity of input handling as
a snapshot will not change based on user input once it is taken.
*/
- (GCGamepadSnapshot *)saveSnapshot;
/**
Required to be analog in the Standard profile. All the elements of this directional input are thus analog.
*/
@property (nonatomic, readonly) GCControllerDirectionPad *dpad;
/**
All face buttons are required to be analog in the Standard profile. These must be arranged
in the diamond pattern given below:
Y
/ \
X B
\ /
A
*/
@property (nonatomic, readonly) GCControllerButtonInput *buttonA;
@property (nonatomic, readonly) GCControllerButtonInput *buttonB;
@property (nonatomic, readonly) GCControllerButtonInput *buttonX;
@property (nonatomic, readonly) GCControllerButtonInput *buttonY;
/**
Shoulder buttons are required to be analog inputs.
*/
@property (nonatomic, readonly) GCControllerButtonInput *leftShoulder;
/**
Shoulder buttons are required to be analog inputs.
*/
@property (nonatomic, readonly) GCControllerButtonInput *rightShoulder;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,68 @@
//
// GCGamepadSnapshot.h
// GameController
//
// Copyright (c) 2012 Apple Inc. All rights reserved.
//
#import <GameController/GCGamepad.h>
NS_ASSUME_NONNULL_BEGIN
/**
A GCGamepadSnapshot snapshot is a concrete GCGamepad implementation. It can be used directly in an
application to implement controller input replays. It is also returned as the result of polling
a controller.
The current snapshotData is readily available to access as NSData. A developer can serialize this to any
destination necessary using the NSData API.
The data contains some version of a GCGamepadSnapShotData structure.
@see -[GCGamepad saveSnapshot]
*/
API_DEPRECATED("GCGamepad has been deprecated, use GCExtendedGamepad instead", macos(10.9, 10.15), ios(7.0, 13.0), tvos(7.0, 13.0))
@interface GCGamepadSnapshot : GCGamepad
@property (atomic, copy) NSData *snapshotData;
- (instancetype)initWithSnapshotData:(NSData *)data;
- (instancetype)initWithController:(GCController *)controller snapshotData:(NSData *)data;
@end
#pragma pack(push, 1)
typedef struct {
// Standard information
uint16_t version; //0x0100
uint16_t size; //sizeof(GCGamepadSnapShotDataV100) or larger
// Standard gamepad data
// Axes in the range [-1.0, 1.0]
float dpadX;
float dpadY;
// Buttons in the range [0.0, 1.0]
float buttonA;
float buttonB;
float buttonX;
float buttonY;
float leftShoulder;
float rightShoulder;
} GCGamepadSnapShotDataV100 API_DEPRECATED("GCGamepad has been deprecated, use GCExtendedGamepad instead", macos(10.9, 10.15), ios(7.0, 13.0), tvos(7.0, 13.0));
#pragma pack(pop)
/**Fills out a v100 snapshot from any compatible NSData source
@return NO if data is nil, snapshotData is nil or the contents of data does not contain a compatible snapshot. YES for all other cases.
*/
BOOL GCGamepadSnapShotDataV100FromNSData(GCGamepadSnapShotDataV100 *__nullable snapshotData, NSData *__nullable data) API_DEPRECATED("GCGamepad has been deprecated, use GCExtendedGamepad instead", macos(10.9, 10.15), ios(7.0, 13.0), tvos(7.0, 13.0));
/**Creates an NSData object from a v100 snapshot.
If the version and size is not set in the snapshot the data will automatically have version 0x100 and sizeof(GCGamepadSnapShotDataV100) set as the values implicitly.
@return nil if the snapshot is NULL, otherwise an NSData instance compatible with GCGamepadSnapshot.snapshotData
*/
NSData *__nullable NSDataFromGCGamepadSnapShotDataV100(GCGamepadSnapShotDataV100 *__nullable snapshotData) API_DEPRECATED("GCGamepad has been deprecated, use GCExtendedGamepad instead", macos(10.9, 10.15), ios(7.0, 13.0), tvos(7.0, 13.0));
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,38 @@
//
// GCGearShifterElement.h
// GameController
//
// Copyright © 2022 Apple Inc. All rights reserved.
//
#import <GameController/GCPhysicalInputElement.h>
#import <GameController/GCSwitchPositionInput.h>
#import <GameController/GCRelativeInput.h>
NS_ASSUME_NONNULL_BEGIN
/**
A \c GCGearShifterElement object represents an attached gear shifter. Both
pattern and sequential gear shifters are supported.
*/
API_AVAILABLE(macos(13.0), macCatalyst(16.0)) API_UNAVAILABLE(ios, tvos)
@interface GCGearShifterElement : NSObject <GCPhysicalInputElement>
/**
Get the input reporting the position of the pattern gear shifter. If this
property is \c nil, the gear shifter is not a pattern gear shifter.
In the returned input, a position of \c -1 corresponds to the "reverse gear".
A position of \c 0 corresponds to the neutral gear.
*/
@property (readonly, nullable) id<GCSwitchPositionInput> patternInput;
/**
Get the input reporting changes to the sequential gear shifter. If this
property is \c nil, the gear shifter is not a sequential gear shifter.
*/
@property (readonly, nullable) id<GCRelativeInput> sequentialInput;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,149 @@
//
// GCInputNames.h
// GameController
//
// Copyright © 2020 Apple Inc. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <GameController/GCExtern.h>
__attribute__((objc_non_runtime_protocol)) NS_REFINED_FOR_SWIFT
@protocol GCPhysicalInputElementName
@end
__attribute__((objc_non_runtime_protocol)) NS_REFINED_FOR_SWIFT
@protocol GCButtonElementName <GCPhysicalInputElementName>
@end
__attribute__((objc_non_runtime_protocol)) NS_REFINED_FOR_SWIFT
@protocol GCAxisElementName <GCPhysicalInputElementName>
@end
__attribute__((objc_non_runtime_protocol)) NS_REFINED_FOR_SWIFT
@protocol GCSwitchElementName <GCPhysicalInputElementName>
@end
__attribute__((objc_non_runtime_protocol)) NS_REFINED_FOR_SWIFT
@protocol GCDirectionPadElementName <GCPhysicalInputElementName>
@end
typedef NSString<GCPhysicalInputElementName> *const GCInputElementName NS_REFINED_FOR_SWIFT NS_TYPED_EXTENSIBLE_ENUM;
typedef NSString<GCButtonElementName> *const GCInputButtonName NS_REFINED_FOR_SWIFT NS_TYPED_EXTENSIBLE_ENUM;
typedef NSString<GCAxisElementName> *const GCInputAxisName NS_REFINED_FOR_SWIFT NS_TYPED_EXTENSIBLE_ENUM;
typedef NSString<GCSwitchElementName> *const GCInputSwitchName NS_REFINED_FOR_SWIFT NS_TYPED_EXTENSIBLE_ENUM;
typedef NSString<GCDirectionPadElementName> *const GCInputDirectionPadName NS_REFINED_FOR_SWIFT NS_TYPED_EXTENSIBLE_ENUM;
/**
A set of commonly used strings that can be used to access controller buttons
@example controller.physicalInputProfile.buttons[GCInputButtonA]
@see GCController.h
@see GCPhysicalInputProfile.h
*/
GAMECONTROLLER_EXTERN GCInputButtonName GCInputButtonA API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)) NS_SWIFT_NAME(a);
GAMECONTROLLER_EXTERN GCInputButtonName GCInputButtonB API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)) NS_SWIFT_NAME(b);
GAMECONTROLLER_EXTERN GCInputButtonName GCInputButtonX API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)) NS_SWIFT_NAME(x);
GAMECONTROLLER_EXTERN GCInputButtonName GCInputButtonY API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)) NS_SWIFT_NAME(y);
GAMECONTROLLER_EXTERN GCInputDirectionPadName GCInputDirectionPad API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)) NS_SWIFT_NAME(directionPad);
GAMECONTROLLER_EXTERN GCInputDirectionPadName GCInputLeftThumbstick API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
GAMECONTROLLER_EXTERN GCInputDirectionPadName GCInputRightThumbstick API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
GAMECONTROLLER_EXTERN GCInputButtonName GCInputLeftThumbstickButton API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
GAMECONTROLLER_EXTERN GCInputButtonName GCInputRightThumbstickButton API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
/*
* Shoulder Buttons
*/
GAMECONTROLLER_EXTERN GCInputButtonName GCInputLeftShoulder API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
GAMECONTROLLER_EXTERN GCInputButtonName GCInputRightShoulder API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
/**
* Identifies the button element located at the top-left/right of a gamepad,
* between the left/right shoulder button and the gamepad's horizontal center.
*/
GAMECONTROLLER_EXTERN GCInputButtonName GCInputLeftBumper API_AVAILABLE(macos(14.4), ios(17.4), tvos(17.4), visionos(1.1));
GAMECONTROLLER_EXTERN GCInputButtonName GCInputRightBumper API_AVAILABLE(macos(14.4), ios(17.4), tvos(17.4), visionos(1.1));
GAMECONTROLLER_EXTERN GCInputButtonName GCInputLeftTrigger API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
GAMECONTROLLER_EXTERN GCInputButtonName GCInputRightTrigger API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
/*
* Back Buttons
*
* Some gamepads include additional buttons or triggers on their underside.
* Because the number and layout of bottom buttons can vary by controller, the
* Game Controller framework identifies them by their ease of operation. The
* back left and right buttons at the first position are located nearest the
* natural rest position of the user's fingers and are suitable for actions
* requiring repeated inputs. The buttons at the 'second' position may require
* the user to move their fingers to press and should be used for less frequent
* actions.
*
* Example view looking at the underside of a gamepad with four back buttons
* arranged horizontally:
*
* +---------------------------------------------------------------+
* | Controller top |
* +---------------------------------------------------------------+
* | |
* R | [(R) 0] [(R) 1] [(L) 1] [(L) 0] | L
* | |
* +---------------------------------------------------------------|
* | Controller bottom (nearest the user) |
* +---------------------------------------------------------------+
*/
/* Note: The `position` argument begins at index 0. */
GAMECONTROLLER_EXTERN GCInputButtonName GCInputBackLeftButton(NSInteger position) NS_REFINED_FOR_SWIFT API_AVAILABLE(macos(14.4), ios(17.4), tvos(17.4), visionos(1.1));
GAMECONTROLLER_EXTERN GCInputButtonName GCInputBackRightButton(NSInteger position) NS_REFINED_FOR_SWIFT API_AVAILABLE(macos(14.4), ios(17.4), tvos(17.4), visionos(1.1));
GAMECONTROLLER_EXTERN GCInputButtonName GCInputButtonHome API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
GAMECONTROLLER_EXTERN GCInputButtonName GCInputButtonMenu API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
GAMECONTROLLER_EXTERN GCInputButtonName GCInputButtonOptions API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
GAMECONTROLLER_EXTERN GCInputButtonName GCInputButtonShare API_AVAILABLE(macos(12.0), ios(15.0), tvos(15.0));
/**
A set of strings commonly used to access Xbox buttons
@example controller.physicalInputProfile.buttons[GCInputButtonPaddleOne]
@see GCController.h
@see GCPhysicalInputProfile.h
*/
GAMECONTROLLER_EXTERN GCInputButtonName GCInputXboxPaddleOne API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
GAMECONTROLLER_EXTERN GCInputButtonName GCInputXboxPaddleTwo API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
GAMECONTROLLER_EXTERN GCInputButtonName GCInputXboxPaddleThree API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
GAMECONTROLLER_EXTERN GCInputButtonName GCInputXboxPaddleFour API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
/**
A set of strings commonly used to access DualShock buttons
@example controller.physicalInputProfile.dpads[GCInputDualShockTouchpadOne]
@see GCController.h
@see GCPhysicalInputProfile.h
*/
GAMECONTROLLER_EXTERN GCInputDirectionPadName GCInputDualShockTouchpadOne API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
GAMECONTROLLER_EXTERN GCInputDirectionPadName GCInputDualShockTouchpadTwo API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
GAMECONTROLLER_EXTERN GCInputButtonName GCInputDualShockTouchpadButton API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
/**
A set of strings commonly used by racing wheels.
*/
GAMECONTROLLER_EXTERN GCInputAxisName GCInputSteeringWheel API_AVAILABLE(macos(13.0), macCatalyst(16.0)) API_UNAVAILABLE(ios, tvos);
GAMECONTROLLER_EXTERN GCInputElementName GCInputShifter API_AVAILABLE(macos(13.0), macCatalyst(16.0)) API_UNAVAILABLE(ios, tvos);
GAMECONTROLLER_EXTERN GCInputButtonName GCInputPedalAccelerator API_AVAILABLE(macos(13.0), macCatalyst(16.0)) API_UNAVAILABLE(ios, tvos);
GAMECONTROLLER_EXTERN GCInputButtonName GCInputPedalBrake API_AVAILABLE(macos(13.0), macCatalyst(16.0)) API_UNAVAILABLE(ios, tvos);
GAMECONTROLLER_EXTERN GCInputButtonName GCInputPedalClutch API_AVAILABLE(macos(13.0), macCatalyst(16.0)) API_UNAVAILABLE(ios, tvos);
GAMECONTROLLER_EXTERN GCInputButtonName GCInputLeftPaddle API_AVAILABLE(macos(13.0), macCatalyst(16.0)) API_UNAVAILABLE(ios, tvos);
GAMECONTROLLER_EXTERN GCInputButtonName GCInputRightPaddle API_AVAILABLE(macos(13.0), macCatalyst(16.0)) API_UNAVAILABLE(ios, tvos);
/// Gets the name of an arcade button at a certain position.
GAMECONTROLLER_EXTERN GCInputButtonName GCInputArcadeButtonName(NSInteger row, NSInteger column) NS_REFINED_FOR_SWIFT API_AVAILABLE(macos(13.0), ios(16.0), tvos(16.0));

View File

@ -0,0 +1,179 @@
//
// GCKeyCodes.h
// GameController
//
// Copyright © 2020 Apple Inc. All rights reserved.
//
#import <GameController/GCExtern.h>
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
/**
A set of low level key codes that can be used to access keyboard buttons
@example [keyboard.keyboardInput buttonForKeyCode:GCKeyCodeSpacebar]
@see GCKeyboardInput.h
*/
typedef CFIndex GCKeyCode NS_TYPED_ENUM API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeKeyA API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* a or A */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeKeyB API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* b or B */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeKeyC API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* c or C */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeKeyD API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* d or D */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeKeyE API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* e or E */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeKeyF API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* f or F */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeKeyG API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* g or G */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeKeyH API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* h or H */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeKeyI API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* i or I */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeKeyJ API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* j or J */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeKeyK API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* k or K */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeKeyL API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* l or L */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeKeyM API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* m or M */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeKeyN API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* n or N */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeKeyO API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* o or O */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeKeyP API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* p or P */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeKeyQ API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* q or Q */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeKeyR API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* r or R */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeKeyS API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* s or S */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeKeyT API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* t or T */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeKeyU API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* u or U */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeKeyV API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* v or V */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeKeyW API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* w or W */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeKeyX API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* x or X */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeKeyY API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* y or Y */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeKeyZ API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* z or Z */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeOne API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* 1 or ! */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeTwo API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* 2 or @ */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeThree API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* 3 or # */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeFour API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* 4 or $ */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeFive API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* 5 or % */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeSix API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* 6 or ^ */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeSeven API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* 7 or & */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeEight API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* 8 or * */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeNine API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* 9 or ( */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeZero API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* 0 or ) */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeReturnOrEnter API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* Return (Enter) */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeEscape API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* Escape */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeDeleteOrBackspace API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* Delete (Backspace) */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeTab API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* Tab */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeSpacebar API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* Spacebar */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeHyphen API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* - or _ */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeEqualSign API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* = or + */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeOpenBracket API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* [ or { */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeCloseBracket API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* ] or } */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeBackslash API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* \ or | */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeNonUSPound API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* Non-US # or _ */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeSemicolon API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* ; or : */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeQuote API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* ' or " */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeGraveAccentAndTilde API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* Grave Accent and Tilde */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeComma API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* , or < */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodePeriod API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* . or > */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeSlash API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* / or ? */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeCapsLock API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* Caps Lock */
/* Function keys */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeF1 API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* F1 */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeF2 API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* F2 */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeF3 API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* F3 */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeF4 API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* F4 */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeF5 API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* F5 */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeF6 API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* F6 */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeF7 API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* F7 */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeF8 API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* F8 */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeF9 API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* F9 */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeF10 API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* F10 */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeF11 API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* F11 */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeF12 API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* F12 */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeF13 API_AVAILABLE(macos(12.0), ios(15.0), tvos(15.0)); /* F13 */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeF14 API_AVAILABLE(macos(12.0), ios(15.0), tvos(15.0)); /* F14 */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeF15 API_AVAILABLE(macos(12.0), ios(15.0), tvos(15.0)); /* F15 */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeF16 API_AVAILABLE(macos(12.0), ios(15.0), tvos(15.0)); /* F16 */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeF17 API_AVAILABLE(macos(12.0), ios(15.0), tvos(15.0)); /* F17 */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeF18 API_AVAILABLE(macos(12.0), ios(15.0), tvos(15.0)); /* F18 */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeF19 API_AVAILABLE(macos(12.0), ios(15.0), tvos(15.0)); /* F19 */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeF20 API_AVAILABLE(macos(12.0), ios(15.0), tvos(15.0)); /* F20 */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodePrintScreen API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* Print Screen */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeScrollLock API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* Scroll Lock */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodePause API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* Pause */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeInsert API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* Insert */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeHome API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* Home */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodePageUp API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* Page Up */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeDeleteForward API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* Delete Forward */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeEnd API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* End */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodePageDown API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* Page Down */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeRightArrow API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* Right Arrow */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeLeftArrow API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* Left Arrow */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeDownArrow API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* Down Arrow */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeUpArrow API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* Up Arrow */
/* Keypad (numpad) keys */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeKeypadNumLock API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* Keypad NumLock or Clear */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeKeypadSlash API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* Keypad / */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeKeypadAsterisk API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* Keypad * */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeKeypadHyphen API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* Keypad - */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeKeypadPlus API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* Keypad + */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeKeypadEnter API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* Keypad Enter */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeKeypad1 API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* Keypad 1 or End */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeKeypad2 API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* Keypad 2 or Down Arrow */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeKeypad3 API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* Keypad 3 or Page Down */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeKeypad4 API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* Keypad 4 or Left Arrow */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeKeypad5 API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* Keypad 5 */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeKeypad6 API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* Keypad 6 or Right Arrow */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeKeypad7 API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* Keypad 7 or Home */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeKeypad8 API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* Keypad 8 or Up Arrow */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeKeypad9 API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* Keypad 9 or Page Up */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeKeypad0 API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* Keypad 0 or Insert */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeKeypadPeriod API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* Keypad . or Delete */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeKeypadEqualSign API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* Keypad = */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeNonUSBackslash API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* Non-US \ or | */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeApplication API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* Application */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodePower API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* Power */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeInternational1 API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* International1 */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeInternational2 API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* International2 */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeInternational3 API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* International3 */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeInternational4 API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* International4 */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeInternational5 API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* International5 */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeInternational6 API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* International6 */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeInternational7 API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* International7 */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeInternational8 API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* International8 */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeInternational9 API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* International9 */
/* LANG1: On Apple keyboard for Japanese, this is the kana switch (かな) key */
/* On Korean keyboards, this is the Hangul/English toggle key. */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeLANG1 API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* LANG1 */
/* LANG2: On Apple keyboards for Japanese, this is the alphanumeric (英数) key */
/* On Korean keyboards, this is the Hanja conversion key. */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeLANG2 API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* LANG2 */
/* LANG3: Defines the Katakana key for Japanese USB word-processing keyboards. */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeLANG3 API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* LANG3 */
/* LANG4: Defines the Hiragana key for Japanese USB word-processing keyboards. */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeLANG4 API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* LANG4 */
/* LANG5: Defines the Zenkaku/Hankaku key for Japanese USB word-processing keyboards. */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeLANG5 API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* LANG5 */
/* LANG6-9: Reserved for language-specific functions, such as Front End Processors and Input Method Editors. */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeLANG6 API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* LANG6 */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeLANG7 API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* LANG7 */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeLANG8 API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* LANG8 */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeLANG9 API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* LANG9 */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeLeftControl API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* Left Control */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeLeftShift API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* Left Shift */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeLeftAlt API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* Left Alt */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeLeftGUI API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* Left GUI */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeRightControl API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* Right Control */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeRightShift API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* Right Shift */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeRightAlt API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* Right Alt */
GAMECONTROLLER_EXTERN GCKeyCode const GCKeyCodeRightGUI API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* Right GUI */
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,177 @@
//
// GCKeys.h
// GameController
//
// Copyright © 2020 Apple Inc. All rights reserved.
//
#import <GameController/GCExtern.h>
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
/**
A set of strings that can be used to access keyboard buttons
@example keyboard.physicalInputProfile.buttons[GCKeySpacebar]
@see GCKeyboardInput.h
@see GCPhysicalInputProfile.h
*/
GAMECONTROLLER_EXTERN NSString *const GCKeyA API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* a or A */
GAMECONTROLLER_EXTERN NSString *const GCKeyB API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* b or B */
GAMECONTROLLER_EXTERN NSString *const GCKeyC API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* c or C */
GAMECONTROLLER_EXTERN NSString *const GCKeyD API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* d or D */
GAMECONTROLLER_EXTERN NSString *const GCKeyE API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* e or E */
GAMECONTROLLER_EXTERN NSString *const GCKeyF API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* f or F */
GAMECONTROLLER_EXTERN NSString *const GCKeyG API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* g or G */
GAMECONTROLLER_EXTERN NSString *const GCKeyH API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* h or H */
GAMECONTROLLER_EXTERN NSString *const GCKeyI API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* i or I */
GAMECONTROLLER_EXTERN NSString *const GCKeyJ API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* j or J */
GAMECONTROLLER_EXTERN NSString *const GCKeyK API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* k or K */
GAMECONTROLLER_EXTERN NSString *const GCKeyL API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* l or L */
GAMECONTROLLER_EXTERN NSString *const GCKeyM API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* m or M */
GAMECONTROLLER_EXTERN NSString *const GCKeyN API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* n or N */
GAMECONTROLLER_EXTERN NSString *const GCKeyO API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* o or O */
GAMECONTROLLER_EXTERN NSString *const GCKeyP API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* p or P */
GAMECONTROLLER_EXTERN NSString *const GCKeyQ API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* q or Q */
GAMECONTROLLER_EXTERN NSString *const GCKeyR API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* r or R */
GAMECONTROLLER_EXTERN NSString *const GCKeyS API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* s or S */
GAMECONTROLLER_EXTERN NSString *const GCKeyT API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* t or T */
GAMECONTROLLER_EXTERN NSString *const GCKeyU API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* u or U */
GAMECONTROLLER_EXTERN NSString *const GCKeyV API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* v or V */
GAMECONTROLLER_EXTERN NSString *const GCKeyW API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* w or W */
GAMECONTROLLER_EXTERN NSString *const GCKeyX API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* x or X */
GAMECONTROLLER_EXTERN NSString *const GCKeyY API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* y or Y */
GAMECONTROLLER_EXTERN NSString *const GCKeyZ API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* z or Z */
GAMECONTROLLER_EXTERN NSString *const GCKeyOne API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* 1 or ! */
GAMECONTROLLER_EXTERN NSString *const GCKeyTwo API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* 2 or @ */
GAMECONTROLLER_EXTERN NSString *const GCKeyThree API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* 3 or # */
GAMECONTROLLER_EXTERN NSString *const GCKeyFour API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* 4 or $ */
GAMECONTROLLER_EXTERN NSString *const GCKeyFive API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* 5 or % */
GAMECONTROLLER_EXTERN NSString *const GCKeySix API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* 6 or ^ */
GAMECONTROLLER_EXTERN NSString *const GCKeySeven API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* 7 or & */
GAMECONTROLLER_EXTERN NSString *const GCKeyEight API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* 8 or * */
GAMECONTROLLER_EXTERN NSString *const GCKeyNine API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* 9 or ( */
GAMECONTROLLER_EXTERN NSString *const GCKeyZero API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* 0 or ) */
GAMECONTROLLER_EXTERN NSString *const GCKeyReturnOrEnter API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* Return (Enter) */
GAMECONTROLLER_EXTERN NSString *const GCKeyEscape API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* Escape */
GAMECONTROLLER_EXTERN NSString *const GCKeyDeleteOrBackspace API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* Delete (Backspace) */
GAMECONTROLLER_EXTERN NSString *const GCKeyTab API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* Tab */
GAMECONTROLLER_EXTERN NSString *const GCKeySpacebar API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* Spacebar */
GAMECONTROLLER_EXTERN NSString *const GCKeyHyphen API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* - or _ */
GAMECONTROLLER_EXTERN NSString *const GCKeyEqualSign API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* = or + */
GAMECONTROLLER_EXTERN NSString *const GCKeyOpenBracket API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* [ or { */
GAMECONTROLLER_EXTERN NSString *const GCKeyCloseBracket API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* ] or } */
GAMECONTROLLER_EXTERN NSString *const GCKeyBackslash API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* \ or | */
GAMECONTROLLER_EXTERN NSString *const GCKeyNonUSPound API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* Non-US # or _ */
GAMECONTROLLER_EXTERN NSString *const GCKeySemicolon API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* ; or : */
GAMECONTROLLER_EXTERN NSString *const GCKeyQuote API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* ' or " */
GAMECONTROLLER_EXTERN NSString *const GCKeyGraveAccentAndTilde API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* Grave Accent and Tilde */
GAMECONTROLLER_EXTERN NSString *const GCKeyComma API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* , or < */
GAMECONTROLLER_EXTERN NSString *const GCKeyPeriod API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* . or > */
GAMECONTROLLER_EXTERN NSString *const GCKeySlash API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* / or ? */
GAMECONTROLLER_EXTERN NSString *const GCKeyCapsLock API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* Caps Lock */
/* Function keys */
GAMECONTROLLER_EXTERN NSString *const GCKeyF1 API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* F1 */
GAMECONTROLLER_EXTERN NSString *const GCKeyF2 API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* F2 */
GAMECONTROLLER_EXTERN NSString *const GCKeyF3 API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* F3 */
GAMECONTROLLER_EXTERN NSString *const GCKeyF4 API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* F4 */
GAMECONTROLLER_EXTERN NSString *const GCKeyF5 API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* F5 */
GAMECONTROLLER_EXTERN NSString *const GCKeyF6 API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* F6 */
GAMECONTROLLER_EXTERN NSString *const GCKeyF7 API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* F7 */
GAMECONTROLLER_EXTERN NSString *const GCKeyF8 API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* F8 */
GAMECONTROLLER_EXTERN NSString *const GCKeyF9 API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* F9 */
GAMECONTROLLER_EXTERN NSString *const GCKeyF10 API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* F10 */
GAMECONTROLLER_EXTERN NSString *const GCKeyF11 API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* F11 */
GAMECONTROLLER_EXTERN NSString *const GCKeyF12 API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* F12 */
GAMECONTROLLER_EXTERN NSString *const GCKeyF13 API_AVAILABLE(macos(12.0), ios(15.0), tvos(15.0)); /* F13 */
GAMECONTROLLER_EXTERN NSString *const GCKeyF14 API_AVAILABLE(macos(12.0), ios(15.0), tvos(15.0)); /* F14 */
GAMECONTROLLER_EXTERN NSString *const GCKeyF15 API_AVAILABLE(macos(12.0), ios(15.0), tvos(15.0)); /* F15 */
GAMECONTROLLER_EXTERN NSString *const GCKeyF16 API_AVAILABLE(macos(12.0), ios(15.0), tvos(15.0)); /* F16 */
GAMECONTROLLER_EXTERN NSString *const GCKeyF17 API_AVAILABLE(macos(12.0), ios(15.0), tvos(15.0)); /* F17 */
GAMECONTROLLER_EXTERN NSString *const GCKeyF18 API_AVAILABLE(macos(12.0), ios(15.0), tvos(15.0)); /* F18 */
GAMECONTROLLER_EXTERN NSString *const GCKeyF19 API_AVAILABLE(macos(12.0), ios(15.0), tvos(15.0)); /* F19 */
GAMECONTROLLER_EXTERN NSString *const GCKeyF20 API_AVAILABLE(macos(12.0), ios(15.0), tvos(15.0)); /* F20 */
GAMECONTROLLER_EXTERN NSString *const GCKeyPrintScreen API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* Print Screen */
GAMECONTROLLER_EXTERN NSString *const GCKeyScrollLock API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* Scroll Lock */
GAMECONTROLLER_EXTERN NSString *const GCKeyPause API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* Pause */
GAMECONTROLLER_EXTERN NSString *const GCKeyInsert API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* Insert */
GAMECONTROLLER_EXTERN NSString *const GCKeyHome API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* Home */
GAMECONTROLLER_EXTERN NSString *const GCKeyPageUp API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* Page Up */
GAMECONTROLLER_EXTERN NSString *const GCKeyDeleteForward API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* Delete Forward */
GAMECONTROLLER_EXTERN NSString *const GCKeyEnd API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* End */
GAMECONTROLLER_EXTERN NSString *const GCKeyPageDown API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* Page Down */
GAMECONTROLLER_EXTERN NSString *const GCKeyRightArrow API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* Right Arrow */
GAMECONTROLLER_EXTERN NSString *const GCKeyLeftArrow API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* Left Arrow */
GAMECONTROLLER_EXTERN NSString *const GCKeyDownArrow API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* Down Arrow */
GAMECONTROLLER_EXTERN NSString *const GCKeyUpArrow API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* Up Arrow */
/* Keypad (numpad) keys */
GAMECONTROLLER_EXTERN NSString *const GCKeyKeypadNumLock API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* Keypad NumLock or Clear */
GAMECONTROLLER_EXTERN NSString *const GCKeyKeypadSlash API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* Keypad / */
GAMECONTROLLER_EXTERN NSString *const GCKeyKeypadAsterisk API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* Keypad * */
GAMECONTROLLER_EXTERN NSString *const GCKeyKeypadHyphen API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* Keypad - */
GAMECONTROLLER_EXTERN NSString *const GCKeyKeypadPlus API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* Keypad + */
GAMECONTROLLER_EXTERN NSString *const GCKeyKeypadEnter API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* Keypad Enter */
GAMECONTROLLER_EXTERN NSString *const GCKeyKeypad1 API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* Keypad 1 or End */
GAMECONTROLLER_EXTERN NSString *const GCKeyKeypad2 API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* Keypad 2 or Down Arrow */
GAMECONTROLLER_EXTERN NSString *const GCKeyKeypad3 API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* Keypad 3 or Page Down */
GAMECONTROLLER_EXTERN NSString *const GCKeyKeypad4 API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* Keypad 4 or Left Arrow */
GAMECONTROLLER_EXTERN NSString *const GCKeyKeypad5 API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* Keypad 5 */
GAMECONTROLLER_EXTERN NSString *const GCKeyKeypad6 API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* Keypad 6 or Right Arrow */
GAMECONTROLLER_EXTERN NSString *const GCKeyKeypad7 API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* Keypad 7 or Home */
GAMECONTROLLER_EXTERN NSString *const GCKeyKeypad8 API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* Keypad 8 or Up Arrow */
GAMECONTROLLER_EXTERN NSString *const GCKeyKeypad9 API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* Keypad 9 or Page Up */
GAMECONTROLLER_EXTERN NSString *const GCKeyKeypad0 API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* Keypad 0 or Insert */
GAMECONTROLLER_EXTERN NSString *const GCKeyKeypadPeriod API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* Keypad . or Delete */
GAMECONTROLLER_EXTERN NSString *const GCKeyKeypadEqualSign API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* Keypad = */
GAMECONTROLLER_EXTERN NSString *const GCKeyNonUSBackslash API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* Non-US \ or | */
GAMECONTROLLER_EXTERN NSString *const GCKeyApplication API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* Application */
GAMECONTROLLER_EXTERN NSString *const GCKeyPower API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* Power */
GAMECONTROLLER_EXTERN NSString *const GCKeyInternational1 API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* International1 */
GAMECONTROLLER_EXTERN NSString *const GCKeyInternational2 API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* International2 */
GAMECONTROLLER_EXTERN NSString *const GCKeyInternational3 API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* International3 */
GAMECONTROLLER_EXTERN NSString *const GCKeyInternational4 API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* International4 */
GAMECONTROLLER_EXTERN NSString *const GCKeyInternational5 API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* International5 */
GAMECONTROLLER_EXTERN NSString *const GCKeyInternational6 API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* International6 */
GAMECONTROLLER_EXTERN NSString *const GCKeyInternational7 API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* International7 */
GAMECONTROLLER_EXTERN NSString *const GCKeyInternational8 API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* International8 */
GAMECONTROLLER_EXTERN NSString *const GCKeyInternational9 API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* International9 */
/* LANG1: On Apple keyboard for Japanese, this is the kana switch (かな) key */
/* On Korean keyboards, this is the Hangul/English toggle key. */
GAMECONTROLLER_EXTERN NSString *const GCKeyLANG1 API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* LANG1 */
/* LANG2: On Apple keyboards for Japanese, this is the alphanumeric (英数) key */
/* On Korean keyboards, this is the Hanja conversion key. */
GAMECONTROLLER_EXTERN NSString *const GCKeyLANG2 API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* LANG2 */
/* LANG3: Defines the Katakana key for Japanese USB word-processing keyboards. */
GAMECONTROLLER_EXTERN NSString *const GCKeyLANG3 API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* LANG3 */
/* LANG4: Defines the Hiragana key for Japanese USB word-processing keyboards. */
GAMECONTROLLER_EXTERN NSString *const GCKeyLANG4 API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* LANG4 */
/* LANG5: Defines the Zenkaku/Hankaku key for Japanese USB word-processing keyboards. */
GAMECONTROLLER_EXTERN NSString *const GCKeyLANG5 API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* LANG5 */
/* LANG6-9: Reserved for language-specific functions, such as Front End Processors and Input Method Editors. */
GAMECONTROLLER_EXTERN NSString *const GCKeyLANG6 API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* LANG6 */
GAMECONTROLLER_EXTERN NSString *const GCKeyLANG7 API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* LANG7 */
GAMECONTROLLER_EXTERN NSString *const GCKeyLANG8 API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* LANG8 */
GAMECONTROLLER_EXTERN NSString *const GCKeyLANG9 API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* LANG9 */
GAMECONTROLLER_EXTERN NSString *const GCKeyLeftControl API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* Left Control */
GAMECONTROLLER_EXTERN NSString *const GCKeyLeftShift API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* Left Shift */
GAMECONTROLLER_EXTERN NSString *const GCKeyLeftAlt API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* Left Alt */
GAMECONTROLLER_EXTERN NSString *const GCKeyLeftGUI API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* Left GUI */
GAMECONTROLLER_EXTERN NSString *const GCKeyRightControl API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* Right Control */
GAMECONTROLLER_EXTERN NSString *const GCKeyRightShift API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* Right Shift */
GAMECONTROLLER_EXTERN NSString *const GCKeyRightAlt API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* Right Alt */
GAMECONTROLLER_EXTERN NSString *const GCKeyRightGUI API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0)); /* Right GUI */
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,58 @@
//
// GCKeyboard.h
// GameController
//
// Copyright © 2020 Apple Inc. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <GameController/GCExtern.h>
#import <GameController/GCDevice.h>
@class GCKeyboard;
@class GCKeyboardInput;
NS_ASSUME_NONNULL_BEGIN
/**
Use these constants with NSNotificationCenter to listen to connection and disconnection events
Use GCKeyboardDidConnectNotification for observing keyboard connection
Use GCKeyboardDidDisconnectNotification for observing keyboard disconnection
The 'object' property of the notification will contain the GCKeyboard that was connected or disconnected.
@see NSNotificationCetner
@note All connected keyboards are coalesced into one keyboard object, so notification about connection/disconnection will only be delivered once until last keyboard disconnects.
*/
GAMECONTROLLER_EXTERN NSString *const GCKeyboardDidConnectNotification API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
GAMECONTROLLER_EXTERN NSString *const GCKeyboardDidDisconnectNotification API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
/**
GCKeyboard is available to an application that links to GameController.framework
There are 2 ways to access keyboard paired to the system:
1: Querying for the coalescedKeyboard using [GCKeyboard coalescedKeyboard]
2: Registering for Connection/Disconnection notifications from NSNotificationCenter
@note All connected keyboards are coalesced into one keyboard object, so notification about connection/disconnection will only be delivered once.
*/
API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0))
@interface GCKeyboard : NSObject <GCDevice>
/**
Unlike GCController GCKeyboard only has one input profile.
This profile allows you to query buttons and button state
*/
@property (nonatomic, strong, readonly, nullable) GCKeyboardInput *keyboardInput API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
/**
Keyboard object that represents all keyboards connected to the device
Should be used to query key states every time input needs to be handled
*/
@property (class, atomic, strong, readonly, nullable) GCKeyboard *coalescedKeyboard API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,49 @@
//
// GCKeyboardInput.h
// GameController
//
// Copyright © 2020 Apple Inc. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <GameController/GCExtern.h>
#import <GameController/GCPhysicalInputProfile.h>
NS_ASSUME_NONNULL_BEGIN
/**
Keyboard profile. Contains the current state of buttons specified in GCKeyCodes.h.
GCKeyboardInput is designed primarly for input polling. For the best text input experience, UIKit/AppKit usage is recommended.
*/
API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0))
@interface GCKeyboardInput : GCPhysicalInputProfile
/**
Set this block if you want to be notified when a value of a key changed. If multiple keys have changed this block will be called
cd for each key that changed.
@param keyboard this keyboard that is being used to map the raw input data into logical values on keyboard keys.
@param key the key that has been modified
@param pressed the state of the key at the moment of block calling
*/
typedef void (^GCKeyboardValueChangedHandler)(GCKeyboardInput *keyboard, GCDeviceButtonInput *key, GCKeyCode keyCode, BOOL pressed);
@property (nonatomic, copy, nullable) GCKeyboardValueChangedHandler keyChangedHandler;
/**
Before querying any key for a value it might be useful to check if any key is actually pressed
*/
@property (nonatomic, readonly, getter = isAnyKeyPressed) BOOL anyKeyPressed;
/**
Alongside general subscript notation of GCPhysicalInputProfile keys can be accessed using this method.
@example [keyboard buttonForKey:GCKeyCode.UpArrow] == keyboard[GCKeyUpArrow]
@param code is a low level key code that can be used for accessing a keyboard button.
@note Full list of supported key constants can be found in GCKeyCodes.h and GCKeyNames.h
*/
- (GCDeviceButtonInput * _Nullable)buttonForKeyCode:(GCKeyCode)code;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,87 @@
//
// GCLinearInput.h
// GameController
//
// Copyright © 2021 Apple Inc. All rights reserved.
//
#import <Foundation/Foundation.h>
@protocol GCPhysicalInputElement;
@protocol GCPhysicalInputSource;
NS_ASSUME_NONNULL_BEGIN
/**
An object conforming to \c GCLinearInput represents an input that produces
normalized values in the unit interval - between [0, 1].
*/
API_AVAILABLE(macos(13.0), ios(16.0), tvos(16.0))
@protocol GCLinearInput <NSObject>
/**
Set this block to be notified when the value of the input changes.
@param element the element that has been modified.
@param input the input that has been modified.
@param value the value the axis was set to at the time the valueDidChangeHandler fired.
*/
@property (atomic, copy, nullable) void (^valueDidChangeHandler)(__kindof id<GCPhysicalInputElement> element, id<GCLinearInput> input, float value);
/**
A normalized value for the axis input, between 0 and 1 (inclusive). The values
are deadzoned and saturated before they are returned so there is no value
outside the range. Deadzoning does not remove values from the range, the full
0 to 1 magnitude of values are possible from the input.
You can rely on a value of 0 meaning the value is inside the deadzone. Any
value greater than zero is not in the deadzone.
*/
@property (readonly) float value;
/**
Check if the input can support more than just digital values.
If \c YES, the input can produce any value between [0, 1]. Otherwise, the
input only produces the values 0 or 1.
*/
@property (readonly, getter = isAnalog) BOOL analog;
/**
Check if the input value "rolls over" when reaching either the extreme high
or low value. For example, some dials can be rotated past the position that
represents their maximum value, causing the next reported value to roll over.
Defaults to NO for most inputs.
*/
@property (readonly) BOOL canWrap;
/**
The timestamp of the last value.
This time interval is not relative to any specific point in time. You can
subtract a previous timestamp from the current timestamp to determine the time
(in seconds) between changes to the value.
*/
@property (readonly) NSTimeInterval lastValueTimestamp;
/**
The interval (in seconds) between the timestamp of the last event and the
current time.
This should be treated as a lower bound of the event latency. It may not
include (wired or wireless) transmission latency, or latency accrued on
the device before the event was transmitted to the host.
*/
@property (readonly) NSTimeInterval lastValueLatency;
/**
An object describing the physical action(s) the user performs to manipulate
this input.
*/
@property (copy, readonly) NSSet<id<GCPhysicalInputSource>> *sources API_AVAILABLE(macos(14.0), ios(17.0), tvos(17.0));
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,154 @@
//
// GCMicroGamepad.h
// GameController
//
// Copyright (c) 2014 Apple Inc. All rights reserved.
//
#import <GameController/GCPhysicalInputProfile.h>
NS_ASSUME_NONNULL_BEGIN
@class GCController;
@class GCMicroGamepadSnapshot;
/**
The primary directional input surface for the directional gamepad
@note Equivalent to microgamepad.dpad
@note For the 1st generation and 2nd generation Siri Remotes, this represents touching anywhere on the entire touch surface.
*/
GAMECONTROLLER_EXTERN NSString *const GCInputMicroGamepadDpad API_AVAILABLE(macos(12.0), ios(15.0), tvos(15.0));
/**
The primary button for the microgamepad
@note For the 1st generation and 2nd generation Siri Remotes, this represents pressing anywhere on the touch surface.
*/
GAMECONTROLLER_EXTERN NSString *const GCInputMicroGamepadButtonA API_AVAILABLE(macos(12.0), ios(15.0), tvos(15.0));
/**
The secondary button for the microgamepad
@note Equivalent to microgamepad.buttonX
@note For the 1st and 2nd generation Siri Remotes, this represents pressing the play/pause button.
*/
GAMECONTROLLER_EXTERN NSString *const GCInputMicroGamepadButtonX API_AVAILABLE(macos(12.0), ios(15.0), tvos(15.0));
/**
The primary menu button for the microgamepad
@note Equivalent to microgamepad.buttonMenu
@note For the 1st generation Siri Remote, this represents pressing the play/pause button. For the 2nd generation Siri Remote, this represents pressing the back button.
@note You should avoid polling this button every frame. tvOS will run a gesture recognizer on events before forwarding them to your application that can reduce the window
to poll button changes. Instead, register a pressedChangedHandler or a valueChangedHandler.
*/
GAMECONTROLLER_EXTERN NSString *const GCInputMicroGamepadButtonMenu API_AVAILABLE(macos(12.0), ios(15.0), tvos(15.0));
/**
Micro Gamepad profile.
All controller profiles provide a base level of information about the controller they belong to.
A profile maps the hardware notion of a controller into a logical controller. One that a developer can design for
and depend on, no matter the underlying hardware.
*/
API_AVAILABLE(macos(10.11), ios(9.0), tvos(9.0))
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunguarded-availability"
@interface GCMicroGamepad : GCPhysicalInputProfile
#pragma clang diagnostic pop
/**
A profile keeps a reference to the controller that this profile is mapping input from.
*/
#if !__has_feature(objc_arc)
@property (nonatomic, readonly, assign) GCController *controller;
#else
@property (nonatomic, readonly, weak) GCController *controller;
#endif
/**
Set this block if you want to be notified when a value on a element changed. If multiple elements have changed this block will be called
for each element that changed. As elements in a collection, such as the axis in a dpad, tend to change at the same time and thus
will only call this once with the collection as the element.
@param gamepad this gamepad that is being used to map the raw input data into logical values on controller elements such as the dpad or the buttons.
@param element the element that has been modified.
*/
typedef void (^GCMicroGamepadValueChangedHandler)(GCMicroGamepad *gamepad, GCControllerElement *element);
@property (nonatomic, copy, nullable) GCMicroGamepadValueChangedHandler valueChangedHandler;
/**
Polls the state vector of the controller and saves it to a snapshot. The snapshot is stored in a device independent
format that can be serialized and used at a later date. This is useful for features such as quality assurance,
save game or replay functionality among many.
If your application is heavily multithreaded this may also be useful to guarantee atomicity of input handling as
a snapshot will not change based on user input once it is taken.
@see GCMicroGamepadSnapshot
*/
- (GCMicroGamepadSnapshot *)saveSnapshot API_DEPRECATED("GCMicroGamepadSnapshot has been deprecated, use [GCController capture] instead", macos(10.9, 10.15), ios(7.0, 13.0), tvos(7.0, 13.0));
/**
Optionally analog in the Micro profile. All the elements of this directional input are either analog or digital.
*/
@property (nonatomic, readonly, strong) GCControllerDirectionPad *dpad;
/**
The Micro profile has two buttons that are optionally analog in the Micro profile.
Button A is the primary action button, it indicates affirmative action and should be used to advance in menus
or perform the primary action in gameplay.
*/
@property (nonatomic, readonly, strong) GCControllerButtonInput *buttonA;
/**
Button X is the secondary action button, it indicates an alternate affirmative action and should be used to perform
a secondary action. If there is no secondary action it should be used as equivalent to buttonA.
Unlike on other profiles there is no negative button on this profile. Instead the menu button should be
used to present menu content or to retreat in a menu flow.
@see buttonA
*/
@property (nonatomic, readonly, strong) GCControllerButtonInput *buttonX;
/**
Button menu is the primary menu button, and should be used to enter the main menu and pause the game.
*/
@property (nonatomic, readonly) GCControllerButtonInput *buttonMenu API_AVAILABLE(macos(10.15), ios(13.0), tvos(13.0));
/**
The Micro profile can use the raw position values of the touchpad on the remote as D-pad values, or it can create a virtual dpad centered around the first contact point with the surface.
If NO; a smaller sliding window is created around the initial touch point and subsequent movement is relative to that center. Movement outside the window will slide the window with it to re-center it. This is great for surfaces where there is no clear sense of a middle and drift over time is an issue.
If YES; the absolute values are used and any drift will have to managed manually either through user traning or by a developer using the dpad.
The default value for this property is NO, meaning a sliding window is used for the dpad.
*/
@property (nonatomic) BOOL reportsAbsoluteDpadValues;
/**
Allows the Micro profile to monitor the orientation of the controller, if the controller is positioned in landscape orientation, D-pad input values will be transposed 90 degrees to match the new orientation.
The default value for this property is NO.
*/
@property (nonatomic) BOOL allowsRotation;
/**
Sets the state vector of the micro gamepad to a copy of the input micro gamepad's state vector.
@note If the controller's snapshot flag is set to NO, this method has no effect.
@see GCController.snapshot
*/
- (void) setStateFromMicroGamepad:(GCMicroGamepad *)microGamepad API_AVAILABLE(macos(10.15), ios(13.0), tvos(13.0));
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,106 @@
//
// GCMicroGamepadSnapshot.h
// GameController
//
// Copyright (c) 2014 Apple Inc. All rights reserved.
//
#import <GameController/GCMicroGamepad.h>
NS_ASSUME_NONNULL_BEGIN
/**
A GCMicroGamepadSnapshot snapshot is a concrete GCMicroGamepad implementation. It can be used directly in an
application to implement controller input replays. It is also returned as the result of polling
a controller.
The current snapshotData is readily available to access as NSData. A developer can serialize this to any
destination necessary using the NSData API.
The data contains some version of a GCMicroGamepadSnapShotData structure.
@see -[GCMicroGamepad saveSnapshot]
*/
API_DEPRECATED("GCMicroGamepadSnapshot has been deprecated, use [GCController controllerWithMicroGamepad] instead", macos(10.11, 10.15), ios(9.0, 13.0), tvos(9.0, 13.0))
@interface GCMicroGamepadSnapshot : GCMicroGamepad
@property (atomic, copy) NSData *snapshotData;
- (instancetype)initWithSnapshotData:(NSData *)data;
- (instancetype)initWithController:(GCController *)controller snapshotData:(NSData *)data;
@end
typedef NS_ENUM(NSInteger, GCMicroGamepadSnapshotDataVersion) {
GCMicroGamepadSnapshotDataVersion1 = 0x0100
} API_DEPRECATED("GCMicroGamepadSnapshot has been deprecated, use [GCController controllerWithMicroGamepad] instead", macos(10.11, 10.15), ios(9.0, 13.0), tvos(9.0, 13.0));
extern const GCMicroGamepadSnapshotDataVersion GCCurrentMicroGamepadSnapshotDataVersion API_DEPRECATED("GCMicroGamepadSnapshot has been deprecated, use [GCController controllerWithMicroGamepad] instead", macos(10.11, 10.15), ios(9.0, 13.0), tvos(9.0, 13.0));
#pragma pack(push, 1)
typedef struct {
#pragma mark - GCMicroGamepadSnapshotDataVersion1+
uint16_t version;
uint16_t size;
// Standard gamepad data
// Axes in the range [-1.0, 1.0]
float dpadX;
float dpadY;
// Buttons in the range [0.0, 1.0]
float buttonA;
float buttonX;
} GCMicroGamepadSnapshotData API_DEPRECATED("GCMicroGamepadSnapshot has been deprecated, use [GCController controllerWithMicroGamepad] instead", macos(10.11, 10.15), ios(9.0, 13.0), tvos(9.0, 13.0));
#pragma pack(pop)
/**Fills out a snapshot from any compatible NSData source
@return NO if data is nil, snapshotData is nil or the contents of data does not contain a compatible snapshot. YES for all other cases.
*/
BOOL GCMicroGamepadSnapshotDataFromNSData(GCMicroGamepadSnapshotData *__nullable snapshotData, NSData *__nullable data) API_DEPRECATED("GCMicroGamepadSnapshot has been deprecated, use [GCController controllerWithMicroGamepad] instead", macos(10.11, 10.15), ios(9.0, 13.0), tvos(9.0, 13.0));
/**Creates an NSData object from a snapshot.
If the version and size is not set in the snapshot the data will automatically have version GCCurrentMicroGamepadSnapshotDataVersion and sizeof(GCMicroGamepadSnapshotData) set as the values implicitly.
@return nil if the snapshot is NULL, otherwise an NSData instance compatible with GCGamepadSnapshot.snapshotData
*/
NSData *__nullable NSDataFromGCMicroGamepadSnapshotData(GCMicroGamepadSnapshotData *__nullable snapshotData) API_DEPRECATED("GCMicroGamepadSnapshot has been deprecated, use [GCController controllerWithMicroGamepad] instead", macos(10.11, 10.15), ios(9.0, 13.0), tvos(9.0, 13.0));
#pragma mark - Deprecated Versioning System
#pragma pack(push, 1)
typedef struct {
// Standard information
uint16_t version; //0x0100
uint16_t size; //sizeof(GCMicroGamepadSnapShotDataV100) or larger
// Standard gamepad data
// Axes in the range [-1.0, 1.0]
float dpadX;
float dpadY;
// Buttons in the range [0.0, 1.0]
float buttonA;
float buttonX;
} GCMicroGamepadSnapShotDataV100 API_DEPRECATED("GCMicroGamepadSnapshot has been deprecated, use [GCController controllerWithMicroGamepad] instead", macos(10.11, 10.15), ios(9.0, 13.0), tvos(9.0, 13.0));
#pragma pack(pop)
/**Fills out a v100 snapshot from any compatible NSData source
@return NO if data is nil, snapshotData is nil or the contents of data does not contain a compatible snapshot. YES for all other cases.
*/
BOOL GCMicroGamepadSnapShotDataV100FromNSData(GCMicroGamepadSnapShotDataV100 *__nullable snapshotData, NSData *__nullable data) API_DEPRECATED("GCMicroGamepadSnapshot has been deprecated, use [GCController controllerWithMicroGamepad] instead", macos(10.11, 10.15), ios(9.0, 13.0), tvos(9.0, 13.0));
/**Creates an NSData object from a v100 snapshot.
If the version and size is not set in the snapshot the data will automatically have version 0x100 and sizeof(GCMicroGamepadSnapShotDataV100) set as the values implicitly.
@return nil if the snapshot is NULL, otherwise an NSData instance compatible with GCGamepadSnapshot.snapshotData
*/
NSData *__nullable NSDataFromGCMicroGamepadSnapShotDataV100(GCMicroGamepadSnapShotDataV100 *__nullable snapshotData) API_DEPRECATED("GCMicroGamepadSnapshot has been deprecated, use [GCController controllerWithMicroGamepad] instead", macos(10.11, 10.15), ios(9.0, 13.0), tvos(9.0, 13.0));
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,259 @@
//
// GCMotion.h
// GameController
//
// Copyright (c) 2012 Apple Inc. All rights reserved.
//
#import <Foundation/Foundation.h>
@class GCController;
NS_ASSUME_NONNULL_BEGIN
/**
A 3 dimensional acceleration vector measured as scalar multiples of earth's gravitational acceleration, G.
The azimuth direction is assumed to be (0, 0, 1), so a device held at rest with the z axis aligned with the azimuth
is assumed to have gravitation applying the vector (0, 0, -1).
@field x X-axis acceleration as a scalar multiple of earth's gravitational acceleration, G.
@field y Y-axis acceleration as a scalar multiple of earth's gravitational acceleration, G.
@field z Z-axis acceleration as a scalar multiple of earth's gravitational acceleration, G.
*/
typedef struct {
double x, y, z;
} GCAcceleration;
/**
A structure containing 3-axis rotation rate data.
@field x X-axis rotation rate in radians/second. The sign follows the right hand
rule (i.e. if the right hand is wrapped around the X axis such that the
tip of the thumb points toward positive X, a positive rotation is one
toward the tips of the other 4 fingers).
@field y Y-axis rotation rate in radians/second. The sign follows the right hand
rule (i.e. if the right hand is wrapped around the Y axis such that the
tip of the thumb points toward positive Y, a positive rotation is one
toward the tips of the other 4 fingers).
@field z
Z-axis rotation rate in radians/second. The sign follows the right hand
rule (i.e. if the right hand is wrapped around the Z axis such that the
tip of the thumb points toward positive Z, a positive rotation is one
toward the tips of the other 4 fingers).
*/
typedef struct {
double x, y, z;
} GCRotationRate;
/**
A structure containing 3-axis rotation data. The angles are rotated in order or pitch then yaw then roll.
@field pitch X-axis rotation in radians. The sign follows the right hand
rule (i.e. if the right hand is wrapped around the X axis such that the
tip of the thumb points toward positive X, a positive rotation is one
toward the tips of the other 4 fingers).
@field yaw Y-axis rotation in radians. The sign follows the right hand
rule (i.e. if the right hand is wrapped around the Y axis such that the
tip of the thumb points toward positive Y, a positive rotation is one
toward the tips of the other 4 fingers).
@field roll Z-axis rotation in radians. The sign follows the right hand
rule (i.e. if the right hand is wrapped around the Z axis such that the
tip of the thumb points toward positive Z, a positive rotation is one
toward the tips of the other 4 fingers).
*/
typedef struct {
double pitch, yaw, roll;
} GCEulerAngles;
/**
Represents a quaternion (one way of parameterizing attitude).
If q is an instance of GCQuaternion, mathematically it represents the following quaternion:
q.x*i + q.y*j + q.z*k + q.w
*/
typedef struct GCQuaternion {
double x, y, z, w;
} GCQuaternion;
/**
A profile for getting motion input from a controller that has the ability to measure acceleration
and rotation rate.
You check for the availablity of motion inputs by getting the motion property
of a controller. If that returns a nil value; motion is not available. A non-nil value is a valid
GCMotion profile that is able to provide motion input.
@see GCController.motion
*/
API_AVAILABLE(macos(10.10), ios(8.0), tvos(8.0))
@interface GCMotion : NSObject
/**
A profile keeps a reference to the controller that it is mapping input from.
@see GCController
*/
#if !__has_feature(objc_arc)
@property (nonatomic, readonly, weak) GCController *controller;
#else
@property (nonatomic, readonly, weak) GCController *controller;
#endif
/**
Called whenever a motion value changed.
*/
typedef void (^GCMotionValueChangedHandler)(GCMotion *motion);
@property (nonatomic, copy, nullable) GCMotionValueChangedHandler valueChangedHandler;
/**
If this property is returns YES, you are responsible for setting sensorsActive to YES when you need motion data from the controller.
Some controllers, such as the Siri Remote, automatically activate and deactivate motion sensors. In such a case, this property
will return NO.
@see sensorsActive
*/
@property (nonatomic, readonly) BOOL sensorsRequireManualActivation API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
/**
Set this property to YES when you wish to receive motion data from the controller. When you set this property to NO, the motion sensors
will be disabled and the GCMotion profile will not be updated.
@note It is highly recommended that you only enable sensor during the period of time you directly need motion data. Motion sensors
can drain controller battery, device battery, and needlessly consume Bluetooth bandwidth.
@see sensorsRequireManualActivation
*/
@property (nonatomic) BOOL sensorsActive API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
/**
Returns YES if the controller is capable of reporting gravity and user acceleration separately.
@note Some controllers do not separate gravity from user acceleration, and only report the total acceleration of the controller.
Query whether the connected controller has the ability to separate gravity and user acceleration, and it doesnt, use acceleration instead.
@see acceleration
*/
@property (nonatomic, readonly) BOOL hasGravityAndUserAcceleration API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
/**
The gravity vector expressed in the controller's reference frame.
Note that the total acceleration of the controller is equal to gravity plus userAcceleration.
@see userAcceleration
@see acceleration
*/
@property (nonatomic, readonly) GCAcceleration gravity;
/**
The acceleration that the user is giving to the controller.
Note that the total acceleration of the controller is equal to gravity plus userAcceleration.
@see gravity
@see acceleration
*/
@property (nonatomic, readonly) GCAcceleration userAcceleration;
/**
The total acceleration of the controller.
@see gravity
@see userAcceleration
*/
@property (nonatomic, readonly) GCAcceleration acceleration API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
/**
The controller generating the motion data has sensors that can accurately determine the current attitude and rotation rate. If this is enabled the motion data for attitude and rotation rate are usable for inputs.
*/
@property (nonatomic, readonly) BOOL hasAttitudeAndRotationRate API_DEPRECATED("hasAttitudeAndRotationRate has been deprecated, use -hasAttitude and -hasRotationRate instead", macos(10.13, 11.0), ios(11.0, 14.0), tvos(11.0, 14.0));
/**
The controller generating the motion data has sensors that can accurately determine the current attitude. If this is enabled the motion data for attitude is usable for inputs.
*/
@property (nonatomic, readonly) BOOL hasAttitude API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
/**
The controller generating the motion data has sensors that can accurately determine the current rotation rate. If this is enabled the motion data for rotation rate is usable for inputs.
*/
@property (nonatomic, readonly) BOOL hasRotationRate API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
/**
The current attitude of the controller.
@note Remotes without accurate attitude and rotation rate can not determine a stable attitude so the values will be (0,0,0,1) at all times.
@see hasAttitude
@see GCMicroGamepad
*/
@property (nonatomic, readonly) GCQuaternion attitude API_AVAILABLE(macos(10.13), ios(11.0), tvos(11.0));
/**
The current rotation rate of the controller.
@note Remotes without accurate attitude and rotation rate can not determine a stable rotation rate so the values will be (0,0,0) at all times.
@see hasRotationRate
@see GCMicroGamepad
*/
@property (nonatomic, readonly) GCRotationRate rotationRate API_AVAILABLE(macos(10.13), ios(11.0), tvos(11.0));
/**
Sets the gravity vector expressed in the controller's reference frame.
@note If the controller's snapshot flag is set to NO, this method has no effect.
@see gravity
*/
- (void)setGravity:(GCAcceleration)gravity API_AVAILABLE(macos(10.15), ios(13.0), tvos(13.0));
/**
Sets the acceleration that the user is giving to the controller.
@note If the controller's snapshot flag is set to NO, this method has no effect.
@see userAcceleration
*/
- (void)setUserAcceleration:(GCAcceleration)userAcceleration API_AVAILABLE(macos(10.15), ios(13.0), tvos(13.0));
/**
Sets the acceleration that the user is giving to the controller.
@note If the controller's snapshot flag is set to NO, this method has no effect.
@see userAcceleration
*/
- (void)setAcceleration:(GCAcceleration)acceleration API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
/**
Sets the current rotation rate of the controller.
@note If the controller's snapshot flag is set to NO, this method has no effect.
@see attitude
*/
- (void)setAttitude:(GCQuaternion)attitude API_AVAILABLE(macos(10.15), ios(13.0), tvos(13.0));
/**
Sets the current rotation rate of the controller.
@note If the controller's snapshot flag is set to NO, this method has no effect.
@see rotationRate
*/
- (void)setRotationRate:(GCRotationRate)rotationRate API_AVAILABLE(macos(10.15), ios(13.0), tvos(13.0));
/**
Sets the state vector of the motion profile to a copy of the input motion profile's state vector.
@note If the controller's snapshot flag is set to NO, this method has no effect.
@see GCController.snapshot
*/
- (void)setStateFromMotion:(GCMotion *)motion API_AVAILABLE(macos(10.15), ios(13.0), tvos(13.0));
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,95 @@
//
// GCMouse.h
// GameController
//
// Copyright © 2020 Apple Inc. All rights reserved.
//
#import <GameController/GameController.h>
#import <GameController/GCExtern.h>
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
/**
Use these constants with NSNotificationCenter to listen to connection and disconnection events.
Use GCMouseDidConnectNotification for observing connections of mice.
Use GCMouserDidDisconnectNotification for observing disconnections of mice.
Connections and disconnections of mice will also be reflected in the mice array
of the GCMouse class.
The 'object' property of the notification will contain the GCMouse that was connected or disconnected.
For example:
- (void)controllerDidConnect:(NSNotification *)note {
GCMouse *mouse = note.object;
....
}
@see NSNotificationCenter
@see GCMouse.mice
*/
GAMECONTROLLER_EXTERN NSString *const GCMouseDidConnectNotification API_AVAILABLE(macos(11.0), ios(14.0));
GAMECONTROLLER_EXTERN NSString *const GCMouseDidDisconnectNotification API_AVAILABLE(macos(11.0), ios(14.0));
/**
Use these constants with NSNotificationCenter to listen to a controller becoming the most recently used mouse.
This is a good time to swap out UI to match the new current mouse, and unregister any handlers with
the old current controller.
The 'object' property of the notification will contain the GCMouse that became the current one.
For example:
- (void)mouseDidBecomeCurrent:(NSNotification *)note {
GCMouse *mouse = note.object;
...
}
@see NSNotificationCenter
@see GCMouse.mice
@see GCMouse.current
*/
GAMECONTROLLER_EXTERN NSString *const GCMouseDidBecomeCurrentNotification API_AVAILABLE(macos(11.0), ios(14.0));
GAMECONTROLLER_EXTERN NSString *const GCMouseDidStopBeingCurrentNotification API_AVAILABLE(macos(11.0), ios(14.0));
/**
Mice are available to an application that links to GameController.framework. There are 2 ways to access mice
paired to the system. Adopt both to ensure the best user experience:
1: Querying for the current array of mice using [GCMouse mice]
2: Registering for Connection/Disconnection notifications from NSNotificationCenter.
*/
API_AVAILABLE(macos(11.0), ios(14.0))
@interface GCMouse : NSObject<GCDevice>
/**
Unlike GCController GCMouse supports only one input profile
Profile contains mouse buttons, scroll wheel and pointer delta.
*/
@property (nonatomic, strong, readonly, nullable) GCMouseInput *mouseInput;
/**
The most recently used mouse device. If a user actuates a mouse input, that mouse will become the current one.
@see GCMouseDidBecomeCurrentNotification
@see GCMouseDidStopBeingCurrentNotification
*/
@property (class, atomic, strong, readonly, nullable) GCMouse *current;
/*
Get a list of mice currently attached to the system
@see GCMouseDidConnectNotification
@see GCMouseDidDisconnectNotification
*/
+ (NSArray<GCMouse *> *)mice;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,50 @@
//
// GCMouseInput.h
// GameController
//
// Copyright © 2020 Apple Inc. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <GameController/GCExtern.h>
#import <GameController/GCPhysicalInputProfile.h>
@class GCDeviceCursor;
NS_ASSUME_NONNULL_BEGIN
/**
Mouse profile that represent a physical mouse object with two axis cursor, two axis scroll,
left button, optional right and middle buttons and optional set of auxiliary buttons.
It only provides information about raw mouse movement deltas. For the valid cursor position
at given point in time, use UIHoverGestureRecognizer and NSEvent.mouseLocation.
*/
API_AVAILABLE(macos(11.0), ios(14.0))
@interface GCMouseInput : GCPhysicalInputProfile
/**
Set this block if you want to be notified when the mouse was moved
@param mouse this mouse that is being used for input
@param deltaX the value of raw mouse delta along x axis. Not affected by mouse sensitivity settings
@param deltaY the value of raw mouse delta along y axis. Not affected by mouse sensitivity settings
*/
typedef void (^GCMouseMoved)(GCMouseInput* mouse, float deltaX, float deltaY);
@property (nonatomic, copy, nullable) GCMouseMoved mouseMovedHandler;
/**
Scroll is a dpad with undefined range.
*/
@property(readonly, nonatomic) GCDeviceCursor* scroll;
/**
Mouse buttons that can be used only as digital inputs
*/
@property (nonatomic, readonly) GCDeviceButtonInput *leftButton;
@property (nullable, nonatomic, readonly) GCDeviceButtonInput *rightButton;
@property (nullable, nonatomic, readonly) GCDeviceButtonInput *middleButton;
@property (nullable, nonatomic, readonly) NSArray<GCDeviceButtonInput*> *auxiliaryButtons;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,75 @@
//
// GCPhysicalInputElement.h
// GameController
//
// Copyright © 2021 Apple Inc. All rights reserved.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
/**
The \c GCPhysicalInputElement protocol is a base protocol for specific types
of elements that represent controls on a device.
*/
API_AVAILABLE(macos(13.0), ios(16.0), tvos(16.0))
@protocol GCPhysicalInputElement <NSObject>
/**
The set of aliases that can be used to access this element with keyed subscript
notation.
*/
@property (copy, readonly) NSSet<NSString *> *aliases;
/**
The element's localized display name.
This is the string that your app should display in any on-screen messages
instructing the user to interact with the control. For example:
"Press \(buttonA.localizedName) to jump!"
Do not cache this value - it can change when the user remaps controls.
*/
@property (copy, readonly, nullable) NSString *localizedName;
/** The SF Symbols name for the element. */
@property (copy, readonly, nullable) NSString *sfSymbolsName;
@end
/**
An instance of \c GCPhysicalInputElementCollection contains the collection of
input elements found in a device's physical input profile.
*/
API_AVAILABLE(macos(13.0), ios(16.0), tvos(16.0)) NS_REFINED_FOR_SWIFT
@interface GCPhysicalInputElementCollection<Key: NSString*, __covariant Element: id<GCPhysicalInputElement>> : NSObject <NSFastEnumeration>
+ (instancetype)new NS_UNAVAILABLE;
- (instancetype)init NS_UNAVAILABLE;
/** The number of elements in the collection. */
@property (readonly) NSUInteger count;
/**
Returns the element associated with a given alias.
@param alias
The alias for which to return the corresponding element. Typically, you
pass one of the constants defined in \c GCInputNames.h.
@return
The element associated with \a alias, or nil if no element is associated
with \a alias.
*/
- (Element _Nullable)elementForAlias:(Key)alias;
- (Element _Nullable)objectForKeyedSubscript:(Key)key;
- (NSEnumerator<Element> *)elementEnumerator;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,143 @@
//
// GCControllerProfile.h
// GameController
//
// Copyright (c) 2019 Apple Inc. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <GameController/GCExtern.h>
@protocol GCDevice;
@class GCControllerElement;
@class GCControllerButtonInput;
@class GCControllerAxisInput;
@class GCControllerDirectionPad;
@class GCControllerTouchpad;
@compatibility_alias GCDeviceElement GCControllerElement;
@compatibility_alias GCDeviceButtonInput GCControllerButtonInput;
@compatibility_alias GCDeviceAxisInput GCControllerAxisInput;
@compatibility_alias GCDeviceDirectionPad GCControllerDirectionPad;
@compatibility_alias GCDeviceTouchpad GCControllerTouchpad;
NS_ASSUME_NONNULL_BEGIN
/**
A game controller profile representing physical buttons, thumbsticks, dpads, etc... on a controller.
All controller profiles provide a base level of information about the controller they belong to.
A profile maps the hardware notion of a controller into a logical controller. One that a developer can design for
and depend on, no matter the underlying hardware.
*/
API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0))
@interface GCPhysicalInputProfile : NSObject
/**
A profile keeps a reference to the device that this profile is mapping input from
*/
@property (nonatomic, readonly, weak) id<GCDevice> device API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
/**
The last time elements of this profile were updated.
*/
@property (atomic, readonly) NSTimeInterval lastEventTimestamp API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
/**
Whether the user has remapped their physical input controls for this profile at the system level.
@discussion On iOS and tvOS, users can remap their game controller inputs in Settings.
*/
@property (nonatomic, readonly) BOOL hasRemappedElements API_AVAILABLE(macos(12.0), ios(15.0), tvos(15.0));
/**
Set this block if you want to be notified when a value on a element changed. If multiple elements have changed this block will be called
for each element that changed.
@param profile this profile that is being used to map the raw input data into logical values on controller elements such as the dpad or the buttons.
@param element the element that has been modified.
*/
@property (nonatomic, copy, nullable) void (^valueDidChangeHandler)(__kindof GCPhysicalInputProfile *profile, GCControllerElement *element) API_AVAILABLE(macos(13.0), ios(16.0), tvos(16.0));
/**
The following properties allow for runtime lookup of any input element on a profile, when provided with a valid alias.
@example extendedGamepad.elements["Button A"] == extendedGamepad.buttonA // YES
@example extendedGamepad.dpads["Left Thumbstick"] == extendedGamepad.leftThumbstick // YES
@example extendedGamepad.dpads["Button B"] // returns nil, "Button B" is not a GCControllerDirectionPad
*/
@property (nonatomic, readonly, strong) NSDictionary<NSString *, GCDeviceElement *> *elements API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
@property (nonatomic, readonly, strong) NSDictionary<NSString *, GCDeviceButtonInput *> *buttons API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
@property (nonatomic, readonly, strong) NSDictionary<NSString *, GCDeviceAxisInput *> *axes API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
@property (nonatomic, readonly, strong) NSDictionary<NSString *, GCDeviceDirectionPad *> *dpads API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
@property (nonatomic, readonly, strong) NSDictionary<NSString *, GCDeviceTouchpad *> *touchpads API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
/**
The following properties allow for dynamic querying of the input elements available on a profile.
*/
@property (nonatomic, readonly, strong) NSSet<GCDeviceElement *> *allElements API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
@property (nonatomic, readonly, strong) NSSet<GCDeviceButtonInput *> *allButtons API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
@property (nonatomic, readonly, strong) NSSet<GCDeviceAxisInput *> *allAxes API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
@property (nonatomic, readonly, strong) NSSet<GCDeviceDirectionPad *> *allDpads API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
@property (nonatomic, readonly, strong) NSSet<GCDeviceTouchpad *> *allTouchpads API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
/**
Profile elements can be accessed using keyed subscript notation, with a valid alias of its inputs.
@example extendedGamepad["Button A"] == extendedGamepad.buttonA // YES
@example microGamepad["Button X"] == microGamepad.buttonX // YES
@note Equivalent to -elements
*/
- (__kindof GCDeviceElement * _Nullable)objectForKeyedSubscript:(NSString *)key API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
/**
Polls the state vector of the physical input input and saves it to a new and writable instance of GCPhysicalInputProfile.
If your application is heavily multithreaded this may also be useful to guarantee atomicity of input handling as
a snapshot will not change based on user input once it is taken.
@see snapshot
@return A new physical input profile with the duplicated state vector of the current physical input
*/
- (instancetype)capture API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
/**
Sets the state vector of the physical input profile to a copy of the passed in physical input profile's state vector.
@note If the controller's snapshot flag is set to NO, this method has no effect.
@see GCController.snapshot
*/
- (void)setStateFromPhysicalInput:(GCPhysicalInputProfile *)physicalInput API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0));
/**
Returns the primary alias of the GCControllerElement that a given physical input maps to.
@discussion If the user were to map a physical press of the A button of their game controller to the B button, then
-[GCPhysicalInputProfile mappedElementAliasForPhysicalInputName: GCInputButtonA] would return GCInputButtonB.
Note that mappings can change anytime your app is backgrounded, so make sure you update any relevant visuals when
returning to foreground.
@param inputName A GCInput string corresponding to the physical button you want the mapped element alias for.
@returns A GCInput string corresponding to the primary alias of the GCControllerElement that a given physical button maps to, or nil if there is no mapping.
*/
- (NSString *)mappedElementAliasForPhysicalInputName:(NSString *)inputName API_AVAILABLE(macos(12.0), ios(15.0), tvos(15.0));
/**
Returns a set of GCInput strings corresponding to physical inputs that are mapped to a given GCControllerElement.
@discussion If the user mapped the physical press of the A button, the B button, and the X button to the B button, then
-[GCPhysicalInputProfile mappedPhysicalInputNamesForElementAlias: GCInputButtonB] would return [GCInputButtonA, GCInputButtonB, GCInputButtonX].
Note that mappings can change anytime your app is backgrounded, so make sure you update any relevant visuals when
returning to foreground.
@param elementAlias A GCInput string corresponding to an alias of the GCControllerElement you want the physical buttons for.
@returns A set of GCInput strings corresponding to physical inputs that are mapped to a given GCControllerElement, or an empty set if there are no mappings.
*/
- (NSSet<NSString *> *)mappedPhysicalInputNamesForElementAlias:(NSString *)elementAlias API_AVAILABLE(macos(12.0), ios(15.0), tvos(15.0));
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,72 @@
//
// GCPhysicalInputSource.h
// GameController
//
// Copyright © 2022 Apple Inc. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <GameController/GCInputNames.h>
NS_ASSUME_NONNULL_BEGIN
/**
* One or more directions associated with a \c GCPhysicalInputSource.
*/
typedef NS_OPTIONS(NSUInteger, GCPhysicalInputSourceDirection) {
GCPhysicalInputSourceDirectionNotApplicable = 0,
GCPhysicalInputSourceDirectionUp = (1<<0UL),
GCPhysicalInputSourceDirectionRight = (1<<1UL),
GCPhysicalInputSourceDirectionDown = (1<<2UL),
GCPhysicalInputSourceDirectionLeft = (1<<3UL),
};
/**
* A description of the actual physical input element that a user interacts
* with to manipulate the the value of an input that is exposed to the app.
*
* By querying the source of an element's input that is returned from
* \c GCDevicePhysicalInput or \c GCDevicePhysicalInputState, an app
* can see through element remappings applied by the user in the system
* game controller settings. For example, assuming the user has
* swapped the A and B buttons in the system game controller settings...
*
* YES == [physicalInput.buttons[GCInputButtonA].pressedInput.source.elementAliases contains:GCInputButtonB]
* YES == [physicalInput.buttons[GCInputButtonB].pressedInput.source.elementAliases contains:GCInputButtonA]
*
* Examining an input's source is discouraged, but may be necessary depending
* on how your game's input handling code is implemented. If possible, prefer
* to load and display the \c sfSymbolsName and \c localizedName from the
* \c GCPhysicalInputElement in any in-game U.I.
*
* // Use these anywhere you need to instruct the user to press the 'A'
* // button in your game UI. The symbol name and localized string
* // returned will reflect the element that GCInputButtonA has been
* // remapped to (Button B in the above case).
* physicalInput.buttons[GCInputButtonA].localizedName
* physicalInput.buttons[GCInputButtonA].sfSymbolsName
*
* @note
* Objects conforming to \c GCPhysicalInputSource protocol are vended by the
* GameController framework. You should not conform to this protocol in your
* own types.
*/
API_AVAILABLE(macos(14.0), ios(17.0), tvos(17.0))
@protocol GCPhysicalInputSource <NSObject>
/** The set of aliases for the element that the user interacts with. */
@property (copy, readonly) NSSet<GCInputElementName> *elementAliases;
/** The localized name of the element that the user interacts with. */
@property (copy, readonly, nullable) NSString *elementLocalizedName;
/** The SF Symbol of the element that the user interacts with. */
@property (copy, readonly, nullable) NSString *sfSymbolsName;
/** One or more directions associated with the source. */
@property (readonly) GCPhysicalInputSourceDirection direction;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,71 @@
//
// GCPressedStateInput.h
// GameController
//
// Copyright © 2021 Apple Inc. All rights reserved.
//
#import <Foundation/Foundation.h>
@protocol GCPhysicalInputElement;
@protocol GCPhysicalInputSource;
NS_ASSUME_NONNULL_BEGIN
/**
An object conforming to \c GCPressedStateInput represents the pressed state of
an element, typically a button.
*/
API_AVAILABLE(macos(13.0), ios(16.0), tvos(16.0))
@protocol GCPressedStateInput <NSObject>
/**
Set this block if you want to be notified when the pressed state changes.
*/
@property (atomic, copy, nullable) void (^pressedDidChangeHandler)(__kindof id<GCPhysicalInputElement> element, id<GCPressedStateInput> input, BOOL pressed);
/**
Buttons are mostly used in a digital sense, thus we have a recommended method
for checking for pressed state instead of interpreting the value.
As a general guideline a button is pressed if the value exceeds 0. However
there may be hysteresis applied to counter noisy input values, thus incidental
values around the threshold value may not trigger a change in pressed state.
Other buttons may support two-stage actuation, where the button reports a
value between 0 and 1 but is only considered pressed when its value is greater
than some threshold other than 0.
@see pressedDidChangeHandler
*/
@property (readonly, getter = isPressed) BOOL pressed;
/**
The timestamp of the last pressed state change.
This time interval is not relative to any specific point in time. You can
subtract a previous timestamp from the current timestamp to determine the time
(in seconds) between changes to the value.
*/
@property (readonly) NSTimeInterval lastPressedStateTimestamp;
/**
The interval (in seconds) between the timestamp of the last pressed state
change and the current time.
This should be treated as a lower bound of the event latency. It may not
include (wired or wireless) transmission latency, or latency accrued on
the device before the event was transmitted to the host.
*/
@property (readonly) NSTimeInterval lastPressedStateLatency;
/**
An object describing the physical action(s) the user performs to manipulate
this input.
*/
@property (copy, readonly) NSSet<id<GCPhysicalInputSource>> *sources API_AVAILABLE(macos(14.0), ios(17.0), tvos(17.0));
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,60 @@
//
// GCProductCategories.h
// GameController
//
// Copyright © 2021 Apple Inc. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <GameController/GCExtern.h>
/**
A set of common values of -[GCDevice productCategory]. Check a device's' productCategory against these values to
set appropriate UI elements based on what type of device is connected.
@see GCDevice.h
*/
/// Game Controller Product Categories
GAMECONTROLLER_EXTERN NSString *const GCProductCategoryDualSense API_AVAILABLE(macos(12.0), ios(15.0), tvos(15.0));
GAMECONTROLLER_EXTERN NSString *const GCProductCategoryDualShock4 API_AVAILABLE(macos(12.0), ios(15.0), tvos(15.0));
GAMECONTROLLER_EXTERN NSString *const GCProductCategoryMFi API_AVAILABLE(macos(12.0), ios(15.0), tvos(15.0));
GAMECONTROLLER_EXTERN NSString *const GCProductCategoryXboxOne API_AVAILABLE(macos(12.0), ios(15.0), tvos(15.0));
GAMECONTROLLER_EXTERN NSString *const GCProductCategoryHID API_AVAILABLE(macos(13.0), ios(16.0), tvos(16.0));
GAMECONTROLLER_EXTERN NSString *const GCProductCategoryArcadeStick API_AVAILABLE(macos(14.0), ios(17.0), tvos(17.0));
/// Remote Product Categories
/// The Siri Remote (1st generation), or Apple TV Remote (1st generation), was first introduced in 2015. It features a Touch surface for touch navigation, and supports device motion.
GAMECONTROLLER_EXTERN NSString *const GCProductCategorySiriRemote1stGen API_AVAILABLE(macos(12.0), ios(15.0), tvos(15.0));
/// The Siri Remote (2nd generation), or Apple TV Remote (2nd generation), was first introduced in 2021. It features a touch-enabled clickpad for navigation.
GAMECONTROLLER_EXTERN NSString *const GCProductCategorySiriRemote2ndGen API_AVAILABLE(macos(12.0), ios(15.0), tvos(15.0));
/// Users can use Apple TV Remote controls in Control Center on an iOS or iPadOS device.
GAMECONTROLLER_EXTERN NSString *const GCProductCategoryControlCenterRemote API_AVAILABLE(macos(12.0), ios(15.0), tvos(15.0));
/// The Universal Electronics remote is an infrared and Bluetooth Low Energy remote designed to work with the Apple TV.
GAMECONTROLLER_EXTERN NSString *const GCProductCategoryUniversalElectronicsRemote API_AVAILABLE(macos(12.0), ios(15.0), tvos(15.0));
/**
If multiple remotes have been combined into one, the device will have the GCProductCategoryCoalescedRemote product category.
@discussion By default, the Game Controller framework will try to coalesce, or combine, the physical Apple TV Remote and the
virtual Control Center remote and treat them as a single GCDevice instance. By setting GCSupportsMultipleMicroGamepads in your
app's plist to true, you can disable this behavior.
*/
GAMECONTROLLER_EXTERN NSString *const GCProductCategoryCoalescedRemote API_AVAILABLE(macos(12.0), ios(15.0), tvos(15.0));
/// Keyboards and Mice Product Categories
GAMECONTROLLER_EXTERN NSString *const GCProductCategoryMouse API_AVAILABLE(macos(12.0), ios(15.0), tvos(15.0));
GAMECONTROLLER_EXTERN NSString *const GCProductCategoryKeyboard API_AVAILABLE(macos(12.0), ios(15.0), tvos(15.0));

View File

@ -0,0 +1,99 @@
//
// GCRacingWheel.h
// GameController
//
// Copyright © 2021 Apple Inc. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <GameController/GameController.h>
@class GCRacingWheelInput;
NS_ASSUME_NONNULL_BEGIN
/**
Use these constants with NSNotificationCenter to listen to connection and disconnection events.
Use GCRacingWheelDidConnectNotification for observing connections of racing wheels.
Use GCRacingWheelDidDisconnectNotification for observing disconnections of racing wheels.
Connections and disconnections of racing wheels will also be reflected in the connectedRacingWheels array
of the GCRacingWheel class.
The 'object' property of the notification will contain the GCRacingWheel that was connected or disconnected.
For example:
- (void)wheelDidConnect:(NSNotification *)note {
GCRacingWheel *controller = note.object;
....
}
@see NSNotificationCenter
@see GCRacingWheel.connectedRacingWheels
*/
GAMECONTROLLER_EXTERN NSString *const GCRacingWheelDidConnectNotification API_AVAILABLE(macos(13.0), macCatalyst(16.0)) API_UNAVAILABLE(ios, tvos);
GAMECONTROLLER_EXTERN NSString *const GCRacingWheelDidDisconnectNotification API_AVAILABLE(macos(13.0), macCatalyst(16.0)) API_UNAVAILABLE(ios, tvos);
API_AVAILABLE(macos(13.0), macCatalyst(16.0)) API_UNAVAILABLE(ios, tvos)
@interface GCRacingWheel : NSObject <GCDevice>
- (instancetype)init NS_UNAVAILABLE;
/**
Get the collection of racing wheels currently attached to the system.
@see GCRacingWheelDidConnectNotification
@see GCRacingWheelDidDisconnectNotification
*/
@property (nonatomic, readonly, class) NSSet<GCRacingWheel*> *connectedRacingWheels;
/**
A GCRacingWheel must be acquired before your application can begin receiving
events from it. Prior to acquisition, your application may only query the
properties of the racing wheel. Acquisition is exclusive and may fail.
*/
- (BOOL)acquireDeviceWithError:(NSError * __autoreleasing __nullable * __nullable)error;
/**
Releases a previous acquisition of the racing wheel.
*/
- (void)relinquishDevice;
/**
Checks if the racing wheel has been acquired by the application.
This property is observable.
*/
@property (readonly, getter = isAcquired) BOOL acquired;
/** Get the physical input profile for the racing wheel. */
@property (strong, readonly) GCRacingWheelInput *wheelInput;
#pragma mark Snapshots
/**
A GCRacingWheel may represent a real device managed by the operating system,
or a snapshot created by the developer.
@see capture
*/
@property (atomic, readonly, getter = isSnapshot) BOOL snapshot;
/**
Polls the state vector of the racing wheel and saves it to a new instance of
GCRacingWheel.
If your application is heavily multithreaded this may also be useful to
guarantee atomicity of input handling as a snapshot will not change based on
user input once it is taken.
@see snapshot
@return A new racing wheel with the duplicated state vector of the receiver.
*/
- (GCRacingWheel *)capture;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,56 @@
//
// GCRacingWheelInput.h
// GameController
//
// Copyright © 2021 Apple Inc. All rights reserved.
//
#import <GameController/GCDevicePhysicalInput.h>
@protocol GCButtonInput;
@protocol GCSwitchInput;
@class GCSteeringWheelElement;
@class GCGearShifterElement;
NS_ASSUME_NONNULL_BEGIN
API_AVAILABLE(macos(13.0), macCatalyst(16.0)) API_UNAVAILABLE(ios, tvos)
@interface GCRacingWheelInputState : NSObject <GCDevicePhysicalInputState>
/** The steering wheel element. */
@property (readonly) GCSteeringWheelElement *wheel;
@property (readonly, nullable) id<GCButtonElement> acceleratorPedal;
@property (readonly, nullable) id<GCButtonElement> brakePedal;
@property (readonly, nullable) id<GCButtonElement> clutchPedal;
/**
The element representing an attached gear shifter accessory.
Note that this element only represents an external gear shifter accessory.
Many racing wheels have a pair of built in paddle buttons that can be used for
sequential gear shifting. Those buttons are can be looked up with the
\c GCInputLeftPaddle and \c GCInputRightPaddle input names.
*/
@property (readonly, nullable) GCGearShifterElement *shifter;
@end
API_AVAILABLE(macos(13.0), macCatalyst(16.0)) API_UNAVAILABLE(ios, tvos)
@interface GCRacingWheelInput : GCRacingWheelInputState <GCDevicePhysicalInput>
/**
Polls the current state vector of the racing wheel input and saves it to a new
instance.
*/
- (GCRacingWheelInputState *)capture;
- (nullable GCRacingWheelInputState<GCDevicePhysicalInputStateDiff> *)nextInputState;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,74 @@
//
// GCRelativeInput.h
// GameController
//
// Copyright © 2021 Apple Inc. All rights reserved.
//
#import <Foundation/Foundation.h>
@protocol GCPhysicalInputElement;
@protocol GCPhysicalInputSource;
NS_ASSUME_NONNULL_BEGIN
/**
An object conforming to \c GCRelativeInput represents an input that reports
its change in position along an axis (delta) since the previous event.
Relative inputs have no fixed origin from which a coordinate syatem can be
defined.
*/
API_AVAILABLE(macos(13.0), ios(16.0), tvos(16.0))
@protocol GCRelativeInput <NSObject>
/**
Set this block to be notified when the delta of the input changes.
@param delta
The amount that the input has changed since the last time
\c deltaDidChangeHandler fired.
*/
@property (atomic, copy, nullable) void (^deltaDidChangeHandler)(__kindof id<GCPhysicalInputElement> element, id<GCRelativeInput> input, float delta);
/**
The last reported delta for the input.
*/
@property (readonly) float delta;
/**
Check if the input can support more than just digital values.
Defaults to \c YES for most relative inputs.
*/
@property (readonly, getter = isAnalog) BOOL analog;
/**
The timestamp of the last change.
This time interval is not relative to any specific point in time. You can
subtract a previous timestamp from the current timestamp to determine the time
(in seconds) between changes to the value.
*/
@property (readonly) NSTimeInterval lastDeltaTimestamp;
/**
The interval (in seconds) between the timestamp of the last change and the
current time.
This should be treated as a lower bound of the event latency. It may not
include (wired or wireless) transmission latency, or latency accrued on
the device before the event was transmitted to the host.
*/
@property (readonly) NSTimeInterval lastDeltaLatency;
/**
An object describing the physical action(s) the user performs to manipulate
this input.
*/
@property (copy, readonly) NSSet<id<GCPhysicalInputSource>> *sources API_AVAILABLE(macos(14.0), ios(17.0), tvos(17.0));
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,23 @@
//
// GCSteeringWheelElement.h
// GameController
//
// Copyright © 2021 Apple Inc. All rights reserved.
//
#import <GameController/GCPhysicalInputElement.h>
#import <GameController/GCAxisElement.h>
NS_ASSUME_NONNULL_BEGIN
API_AVAILABLE(macos(13.0), macCatalyst(16.0)) API_UNAVAILABLE(ios, tvos)
@interface GCSteeringWheelElement : NSObject <GCAxisElement>
- (instancetype)init NS_UNAVAILABLE;
/* The maximum angle, in degrees, the wheel can be rotated. */
@property (readonly) float maximumDegreesOfRotation;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,28 @@
//
// GCSwitchElement.h
// GameController
//
// Copyright © 2021 Apple Inc. All rights reserved.
//
#import <GameController/GCPhysicalInputElement.h>
#import <GameController/GCSwitchPositionInput.h>
NS_ASSUME_NONNULL_BEGIN
/**
An object conforming to \c GCSwitchElement represents a latching switch.
A switch may be in one of several positions, and remains in its last position
after the user stops interacting with it.
*/
API_AVAILABLE(macos(13.0), ios(16.0), tvos(16.0))
@protocol GCSwitchElement <GCPhysicalInputElement>
/**
Get the input containing the absolute position of the switch.
*/
@property (readonly) id<GCSwitchPositionInput> positionInput;
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,80 @@
//
// GCSwitchPositionInput.h
// GameController
//
// Copyright © 2021 Apple Inc. All rights reserved.
//
#import <Foundation/Foundation.h>
@protocol GCPhysicalInputElement;
@protocol GCPhysicalInputSource;
NS_ASSUME_NONNULL_BEGIN
API_AVAILABLE(macos(13.0), ios(16.0), tvos(16.0))
@protocol GCSwitchPositionInput <NSObject>
/**
Set this block if you want to be notified when the value on the switch changes.
@param input the element that has been modified.
@see value
*/
@property (atomic, copy, nullable) void (^positionDidChangeHandler)(__kindof id<GCPhysicalInputElement> element, id<GCSwitchPositionInput> input, NSInteger position);
/**
The switch's position.
@see valueDidChangeHandler
*/
@property (readonly) NSInteger position;
/**
The (inclusive) bounds of possible position values for the switch.
*/
@property (readonly) NSRange positionRange;
/**
\c YES if the switch input can only transition to positions that are adjacent
to the current position.
*/
@property (readonly, getter = isSequential) BOOL sequential;
/**
Check if the position input value can "roll over" when reaching either of its
bounds.
This will always be \c YES for non-sequential switch inputs.
*/
@property (readonly) BOOL canWrap;
/**
The timestamp of the last value.
This time interval is not relative to any specific point in time. You can
subtract a previous timestamp from the returned timestamp to determine the time
(in seconds) between changes to the value.
*/
@property (readonly) NSTimeInterval lastPositionTimestamp;
/**
The interval (in seconds) between the timestamp of the last event and the
current time.
This should be treated as a lower bound of the event latency. It may not
include (wired or wireless) transmission latency, or latency accrued on
the device before the event was transmitted to the host.
*/
@property (readonly) NSTimeInterval lastPositionLatency;
/**
An object describing the physical action(s) the user performs to manipulate
this input.
*/
@property (copy, readonly) NSSet<id<GCPhysicalInputSource>> *sources API_AVAILABLE(macos(14.0), ios(17.0), tvos(17.0));
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,59 @@
//
// GCSyntheticDeviceKeys.h
// GameController
//
// Copyright © 2021 Apple Inc. All rights reserved.
//
#ifndef GCSyntheticDeviceKeys_h
#define GCSyntheticDeviceKeys_h
/**
* This key is present with a \c Boolean value of \c true on all synthetic
* HID devices created by the GameController framework.
*
* If your application needs to exclude these synthetic HID devices from being
* discovered by \c IOHIDManager, \c IOServiceGetMatchingServices, or
* \c IOServiceAddMatchingNotification, include '"GCSyntheticDevice" = false'
* in your matching criteria.
*
* Example using \c IOHIDManager to discover connected HID devices, excluding
* synthetic HID devices:
*
* IOHIDManagerRef manager = IOHIDManagerCreate(kCFAllocatorDefault, kIOHIDManagerOptionNone);
* IOHIDManagerSetDeviceMatching(manager, (__bridge CFDictionaryRef)@{
* @kIOProviderClassKey: @kIOHIDDeviceKey,
* @kIOHIDGCSyntheticDeviceKey: @(NO)
* });
*
* Example using \c IOServiceAddMatchingNotification to discover kernel
* \c IOHIDDevice objects, excluding synthetic HID devices:
*
* CFMutableDictionaryRef matchingDict = IOServiceMatching(kIOHIDDeviceKey);
* CFDictionarySetValue(matchingDict, CFSTR(kIOHIDGCSyntheticDeviceKey), kCFBooleanFalse);
*
* io_iterator_t iterator = IO_OBJECT_NULL;
* IOServiceAddMatchingNotification(
* notifyPort,
* kIOFirstMatchNotification,
* matchingDict,
* NULL,
* serviceMatchedCallback,
* &iterator);
*
* If you have an \c io_service_t or \c IOHIDDeviceRef, you can check if it
* refers to a synthetic HID device by querying the "GCSyntheticDevice"
* property.
*
* if ( IOHIDDeviceGetProperty(device, CFSTR(kIOHIDGCSyntheticDeviceKey)) == kCFBooleanTrue ) {
* // Is synthetic HID device
* }
*
* @note
* Checking for the "GCSyntheticDevice" property is the ONLY supported way to
* determine if a \c IOHIDDeviceRef or \c io_service_t refers to a synthetic
* HID device.
*/
#define kIOHIDGCSyntheticDeviceKey "GCSyntheticDevice"
#endif /* GCSyntheticDeviceKeys_h */

View File

@ -0,0 +1,69 @@
//
// GCTouchedStateInput.h
// GameController
//
// Copyright © 2021 Apple Inc. All rights reserved.
//
#import <Foundation/Foundation.h>
@protocol GCPhysicalInputElement;
@protocol GCPhysicalInputSource;
NS_ASSUME_NONNULL_BEGIN
/**
An object conforming to \c GCTouchedStateInput represents the touched state of
an element.
Some buttons feature capacitive touch capabilities, where the user can touch
the button without pressing it. In such cases, a button can be touched without
being pressed.
*/
API_AVAILABLE(macos(13.0), ios(16.0), tvos(16.0))
@protocol GCTouchedStateInput <NSObject>
/**
Set this block if you want to be notified when the touched state changes.
*/
@property (atomic, copy, nullable) void (^touchedDidChangeHandler)(__kindof id<GCPhysicalInputElement> element, id<GCTouchedStateInput> input, BOOL touched);
/**
Some buttons feature capacitive touch capabilities, where the user can touch
the button without pressing it. In such cases, a button will be touched before
it is pressed.
@see touchedDidChangeHandler
@see GCPressedStateInput
*/
@property (readonly, getter = isTouched) BOOL touched;
/**
The timestamp of the last touched state change.
This time interval is not relative to any specific point in time. You can
subtract a previous timestamp from the returned timestamp to determine the time
(in seconds) between changes to the value.
*/
@property (readonly) NSTimeInterval lastTouchedStateTimestamp;
/**
The interval (in seconds) between the timestamp of the last touched state
change and the current time.
This should be treated as a lower bound of the event latency. It may not
include (wired or wireless) transmission latency, or latency accrued on
the device before the event was transmitted to the host.
*/
@property (readonly) NSTimeInterval lastTouchedStateLatency;
/**
An object describing the physical action(s) the user performs to manipulate
this input.
*/
@property (copy, readonly) NSSet<id<GCPhysicalInputSource>> *sources API_AVAILABLE(macos(14.0), ios(17.0), tvos(17.0));
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,42 @@
//
// GCTypes.h
// GameController
//
// Copyright © 2020 Apple Inc. All rights reserved.
//
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
struct GCPoint2 {
float x;
float y;
};
typedef struct CF_BOXABLE GCPoint2 GCPoint2;
/* The "zero" point -- equivalent to GCPoint2Make(0, 0). */
GAMECONTROLLER_EXTERN const GCPoint2 GCPoint2Zero API_AVAILABLE(macos(14.3), ios(17.4), tvos(17.4), visionos(1.1));
CF_INLINE GCPoint2
GCPoint2Make(float x, float y) {
GCPoint2 p; p.x = x; p.y = y; return p;
}
CF_INLINE bool
GCPoint2Equal(GCPoint2 point1, GCPoint2 point2) {
return point1.x == point2.x && point1.y == point2.y;
}
GAMECONTROLLER_EXTERN NSString* NSStringFromGCPoint2(GCPoint2 point) API_AVAILABLE(macos(14.3), ios(17.4), tvos(17.4), visionos(1.1));
@interface NSValue (GCTypes)
+ (instancetype)valueWithGCPoint2:(GCPoint2)point API_AVAILABLE(macos(14.3), ios(17.4), tvos(17.4), visionos(1.1));
@property(nonatomic, readonly) GCPoint2 GCPoint2Value API_AVAILABLE(macos(14.3), ios(17.4), tvos(17.4), visionos(1.1));
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,108 @@
//
// GCVirtualController.h
// GameController
//
// Copyright © 2021 Apple Inc. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
/**
* @class GCVirtualControllerConfiguration
*/
API_AVAILABLE(ios(15.0)) API_UNAVAILABLE(macos, tvos) API_UNAVAILABLE(visionos)
NS_SWIFT_NAME(GCVirtualController.Configuration)
@interface GCVirtualControllerConfiguration : NSObject
/**
The set of controller elements to be made available on \c GCVirtualController instances created with this configuration. e.g. [GCInputDirectionPad, GCInputLeftShoulder, etc...]
*/
@property (nonatomic, strong) NSSet<NSString *> *elements;
/**
Defaults to false, indicating that the default system touch control elements will be drawn using a touchable full-screen overlay. When set to true,
the application is responsible for drawing its own control UI and should call \c -setValue: and \c -setPosition: methods on the \c GCVirtualController
in response to touch or other events, which will then be translated into \c GCController events.
*/
@property (nonatomic, getter=isHidden) BOOL hidden API_AVAILABLE(ios(17.0));
@end
/**
* @class GCVirtualControllerElementConfiguration
*/
API_AVAILABLE(ios(15.0)) API_UNAVAILABLE(macos, tvos) API_UNAVAILABLE(visionos)
NS_SWIFT_NAME(GCVirtualController.ElementConfiguration)
@interface GCVirtualControllerElementConfiguration : NSObject
/**
A Boolean value that determines whether the element is hidden
*/
@property (nonatomic, getter=isHidden) BOOL hidden;
/**
Path that defines custom element image
Only supported for button elements
*/
@property (nonatomic, strong, nullable) UIBezierPath* path;
/**
A Boolean value that determines if the thumbstick is acting as a touchpad
Only supported for thumbsticks
*/
@property (nonatomic) BOOL actsAsTouchpad;
@end
/**
* @class GCVirtualController
*/
API_AVAILABLE(ios(15.0)) API_UNAVAILABLE(macos, tvos) API_UNAVAILABLE(visionos)
@interface GCVirtualController : NSObject
/**
Create a virtual controller
@see GCVirtualControllerConfiguration
*/
+ (GCVirtualController *)virtualControllerWithConfiguration:(GCVirtualControllerConfiguration *)configuration;
+ (instancetype)new NS_UNAVAILABLE;
- (instancetype)init NS_UNAVAILABLE;
- (instancetype)initWithConfiguration:(GCVirtualControllerConfiguration *)configuration NS_DESIGNATED_INITIALIZER;
- (void)connectWithReplyHandler:(nullable void(^)(NSError * _Nullable error))reply NS_SWIFT_ASYNC_NAME(connect());
- (void)disconnect;
/**
GCController is only available when GCVirtualController is connected
*/
@property (nonatomic, readonly, nullable) GCController *controller;
/**
Changes the GCVirtualControllerElementConfiguration on a per element basis. Only applicable when the GCVirtualController is not hidden and its
UI is being drawn by the system.
*/
- (void)updateConfigurationForElement:(NSString *)element configuration:(NS_NOESCAPE GCVirtualControllerElementConfiguration* (^)(GCVirtualControllerElementConfiguration *oldConfiguration))config;
/**
Sets the value for a GCControllerButton element. Values are clamped to the range (0.0 - 1.0).
*/
- (void)setValue:(CGFloat)value forButtonElement:(NSString *)element API_AVAILABLE(ios(17.0));
/**
Sets the (x,y) position for a GCControllerDirectionPad element (D-Pads as well as Joysticks). X and Y values are clamped to the range (-1.0 - 1.0).
*/
- (void)setPosition:(CGPoint)position forDirectionPadElement:(NSString *)element API_AVAILABLE(ios(17.0));
@end
NS_ASSUME_NONNULL_END

View File

@ -0,0 +1,44 @@
//
// GCXboxGamepad.h
// GameController
//
// Copyright © 2019 Apple Inc. All rights reserved.
//
#import <GameController/GCExtendedGamepad.h>
/**
The GCXboxGamepad profile represents any supported Xbox controller.
@see GCExtendedGamepad
*/
API_AVAILABLE(macos(11.0), ios(14.0), tvos(14.0))
@interface GCXboxGamepad : GCExtendedGamepad
/**
Some Xbox controller variants can support up to four additional buttons.
@example The standard Bluetooth-enabled Xbox Wireless Controller does not have paddle buttons
@example The Xbox Elite Wireless Controller has four extra digital buttons.
@note The four extra digital buttons on the Xbox Elite Wireless Controller are only directly addressable when the controller
is on its default mapping profile. Otherwise, the paddle buttons are directly bound to other inputs on the controller.
*/
@property (nonatomic, readonly, nullable) GCControllerButtonInput *paddleButton1;
@property (nonatomic, readonly, nullable) GCControllerButtonInput *paddleButton2;
@property (nonatomic, readonly, nullable) GCControllerButtonInput *paddleButton3;
@property (nonatomic, readonly, nullable) GCControllerButtonInput *paddleButton4;
/**
Some Xbox controller variants feature a Share button.
@example The Bluetooth-enabled Xbox Wireless Controller introduced with the Xbox Series X and Xbox Series S in 2020
has a Share button.
@note The Share button is reserved by the system for screenshot and video recording gestures. If you wish to disable these
gestures in your app and take control of the Share button, set buttonShare.preferredSystemGestureState to
GCSystemGestureStateDisabled.
*/
@property (nonatomic, readonly, nullable) GCControllerButtonInput *buttonShare API_AVAILABLE(macos(12.0), ios(15.0), tvos(15.0));
@end

View File

@ -0,0 +1,90 @@
//
// GameController.h
// GameController
//
// Copyright (c) 2012 Apple Inc. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <TargetConditionals.h>
#import <GameController/GCExtern.h>
#import <GameController/GCTypes.h>
#import <GameController/GCColor.h>
#import <GameController/GCDevice.h>
#import <GameController/GCDevicePhysicalInput.h>
#import <GameController/GCPhysicalInputElement.h>
#import <GameController/GCPhysicalInputSource.h>
#import <GameController/GCLinearInput.h>
#import <GameController/GCAxisInput.h>
#import <GameController/GCAxis2DInput.h>
#import <GameController/GCRelativeInput.h>
#import <GameController/GCPressedStateInput.h>
#import <GameController/GCTouchedStateInput.h>
#import <GameController/GCSwitchPositionInput.h>
#import <GameController/GCButtonElement.h>
#import <GameController/GCAxisElement.h>
#import <GameController/GCSwitchElement.h>
#import <GameController/GCDirectionPadElement.h>
#import <GameController/GCDeviceLight.h>
#import <GameController/GCDeviceBattery.h>
#import <GameController/GCControllerElement.h>
#import <GameController/GCControllerAxisInput.h>
#import <GameController/GCControllerButtonInput.h>
#import <GameController/GCControllerDirectionPad.h>
#import <GameController/GCControllerTouchpad.h>
#import <GameController/GCDualSenseAdaptiveTrigger.h>
#import <GameController/GCDeviceCursor.h>
#import <GameController/GCMotion.h>
#import <GameController/GCPhysicalInputProfile.h>
#import <GameController/GCInputNames.h>
#import <GameController/GCGamepad.h>
#import <GameController/GCGamepadSnapshot.h>
#import <GameController/GCExtendedGamepad.h>
#import <GameController/GCExtendedGamepadSnapshot.h>
#import <GameController/GCKeyCodes.h>
#import <GameController/GCKeyNames.h>
#import <GameController/GCKeyboardInput.h>
#import <GameController/GCMouseInput.h>
#import <GameController/GCXboxGamepad.h>
#import <GameController/GCDualShockGamepad.h>
#import <GameController/GCDualSenseGamepad.h>
#import <GameController/GCMicroGamepad.h>
#import <GameController/GCMicroGamepadSnapshot.h>
#import <GameController/GCDirectionalGamepad.h>
#import <GameController/GCProductCategories.h>
#import <GameController/GCController.h>
#import <GameController/GCKeyboard.h>
#import <GameController/GCMouse.h>
#import <GameController/GCRacingWheel.h>
#import <GameController/GCRacingWheelInput.h>
#import <GameController/GCSteeringWheelElement.h>
#import <GameController/GCGearShifterElement.h>
#import <GameController/GCDeviceHaptics.h>
#import <GameController/GCEventViewController.h>
#if __has_include(<UIKit/UIKit.h>)
#import <GameController/GCEventInteraction.h>
#import <GameController/GCGameControllerActivationContext.h>
#import <GameController/GCGameControllerSceneDelegate.h>
#endif
#if __has_include(<GameController/GCVirtualController.h>)
#import <GameController/GCVirtualController.h>
#endif
#import <GameController/GCSyntheticDeviceKeys.h>

View File

@ -0,0 +1,4 @@
---
version: 1
modules:
- name: _GameController_SwiftUI

View File

@ -0,0 +1,431 @@
// swift-interface-format-version: 1.0
// swift-compiler-version: Apple Swift version 6.0 effective-5.10 (swiftlang-6.0.0.3.38 clang-1600.0.20.6)
// swift-module-flags: -target arm64-apple-ios18.0 -enable-objc-interop -enable-library-evolution -swift-version 5 -enforce-exclusivity=unchecked -O -library-level api -enable-bare-slash-regex -user-module-version 12.0.31 -module-name GameController
@_exported import GameController
import Swift
import UIKit
import _Concurrency
import _StringProcessing
import _SwiftConcurrencyShims
@available(macOS 13.0, iOS 16.0, tvOS 16.0, *)
public struct GCPhysicalInputElementCollection<T> : Swift.Collection where T : GameController.GCPhysicalInputElement {
#if compiler(>=5.3) && $NoncopyableGenerics
public subscript(elementName: Swift.String) -> T? {
get
}
#else
public subscript(elementName: Swift.String) -> T? {
get
}
#endif
public typealias Element = T
public struct Index : Swift.Comparable {
public static func == (lhs: GameController.GCPhysicalInputElementCollection<T>.Index, rhs: GameController.GCPhysicalInputElementCollection<T>.Index) -> Swift.Bool
public static func < (lhs: GameController.GCPhysicalInputElementCollection<T>.Index, rhs: GameController.GCPhysicalInputElementCollection<T>.Index) -> Swift.Bool
}
public subscript(position: GameController.GCPhysicalInputElementCollection<T>.Index) -> GameController.GCPhysicalInputElementCollection<T>.Element {
get
}
public var startIndex: GameController.GCPhysicalInputElementCollection<T>.Index {
get
}
public var endIndex: GameController.GCPhysicalInputElementCollection<T>.Index {
get
}
public func index(after i: GameController.GCPhysicalInputElementCollection<T>.Index) -> GameController.GCPhysicalInputElementCollection<T>.Index
@available(iOS 16.0, tvOS 16.0, macOS 13.0, *)
public typealias Indices = Swift.DefaultIndices<GameController.GCPhysicalInputElementCollection<T>>
@available(iOS 16.0, tvOS 16.0, macOS 13.0, *)
public typealias Iterator = Swift.IndexingIterator<GameController.GCPhysicalInputElementCollection<T>>
@available(iOS 16.0, tvOS 16.0, macOS 13.0, *)
public typealias SubSequence = Swift.Slice<GameController.GCPhysicalInputElementCollection<T>>
}
@available(macOS 14.0, iOS 17.0, tvOS 17.0, *)
public protocol GCPhysicalInputElementTypedName : Swift.Hashable, Swift.RawRepresentable, Swift.Sendable where Self.RawValue == Swift.String {
associatedtype PhysicalInputElement : GameController.GCPhysicalInputElement
}
@available(macOS 13.0, iOS 16.0, tvOS 16.0, *)
public struct GCPhysicalInputElementName : Swift.RawRepresentable, Swift.Hashable, Swift.Sendable {
public init(rawValue: Swift.String)
public var rawValue: Swift.String {
get
}
@available(macOS 13.0, macCatalyst 16.0, *)
@available(iOS, unavailable)
@available(tvOS, unavailable)
public static let shifter: GameController.GCPhysicalInputElementName
@available(iOS 16.0, tvOS 16.0, macOS 13.0, *)
public typealias RawValue = Swift.String
}
@available(macOS 14.0, iOS 17.0, tvOS 17.0, *)
extension GameController.GCPhysicalInputElementName : GameController.GCPhysicalInputElementTypedName {
public typealias PhysicalInputElement = GameController.GCPhysicalInputElement
}
@available(macOS 13.0, iOS 16.0, tvOS 16.0, *)
extension GameController.GCPhysicalInputElementCollection where T == any GameController.GCPhysicalInputElement {
#if compiler(>=5.3) && $NoncopyableGenerics
public subscript(elementName: GameController.GCPhysicalInputElementName) -> T? {
get
}
#else
public subscript(elementName: GameController.GCPhysicalInputElementName) -> T? {
get
}
#endif
}
@available(macOS 14.0, iOS 17.0, tvOS 17.0, *)
extension GameController.GCPhysicalInputElementCollection {
#if compiler(>=5.3) && $NoncopyableGenerics
public subscript<Name>(elementName: Name) -> Name.PhysicalInputElement? where Name : GameController.GCPhysicalInputElementTypedName {
get
}
#else
public subscript<Name>(elementName: Name) -> Name.PhysicalInputElement? where Name : GameController.GCPhysicalInputElementTypedName {
get
}
#endif
#if compiler(>=5.3) && $NoncopyableGenerics
public subscript<Name>(elementName: Name) -> (any GameController.GCPhysicalInputElement)? where T == any GameController.GCPhysicalInputElement, Name : GameController.GCPhysicalInputElementTypedName {
get
}
#else
public subscript<Name>(elementName: Name) -> (any GameController.GCPhysicalInputElement)? where T == any GameController.GCPhysicalInputElement, Name : GameController.GCPhysicalInputElementTypedName {
get
}
#endif
}
extension GameController.GCDevicePhysicalInputStateDiff {
#if compiler(>=5.3) && $NoncopyableGenerics
@available(macOS 13.0, iOS 16.0, tvOS 16.0, *)
@_transparent @_disfavoredOverload public func changedElements() -> Foundation.NSEnumerator? {
return __changedElements()
}
#else
@available(macOS 13.0, iOS 16.0, tvOS 16.0, *)
@_transparent @_disfavoredOverload public func changedElements() -> Foundation.NSEnumerator? {
return __changedElements()
}
#endif
#if compiler(>=5.3) && $NoncopyableGenerics
@available(macOS 13.0, iOS 16.0, tvOS 16.0, *)
@backDeployed(before: macOS 14.0, iOS 17.0, tvOS 17.0)
@inlinable public func changedElements() -> (some Swift.Sequence<any GameController.GCPhysicalInputElement>)? {
return __changedElements()?.lazy.compactMap { $0 as? any GCPhysicalInputElement }
}
#else
@available(macOS 13.0, iOS 16.0, tvOS 16.0, *)
@backDeployed(before: macOS 14.0, iOS 17.0, tvOS 17.0)
@inlinable public func changedElements() -> (some Swift.Sequence<any GameController.GCPhysicalInputElement>)? {
return __changedElements()?.lazy.compactMap { $0 as? any GCPhysicalInputElement }
}
#endif
}
@available(macOS 13.0, iOS 16.0, tvOS 16.0, *)
public struct GCAxisElementName : Swift.RawRepresentable, Swift.Hashable, Swift.Sendable {
public init(rawValue: Swift.String)
public var rawValue: Swift.String {
get
}
@available(macOS 13.0, macCatalyst 16.0, *)
@available(iOS, unavailable)
@available(tvOS, unavailable)
public static let steeringWheel: GameController.GCAxisElementName
@available(iOS 16.0, tvOS 16.0, macOS 13.0, *)
public typealias RawValue = Swift.String
}
@available(macOS 13.0, iOS 16.0, tvOS 16.0, *)
extension GameController.GCPhysicalInputElementCollection where T == any GameController.GCAxisElement {
#if compiler(>=5.3) && $NoncopyableGenerics
public subscript(elementName: GameController.GCAxisElementName) -> T? {
get
}
#else
public subscript(elementName: GameController.GCAxisElementName) -> T? {
get
}
#endif
}
@available(macOS 14.0, iOS 17.0, tvOS 17.0, *)
extension GameController.GCAxisElementName : GameController.GCPhysicalInputElementTypedName {
public typealias PhysicalInputElement = GameController.GCAxisElement
}
@available(macOS 13.0, iOS 16.0, tvOS 16.0, *)
extension GameController.GCDevicePhysicalInputState {
public var elements: GameController.GCPhysicalInputElementCollection<any GameController.GCPhysicalInputElement> {
get
}
public var buttons: GameController.GCPhysicalInputElementCollection<any GameController.GCButtonElement> {
get
}
public var axes: GameController.GCPhysicalInputElementCollection<any GameController.GCAxisElement> {
get
}
public var switches: GameController.GCPhysicalInputElementCollection<any GameController.GCSwitchElement> {
get
}
public var dpads: GameController.GCPhysicalInputElementCollection<any GameController.GCDirectionPadElement> {
get
}
}
@available(macOS 13.0, iOS 16.0, tvOS 16.0, *)
public struct GCDirectionPadElementName : Swift.RawRepresentable, Swift.Hashable, Swift.Sendable {
public init(rawValue: Swift.String)
public var rawValue: Swift.String {
get
}
public static let directionPad: GameController.GCDirectionPadElementName
public static let leftThumbstick: GameController.GCDirectionPadElementName
public static let rightThumbstick: GameController.GCDirectionPadElementName
@available(iOS 16.0, tvOS 16.0, macOS 13.0, *)
public typealias RawValue = Swift.String
}
@available(macOS 13.0, iOS 16.0, tvOS 16.0, *)
extension GameController.GCPhysicalInputElementCollection where T == any GameController.GCDirectionPadElement {
#if compiler(>=5.3) && $NoncopyableGenerics
public subscript(elementName: GameController.GCDirectionPadElementName) -> T? {
get
}
#else
public subscript(elementName: GameController.GCDirectionPadElementName) -> T? {
get
}
#endif
}
@available(macOS 14.0, iOS 17.0, tvOS 17.0, *)
extension GameController.GCDirectionPadElementName : GameController.GCPhysicalInputElementTypedName {
public typealias PhysicalInputElement = GameController.GCDirectionPadElement
}
@available(macOS 11.0, iOS 14.0, tvOS 14.0, *)
@_alwaysEmitIntoClient public var GCInputButtonA: Swift.String {
get { __GCInputButtonName.a.rawValue }
}
@available(macOS 11.0, iOS 14.0, tvOS 14.0, *)
@_alwaysEmitIntoClient public var GCInputButtonB: Swift.String {
get { __GCInputButtonName.b.rawValue }
}
@available(macOS 11.0, iOS 14.0, tvOS 14.0, *)
@_alwaysEmitIntoClient public var GCInputButtonX: Swift.String {
get { __GCInputButtonName.x.rawValue }
}
@available(macOS 11.0, iOS 14.0, tvOS 14.0, *)
@_alwaysEmitIntoClient public var GCInputButtonY: Swift.String {
get { __GCInputButtonName.y.rawValue }
}
@available(macOS 11.0, iOS 14.0, tvOS 14.0, *)
@_alwaysEmitIntoClient public var GCInputDirectionPad: Swift.String {
get { __GCInputDirectionPadName.directionPad.rawValue }
}
@available(macOS 11.0, iOS 14.0, tvOS 14.0, *)
@_alwaysEmitIntoClient public var GCInputLeftThumbstick: Swift.String {
get { __GCInputDirectionPadName.leftThumbstick.rawValue }
}
@available(macOS 11.0, iOS 14.0, tvOS 14.0, *)
@_alwaysEmitIntoClient public var GCInputRightThumbstick: Swift.String {
get { __GCInputDirectionPadName.rightThumbstick.rawValue }
}
@available(macOS 11.0, iOS 14.0, tvOS 14.0, *)
@_alwaysEmitIntoClient public var GCInputLeftShoulder: Swift.String {
get { __GCInputButtonName.leftShoulder.rawValue }
}
@available(macOS 11.0, iOS 14.0, tvOS 14.0, *)
@_alwaysEmitIntoClient public var GCInputRightShoulder: Swift.String {
get { __GCInputButtonName.rightShoulder.rawValue }
}
@available(macOS 11.0, iOS 14.0, tvOS 14.0, *)
@_alwaysEmitIntoClient public var GCInputLeftTrigger: Swift.String {
get { __GCInputButtonName.leftTrigger.rawValue }
}
@available(macOS 11.0, iOS 14.0, tvOS 14.0, *)
@_alwaysEmitIntoClient public var GCInputRightTrigger: Swift.String {
get { __GCInputButtonName.rightTrigger.rawValue }
}
@available(macOS 11.0, iOS 14.0, tvOS 14.0, *)
@_alwaysEmitIntoClient public var GCInputLeftThumbstickButton: Swift.String {
get { __GCInputButtonName.leftThumbstickButton.rawValue }
}
@available(macOS 11.0, iOS 14.0, tvOS 14.0, *)
@_alwaysEmitIntoClient public var GCInputRightThumbstickButton: Swift.String {
get { __GCInputButtonName.rightThumbstickButton.rawValue }
}
@available(macOS 11.0, iOS 14.0, tvOS 14.0, *)
@_alwaysEmitIntoClient public var GCInputButtonHome: Swift.String {
get { __GCInputButtonName.home.rawValue }
}
@available(macOS 11.0, iOS 14.0, tvOS 14.0, *)
@_alwaysEmitIntoClient public var GCInputButtonMenu: Swift.String {
get { __GCInputButtonName.menu.rawValue }
}
@available(macOS 11.0, iOS 14.0, tvOS 14.0, *)
@_alwaysEmitIntoClient public var GCInputButtonOptions: Swift.String {
get { __GCInputButtonName.options.rawValue }
}
@available(macOS 12.0, iOS 15.0, tvOS 15.0, *)
@_alwaysEmitIntoClient public var GCInputButtonShare: Swift.String {
get { __GCInputButtonName.share.rawValue }
}
@available(macOS 11.0, iOS 14.0, tvOS 14.0, *)
@_alwaysEmitIntoClient public var GCInputXboxPaddleOne: Swift.String {
get { __GCInputButtonName.xboxPaddleOne.rawValue }
}
@available(macOS 11.0, iOS 14.0, tvOS 14.0, *)
@_alwaysEmitIntoClient public var GCInputXboxPaddleTwo: Swift.String {
get { __GCInputButtonName.xboxPaddleTwo.rawValue }
}
@available(macOS 11.0, iOS 14.0, tvOS 14.0, *)
@_alwaysEmitIntoClient public var GCInputXboxPaddleThree: Swift.String {
get { __GCInputButtonName.xboxPaddleThree.rawValue }
}
@available(macOS 11.0, iOS 14.0, tvOS 14.0, *)
@_alwaysEmitIntoClient public var GCInputXboxPaddleFour: Swift.String {
get { __GCInputButtonName.xboxPaddleFour.rawValue }
}
@available(macOS 11.0, iOS 14.0, tvOS 14.0, *)
@_alwaysEmitIntoClient public var GCInputDualShockTouchpadOne: Swift.String {
get { __GCInputDirectionPadName.dualShockTouchpadOne.rawValue }
}
@available(macOS 11.0, iOS 14.0, tvOS 14.0, *)
@_alwaysEmitIntoClient public var GCInputDualShockTouchpadTwo: Swift.String {
get { __GCInputDirectionPadName.dualShockTouchpadTwo.rawValue }
}
@available(macOS 11.0, iOS 14.0, tvOS 14.0, *)
@_alwaysEmitIntoClient public var GCInputDualShockTouchpadButton: Swift.String {
get { __GCInputButtonName.dualShockTouchpadButton.rawValue }
}
@available(macOS 13.0, macCatalyst 16.0, *)
@available(iOS, unavailable)
@available(tvOS, unavailable)
@_alwaysEmitIntoClient public var GCInputSteeringWheel: Swift.String {
get { __GCInputAxisName.steeringWheel.rawValue }
}
@available(macOS 13.0, macCatalyst 16.0, *)
@available(iOS, unavailable)
@available(tvOS, unavailable)
@_alwaysEmitIntoClient public var GCInputShifter: Swift.String {
get { __GCInputElementName.shifter.rawValue }
}
@available(macOS 13.0, macCatalyst 16.0, *)
@available(iOS, unavailable)
@available(tvOS, unavailable)
@_alwaysEmitIntoClient public var GCInputPedalAccelerator: Swift.String {
get { __GCInputButtonName.pedalAccelerator.rawValue }
}
@available(macOS 13.0, macCatalyst 16.0, *)
@available(iOS, unavailable)
@available(tvOS, unavailable)
@_alwaysEmitIntoClient public var GCInputPedalBrake: Swift.String {
get { __GCInputButtonName.pedalBrake.rawValue }
}
@available(macOS 13.0, macCatalyst 16.0, *)
@available(iOS, unavailable)
@available(tvOS, unavailable)
@_alwaysEmitIntoClient public var GCInputPedalClutch: Swift.String {
get { __GCInputButtonName.pedalClutch.rawValue }
}
@available(macOS 13.0, macCatalyst 16.0, *)
@available(iOS, unavailable)
@available(tvOS, unavailable)
@_alwaysEmitIntoClient public var GCInputLeftPaddle: Swift.String {
get { __GCInputButtonName.leftPaddle.rawValue }
}
@available(macOS 13.0, macCatalyst 16.0, *)
@available(iOS, unavailable)
@available(tvOS, unavailable)
@_alwaysEmitIntoClient public var GCInputRightPaddle: Swift.String {
get { __GCInputButtonName.rightPaddle.rawValue }
}
@available(macOS 13.0, iOS 16.0, tvOS 16.0, *)
public struct GCSwitchElementName : Swift.RawRepresentable, Swift.Hashable, Swift.Sendable {
public init(rawValue: Swift.String)
public var rawValue: Swift.String {
get
}
@available(iOS 16.0, tvOS 16.0, macOS 13.0, *)
public typealias RawValue = Swift.String
}
@available(macOS 13.0, iOS 16.0, tvOS 16.0, *)
extension GameController.GCPhysicalInputElementCollection where T == any GameController.GCSwitchElement {
#if compiler(>=5.3) && $NoncopyableGenerics
public subscript(elementName: GameController.GCSwitchElementName) -> T? {
get
}
#else
public subscript(elementName: GameController.GCSwitchElementName) -> T? {
get
}
#endif
}
@available(macOS 14.0, iOS 17.0, tvOS 17.0, *)
extension GameController.GCSwitchElementName : GameController.GCPhysicalInputElementTypedName {
public typealias PhysicalInputElement = GameController.GCSwitchElement
}
@available(macOS 13.0, iOS 16.0, tvOS 16.0, *)
public struct GCButtonElementName : Swift.RawRepresentable, Swift.Hashable, Swift.Sendable {
public init(rawValue: Swift.String)
public var rawValue: Swift.String {
get
}
public static let a: GameController.GCButtonElementName
public static let b: GameController.GCButtonElementName
public static let x: GameController.GCButtonElementName
public static let y: GameController.GCButtonElementName
public static let leftShoulder: GameController.GCButtonElementName
public static let rightShoulder: GameController.GCButtonElementName
@available(macOS 14.4, iOS 17.4, tvOS 17.4, visionOS 1.1, *)
public static let leftBumper: GameController.GCButtonElementName
@available(macOS 14.4, iOS 17.4, tvOS 17.4, visionOS 1.1, *)
public static let rightBumper: GameController.GCButtonElementName
public static let leftTrigger: GameController.GCButtonElementName
public static let rightTrigger: GameController.GCButtonElementName
public static let leftThumbstickButton: GameController.GCButtonElementName
public static let rightThumbstickButton: GameController.GCButtonElementName
@available(macOS 14.4, iOS 17.4, tvOS 17.4, visionOS 1.1, *)
public static func backLeftButton(position: Swift.Int) -> GameController.GCButtonElementName
@available(macOS 14.4, iOS 17.4, tvOS 17.4, visionOS 1.1, *)
public static func backRightButton(position: Swift.Int) -> GameController.GCButtonElementName
public static let home: GameController.GCButtonElementName
public static let menu: GameController.GCButtonElementName
public static let options: GameController.GCButtonElementName
public static let share: GameController.GCButtonElementName
@available(macOS 13.0, macCatalyst 16.0, *)
@available(iOS, unavailable)
@available(tvOS, unavailable)
public static let pedalAccelerator: GameController.GCButtonElementName
@available(macOS 13.0, macCatalyst 16.0, *)
@available(iOS, unavailable)
@available(tvOS, unavailable)
public static let pedalBrake: GameController.GCButtonElementName
@available(macOS 13.0, macCatalyst 16.0, *)
@available(iOS, unavailable)
@available(tvOS, unavailable)
public static let pedalClutch: GameController.GCButtonElementName
@available(macOS 13.0, macCatalyst 16.0, *)
@available(iOS, unavailable)
@available(tvOS, unavailable)
public static let leftPaddle: GameController.GCButtonElementName
@available(macOS 13.0, macCatalyst 16.0, *)
@available(iOS, unavailable)
@available(tvOS, unavailable)
public static let rightPaddle: GameController.GCButtonElementName
@available(macOS 14.0, iOS 17.0, tvOS 17.0, *)
public static func arcadeButton(row: Swift.Int, column: Swift.Int) -> GameController.GCButtonElementName
@available(iOS 16.0, tvOS 16.0, macOS 13.0, *)
public typealias RawValue = Swift.String
}
@available(macOS 13.0, iOS 16.0, tvOS 16.0, *)
extension GameController.GCPhysicalInputElementCollection where T == any GameController.GCButtonElement {
#if compiler(>=5.3) && $NoncopyableGenerics
public subscript(elementName: GameController.GCButtonElementName) -> T? {
get
}
#else
public subscript(elementName: GameController.GCButtonElementName) -> T? {
get
}
#endif
}
@available(macOS 14.0, iOS 17.0, tvOS 17.0, *)
extension GameController.GCButtonElementName : GameController.GCPhysicalInputElementTypedName {
public typealias PhysicalInputElement = GameController.GCButtonElement
}

View File

@ -0,0 +1,431 @@
// swift-interface-format-version: 1.0
// swift-compiler-version: Apple Swift version 6.0 effective-5.10 (swiftlang-6.0.0.3.38 clang-1600.0.20.6)
// swift-module-flags: -target arm64e-apple-ios18.0 -enable-objc-interop -enable-library-evolution -swift-version 5 -enforce-exclusivity=unchecked -O -library-level api -enable-bare-slash-regex -user-module-version 12.0.31 -module-name GameController
@_exported import GameController
import Swift
import UIKit
import _Concurrency
import _StringProcessing
import _SwiftConcurrencyShims
@available(macOS 13.0, iOS 16.0, tvOS 16.0, *)
public struct GCPhysicalInputElementCollection<T> : Swift.Collection where T : GameController.GCPhysicalInputElement {
#if compiler(>=5.3) && $NoncopyableGenerics
public subscript(elementName: Swift.String) -> T? {
get
}
#else
public subscript(elementName: Swift.String) -> T? {
get
}
#endif
public typealias Element = T
public struct Index : Swift.Comparable {
public static func == (lhs: GameController.GCPhysicalInputElementCollection<T>.Index, rhs: GameController.GCPhysicalInputElementCollection<T>.Index) -> Swift.Bool
public static func < (lhs: GameController.GCPhysicalInputElementCollection<T>.Index, rhs: GameController.GCPhysicalInputElementCollection<T>.Index) -> Swift.Bool
}
public subscript(position: GameController.GCPhysicalInputElementCollection<T>.Index) -> GameController.GCPhysicalInputElementCollection<T>.Element {
get
}
public var startIndex: GameController.GCPhysicalInputElementCollection<T>.Index {
get
}
public var endIndex: GameController.GCPhysicalInputElementCollection<T>.Index {
get
}
public func index(after i: GameController.GCPhysicalInputElementCollection<T>.Index) -> GameController.GCPhysicalInputElementCollection<T>.Index
@available(iOS 16.0, tvOS 16.0, macOS 13.0, *)
public typealias Indices = Swift.DefaultIndices<GameController.GCPhysicalInputElementCollection<T>>
@available(iOS 16.0, tvOS 16.0, macOS 13.0, *)
public typealias Iterator = Swift.IndexingIterator<GameController.GCPhysicalInputElementCollection<T>>
@available(iOS 16.0, tvOS 16.0, macOS 13.0, *)
public typealias SubSequence = Swift.Slice<GameController.GCPhysicalInputElementCollection<T>>
}
@available(macOS 14.0, iOS 17.0, tvOS 17.0, *)
public protocol GCPhysicalInputElementTypedName : Swift.Hashable, Swift.RawRepresentable, Swift.Sendable where Self.RawValue == Swift.String {
associatedtype PhysicalInputElement : GameController.GCPhysicalInputElement
}
@available(macOS 13.0, iOS 16.0, tvOS 16.0, *)
public struct GCPhysicalInputElementName : Swift.RawRepresentable, Swift.Hashable, Swift.Sendable {
public init(rawValue: Swift.String)
public var rawValue: Swift.String {
get
}
@available(macOS 13.0, macCatalyst 16.0, *)
@available(iOS, unavailable)
@available(tvOS, unavailable)
public static let shifter: GameController.GCPhysicalInputElementName
@available(iOS 16.0, tvOS 16.0, macOS 13.0, *)
public typealias RawValue = Swift.String
}
@available(macOS 14.0, iOS 17.0, tvOS 17.0, *)
extension GameController.GCPhysicalInputElementName : GameController.GCPhysicalInputElementTypedName {
public typealias PhysicalInputElement = GameController.GCPhysicalInputElement
}
@available(macOS 13.0, iOS 16.0, tvOS 16.0, *)
extension GameController.GCPhysicalInputElementCollection where T == any GameController.GCPhysicalInputElement {
#if compiler(>=5.3) && $NoncopyableGenerics
public subscript(elementName: GameController.GCPhysicalInputElementName) -> T? {
get
}
#else
public subscript(elementName: GameController.GCPhysicalInputElementName) -> T? {
get
}
#endif
}
@available(macOS 14.0, iOS 17.0, tvOS 17.0, *)
extension GameController.GCPhysicalInputElementCollection {
#if compiler(>=5.3) && $NoncopyableGenerics
public subscript<Name>(elementName: Name) -> Name.PhysicalInputElement? where Name : GameController.GCPhysicalInputElementTypedName {
get
}
#else
public subscript<Name>(elementName: Name) -> Name.PhysicalInputElement? where Name : GameController.GCPhysicalInputElementTypedName {
get
}
#endif
#if compiler(>=5.3) && $NoncopyableGenerics
public subscript<Name>(elementName: Name) -> (any GameController.GCPhysicalInputElement)? where T == any GameController.GCPhysicalInputElement, Name : GameController.GCPhysicalInputElementTypedName {
get
}
#else
public subscript<Name>(elementName: Name) -> (any GameController.GCPhysicalInputElement)? where T == any GameController.GCPhysicalInputElement, Name : GameController.GCPhysicalInputElementTypedName {
get
}
#endif
}
extension GameController.GCDevicePhysicalInputStateDiff {
#if compiler(>=5.3) && $NoncopyableGenerics
@available(macOS 13.0, iOS 16.0, tvOS 16.0, *)
@_transparent @_disfavoredOverload public func changedElements() -> Foundation.NSEnumerator? {
return __changedElements()
}
#else
@available(macOS 13.0, iOS 16.0, tvOS 16.0, *)
@_transparent @_disfavoredOverload public func changedElements() -> Foundation.NSEnumerator? {
return __changedElements()
}
#endif
#if compiler(>=5.3) && $NoncopyableGenerics
@available(macOS 13.0, iOS 16.0, tvOS 16.0, *)
@backDeployed(before: macOS 14.0, iOS 17.0, tvOS 17.0)
@inlinable public func changedElements() -> (some Swift.Sequence<any GameController.GCPhysicalInputElement>)? {
return __changedElements()?.lazy.compactMap { $0 as? any GCPhysicalInputElement }
}
#else
@available(macOS 13.0, iOS 16.0, tvOS 16.0, *)
@backDeployed(before: macOS 14.0, iOS 17.0, tvOS 17.0)
@inlinable public func changedElements() -> (some Swift.Sequence<any GameController.GCPhysicalInputElement>)? {
return __changedElements()?.lazy.compactMap { $0 as? any GCPhysicalInputElement }
}
#endif
}
@available(macOS 13.0, iOS 16.0, tvOS 16.0, *)
public struct GCAxisElementName : Swift.RawRepresentable, Swift.Hashable, Swift.Sendable {
public init(rawValue: Swift.String)
public var rawValue: Swift.String {
get
}
@available(macOS 13.0, macCatalyst 16.0, *)
@available(iOS, unavailable)
@available(tvOS, unavailable)
public static let steeringWheel: GameController.GCAxisElementName
@available(iOS 16.0, tvOS 16.0, macOS 13.0, *)
public typealias RawValue = Swift.String
}
@available(macOS 13.0, iOS 16.0, tvOS 16.0, *)
extension GameController.GCPhysicalInputElementCollection where T == any GameController.GCAxisElement {
#if compiler(>=5.3) && $NoncopyableGenerics
public subscript(elementName: GameController.GCAxisElementName) -> T? {
get
}
#else
public subscript(elementName: GameController.GCAxisElementName) -> T? {
get
}
#endif
}
@available(macOS 14.0, iOS 17.0, tvOS 17.0, *)
extension GameController.GCAxisElementName : GameController.GCPhysicalInputElementTypedName {
public typealias PhysicalInputElement = GameController.GCAxisElement
}
@available(macOS 13.0, iOS 16.0, tvOS 16.0, *)
extension GameController.GCDevicePhysicalInputState {
public var elements: GameController.GCPhysicalInputElementCollection<any GameController.GCPhysicalInputElement> {
get
}
public var buttons: GameController.GCPhysicalInputElementCollection<any GameController.GCButtonElement> {
get
}
public var axes: GameController.GCPhysicalInputElementCollection<any GameController.GCAxisElement> {
get
}
public var switches: GameController.GCPhysicalInputElementCollection<any GameController.GCSwitchElement> {
get
}
public var dpads: GameController.GCPhysicalInputElementCollection<any GameController.GCDirectionPadElement> {
get
}
}
@available(macOS 13.0, iOS 16.0, tvOS 16.0, *)
public struct GCDirectionPadElementName : Swift.RawRepresentable, Swift.Hashable, Swift.Sendable {
public init(rawValue: Swift.String)
public var rawValue: Swift.String {
get
}
public static let directionPad: GameController.GCDirectionPadElementName
public static let leftThumbstick: GameController.GCDirectionPadElementName
public static let rightThumbstick: GameController.GCDirectionPadElementName
@available(iOS 16.0, tvOS 16.0, macOS 13.0, *)
public typealias RawValue = Swift.String
}
@available(macOS 13.0, iOS 16.0, tvOS 16.0, *)
extension GameController.GCPhysicalInputElementCollection where T == any GameController.GCDirectionPadElement {
#if compiler(>=5.3) && $NoncopyableGenerics
public subscript(elementName: GameController.GCDirectionPadElementName) -> T? {
get
}
#else
public subscript(elementName: GameController.GCDirectionPadElementName) -> T? {
get
}
#endif
}
@available(macOS 14.0, iOS 17.0, tvOS 17.0, *)
extension GameController.GCDirectionPadElementName : GameController.GCPhysicalInputElementTypedName {
public typealias PhysicalInputElement = GameController.GCDirectionPadElement
}
@available(macOS 11.0, iOS 14.0, tvOS 14.0, *)
@_alwaysEmitIntoClient public var GCInputButtonA: Swift.String {
get { __GCInputButtonName.a.rawValue }
}
@available(macOS 11.0, iOS 14.0, tvOS 14.0, *)
@_alwaysEmitIntoClient public var GCInputButtonB: Swift.String {
get { __GCInputButtonName.b.rawValue }
}
@available(macOS 11.0, iOS 14.0, tvOS 14.0, *)
@_alwaysEmitIntoClient public var GCInputButtonX: Swift.String {
get { __GCInputButtonName.x.rawValue }
}
@available(macOS 11.0, iOS 14.0, tvOS 14.0, *)
@_alwaysEmitIntoClient public var GCInputButtonY: Swift.String {
get { __GCInputButtonName.y.rawValue }
}
@available(macOS 11.0, iOS 14.0, tvOS 14.0, *)
@_alwaysEmitIntoClient public var GCInputDirectionPad: Swift.String {
get { __GCInputDirectionPadName.directionPad.rawValue }
}
@available(macOS 11.0, iOS 14.0, tvOS 14.0, *)
@_alwaysEmitIntoClient public var GCInputLeftThumbstick: Swift.String {
get { __GCInputDirectionPadName.leftThumbstick.rawValue }
}
@available(macOS 11.0, iOS 14.0, tvOS 14.0, *)
@_alwaysEmitIntoClient public var GCInputRightThumbstick: Swift.String {
get { __GCInputDirectionPadName.rightThumbstick.rawValue }
}
@available(macOS 11.0, iOS 14.0, tvOS 14.0, *)
@_alwaysEmitIntoClient public var GCInputLeftShoulder: Swift.String {
get { __GCInputButtonName.leftShoulder.rawValue }
}
@available(macOS 11.0, iOS 14.0, tvOS 14.0, *)
@_alwaysEmitIntoClient public var GCInputRightShoulder: Swift.String {
get { __GCInputButtonName.rightShoulder.rawValue }
}
@available(macOS 11.0, iOS 14.0, tvOS 14.0, *)
@_alwaysEmitIntoClient public var GCInputLeftTrigger: Swift.String {
get { __GCInputButtonName.leftTrigger.rawValue }
}
@available(macOS 11.0, iOS 14.0, tvOS 14.0, *)
@_alwaysEmitIntoClient public var GCInputRightTrigger: Swift.String {
get { __GCInputButtonName.rightTrigger.rawValue }
}
@available(macOS 11.0, iOS 14.0, tvOS 14.0, *)
@_alwaysEmitIntoClient public var GCInputLeftThumbstickButton: Swift.String {
get { __GCInputButtonName.leftThumbstickButton.rawValue }
}
@available(macOS 11.0, iOS 14.0, tvOS 14.0, *)
@_alwaysEmitIntoClient public var GCInputRightThumbstickButton: Swift.String {
get { __GCInputButtonName.rightThumbstickButton.rawValue }
}
@available(macOS 11.0, iOS 14.0, tvOS 14.0, *)
@_alwaysEmitIntoClient public var GCInputButtonHome: Swift.String {
get { __GCInputButtonName.home.rawValue }
}
@available(macOS 11.0, iOS 14.0, tvOS 14.0, *)
@_alwaysEmitIntoClient public var GCInputButtonMenu: Swift.String {
get { __GCInputButtonName.menu.rawValue }
}
@available(macOS 11.0, iOS 14.0, tvOS 14.0, *)
@_alwaysEmitIntoClient public var GCInputButtonOptions: Swift.String {
get { __GCInputButtonName.options.rawValue }
}
@available(macOS 12.0, iOS 15.0, tvOS 15.0, *)
@_alwaysEmitIntoClient public var GCInputButtonShare: Swift.String {
get { __GCInputButtonName.share.rawValue }
}
@available(macOS 11.0, iOS 14.0, tvOS 14.0, *)
@_alwaysEmitIntoClient public var GCInputXboxPaddleOne: Swift.String {
get { __GCInputButtonName.xboxPaddleOne.rawValue }
}
@available(macOS 11.0, iOS 14.0, tvOS 14.0, *)
@_alwaysEmitIntoClient public var GCInputXboxPaddleTwo: Swift.String {
get { __GCInputButtonName.xboxPaddleTwo.rawValue }
}
@available(macOS 11.0, iOS 14.0, tvOS 14.0, *)
@_alwaysEmitIntoClient public var GCInputXboxPaddleThree: Swift.String {
get { __GCInputButtonName.xboxPaddleThree.rawValue }
}
@available(macOS 11.0, iOS 14.0, tvOS 14.0, *)
@_alwaysEmitIntoClient public var GCInputXboxPaddleFour: Swift.String {
get { __GCInputButtonName.xboxPaddleFour.rawValue }
}
@available(macOS 11.0, iOS 14.0, tvOS 14.0, *)
@_alwaysEmitIntoClient public var GCInputDualShockTouchpadOne: Swift.String {
get { __GCInputDirectionPadName.dualShockTouchpadOne.rawValue }
}
@available(macOS 11.0, iOS 14.0, tvOS 14.0, *)
@_alwaysEmitIntoClient public var GCInputDualShockTouchpadTwo: Swift.String {
get { __GCInputDirectionPadName.dualShockTouchpadTwo.rawValue }
}
@available(macOS 11.0, iOS 14.0, tvOS 14.0, *)
@_alwaysEmitIntoClient public var GCInputDualShockTouchpadButton: Swift.String {
get { __GCInputButtonName.dualShockTouchpadButton.rawValue }
}
@available(macOS 13.0, macCatalyst 16.0, *)
@available(iOS, unavailable)
@available(tvOS, unavailable)
@_alwaysEmitIntoClient public var GCInputSteeringWheel: Swift.String {
get { __GCInputAxisName.steeringWheel.rawValue }
}
@available(macOS 13.0, macCatalyst 16.0, *)
@available(iOS, unavailable)
@available(tvOS, unavailable)
@_alwaysEmitIntoClient public var GCInputShifter: Swift.String {
get { __GCInputElementName.shifter.rawValue }
}
@available(macOS 13.0, macCatalyst 16.0, *)
@available(iOS, unavailable)
@available(tvOS, unavailable)
@_alwaysEmitIntoClient public var GCInputPedalAccelerator: Swift.String {
get { __GCInputButtonName.pedalAccelerator.rawValue }
}
@available(macOS 13.0, macCatalyst 16.0, *)
@available(iOS, unavailable)
@available(tvOS, unavailable)
@_alwaysEmitIntoClient public var GCInputPedalBrake: Swift.String {
get { __GCInputButtonName.pedalBrake.rawValue }
}
@available(macOS 13.0, macCatalyst 16.0, *)
@available(iOS, unavailable)
@available(tvOS, unavailable)
@_alwaysEmitIntoClient public var GCInputPedalClutch: Swift.String {
get { __GCInputButtonName.pedalClutch.rawValue }
}
@available(macOS 13.0, macCatalyst 16.0, *)
@available(iOS, unavailable)
@available(tvOS, unavailable)
@_alwaysEmitIntoClient public var GCInputLeftPaddle: Swift.String {
get { __GCInputButtonName.leftPaddle.rawValue }
}
@available(macOS 13.0, macCatalyst 16.0, *)
@available(iOS, unavailable)
@available(tvOS, unavailable)
@_alwaysEmitIntoClient public var GCInputRightPaddle: Swift.String {
get { __GCInputButtonName.rightPaddle.rawValue }
}
@available(macOS 13.0, iOS 16.0, tvOS 16.0, *)
public struct GCSwitchElementName : Swift.RawRepresentable, Swift.Hashable, Swift.Sendable {
public init(rawValue: Swift.String)
public var rawValue: Swift.String {
get
}
@available(iOS 16.0, tvOS 16.0, macOS 13.0, *)
public typealias RawValue = Swift.String
}
@available(macOS 13.0, iOS 16.0, tvOS 16.0, *)
extension GameController.GCPhysicalInputElementCollection where T == any GameController.GCSwitchElement {
#if compiler(>=5.3) && $NoncopyableGenerics
public subscript(elementName: GameController.GCSwitchElementName) -> T? {
get
}
#else
public subscript(elementName: GameController.GCSwitchElementName) -> T? {
get
}
#endif
}
@available(macOS 14.0, iOS 17.0, tvOS 17.0, *)
extension GameController.GCSwitchElementName : GameController.GCPhysicalInputElementTypedName {
public typealias PhysicalInputElement = GameController.GCSwitchElement
}
@available(macOS 13.0, iOS 16.0, tvOS 16.0, *)
public struct GCButtonElementName : Swift.RawRepresentable, Swift.Hashable, Swift.Sendable {
public init(rawValue: Swift.String)
public var rawValue: Swift.String {
get
}
public static let a: GameController.GCButtonElementName
public static let b: GameController.GCButtonElementName
public static let x: GameController.GCButtonElementName
public static let y: GameController.GCButtonElementName
public static let leftShoulder: GameController.GCButtonElementName
public static let rightShoulder: GameController.GCButtonElementName
@available(macOS 14.4, iOS 17.4, tvOS 17.4, visionOS 1.1, *)
public static let leftBumper: GameController.GCButtonElementName
@available(macOS 14.4, iOS 17.4, tvOS 17.4, visionOS 1.1, *)
public static let rightBumper: GameController.GCButtonElementName
public static let leftTrigger: GameController.GCButtonElementName
public static let rightTrigger: GameController.GCButtonElementName
public static let leftThumbstickButton: GameController.GCButtonElementName
public static let rightThumbstickButton: GameController.GCButtonElementName
@available(macOS 14.4, iOS 17.4, tvOS 17.4, visionOS 1.1, *)
public static func backLeftButton(position: Swift.Int) -> GameController.GCButtonElementName
@available(macOS 14.4, iOS 17.4, tvOS 17.4, visionOS 1.1, *)
public static func backRightButton(position: Swift.Int) -> GameController.GCButtonElementName
public static let home: GameController.GCButtonElementName
public static let menu: GameController.GCButtonElementName
public static let options: GameController.GCButtonElementName
public static let share: GameController.GCButtonElementName
@available(macOS 13.0, macCatalyst 16.0, *)
@available(iOS, unavailable)
@available(tvOS, unavailable)
public static let pedalAccelerator: GameController.GCButtonElementName
@available(macOS 13.0, macCatalyst 16.0, *)
@available(iOS, unavailable)
@available(tvOS, unavailable)
public static let pedalBrake: GameController.GCButtonElementName
@available(macOS 13.0, macCatalyst 16.0, *)
@available(iOS, unavailable)
@available(tvOS, unavailable)
public static let pedalClutch: GameController.GCButtonElementName
@available(macOS 13.0, macCatalyst 16.0, *)
@available(iOS, unavailable)
@available(tvOS, unavailable)
public static let leftPaddle: GameController.GCButtonElementName
@available(macOS 13.0, macCatalyst 16.0, *)
@available(iOS, unavailable)
@available(tvOS, unavailable)
public static let rightPaddle: GameController.GCButtonElementName
@available(macOS 14.0, iOS 17.0, tvOS 17.0, *)
public static func arcadeButton(row: Swift.Int, column: Swift.Int) -> GameController.GCButtonElementName
@available(iOS 16.0, tvOS 16.0, macOS 13.0, *)
public typealias RawValue = Swift.String
}
@available(macOS 13.0, iOS 16.0, tvOS 16.0, *)
extension GameController.GCPhysicalInputElementCollection where T == any GameController.GCButtonElement {
#if compiler(>=5.3) && $NoncopyableGenerics
public subscript(elementName: GameController.GCButtonElementName) -> T? {
get
}
#else
public subscript(elementName: GameController.GCButtonElementName) -> T? {
get
}
#endif
}
@available(macOS 14.0, iOS 17.0, tvOS 17.0, *)
extension GameController.GCButtonElementName : GameController.GCPhysicalInputElementTypedName {
public typealias PhysicalInputElement = GameController.GCButtonElement
}

View File

@ -0,0 +1,6 @@
framework module GameController [system] {
umbrella header "GameController.h"
export *
module * { export * }
}

674
LICENSE Normal file
View File

@ -0,0 +1,674 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<https://www.gnu.org/licenses/why-not-lgpl.html>.

175
Makefile Normal file
View File

@ -0,0 +1,175 @@
SHELL := /bin/bash
.PHONY: help ios update tvos
RUBY := $(shell command -v ruby 2>/dev/null)
HOMEBREW := $(shell command -v brew 2>/dev/null)
BUNDLER := $(shell command -v bundle 2>/dev/null)
default: help
# Add the following 'help' target to your Makefile
# And add help text after each target name starting with '\#\#'
# A category can be added with @category
# COLORS
GREEN := $(shell tput -Txterm setaf 2)
YELLOW := $(shell tput -Txterm setaf 3)
WHITE := $(shell tput -Txterm setaf 7)
RESET := $(shell tput -Txterm sgr0)
## ----- Helper functions ------
# Helper target for declaring an external executable as a recipe dependency.
# For example,
# `my_target: | _program_awk`
# will fail before running the target named `my_target` if the command `awk` is
# not found on the system path.
_program_%: FORCE
@_=$(or $(shell which $* 2> /dev/null),$(error `$*` command not found. Please install `$*` and try again))
# Helper target for declaring required environment variables.
#
# For example,
# `my_target`: | _var_PARAMETER`
#
# will fail before running `my_target` if the variable `PARAMETER` is not declared.
_var_%: FORCE
@_=$(or $($*),$(error `$*` is a required parameter))
_tag: | _var_VERSION
make --no-print-directory -B README.md
git commit -am "Tagging release $(VERSION)"
git tag -a $(VERSION) $(if $(NOTES),-m '$(NOTES)',-m $(VERSION))
.PHONY: _tag
_push: | _var_VERSION
git push origin $(VERSION)
git push origin master
.PHONY: _push
## ------ Commmands -----------
TARGET_MAX_CHAR_NUM=20
## Show help
help:
@echo ''
@echo 'Usage:'
@echo ' ${YELLOW}make${RESET} ${GREEN}<target>${RESET}'
@echo ''
@echo 'Targets:'
@awk '/^[a-zA-Z\-\_0-9]+:/ { \
helpMessage = match(lastLine, /^## (.*)/); \
if (helpMessage) { \
helpCommand = substr($$1, 0, index($$1, ":")-1); \
helpMessage = substr(lastLine, RSTART + 3, RLENGTH); \
printf " ${YELLOW}%-$(TARGET_MAX_CHAR_NUM)s${RESET} ${GREEN}%s${RESET}\n", helpCommand, helpMessage; \
} \
} \
{ lastLine = $$0 }' \
$(MAKEFILE_LIST)
## Install dependencies.
setup: \
pre_setup
# check_for_homebrew \
# update_homebrew \
pull_request: \
test \
codecov_upload \
danger
pre_setup:
$(info Project setup…)
check_for_ruby:
$(info Checking for Ruby…)
ifeq ($(RUBY),)
$(error Ruby is not installed.)
endif
check_for_homebrew:
$(info Checking for Homebrew…)
ifeq ($(HOMEBREW),)
$(error Homebrew is not installed)
endif
update_homebrew:
$(info Updating Homebrew…)
brew update
install_swift_lint:
$(info Install swiftlint…)
brew unlink swiftlint || true
brew install swiftlint
brew link --overwrite swiftlint
install_bundler_gem:
$(info Checking and installing bundler…)
ifeq ($(BUNDLER),)
gem install bundler -v '~> 1.17'
else
gem update bundler '~> 1.17'
endif
install_ruby_gems:
$(info Installing Ruby gems…)
bundle install
pull:
$(info Pulling new commits…)
git stash push || true
git pull
git stash pop || true
## -- Source Code Tasks --
## Pull upstream and update 3rd party frameworks
update: submodules
submodules:
$(info Updating submodules…)
git submodule update --init --recursive --remote
## -- QA Task Runners --
codecov_upload:
curl -s https://codecov.io/bash | bash
danger:
bundle exec danger
## -- Testing --
## Run test on all targets
test:
bundle exec fastlane test
## -- Building --
build:
@xcodebuild -workspace Pomelo.xcodeproj/project.xcworkspace \
-scheme Pomelo \
-sdk iphoneos \
-destination generic/platform=iOS
archive -archivePath ./archive \
CODE_SIGNING_REQUIRED=NO \
AD_HOC_CODE_SIGNING_ALLOWED=YES \
CODE_SIGNING_ALLOWED=NO \
DWARF_DSYM_FOLDER_PATH="."
ipa:
mkdir Payload
mkdir Payload/Pomelo.app
cp -R archive.xcarchive/Products/Applications/Pomelo.app/ Payload/Pomelo.app/
zip -r Pomelo.ipa Payload

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:">
</FileRef>
</Workspace>

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict/>
</plist>

View File

@ -0,0 +1,90 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1600"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES"
buildArchitectures = "Automatic">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "384F18892C1DCB4F0073375C"
BuildableName = "Pomelo.app"
BlueprintName = "Pomelo"
ReferencedContainer = "container:Pomelo.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Release"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
shouldAutocreateTestPlan = "YES">
</TestAction>
<LaunchAction
buildConfiguration = "Release"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
enableGPUValidationMode = "1"
allowLocationSimulation = "YES"
viewDebuggingEnabled = "No"
queueDebuggingEnabled = "No"
consoleMode = "0"
structuredConsoleMode = "1">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "384F18892C1DCB4F0073375C"
BuildableName = "Pomelo.app"
BlueprintName = "Pomelo"
ReferencedContainer = "container:Pomelo.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<AdditionalOptions>
<AdditionalOption
key = "APP_DISTRIBUTOR_ID_OVERRIDE"
value = "com.apple.AppStore"
isEnabled = "YES">
</AdditionalOption>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "384F18892C1DCB4F0073375C"
BuildableName = "Pomelo.app"
BlueprintName = "Pomelo"
ReferencedContainer = "container:Pomelo.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Release">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

Some files were not shown because too many files have changed in this diff Show More