Using the Logitech F510 Controller Help

Hello everyone,

I’ve been trying to get the Logitech F510 to work with the Command Based Robot Template structure. I’ve managed to get the axises working with ‘GetRawAxis()’, however I am having trouble getting the buttons to respond. I am not sure if I properly understand where and what to put in order to make them function. Can anybody help me with the structure of button OI in the code and - if you can - which button coresponds to what number (not really necessary, although helpful)?

P.S. I am using WindRiver C++

EDIT: We checked the controller to see if it functions properly, it does. We also used another teams controller to make sure it was the code, and it is. It is very urgent that this be solved as quickly as possible. Any help would be incredible, thank you.

Some additional info;
I have the following in OI.cpp:

#include "OI.h"
#include "Robotmap.h"
#include "Commands/C_PullyFwd.h"
#include "Commands/C_PullyRev.h"
#include "Subsystems/Chassis.h"

OI::OI() {
	Chassis *chassis;
	gamepad = new Joystick(GAMEPAD_PORT);
	bool gamepad_button_x = gamepad->GetRawButton(GAMEPAD_BUTTON_X);
	bool gamepad_button_a = gamepad->GetRawButton(GAMEPAD_BUTTON_A);
	bool gamepad_button_b = gamepad->GetRawButton(GAMEPAD_BUTTON_B);
	bool gamepad_button_y = gamepad->GetRawButton(GAMEPAD_BUTTON_Y);
	bool gamepad_button_L1 = gamepad->GetRawButton(GAMEPAD_BUTTON_L1);
	bool gamepad_button_L2 = gamepad->GetRawButton(GAMEPAD_BUTTON_L2);
	bool gamepad_button_R1 = gamepad->GetRawButton(GAMEPAD_BUTTON_R1);
	//bool gamepad_button_R2 = gamepad->GetRawButton(GAMEPAD_BUTTON_R2);
	if (gamepad_button_x == true) { 
	if (gamepad_button_a == true) {
		//Drive straight
		chassis->customTankDrive(1.0, 1.0);
	if (gamepad_button_b == true) {
	if (gamepad_button_y == true) {
	if (gamepad_button_L1 == true) {
		//bridge mech up
	if (gamepad_button_L2 == true) {
		//pulley brings balls out
		new PullyRev(1000);
	if (gamepad_button_R1 == true) {
		//bridge mech down
	if (gamepad_button_R2 == true) {
		//Pully brings in balls
		new PullyFwd(1000);

Joystick * OI::getJoystick() {		//activate the Joystick class
	return gamepad;

-I know the functions being called work
-I’ve tried making the if statement conditions without the ‘== true’
-Tried using if, else if, else if, … else structure
-Tried replacing the if statements with

if ((gamepad->GetRawButton(GAMEPAD_BUTTON_R2) ) == true ) {} 

That code will only be called once, since it’s in the constructor. Assuming you construct everything in your main robot’s constructor, that code will only get called once, and the robot will be disabled (so calling customTankDrive will have no effect).

Have you thought about using another method of output (like printf or smartdashboard) than your robot itself? If it prints out “Button A pressed” when you press button A, you have some valuable debugging info.

Well, I feel stupid now hehe. Thank you so much for your time. Although I do not have access to my robot at the moment for testing, I’m almost sure this is going to work once deployed. I’ll keep you posted on the results.

I hadn’t considered printf in this particular circumstance, however I’ll sure as heck put it in now.

If anybody else has any other suggestions, they’d be welcomed too.

I recommend looking at the GearsBot sample to see how to properly use buttons with the command based template. I fyou have specific questions after looking at it, feel free to ask.

As WizenedEE pointed out, your code will only run once. There are button classes that have been added for use with the command-based template.

I cannot seem to find where this sample project is, could you point me in the right direction?

Sorry about that, forgot that it wasn’t bundled in in C++ like it is in Java. You can find it here:

Thank you very much. I managed to get the Buttons working, however my Drivetrain is now broken. Im thinking of rewriting the whole system.