View unanswered posts | View active topics It is currently Thu Jul 31, 2014 5:49 am






Reply to topic  [ 5 posts ] 
Logitech Gamepad Controls 
Author Message
Rookie

Joined: Wed May 14, 2014 8:21 am
Posts: 3
Post Logitech Gamepad Controls
So recently I have tried putting in controls associated with the Logitech gamepad for RVW, but they keep on giving me errors! please help! Here's my code:

#pragma debuggerWindows("joystickSimple");
#include "JoystickDriver.c"

task main()
{
//Loop Forever
while(1 == 1)
{
//Get the Latest joystick values
getJoystickSettings(joystick);
//Set the driving motors equal to the Y-axis values of the joysticks
motor[leftMotor] = joystick.joy1_y1;
motor[rightMotor] = joystick.joy1_y2;

if(joystick.joy2_Buttons[Btn6U] == 1)
{
motor[armMotor] = 40;
}
else
{
motor[armMotor] = 0;
}
if(joystick.joy2_Buttons[Btn6D] == 1)
{
motor[armMotor] = -40;
}
else
{
motor[armMotor] = 0;
}
}
}

it says I need a "pointer value"


Wed May 14, 2014 8:25 am
Profile
Novice

Joined: Sat Aug 31, 2013 9:15 am
Posts: 97
Post Re: Logitech Gamepad Controls
Unfortunately, in Virtual Worlds you can only use one joystick. So, joystick.joy2_Buttons is undefined. Also, if you want to figure out if a button is pushed, you can simply use:
Code:
joy1Btn(*insert button number here*);

_________________
Burning Lights Programming
FTC Team 6100 Chariots of Fire - Programmer (2012-2013)
FTC Team 7468 Blue Chariots of Fire - Programmer (2013-2014)
Check out our team website at http://cof7468.weebly.com/.


Wed May 14, 2014 9:02 am
Profile
Rookie

Joined: Wed May 14, 2014 8:21 am
Posts: 3
Post Re: Logitech Gamepad Controls
thank you for that, but what are the button numbers in relation to the controller?


Wed May 14, 2014 7:40 pm
Profile
Rookie

Joined: Wed May 14, 2014 8:21 am
Posts: 3
Post Re: Logitech Gamepad Controls
I have taken your suggested changes and now it is still giving me errors.
Here's my code:

#pragma debuggerWindows("joystickSimple");
#include "JoystickDriver.c"

task main()
{
//Loop Forever
while(1 == 1)
{
//Get the Latest joystick values
getJoystickSettings(joystick);
//Set the driving motors equal to the Y-axis values of the joysticks
motor[leftMotor] = joystick.joy1_y1;
motor[rightMotor] = joystick.joy1_y2;

if(joy1Btn[7] == 1)
{
motor[armMotor] = 70;
}
else
{
motor[armMotor] = 0;
}

if(joy1Btn[5] == 1)
{
motor[armMotor] = -70;
}
else
{
motor[armMotor] = 0;
}
}
}

it's telling me I need a "pointer value" again.


Wed May 14, 2014 7:46 pm
Profile
Site Admin
Site Admin
User avatar

Joined: Tue Oct 09, 2012 10:34 am
Posts: 192
Post Re: Logitech Gamepad Controls
Hi adbyers58,
joy1Btn is a function, not an array, so you need to use parentheses () instead of square brackets []

The corrected code would look like:

Code:
#pragma debuggerWindows("joystickSimple");
#include "JoystickDriver.c"

task main()
{
   //Loop Forever
   while(1 == 1)
   {
      //Get the Latest joystick values
      getJoystickSettings(joystick);
      //Set the driving motors equal to the Y-axis values of the joysticks
      motor[leftMotor] = joystick.joy1_y1;
      motor[rightMotor] = joystick.joy1_y2;

      if(joy1Btn(7))
      {
         motor[armMotor] = 70;
      }
      else
      {
         motor[armMotor] = 0;
      }

      if(joy1Btn(5))
      {
         motor[armMotor] = -70;
      }
      else
      {
         motor[armMotor] = 0;
      }
   }
}


Cheers,
--Ryan

_________________
Ryan Cahoon
CMU Robotics Academy
RVW Software Developer

Robot Potato Head; Virtual NXT


Thu May 15, 2014 10:54 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 5 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest


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.