<!--
{
  "availability" : [
    "iOS: -",
    "iPadOS: -",
    "visionOS: 26.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "GameController",
  "identifier" : "/documentation/GameController/GCStylus",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "Game Controller"
    ],
    "preciseIdentifier" : "c:objc(cs)GCStylus"
  },
  "title" : "GCStylus"
}
-->

# GCStylus

An object that represents a physical stylus connected to the device.

```
class GCStylus
```

## Overview

Use the `styli` property to get the currently connect stylus accessories
when your application starts.  Register for `GCStylusDidConnectNotification`
and `GCStylusDidDisconnectNotification` to get notified when a stylus
connects of disconnects while your application is running.

```
// Register for notifications
NotificationCenter.default.addObserver(self, selector: #selector(stylus(didConnect:)), name: NSNotification.Name.GCStylusDidConnect, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(stylus(didDisconnect:)), name: NSNotification.Name.GCStylusDidConnect, object: nil)

// Query current stylus devices
for stylus in GCStylus.styluses {
    ...
}

// Later, handle connection
@objc func stylus(didConnect notification: Notification) {
    guard let stylus = notification.object as? GCStylus else { return }
    ...
}
```

Check the `productCategory` to determine the type of stylus.  A spatial
stylus - capable of 6DoF tracking by Apple Vision Pro - has a
`GCProductCategorySpatialStylus` category.

Use the `input` property to get the input profile of the stylus.  A spatial
stylus includes a pressure sensitive tip and an input cluster composed of
two buttons.

- The primary button (`GCInputStylusPrimaryButton`) is the front button
  (closest to the stylus tip) in the input cluster of the stylus.  This
  button is frequently used grab virtual objects.
- The secondary button (`GCInputStylusSecondaryButton`) is the middle
  button in the input cluster.  It can measures pressure/force levels.
  It’s intended to be used for controlling in-air drawing, selection,
  and generic interactions.
- The tip is also represented as a button (`GCInputStylusTip`).

```
guard let input = stylus.input else { return }
input.inputStateQueueDepth = 20
input.inputStateAvailableHandler = { input in
    // This block will be enqueued for execution when the state of
    // any stylus input changes.

    // Iterate through all input state changes since last execution of
    // the block.
    while let nextState = input.nextInputState() {
        // Use the value of `pressedInput.isPressed` for binary
        // interactions, such as object selection.
        let primaryButtonPressed = nextState.buttons[.stylusPrimaryButton]?.pressedInput.isPressed
        let secondaryButtonPressed = nextState.buttons[.stylusSecondaryButton]?.pressedInput.isPressed
        // Use the normalized press value for analog actions such as
        // controlling virtual ink flow.
        let secondaryButtonPressure = nextState.buttons[.stylusSecondaryButton]?.pressedInput.value
        let tipPressure = nextState.buttons[.stylusTip]?.pressedInput.value

        ...
    }
}
```

Use the `haptics` property to get the haptics profile of the stylus.  A
spatial stylus may optionally support haptic feedback to a single
locality - `GCHapticsLocalityDefault`.

## Topics

### Accessing the styli

[`styli`](/documentation/GameController/GCStylus/styli)

Get the collection of stylus accessories currently connected to the device.

[`GCStylusDidConnectNotification`](/documentation/GameController/GCStylusDidConnectNotification)

A notification that posts after a stylus accessory connects to the device.

[`GCStylusDidDisconnectNotification`](/documentation/GameController/GCStylusDidDisconnectNotification)

A notification that posts after a stylus accessory disconnects from the
device.

### Getting input values and haptics

[`input`](/documentation/GameController/GCStylus/input)

Gets the input profile for the stylus.

[`haptics`](/documentation/GameController/GCStylus/haptics)

Gets the haptics profile for the stylus, if supported.

### Retrieving the buttons

[`GCInputStylusPrimaryButton`](/documentation/GameController/GCInputStylusPrimaryButton-18g2p)

[`GCInputStylusSecondaryButton`](/documentation/GameController/GCInputStylusSecondaryButton-6r3q)

[`GCInputStylusTip`](/documentation/GameController/GCInputStylusTip-1rhuw)



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)