Skip to content

iCade Controller Support

Rob Reuss edited this page Nov 12, 2015 · 1 revision

What is an iCade-compatible Controller?

The original iCade was a portable arcade cabinent you inserted your iPad into, but many other iCade-compatible devices came to market. Because of the costs of licensing use of the dock connector, a quick and dirty approach was developed where the controller appears over Bluetooth as a HID Keyboard, and each control input generates a specific character.

General Approach to Supporting iCade

You can read a general overview of how iCade support is added to iOS games here.

The basic approach is simple and involves placing a hidden text input box (UITextField) on your view, making the text field the first responder, and then responding to each key input relative to the control the character represents (and whether it represents the beginning or end of user action).

VirtualGameController Support for iCade

Overview

VirtualGameController supports iCade controllers by providing mappings between the characters generated by each different model of controller and the control element inputs on the MFi profile. The result is that the iCade controller appears to be MFi hardware, and simply by supporting the GameController / VirtualGameController API, you'll be able to support iCade out-of-the-box...mostly.

Implementing on a Central or a Bridge

Using the VirtualGameController framework, you'll need to have a text field on your main view to receive input from the controller. See the approach used in the iOS Central sample project. There is some trickiness involved with avoiding the presentation of the on-screen keyboard, etc.

Shortly after calling the startAs method, the iCade controller mode should be changed from .Disabled to reference the type of controller the user is attaching:

VgcManager.iCadeControllerMode = = .iCadeMobile

Unfortunately, there is no practical means of getting the model/manufacturer information programmatically (that I know of), and so you'll need to present the user with a list of controllers so they can self-select (these are the supported controllers, from the IcadeControllerMode enumeration):

        case .Disabled: return "iCade Support Disabled"
        case .SnakebyteIdroidCon: return "Snakebyte iDroid:con"
        case .SteelSeriesFree: return "SteelSeries Free"
        case .iCade: return "iCade"
        case .iCadeMobile: return "iCade Mobile"
        case .iCadeJr: return "iCade Jr."
        case .Eightbitty: return "8-bitty"
        case .Gametel: return "Gametel"
        case .iControlPadEarly: return "iControlPad (2.1a, 2.3)"
        case .iControlPadLate: return "iControlPad (2.4)"
        case .GameDock: return "GameDock"
        case .iMpulse: return "iMpulse"
        case .Nyko: return "Nyko PlayPad / Pro"

Once you have your text field in place and your user has selector their model of iCade controller, you'll need to respond to the input from the controller. When you get a key press, you obtain the appropriate element from the mapping function, and then call the handlers on the controller to trigger your own MFi handlers:

var element: Element!
var value: Int
(element, value) = VgcManager.iCadePeripheral.elementForCharacter(iCadeTextField.text!, controllerElements: VgcController.iCadeController.elements)
iCadeTextField.text = ""
if element == nil { return }
element.value = value
VgcController.iCadeController.triggerElementHandlers(element, value: Float(value))

Implementing on a Peripheral

Implementing iCade support on a Bridge is largely the same as implementing it on a Central, except when you receive key input from your controller, you send the value to the Bridge or Central:

var element: Element!
var value: Int
(element, value) = VgcManager.iCadePeripheral.elementForCharacter(keyboardTextField.text!, controllerElements: VgcManager.elements)
iCadeTextField.text = ""
if element == nil { return }
element.value = value
VgcManager.peripheral.sendElementState(element)