View unanswered posts | View active topics It is currently Mon Oct 20, 2014 9:11 pm






Reply to topic  [ 2 posts ] 
Logitech d-pad code? 
Author Message
Rookie

Joined: Sun Oct 10, 2010 1:49 am
Posts: 2
Post Logitech d-pad code?
What would the code be for the d-pad on the left side of the logitech controller?

joystick.joy______?


Sun Oct 10, 2010 1:51 am
Profile
Site Admin
Site Admin

Joined: Mon Jun 08, 2009 4:50 pm
Posts: 70
Post Re: Logitech d-pad code?
Hi,

In the ROBOTC help file under "Joystick Control > Using Joysticks" there is a page that lists all of the buttons and functions related to them.

For the "D-Pad" it is
Code:
joystick.joy1_TopHat


This returns a value from -1 to 7 where -1 means no buttons are pressed, 0 is the top button, and 7 is the upper left button (it starts at the top and counts clockwise from there).
So it looks something like this:
(I'm using the code format just to get the spacing even)
Code:
    0
  7   1
6  -1   2
  5   3
    4


Here is the sample from the help file:
Code:
while(true)                      // Infinite loop:
{
  if(joystick.joy1_TopHat == 0)      // If the topmost button on joy1's D-Pad ('TopHat') is pressed:
  {
    motor[motorA] = 50;                  // MotorA is run at a power level of 50.
  }
}


I hope that helps!

_________________
Bence Feher

Undergraduate Intern - NREC, Robotics Academy
ROBOTC - Testing/Documentation/Developer

Computer Science, Japanese, East Asian Studies
University of Pittsburgh, Konan University 甲南大学


Fri Oct 15, 2010 4:02 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 2 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.