ROBOTC.net forums
http://robotc.net/forums/

Logitech Gamepad Controls
http://robotc.net/forums/viewtopic.php?f=55&t=8794
Page 1 of 1

Author:  adbyers58 [ Wed May 14, 2014 8:25 am ]
Post subject:  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"

Author:  BurningLights [ Wed May 14, 2014 9:02 am ]
Post subject:  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*);

Author:  adbyers58 [ Wed May 14, 2014 7:40 pm ]
Post subject:  Re: Logitech Gamepad Controls

thank you for that, but what are the button numbers in relation to the controller?

Author:  adbyers58 [ Wed May 14, 2014 7:46 pm ]
Post subject:  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.

Author:  rcahoon [ Thu May 15, 2014 10:54 am ]
Post subject:  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

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/