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

# GCVirtualController

A software emulation of a real controller that you configure specifically for your game.

```
class GCVirtualController
```

## Overview

Use a virtual controller to display software controls that you can customize over your game. You create a virtual controller from a configuration where you choose the input elements to display. You can even customize the images for the elements. When you connect the controller to the device, users interact with it similarly to a real controller.

![Screenshot of a virtual controller showing left and right thumbsticks with A and B buttons on the right thumbstick.](images/com.apple.gamecontroller/media-3830787@2x.png)

To add a virtual controller to your game, create a [`GCVirtualController.Configuration`](/documentation/GameController/GCVirtualController/Configuration) object containing the elements you want to appear in the controller. Then create the virtual controller by passing the configuration to the [`init(configuration:)`](/documentation/GameController/GCVirtualController/init(configuration:)) method. Use the [`connect(replyHandler:)`](/documentation/GameController/GCVirtualController/connect(replyHandler:)) method to display the virtual controller on the screen.

To customize an element in the virtual controller, pass a new [`GCVirtualController.ElementConfiguration`](/documentation/GameController/GCVirtualController/ElementConfiguration) object for the element to the [`updateConfiguration(forElement:configuration:)`](/documentation/GameController/GCVirtualController/updateConfiguration(forElement:configuration:)) method.

You process input from a virtual controller similarly to a real controller. Use the [`controller`](/documentation/GameController/GCVirtualController/controller) property to get the underlying [`GCController`](/documentation/GameController/GCController) object. You can either poll the elements of the controller object or set the element’s handlers to get callbacks when their input values change.

## Topics

### Creating virtual controllers

[`virtualControllerWithConfiguration:`](/documentation/GameController/GCVirtualController/virtualControllerWithConfiguration:)

Creates a new virtual controller using the configuration you specify.

[`init(configuration:)`](/documentation/GameController/GCVirtualController/init(configuration:))

Creates a new virtual controller using the configuration you specify.

[`GCVirtualController.Configuration`](/documentation/GameController/GCVirtualController/Configuration)

The configuration of a virtual controller.

### Customizing the elements

[`updateConfiguration(forElement:configuration:)`](/documentation/GameController/GCVirtualController/updateConfiguration(forElement:configuration:))

Changes the configuration for one of the virtual controller’s input elements.

[`GCVirtualController.ElementConfiguration`](/documentation/GameController/GCVirtualController/ElementConfiguration)

The properties of a virtual controller’s element that you can customize.

### Accessing the elements

[`controller`](/documentation/GameController/GCVirtualController/controller)

The underlying controller object that you use to access input elements.

### Connecting and displaying virtual controllers

[`connect(replyHandler:)`](/documentation/GameController/GCVirtualController/connect(replyHandler:))

Connects the virtual controller to the device and displays it on the screen.

[`disconnect()`](/documentation/GameController/GCVirtualController/disconnect())

Disconnects the virtual controller from the device and removes it from the screen.

### Presenting a custom interface

[`setPosition(_:forDirectionPadElement:)`](/documentation/GameController/GCVirtualController/setPosition(_:forDirectionPadElement:))

Changes the value of a directional pad element in the virtual controller.

[`setValue(_:forButtonElement:)`](/documentation/GameController/GCVirtualController/setValue(_:forButtonElement:))

Changes the value of a button element in the virtual controller.



---

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)
