VM Labs SDK Sample Code |
\vmlabs\sample\Game-Controllers\Dead-Zone |
Copyright © 2000-2001 VM Labs, Inc. All Rights Reserved |
March 2, 2001 |
The program simply moves a small sprite around the screen in response to the input from the analog joystick. It demonstrates two ideas.
First is the concept of a center position "dead zone" for analog joysticks. The program does not respond to input from the controller until it reaches a certain threshold. This is done in order to account for the fact that most analog joysticks do not automatically center exactly at the 0,0 position. The adjusted joystick values are printed to the screen.
Please note that this does NOT use the technique of simply masking off the low-order bits of the analog controller values. While this may indeed reduce some jitter and correct for non-centered rest positions, it mainly has the effect of reducing the controller sensitivity, which is usually far the from the desired effect. See the program for an example of how to implement a dead-zone that does not substantially reduce controller sensitivity at the same time.
Second, it demonstrates how to use the input from an analog controller to control how fast and how far an object is moved. Many simple sample programs will use the joystick values to directly represent a particular location on screen. However, this program uses the joystick value to specify the direction and speed of movement, independently of position. The farther the controller is pressed away from the center position, the faster the sprite will move in that direction. If you release the joystick, the sprite will come to rest wherever it happens to be on screen at the time.
Filename | Description |
deadzone.c | Main program code for sample. |
makefile | MAKEFILE for building and running sample program. |
Before attempting to load or run any of the SDK samples, make sure you have first read the Hitchhiker's Guide To NUON document.
After that, if you're still having trouble getting this sample program to work, click here to request assistance from developer support.