WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 03-16-2015, 10:31 AM
shivanangel shivanangel is offline
Member
 
Join Date: Feb 2006
Location: New Jersey
Posts: 180
Question Joystick and XBox Controller in DirectInput?

I am using your example in the Joystick basics to connect to an XBox controller through the new directInput module.

When I call addJoystick(), I get an JoystickSensor, which does not let me call the <xbox>.getControllerID() method.

Do I typecast this to some type? Do I need to use a different method to get access to the actual Xbox methods?

There is nothing in the documentation, so could you please add it in the future? I already printed out the information on the device and it returns true for the isXboxController.

Also, could you please consider changing <xbox>.getControllerID to <xbox>getControllerId to follow capitalization convention better?

Thanks,
George
Reply With Quote
  #2  
Old 03-16-2015, 11:20 AM
shivanangel shivanangel is offline
Member
 
Join Date: Feb 2006
Location: New Jersey
Posts: 180
Also, the button codes appear to be wrong.
I get different codes from the sensor down than what the documentation states:

dinput.XBOX_BUTTON_START reads as a 4, while the left shoulder button reads as a 4 and the start button reads as a 7.
Reply With Quote
  #3  
Old 03-16-2015, 11:34 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Yeah, the documentation is not very clear. You actually need to use the <dinput>.getXboxControllerList() to get a list of Xbox controller objects that provide the additional methods. They are different than the standard joystick objects created through <dinput>.addJoystick().

Here is a sample script that gets all the detected Xbox controllers and displays a config window for them:
Code:
import viz
import vizconfig
viz.go()

dinput = viz.add('DirectInput.dle')

for sensor in dinput.getXboxControllerList():
	vizconfig.register(sensor)

vizconfig.getConfigWindow().setWindowVisible(True)
Reply With Quote
  #4  
Old 03-16-2015, 12:04 PM
shivanangel shivanangel is offline
Member
 
Join Date: Feb 2006
Location: New Jersey
Posts: 180
Great, that also fixed the button mapping problem.

~George
Reply With Quote
  #5  
Old 03-16-2015, 01:58 PM
shivanangel shivanangel is offline
Member
 
Join Date: Feb 2006
Location: New Jersey
Posts: 180
What about the analog sticks for the callbacks?
Has that been phased out and now I just use a timer to read the values?

Before there was a move and a twist method.
Reply With Quote
  #6  
Old 03-17-2015, 09:58 AM
shivanangel shivanangel is offline
Member
 
Join Date: Feb 2006
Location: New Jersey
Posts: 180
Also, what about the dead zone?
Doesn't seem to have an effect when set on the XBox controller.
If I poll the device using the getLeftStick() I still get a value less than the dead zone.

Do I have to manually test for this?
Reply With Quote
  #7  
Old 03-18-2015, 06:53 AM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,453
You could register a callback function with vizact.onupdate to poll the analog values.

Make sure to calibrate your joystick using the Game Controllers dialog in the Windows Control Panel.
Reply With Quote
  #8  
Old 04-17-2015, 02:31 PM
Xombie Xombie is offline
Member
 
Join Date: Jul 2011
Posts: 1
Is my 'DirectInput.dle' out of date? Why do I get this error?

AttributeError: 'DirectInputExtension' object has no attribute 'getXboxControllerList'
Reply With Quote
  #9  
Old 04-17-2015, 03:25 PM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,453
This command is available in Vizard 5.1. If you're using Vizard 5 you can go to 'Help > Check for Updates' to get the latest installer.
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
XBOX360 USB controller intermittently working fivel_lab Vizard 2 01-26-2015 07:09 PM


All times are GMT -7. The time now is 01:05 PM.


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