Adding gamepad support to the Google Cardboard SDK



Many of the plastic VR headsets on the market do not have a physical button on them. Some bundle a small Bluetooth controller to account for this, but these often need switching to "mouse mode" using an unintuitive key combo which adds a black cursor to the screen, and sometimes they simply refuse to work with iOS other than as a media remote.

With the release of VR Kiosk Chaos, players will need to be able to "click" on things (previously in VR Earth Attack I avoided this issue by simply using a gaze-to-shoot mechanic). To provide the maximum compatibility, I needed to accept a gamepad button as well as the usual left-click as an input.

The obvious method of simply adding the Standalone Input Module to the Event System won't work as the events don't flow further than the Gvr Pointer Input Module. As I was already using Event Triggers on my game objects, ideally I wanted to simply enhance the Google Cardboard SDK.

After opening /GoogleVR/Scripts/EventSystem/GvrBasePointer.cs I modified three functions concerning triggers to use the Fire1 virtual input instead of just left-click:

public virtual bool TriggerDown {
    get {
        //bool isTriggerDown = Input.GetMouseButtonDown(0);
        bool isTriggerDown = Input.GetButtonDown("Fire1");
        return isTriggerDown || GvrControllerInput.ClickButtonDown;

public virtual bool Triggering {
    get {
        //bool isTriggering = Input.GetMouseButton(0);
        bool isTriggering = Input.GetButton("Fire1");
        return isTriggering || GvrControllerInput.ClickButton;

public virtual bool TriggerUp {
    get {
        //bool isTriggerDown = Input.GetMouseButtonUp(0);
        bool isTriggerDown = Input.GetButtonUp("Fire1");
        return isTriggerDown || GvrControllerInput.ClickButtonUp;

You can find the inputs configured for Fire1 under Edit -> Project Settings -> Input. By default, they are Left Ctrl, Mouse 0 and Joystick Button 0.

Any of these will now be considered a Google Cardboard trigger which is much more user-friendly!