![]() |
Setting up a Joystick class for Logitech Attack 3?
It seems the default definition for a Joystick class includes a twist axis, since the default joystick provided to rookies has such an axis. The first axis is X, the second Y, the third twist, and the fourth throttle.
Well, when we try to use our trusty Logitech Attack 3's, these do not possess a twist axis, so a formerly-functional GetThrottle() call returns nothing, since the default for throttle in the class is the 4th axis. I was wondering why we were seeing "WARNING: Joystick Axis missing, check if all controllers are plugged in" showing up on the console, and now I think I understand why. I'd like to get rid of this warning. I understand I can get the throttle value by calling GetZ() instead, but I wanted to know, short of writing a custom class, is there a way to instantiate a joystick class that correctly defines the axes and buttons for a Logitech Attack 3 such that GetThrottle will work? |
Re: Properly calling a Logitech Attack 3 Joystick Class
I don't understand why you suggest that writing a custom class is not the appropriate answer. If you want to support the Attack 3 in particular, I think the best way to do it is to extend the Joystick class as an Attack_3 class.
Since the named functions don't give you what you want, the second-best way to do it is probably to avoid them and instead use things like getRawAxis(). We did basically the custom class solution in LabVIEW for several different brands of game controllers this year. It lets us provide the axes and buttons as named components of a cluster, which helps keep the programmer and the driver speaking the same language. Instead of having to remember which array element's number is the left stick's Y axis, we just unbundle LeftX. Similarly, we can refer to the A, X, Start, etc. buttons by name. |
Re: Properly calling a Logitech Attack 3 Joystick Class
Quote:
As for the custom class, it doesn't help matters much when the WPILib C++ source code location isn't a heavily advertised thing...I found it...but it doesn't seem to be something that is as readily available as it was in the past. We read all joystick and gamepad values into more functionally-descriptive variables, and this code is well-commented to provide a cross reference between actual controller axis/button and function, so using "GetZ" or "GetRawAxis" won't be an issue. |
Re: Properly calling a Logitech Attack 3 Joystick Class
Quote:
Quote:
Quote:
|
Re: Properly calling a Logitech Attack 3 Joystick Class
Quote:
Quote:
In the case of the joystick class, I'd simply change the default throttle axis from 3 to 2. Bing bang zoom. But with GetZ or GetRawAxis in the default class, I don't need to do that, so I won't even bother. |
Re: Properly calling a Logitech Attack 3 Joystick Class
Quote:
Quote:
Quote:
Code:
public class Axis_3 extends Joystick {Quote:
|
Re: Properly calling a Logitech Attack 3 Joystick Class
I concur with Alan. Making a specific derivative of Joystick is the way to go. I think there's a mis-understanding with what this means. The following links will show an example of deriving jankyXBoxJoystick from Joystick - cpp and header folllow...
https://github.com/FRCTeam1967/FRCTe...oxJoystick.cpp https://github.com/FRCTeam1967/FRCTe...XboxJoystick.h |
| All times are GMT -5. The time now is 10:08 AM. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi