WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
Old 11-04-2014, 07:05 AM
JB_HP_Viz JB_HP_Viz is offline
Join Date: Jun 2014
Posts: 31
In there a way in Vizconnect to allow user to select between different input devices

Checking to see if there is a way in Vizconnect to allow the user to select controlling the MainView with either a Joystick, a tracker, a Kinect, keyboard/mouse or any other input device?

I can see how to do it using in the example code below where I have allow the user to choose between a Joystick or Keyboard Tracker using keys on the keyboard to change which controls the MainView. Just checking to see if there is a way to do this using Vizconnect?

import sys
import viz
import vizact
import vizconfig
import vizcam


import vizinfo

# Setup keyboard/mouse tracker
keyboard_tracker = vizcam.addWalkNavigate(moveScale=2.0)

# Get list of joystick device information
dinput = viz.add('DirectInput.dle')
devices = dinput.getJoystickDevices()

# Exit if no joystick detected
if not devices:
	sys.exit('No joystick devices connected')

# If there is more than one device, then display selection dialog
if len(devices) > 1:
	selected = viz.choose('Select joystick device', [ d.productName for d in devices ])
	selected = 0

# Connect to selected device
joy = dinput.addJoystick(devices[selected])
if not joy:
	sys.exit('Failed to connect to joystick')

# Set dead zone threshold so small movements of joystick are ignored

# Display joystick information in config window

# Create node for applying joystick movement and link to main view
joystick_node = viz.addGroup(pos=(0,1.8,0)), viz.MainView)

# Use joystick axes to move joystick node
# Horizontal (X) axis controls yaw
# Vertical (Y) axis controls position
def UpdateJoystickMovement():
	e = viz.elapsed()
	x,y,z = joy.getPosition()
	joystick_node.setEuler([x * TURN_SPEED * e, 0, 0], viz.REL_LOCAL)
	joystick_node.setPosition([0, 0, y * MOVE_SPEED * viz.getFrameElapsed()], viz.REL_LOCAL)
vizact.ontimer(0, UpdateJoystickMovement)

# Reset joystick when joystick button 0 is pressed
def ResetPosition():
vizact.onsensordown(joy, 0, ResetPosition)

# Add environment

def linkJoystick():, viz.MainView)

vizact.onkeydown('j', linkJoystick)

def linkKeyboard():,viz.MainView)

vizact.onkeydown('k', linkKeyboard)
thank you

Reply With Quote

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
multi user environment tutorial maya Vizard 0 11-23-2013 08:35 AM
User keyboard input without halting the program Zhi Vizard 2 06-23-2011 12:53 PM
Controlling User Input ohad Vizard 1 03-15-2010 05:16 PM
User Input Hodge1620 Vizard 2 11-17-2005 06:58 AM
user input problem Jerry Vizard 1 11-16-2005 03:15 PM

All times are GMT -7. The time now is 05:04 AM.

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