WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 11-30-2012, 11:45 AM
tokola tokola is offline
Member
 
Join Date: Nov 2012
Posts: 67
EventClass used with multiple joysticks

Hi there.

I have been struggling to make multiple events with multiple joysticks but it seems the last event always supersedes the previous ones. I have used EventClass to do, taken as an example the EventHandlingClass tutorial, but I am obviously doing something wrong. My code is as follows:
Code:
class Joystick(viz.EventClass):
    """This is the Joystick Interacion class"""
    def __init__ (self, window):
        self.joystick = vizjoy.add()
        #Call super class constructor
        viz.EventClass.__init__(self)
        self.window = window
        self.callback(vizjoy.BUTTONDOWN_EVENT, self.joydown)
        self.callback(vizjoy.HAT_EVENT, self.joyhat)
and create two joysticks like this:
Code:
j2 = Interaction.Joystick(somewindow1)
j3 = Interaction.Joystick(somewindow2)
but every time I use the hat (D-pad) or click a button, both of my windows respond to this event. What am I doing wrong?
Reply With Quote
  #2  
Old 11-30-2012, 01:04 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Can you post the code for your callback functions? Within the callback functions, are you checking that the event was generated for the correct joystick object (e.joy is self.joystick)?
Reply With Quote
  #3  
Old 11-30-2012, 01:51 PM
tokola tokola is offline
Member
 
Join Date: Nov 2012
Posts: 67
Truth is I wasn't doing that, but why should this matter since the EventClass instance of each Interaction object has it's own callbacks? Isn't this the purpose of EventClass after all, to be able to assign different callback functions for the same event?

For future reference of anyone visiting this thread, putting the following check at the beginning of each callback function fixed the problem:
Code:
if e.joy != self.joystick:
            return
Thanks a lot!
Reply With Quote
Reply


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
possibility to set multiple projectors in Vizard 4.0? tjwjtj Vizard 6 07-28-2011 03:15 PM
Multiple Cameras for AR artoolkit plugin Pho46 Vizard 3 11-10-2010 07:59 PM
Check presence of joysticks ? hotspur1 Vizard 1 05-18-2010 11:33 AM
2 Joysticks / requirements Sandro Holzer Vizard 1 01-13-2009 05:32 PM
Multiple Stages in one Program Amit Vizard 7 11-11-2005 11:20 AM


All times are GMT -7. The time now is 08:25 PM.


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