|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools |
Rating:
|
Display Modes |
|
|
|
#1
|
||||
|
||||
|
Re: New class for Logitech Dual Action Gamepad
We're planning on using the Logitech gamepad to control our arm, and just for the sake of time I've been using the FRC Joystick class. It actually provides all the functionality you need (axes, buttons, etc), but this should make the code more user-friendly, thanks!
Regarding the actual class: The D-pad is made from a standard x and a y axis (as you know), but each only return either 1 or -1. The if statements (ex: x < -0.5) would more simply be written like if(x = -1). EDIT: this is not good practice, see below. I hope you don't mind, attached is a modification of your Gamepad class that adds an enum for button type (top, bottom-left-trigger, etc) and a Get function that uses the new enum. Hopefully that should make the code more user-friendly. EDIT: Updated attachment to use the original d-pad code (which, as pointed out below, is more portable and better follows convention). Also, this particular class assumes the Logitech Dual-Action gamepad with its button enumeration. This should be easy enough to reorder for other gamepads. Last edited by Phazonmutant : 02-08-2009 at 08:55 PM. |
|
#2
|
||||
|
||||
|
Re: New class for Logitech Dual Action Gamepad
Quote:
|
|
#3
|
||||
|
||||
|
Re: New class for Logitech Dual Action Gamepad
Quote:
Edit 1: You'll notice the article is talking about testing floats when doing floating point math. Since we're doing no math, only testing a returned value, it's safe. Edit 2: Furthermore, it talks about how the binary representation is not 100% precise for some numbers. The binary representation of floating points is implementation-specific, but lets assume the first bit is for the sign, the next 24 bits are for the significant figures, and the last 7 bits are for the base (IEEE 754 defines 24 bits as standard for 32-bit - single precision - floating point numbers). OK, a d1 (a 1 in decimal) looks like: Code:
11000000000000000000000000000000 This is precisely 1. Last edited by Phazonmutant : 02-08-2009 at 07:30 PM. |
|
#4
|
||||
|
||||
|
Re: New class for Logitech Dual Action Gamepad
Quote:
|
|
#5
|
||||
|
||||
|
Re: New class for Logitech Dual Action Gamepad
Quote:
You're absolutely right on all counts. I got a bit too into the argument xD I updated the code I posted above to the original d-pad code. Not a huge improvement over the original code, but worthwhile, I think. |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| define a new class(C++) | nadavsen2 | C/C++ | 15 | 11-02-2010 01:21 PM |
| pic: 716 Dual Motor/Dual Speed | CD47-Bot | Robot Showcase | 18 | 04-23-2004 01:51 AM |
| White Paper Discuss: Dual-motor, dual-speed gearbox | CD47-Bot | Extra Discussion | 8 | 04-05-2004 07:24 PM |
| White Paper Discuss: Dual-motor, dual-speed drive transmission design | CD47-Bot | Extra Discussion | 9 | 09-03-2003 10:40 AM |
| Gamepad Controller | Mike375 | Technical Discussion | 13 | 03-05-2002 09:20 PM |