WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   using i900 joystick in a taskFunction (https://forum.worldviz.com/showthread.php?t=1521)

krimble 06-04-2008 05:12 AM

using i900 joystick in a taskFunction
 
Hi,

What I'm trying to do is, using the buttons on the joystick to scale my virtual world. I'm using a task know, but it seems that the event doesn't get triggered when using "viz.SENSOR_UP_EVENT". If I use "viztask.waitSensorDown" then I don't know what to put in it as a button. I've tried the state things from the manual "joystickSensor.get()[7]" but it doesn't give me the actual pressed button wich I have to put in, right?

Code:

def scaleOnSensorEvent() :
        dataObject = viz.Data
        sensorData = joystickSensor.get()

        while True :
                yield viztask.waitEvent(viz.SENSOR_UP_EVENT, dataObject)
#                yield viztask.waitSensorDown(joystickSensor, button??, dataObject)
                print "something"

if viz.get(viz.TRACKER):

        headSensor = viz.add('intersense.dls')
        viz.tracker()
        headSensor.reset()

        joystickSensor = viz.add('intersense.dls')
        viz.tracker()
        joystickSensor.reset()

viztask.schedule(scaleOnSensorEvent)

thanks for your help

farshizzo 06-04-2008 10:24 AM

The intersense.dls plugin does not generate sensor up/down events. You need to manually check the button state by examining the value at index 7 of the data array. The documentation for the intersense plugin has sample code showing how to check for the button state of the joystick.

krimble 06-06-2008 01:52 AM

Thank you,
I've used a timer now, and it works. It would be handy though to be able to use a task with the IS-900 joystick (wand). The use of tasks makes it a whole lot easier, great concept!

farshizzo 06-10-2008 10:20 AM

You can create your own custom task conditions. For example, here are two conditions that wait for an IS900 button to be pressed or released:
Code:

class waitIS900Down( viztask.Condition ):
    def __init__( self, sensor, button ):
        self._sensor = sensor
        self._button = button
 
    def update( self ):
        return int(self._sensor.getData()[7]) & self._button

class waitIS900Up( viztask.Condition ):
    def __init__( self, sensor, button ):
        self._sensor = sensor
        self._button = button
 
    def update( self ):
        return (int(self._sensor.getData()[7]) & self._button) == 0

Here is code that shows how to use it:
Code:

.
.
.
yield waitIS900Down(isense,1)
print 'Button 1 pressed'
yield waitIS900Up(isense,1)
print 'Button 1 released'
.
.
.



All times are GMT -7. The time now is 10:41 AM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC