Keypad Joystick

The goal of this example is to demonstrate how to setup a Virtual Joystick and control some of its features using Building Blocks. This assumes that the reader is familiar with the basics of creating building blocks as shown in the Detailed Tutorial, and creating a Driver Configuration as shown in the Keyboard Reconfiguration example.

The Belkin n52te has 16 buttons, a scroll wheel, and a 4-way hatswitch. This example will connect the n52te buttons to joystick buttons, the scroll wheel to a Z-Axis, and the 4-way hatswitch to a view hatswitch.

Fifteen of the buttons on the n52te have a default keyboard function – they generate characters just like the left side of a standard keyboard.

The first step will be to "turn off" this keyboard behavior of the n52te using a driver configuration as shown below.

The next step is to create the virtual joystick.

Right-click in the list of Programming Items and select Create Virtual Device ‣ Virtual Joystick.

Enable the Z-Axis and Hatswitch options, and set the number of joystick buttons to "16".

Controls on virtual devices are linked to controls on actual devices using building blocks. Virtual devices that are enabled appear in the Palette window as though they were actual devices. The building blocks for controls on virtual devices can either send a value to the virtual device, or use a value from the virtual device.

The next task is to link the various buttons on the n52te to the buttons on the virtual joystick.

Create a Button building block for Button 01 on the n52te and link it to a Virtual Button building block for Button #1 on the virtual joystick.

Repeat the Button / Virtual Button pairs for each of the buttons on the n52te and virtual joystick.


Using the scroll wheel on the n52te to control the virtual joystick's Z-Axis requires a few more building blocks.

In this setup, the Range building blocks are each configured to detect when the scroll wheel on the n52te turns in one direction or the other. They both have their Report new output values only option turned off. This allows them to trigger the Pulse building blocks even if their outputs are already ON.


The Pulse building blocks are setup with a duration of 0.0s and have their anytime the input updates and is ON option turned on. These settings have the effect of converting a repeated ON value from the Range building block into a very quick ON/OFF combination to trigger the Counter building blocks inputs.

The Counter building block is setup to count between "0" and "255" in increments of "8". The increment size can be changed based on the needs of the application that is watching the virtual joystick.


The last task is to use the "hatswitch" on the n52te to control the hatswitch on the virtual joystick. The n52te "hatswitch" acts like the standard arrow keys on a keyboard. These are setup to control the hatswitch on the virtual joystick using a View Hatswitch Setup building block.

The Button building blocks for the up, down, left, and right arrow keys are attached to the "FWD", "BACK", "LEFT", and "RIGHT" inputs on the View Hatswitch Setup block respectively. No other configuration is necessary.


After the various controls on the n52te are linked to the virtual joystick's controls through building blocks, applications that receive input from the virtual joystick will respond to its controls when the corresponding n52te controls are used.