Vizard 8 » Reference » Input Devices » Gaming devices » Laseraid SpaceGrips
8.0

Laseraid SpaceGrips

This plug-in provides support for the Laseraid SpaceGrips input device. The SpaceGrips provide button data.

Initialization

The SpaceGrips plug-in is implemented as a Vizard extension sensor. You can specify the COM port of the device when adding the sensor. The SpaceGrips extension contains the following methods/constants:

Function

Description

<spacegrips>.addSensor(port=1,baudRate=38400)

Connect to SpaceGrips device on specified port and baud rate. Returns an extension sensor object.

<spacegrips>.LBUTTON1

<spacegrips>.LBUTTON2

<spacegrips>.LBUTTON3

<spacegrips>.LBUTTON4

<spacegrips>.RBUTTON1

<spacegrips>.RBUTTON2

<spacegrips>.RBUTTON3

<spacegrips>.RBUTTON4

Button numbers for left/right SpaceGrips device.

The SpaceGrips extension sensor will generate the standard sensor button events

Example

Here is a sample script that connects to a SpaceGrips device. It creates a quad for each button that will turn red while the button is down and white while it is up:

import viz
viz.go()

#Add the spacegrips extension
spacegrips = viz.add('spacegrips.dle')

#Connect to device on default port
sensor = spacegrips.addSensor()

#Create list of quads for displaying state of each button
buttons = [ viz.addTexQuad(parent=viz.SCREEN,size=100,pos=(x*0.1+0.1,0.1,0)) for x in range(sensor.getButtonCount()) ]

#Register callback for button presses
def gripDown(e):
    if e.object is sensor:
        buttons[e.button].color(viz.RED)
viz.callback(viz.SENSOR_DOWN_EVENT,gripDown)

#Register callback for button releases
def gripUp(e):
    if e.object is sensor:
        buttons[e.button].color(viz.WHITE)
viz.callback(viz.SENSOR_UP_EVENT,gripUp)