13.4. SpaceNavigator and Gamepad

Introduction

EnSight supports simple rotation and translation of the current view using external input devices such as joysticks, game controllers and the 3DConnexion SpaceNavigator (http://www.3dconnexion.com). These devices are especially helpful when used with a cave, wall, or head-mounted display, because you may be away from, or unable to see, a keyboard and mouse.

SpaceNavigator

A SpaceNavigator is a 6-degree of freedom input device used to rotate and translate a model.


Note:  The 3DConnexion SpaceNavigator is not supported on Linux.


This is controlled via the configuration file spacedevice.defaults located in the system site_preferences directory or users resource directory. EnSight will automatically detect and use devices like the SpaceNavigator, but the configuration file can be used to fine-tune the sensitivity of the device. The default file looks something like:

VERSION 1.0
#
# Comments must have the '#' as the first character.
#
# ranges are xmin xmax ymin ymax zmin zmax
#
# these are the values for sensitivity of 50
translate_ranges -400 400 -400 400 -400 400
rotate_ranges -400 400 -400 400 -400 400

The values set the minimum and maximum ranges for the translation and rotations. Adjusting them can correct for asymmetry in the output values from the device and set the device's sensitivity. Narrowing the range has the effect of increasing the sensitivity to smaller motions of the device.

Gamepad

On Windows and Linux platforms, EnSight also supports standard PC joysticks and game controllers using native joystick APIs on those platforms. To use these devices, three additional fields can be used: controller_id, controller_config and single_axis.

single_axis {0|1}

By default, the spacedevice interface only allows transformation by a single axis at a time. If this value is set to 0, transformations over multiple axes (either translations or rotations) are allowed at the same time.

controller_id "name"

The presence of this field enables the use of joysticks/game controllers. The value must be a string in quotes. Under Windows, the value is an integer (as a string) which is the index of the game controller in the system. The first controller is 0. Under Linux, this is the device name of the joystick in question. An example is /dev/input/jp0. The actual value is dependent on the specific Linux distribution.

control_config "configstring"

This field maps device controls (axes and buttons) to the transformation axes. The configuration string consists of some number of axis transformation expressions separated by spaces. Each expression is in the form {transformation axis}={device axis}{u}{device button number}. The axes of transformation are: X: translation in screen X, Y: translation in screen Y, Z: translation in screen Z, A: rotation over the screen X axis, B: rotation over the screen Y axis and C: rotation about the screen Z axis. The device axes follow the Windows game controller naming conventions. The legal values are 'X', 'Y', 'Z', 'R', 'U', 'V'. The mapping of various device controls to these axes varies from controller to controller. Under Windows, the game controller control properties panel allows the user to see the layout of the controls and see what buttons are mapped to which button numbers interactively. The RumblePad uses the X, Y, Z and R axes.

Under Linux, the 'X', 'Y', 'Z', 'R', 'U', 'V' axes map to the first though sixth analog axes respectively.

If no button number is specified, the game controller always controls the selected EnSight transformation. Each axis mapping can be qualified by a button state. For example Y=Z5 means that EnSight translation in Y will be controlled by game controller Z axis, but only while button 5 is pressed. Putting a lowercase u between the controller axis and the button number specifies the link is only made when the named button is not pressed (up state). Therefore, B=Ru6 specifies that rotation over the screen Y axis is controlled by the game controller R axis, but only when the button 6 is not pressed (up).

An example using a Logitech RumblePad 2 on a Windows system might be:

VERSION 1.0
#
# This is the SpaceDevice configuration for
# Logitech RumblePad or equivalent game pad
#
translate_ranges -400 400 -400 400 -400 400
rotate_ranges -400 400 -400 400 -400 400
#
controller_id "0"
controller_config "X=X Y=Yu5 Z=Y5 A=Ru6 B=Z C=R6"
single_axis 0

This file selects the first controller in the system (controller_id "0"), sets the configuration string and enables transformations in multiple axes at the same time. The configuration string maps translation in the X axis to the left stick horizontal axis ("X=X"). It maps translation in the Y axis to the left stick vertical axis, when button 5 is "up" ("Y=Yu5"). Translation in the Z axis is mapped to the left stick vertical axis when button 5 is "down" ("Y=Y5"). Similarly, the right stick axes (R and Z) are mapped to the rotation axes (A, B, C) conditioned by the status of button 6.

Various game pads use different configurations of buttons and axes. The following configuration file is suggested for use with an XBox style controller.

VERSION 1.0
#
# This is the SpaceDevice configuration for
# Microsoft XBox360 or XBoxOne game pad
#
translate_ranges -80 80 -80 80 -80 80
rotate_ranges -80 80 -80 80 -80 80
#
controller_id "0"
controller_config "X=X Y=Yu5 Z=Y5 A=R B=Uu6 C=U6"
single_axis 0