View Single Post
  #1  
Old 11-04-2013, 10:30 AM
shivanangel shivanangel is offline
Member
 
Join Date: Feb 2006
Location: New Jersey
Posts: 182
Question vizjoy.py Twist method

Going over some old code and I had a question.

Years ago, I modified vizjoy.py for the twist method.
The original method is:

Code:
def getTwist(self):
	"""Returns the twist of the joystick"""
	return self.getRotation()[2]
My new method hardly changed anything:

Code:
def getTwist(self):
	"""Returns the twist of the joystick"""
	return self.getRotation()
Why do you only return the second element of the joystick? For other hardware such as the XBoxController with 2 sticks, I can't directly query the state without this information or utilize the overwritten callback to twist that is in your documentation.

That is, I wouldn't be able to do the following with only one element being passed from getTwist

Code:
def twist(self, val):
	self.xRAccel = 0.0
	self.yRAccel = 0.0
		
	if (abs(val.twist[0]) >= self.deadZone):
		self.xRAccel = val.twist[0]

	if (abs(val.twist[1]) >= self.deadZone):
		self.yRAccel = val.twist[1]
Is there something I am missing? Is there another method someplace to get this information about the second analog stick?
Reply With Quote