Go to Post last year's tradition is this year's rule change! - EricH [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 10-01-2009, 09:12
pudgeball pudgeball is offline
Registered User
AKA: Nick McGuire
FRC #2386 (BCHS Trojan Robotics)
Team Role: Mentor
 
Join Date: Jan 2009
Rookie Year: 2008
Location: Ontario
Posts: 13
pudgeball is an unknown quantity at this point
Programming the joystick trigger...

I have searched through forum after forum. And looked as much source code as I could get my hands on. However I can't find how to program the joystick trigger. 2386 is using the joystick provided in the K.O.P. and we are trying to program the trigger like;

if (trigger is down)
{
//Execute code
}

//Edit: Also we are using WindRiver

Last edited by pudgeball : 10-01-2009 at 09:15.
Reply With Quote
  #2   Spotlight this post!  
Unread 10-01-2009, 09:47
JDM JDM is offline
programming lead; team executive;..
FRC #2199 (Robo-Lions)
Team Role: Programmer
 
Join Date: Feb 2008
Rookie Year: 2008
Location: Eldersburg, Maryland
Posts: 34
JDM is on a distinguished road
Re: Programming the joystick trigger...

There's a function of the Joystick class called "GetTrigger".

So, the code that you would want to use would be something like the following, where m_Stick is the name of the Joystick object that you want to check.

Code:
if (m_Stick->GetTrigger()) {
 ...
}
I hope this helps.
Reply With Quote
  #3   Spotlight this post!  
Unread 10-01-2009, 09:52
Dave Scheck's Avatar
Dave Scheck Dave Scheck is offline
Registered User
FRC #0111 (WildStang)
Team Role: Engineer
 
Join Date: Feb 2003
Rookie Year: 2002
Location: Arlington Heights, IL
Posts: 574
Dave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond repute
Re: Programming the joystick trigger...

Look into the Joystick class of WPILib. It provides methods to get axes and buttons. You can see the following methods available in Joystick.h
Code:
virtual bool GetTrigger(JoystickHand hand = kRightHand);
virtual bool GetTop(JoystickHand hand = kRightHand);
virtual bool GetBumper(JoystickHand hand = kRightHand);
virtual bool GetButton(ButtonType button);
bool GetRawButton(UINT32 button);
Hope that puts you on the right track.
Reply With Quote
  #4   Spotlight this post!  
Unread 10-01-2009, 09:58
Dave Scheck's Avatar
Dave Scheck Dave Scheck is offline
Registered User
FRC #0111 (WildStang)
Team Role: Engineer
 
Join Date: Feb 2003
Rookie Year: 2002
Location: Arlington Heights, IL
Posts: 574
Dave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond reputeDave Scheck has a reputation beyond repute
Re: Programming the joystick trigger...

JDM - The only problem with GetTrigger is that it makes the assumption that the trigger button is coming in as raw button 1. This is probably fine for the default joysticks in the KOP, but if you switch to something like a gamepad, trigger might not make as much sense. You can drop this in your code to quickly see what the button mapping is using the raw buttons. Once you know the mapping you can decide whether to use the built in methods (like GetTrigger) or to go get the raw button yourself.
Code:
for(int i = 0; i < 12; i++)
{
    printf("%d:%d ", i + 1, driveStick->GetRawButton(i + 1));
}
Reply With Quote
  #5   Spotlight this post!  
Unread 10-01-2009, 10:25
pudgeball pudgeball is offline
Registered User
AKA: Nick McGuire
FRC #2386 (BCHS Trojan Robotics)
Team Role: Mentor
 
Join Date: Jan 2009
Rookie Year: 2008
Location: Ontario
Posts: 13
pudgeball is an unknown quantity at this point
Re: Programming the joystick trigger...

Quote:
Originally Posted by JDM View Post
There's a function of the Joystick class called "GetTrigger".

So, the code that you would want to use would be something like the following, where m_Stick is the name of the Joystick object that you want to check.

Code:
if (m_Stick->GetTrigger()) {
 ...
}
I hope this helps.

The one thing I find when we try to use '->' is that I get an error; "error: base operand of `->' has non-pointer type `Joystick'". So my around that error was/is;

Code:
if (m_Stick.GetTrigger()) {
...
}
I finally did get the code to work. With that fix mentioned above. But thank you for your help.
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

vB 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
Joystick Programming greatman05 Programming 11 30-01-2008 20:40
Single Click On/Off Using the Trigger in EasyC IraJason Programming 15 01-06-2007 11:37
Joystick Programming LieAfterLie Programming 7 15-02-2007 09:30
Programming a Joystick sbf2009 Programming 3 10-02-2007 15:59
Programming the second joystick in PBASIC archiver 2001 2 24-06-2002 00:25


All times are GMT -5. The time now is 13:17.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi