Before you begin

You should have the following things ready:

  • The BlackBerry 10 Native SDK
  • Your BlackBerry 10 device
  • A basic understanding of the C language and some experience running apps with the Native SDK
  • A Bluetooth Human Interface Device (HID) game controller such as:

The MOGA Pocket Controller is not supported.

Configure your project

This tutorial walks through the Gamepad sample application available from the NDK-Samples repository in GitHub. This sample contains all the code used to set up, initialize, and process gamepad events and render graphics to the screen. The project includes the bbutil.c and bbutil.h files which provide convenience functions for graphics such as initializing and terminating EGL, rendering textures, and changing the screen orientation. Understanding the bbutil API isn't necessary for this tutorial but if you want more information, take a look at Functions in the bbutil API.

To import the complete project:

  1. From the NDK-Samples repository in GitHub, download and extract the sample application.
  2. Launch the Native SDK.
  3. On the File menu, click Import.
  4. Expand General, then select Existing Projects into Workspace. Click Next.
  5. Browse to the location where you extracted the sample app and click OK.
  6. Click Finish to import the project into your workspace

Using the application

If this application runs with a Bluetooth HID game controller connected to the BlackBerry 10 device, a collection of buttons and analog sticks representing the controller is drawn by the application. This virtual gamepad reacts to input events from the controller. You can assign buttons on the virtual gamepad to physical buttons on the real controller by first tapping a virtual button and then pressing a physical button on the controller. This is similar to how a game allows players to change its controls.

Tapping the Polling button at the bottom of the Gamepad application causes device events to be polled rather than triggered by the Screen and Windowing Library.

If this application runs without a gamepad or joystick connected to the BlackBerry 10 device, the message No device detected appears.

Pairing devices

To add support for game controllers to your application, you must first ensure the controller pairs with your BlackBerry 10 device. The SteelSeries Free Mobile Wireless Controller is recommended but any gamepad or joystick compatible with the Bluetooth HID profile should work. The advantage to using a recommended controller, beyond the fact that it's been tested on BlackBerry 10, is that its buttons are mapped to an enumeration in the Screen and Windowing Library. The use of this enumeration is discussed later.

To pair the controller with your BlackBerry 10 device:

  1. On your BlackBerry 10 device, swipe down from the top of the screen.
  2. Tap Settings > Network Connections > Bluetooth.
  3. Ensure Bluetooth is turned on by setting the toggle switch to On.
  4. Put your controller into pairing mode. This is usually done by holding one or more buttons on the controller for several seconds but it varies by device, so you may need to consult your controller's manual. The table below shows pairing instructions for known devices.
  5. In the Settings application, select the controller from the list. If the controller doesn't appear right away, you can tap Refresh and try again.
Device Instructions


  1. If the device is not turned off, turn it off by holding down the START button for three seconds.
  2. Press and hold the START and |o buttons for three seconds to switch the controller to HID Gamepad mode.
  3. After the green LED next to the USB connector blinks, release all buttons. The device is now in HID Gamepad mode.
  4. Start the device by holding the START button for three seconds.

Wii Remote

On the controller, hold down the 1 and 2 buttons.

You must wait until the name of the controller resolves on the Bluetooth settings screen (it will start with "Nintendo") before you attempt to pair.

MOGA Pro Controller

  1. Flip up the MOGA Arm to reveal the power switch.
  2. Turn the switch to the B position to turn the gamepad on in HID mode.

After the pairing completes, the messages Successfully paired and Successfully connected appear on the BlackBerry 10 device. The first message indicates that the Bluetooth connection is established and the second indicates the controller is recognized as providing a Bluetooth HID service. This service is required for the Gamepad sample app to receive Bluetooth HID events from the controller.

Gamepad paired to Bluetooth device

Gamepad connected to Bluetooth

You can test that the controller works by running the completed Gamepad sample app. With your controller connected, you should see a collection of buttons and analog sticks on the screen of the BlackBerry 10 device that light up when you play around with the controller. Now let's move on to the code that makes it happen.

Last modified: 2015-03-31

Got questions about leaving a comment? Get answers from our Disqus FAQ.

comments powered by Disqus