WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rating: Thread Rating: 2 votes, 5.00 average. Display Modes
  #1  
Old 12-17-2008, 11:45 PM
fuyonggang fuyonggang is offline
Member
 
Join Date: Sep 2008
Posts: 5
How to get the data from Logitech G25 racing wheel ?

is it same as Joystick ?
Reply With Quote
  #2  
Old 12-18-2008, 09:29 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Yes, it should be the same as any other joystick. Try running the joystick script that comes with Vizard. It will show you what kind of data the joystick outputs. The script is located at [Vizard]/examples/input/joystick.py
Reply With Quote
  #3  
Old 12-18-2008, 12:01 PM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
I just had to use this script recently and noticed the slider gui object was missing. Here is the script with the slider added.

Code:
import viz
import vizjoy

viz.go()

import vizinfo
vizinfo.add('This script demonstrates how to retrieve certain states\nof the joystick and how to use joystick callbacks')

#IMPORTANT: Need to add a joystick. This will return the first detected joystick
joy = vizjoy.add()

#Add slider object and disable user input
slider = viz.add(viz.SLIDER)
slider.translate(.15,.62)
slider.disable() 

#Add textures
arrow = viz.add('arrow.tif')
dot = viz.add('dot.tif')
up = viz.add('button_up.tif')
down = viz.add('button_down.tif')

#Add the texture quad to display the hat position
hat = viz.add(viz.TEXQUAD,viz.SCREEN)
hat.translate(0.1,0.8)
#Set the hat texture to the dot
hat.texture(dot)

#Add the texture quad for the joystick position
joystick = viz.add(viz.TEXQUAD,viz.SCREEN)
joystick.scale(0.3,0.3,1)
#Set the joystick texture to the dot
joystick.texture(dot)



#Create a border for the joystick position
JOY_CENTER_X = 0.5
JOY_CENTER_Y = 0.35
JOY_SCALE =  10.0
viz.startlayer(viz.LINE_LOOP)
viz.vertexcolor(viz.YELLOW)
viz.vertex((JOY_CENTER_X-(1.1/JOY_SCALE)),(JOY_CENTER_Y+(1.1/JOY_SCALE)))
viz.vertex((JOY_CENTER_X+(1.1/JOY_SCALE)),(JOY_CENTER_Y+(1.1/JOY_SCALE)))
viz.vertex((JOY_CENTER_X+(1.1/JOY_SCALE)),(JOY_CENTER_Y-(1.1/JOY_SCALE)))
viz.vertex((JOY_CENTER_X-(1.1/JOY_SCALE)),(JOY_CENTER_Y-(1.1/JOY_SCALE)))
viz.endlayer(viz.SCREEN)

#Add the texture quad to display the twist position
twist = viz.add(viz.TEXQUAD,viz.SCREEN)
twist.translate(0.1,0.45)
twist.texture(arrow)

#Add the texture quad and text for each button
buttons = []
for x in range(joy.getButtonCount()):
    
    text = viz.add(viz.TEXT3D,str(x+1),viz.SCREEN)
    text.alignment(viz.TEXT_CENTER_CENTER)
    text.scale(0.5,0.5,0.5)
    text.translate(x*0.07+0.04,0.1)
    
    quad = viz.add(viz.TEXQUAD,viz.SCREEN)
    quad.translate(x*0.07+0.04,0.05)
    quad.scale(0.5,0.5,0.5)
    quad.texture(up)
    
    buttons.append(quad)

#Joystick position has changed, update dot
def joymove(e):
    # e.pos     - new position value
    # e.oldPos  - old position value
    joystick.translate(JOY_CENTER_X+(e.pos[0]/10.0),JOY_CENTER_Y-(e.pos[1]/10.0))
    
#A joystick button is down, set it its texture to the down texture
def joydown(e):
    # e.button  - button number that is down
    buttons[e.button-1].texture(down)

#A joystick button is up, set it its texture to the up texture
def joyup(e):
    # e.button  - button number that is up
    buttons[e.button-1].texture(up)

#The joystick slider changed, set the slider position
def joyslider(e):
    # e.slider      - new slider value
    # e.oldSlider   - old slider value
    slider.set( (e.slider+1)/2.0 )
    
#The joystick hat changed, rotate the quad
def joyhat(e):
    # e.hat     - new hat value
    # e.oldHat  - old hat value
    if e.hat == -1:
        hat.texture(dot)
    else:
        hat.texture(arrow)
        hat.rotate(0,0,-1,e.hat)

#The joystick twist changed, rotate the quad
def joytwist(e):
    # e.twist       - new twist value
    # e.oldTwist    - old twist value
    twist.rotate(0,0,-1,e.twist*450)
    
#Set all the joystick callbacks
viz.callback(vizjoy.BUTTONDOWN_EVENT,joydown)
viz.callback(vizjoy.BUTTONUP_EVENT,joyup)
viz.callback(vizjoy.SLIDER_EVENT,joyslider)
viz.callback(vizjoy.HAT_EVENT,joyhat)
viz.callback(vizjoy.MOVE_EVENT,joymove)
viz.callback(vizjoy.TWIST_EVENT,joytwist)
Reply With Quote
  #4  
Old 12-18-2008, 12:39 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
The slider object and the text labels are defined in the stage (.viz) file. If you run the script from the directory I mentioned above it should show up fine.
Reply With Quote
  #5  
Old 12-18-2008, 06:14 PM
fuyonggang fuyonggang is offline
Member
 
Join Date: Sep 2008
Posts: 5
thanks ! got it

thanks for you all
Reply With Quote
Reply

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
writing joystick position to a data file Saz Vizard 3 12-17-2008 05:18 AM
Flagging the Data Elittdogg Vizard 5 04-11-2008 11:40 AM
data glove navigation arielasso Vizard 6 10-24-2007 02:15 PM
tracking using quaternarion data jfreeman Vizard 2 06-01-2005 08:48 AM
Do you have some idea about the bicycle and wheel sled Vizard 6 08-01-2003 10:03 PM


All times are GMT -7. The time now is 01:08 AM.


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