DEVELOPERS BLOG

↑ ↑ ↓ ↓ ← → ← → B A: Gamepad Offer Update

EVENTS / 11.20.13 / eoros

BlackBerry10_GamepadSupport

We have two important updates for BlackBerry 10 developers who are integrating gamepad support into their BlackBerry 10 applications.

Gamepad Offer Update

Back in September, we announced an offer for BlackBerry 10 game developers: Enable Gamepads For Your BlackBerry 10 Game, Get Rewards!

The criteria are pretty simple. Upload your game to BlackBerry World in draft mode and ensure it is identified as a gamepad-enabled by adding the <permission>use_gamepad</permission> element to your bar-descriptor. Unity developers would also need to ensure to add the Gamepad keyword to their BlackBerry World submissions.

Completing the above will flag your game as gamepad-enabled in our system. After doing so, you should receive an email to receive free MOGA Pro and SteelSeries Free controller to aid you in implementing full gamepad support for your game before submitting to post your game for sale. Specifics on the gamepad criteria can be found here.

Once your application has fully integrated gamepad support, submit your application for review. After it is approved for sale, our testing teams will evaluate it against the gamepad criteria to see if you qualify for the special gamepad-enabled category in BlackBerry World.

Since the start of the offer, we’ve received a number of terrific submissions. We completed the first round of reviews and sent emails to those developers whose applications were approved to be up for sale! If your application was approved, but you have not yet received any email follow-up, please reach out to eoros@blackberry.com.

If your game already successfully meets all of the gamepad criteria, you’ve automatically earned your coveted spot among other gamepad-enabled games. You’ll also be able to post your application up for sale and, once the gamepad-enabled category goes live in BlackBerry World, users will be able to easily discover your games!

If there are some criteria you haven’t met, we’ll let you know what still needs to be done in your application. You can still post your application up for sale, but it won’t appear with other gamepad-enabled games until you meet all of the criteria.

Also, don’t forget that gamepad integration counts as a Platform Service for the Built For BlackBerry program, which is one of the more complex requirements. If you’re already integrating gamepad support, check out the Built For BlackBerry criteria, fine-tune your game, and shine even more light on your game within BlackBerry World!

The gamepad offer is still open, so if you haven’t submitted your games yet, get coding and join your fellow gamepad trailblazers in BlackBerry World!

If you have any questions about the gamepad offer, don’t hesitate to reach out to BlackBerryDeveloperProgram@blackberry.com

Gamepad Integration Update for Unity Developers

Back in June, we posted an article about adding gamepad support to Unity games on BlackBerry 10.

Since then, there have been a few key changes that Unity developers should be aware of when integrating gamepad support for their games.

First, certain axes and buttons are mapped to Unity differently. Let’s take a look at the input configuration that can be reached via Edit > Project Settings > Input.

BlackBerry Gamepad Edit Project Settings Input

On BlackBerry 10, we now need to configure six axes if we want to support both joystick and directional-pad inputs. More importantly, the mappings for existing axes have changed slightly since March.

  • X axis corresponds to the Horizontal Axis on the Left Joystick.
  • Y axis corresponds to the Vertical Axis on the Left Joystick.
  • 4th axis corresponds to the Horizontal Axis on the Right Joystick.
  • 5th axis corresponds to the Vertical Axis on the Right Joystick.
  • 6th axis corresponds to the Left and Right directions on the Directional-Pad.
  • 7th axis corresponds to the Up and Down directions on the Directional-Pad.

X axis and Y axis integration_gamepad Examples of X axis and Y axis integration. You can Name the axis something more descriptive in order to identify it more easily within your code.

You can also leverage the Joy Num field to narrow down which gamepads are inputting data to each axis. This will be required for most multiplayer games.

Once your axes are configured within the Input panel, you can access the input data within your scripts by leveraging the Input.GetAxisRaw API where the axisName refers to the Name you gave the axis in the Input panel.

  using UnityEngine;
  using System.Collections;

  public class Example : MonoBehaviour {
    void Update() {
      float speed = Input.GetAxisRaw("X axis") * Time.deltaTime;
      transform.Rotate(0, speed, 0);
    }
  }

The button mappings have not changed, however it is important to note that L2 and R2 do not currently map to any buttons. To access button data within your scripts, you can leverage the Input.GetKey and Input.GetKeyDown APIs where the name will refer to one of the KeyCode constants.

  using UnityEngine;
  using System.Collections;

  public class Example : MonoBehaviour {
    void Update() {
      /* The following will be triggered every frame. */

      /* SteelSeries Free (Button 4), MOGA Pro (Button A) */
      if (Input.GetKey(KeyCode.Joystick1Button0)) {}

      /* SteelSeries Free (Button 3), MOGA Pro (Button B) */
      if (Input.GetKey(KeyCode.Joystick1Button1)) {}

      /* SteelSeries Free (Button 1), MOGA Pro (Button X) */
      if (Input.GetKey(KeyCode.Joystick1Button2)) {}

      /* SteelSeries Free (Button 2), MOGA Pro (Button Y) */
      if (Input.GetKey(KeyCode.Joystick1Button3)) {}

      /* The following will only be triggered once until released. */

      /* SteelSeries Free (Button L), MOGA Pro (Button L1) */
      if (Input.GetKeyDown(KeyCode.Joystick1Button4)) {}

      /* SteelSeries Free (Button R), MOGA Pro (Button R1) */
      if (Input.GetKeyDown (KeyCode.Joystick1Button5)) {}

      /* SteelSeries Free (Button A), MOGA Pro (Button Select) */
      if (Input.GetKeyDown (KeyCode.Joystick1Button6)) {}

      /* SteelSeries Free (Button B), MOGA Pro (Button Start) */
      if (Input.GetKeyDown (KeyCode.Joystick1Button7)) {}
    }
  }

For a quick reference of all axis and button mappings, please refer to the following diagrams.

gamepad diagram

It is also important to note that that your gamepad must be in HID mode; for the MOGA Pro this is Mode B and on the SteelSeries Free this is the single-blink mode.

Once connected, you can poll for supported, connected gamepads with the Input.GetJoystickNames API. This will return a String[] you can cycle through, leveraging the String.Contains API to compare against “BlackBerry Gamepad” to detect BlackBerry supported gamepads. Currently all supported gamepads will return a string containing this. Do not use the String.Equals API, as the full joystick name may have additional content identifying the gamepad.

While all supported gamepads will have the same mappings on BlackBerry 10 devices, the mappings between BlackBerry 10, PC and other devices may vary. A very crude but handy script to display all KeyCode states, joystick names, and axis inputs can be found here. You can leverage the script on any platform as a method of evaluating what a particular gamepad’s mappings are, though you may need to adjust the script for available screen dimensions.

Finally, as of Unity 4.3, you can now set the gamepad permission within the Editor! Don’t forget to check this box when you are submitting your gamepad enabled applications. It can be found under the Other Settings panel of the Player Settings configuration pane.

gamepad permission

If you have any questions at all about Unity gamepad integration, please do not hesitate to reach out to me directly at eoros@blackberry.com.

About eoros