WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 05-04-2012, 06:24 AM
hrm hrm is offline
Member
 
Join Date: Feb 2012
Posts: 2
Hello there,
An update.
So using either A) viz.callback or B) viztask.schedule functions work in getting some response from the button box presses. -- see below

BUT I can't seem to get these keypresses from the button box to move the views using if-else conditions
viz.key.isDown('2'):#(viz.KEY_UP):
Should I be using viz.key.isDown with the button box keys? The function works for keyboard keys though...
I also did get this error:
"before Glyph::subload(): detected OpenGL error: invalid enumerant"
i) I am not sure if it the inability to move the trigger based on a button box key press is related to that error.
ii) would lack of RAM be an issue?

Any help/advise would be appreciated!
Thanks in advance.
May

--------------------------------------------------------------------
A)
import viz
import viztask

viz.go()

keyDisplay = viz.addText( 'key pressed: ', viz.SCREEN , pos=(0.25,0.5,0) )
keyDisplay.fontSize(30)
keyDisplay2 = viz.addText( 'keys 1,2, or 3 pressed: ', viz.SCREEN , pos=(0.25,0.75,0) )
keyDisplay2.color(viz.RED)
keyDisplay2.fontSize(30)

global key
def mykeyinput(key):
ShowData(viz.tick(),key)
viz.callback(viz.KEYDOWN_EVENT, mykeyinput)


def ShowData(currenttime,key):#(k):#(currenttime,key,k ):
global data
data = 'time: '+ str(currenttime) + ' keypress: "' + key + '"'
print data
kpress = 'Key " '+key+ ' "'
keyDisplay.message(kpress)#( 'keypress: ' + str(k.key) )
if key=='1':
keyDisplay2.message('yo!')#(kpress)
elif key=='2':
keyDisplay2.message('yoyo!')#(kpress)
elif key=='3':
keyDisplay2.message('yoyoyo!')#(kpress)
elif key=='4':
keyDisplay2.message('yoyoyoyo!')#(kpress)
else:
keyDisplay2.message('oooooooooooooooooooo!')#(kpre ss)

B)
import viz
import viztask

viz.go()

keyDisplay = viz.addText( 'key pressed: ', viz.SCREEN , pos=(0.25,0.5,0) )
keyDisplay.fontSize(30)
keyDisplay2 = viz.addText( 'keys 1,2, or 3 pressed: ', viz.SCREEN , pos=(0.25,0.75,0) )
keyDisplay2.color(viz.RED)
keyDisplay2.fontSize(30)

def mykeyinput():#(key):
global k
while True:
k=yield viztask.waitKeyDown(None)
# Calls the function SaveData and hands it the current time and key
#ShowData(viz.tick(),key,k)
ShowData(k)
#displayKeypress(k)
# Defines a callback for keyboard events
#viz.callback(viz.KEYDOWN_EVENT, mykeyboard)
viztask.schedule(mykeyinput)

def ShowData(k):#(currenttime,key,k):
global data
#data = 'time: '+ str(currenttime) + ' keypress: "' + key + '"'
data = "Key '"+k.key+"' was pressed at time",k.time
print data
kpress = 'Key " '+ k.key+' "'
#displayKey = viz.addText(str(kpress), viz.SCREEN , pos=(0.1,0.5,0) )
keyDisplay.message(kpress)#( 'keypress: ' + str(k.key) )
if k.key=='1':
keyDisplay2.message('yo!')#(kpress)
elif k.key=='2':
keyDisplay2.message('yoyo!')#(kpress)
elif k.key=='3':
keyDisplay2.message('yoyoyo!')#(kpress)
else:
keyDisplay2.message('oooooooooooooooooooo!')#(kpre ss)
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
integrating osgocean with vizard mousa Plug-in development 0 01-10-2012 04:57 AM
Integrating Triton Ocean with Vizard 3.18 mousa Vizard 0 01-07-2012 08:24 AM
Vizard 4 Beta Testing farshizzo Announcements 0 02-01-2011 10:46 AM
Vizard 4 Beta Testing farshizzo Vizard 0 02-01-2011 10:46 AM
Vizard tech tip: Using the Python Imaging Library (PIL) Jeff Vizard 0 03-23-2009 11:13 AM


All times are GMT -7. The time now is 06:36 PM.


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