Problems compiling old command code using POVButton


We are trying to use the POVButton class, since we are running out of standard buttons on our Logitech F310.

And so far, we have had no problems using the old commands (other knowing it is deprecated).

The problem is when we try to instantiate a POVButton class, the compiler does not recognize the constuctor I’m using.

Here’s some snippets of code:


#include "frc/Joystick.h"
#include "frc/buttons/POVButton.h"

class OI {
    frc::Joystick* getJoystick();
    frc::POVButton* m_button1;

and OI.cpp

#include "OI.h"
#include "RobotMap.h"
#include "commands/Cmd1.h"

OI::OI() {
  m_joystick = new frc::Joystick(0);
  m_button1 = new frc::POVButton(m_joystick, 0, 0);
  m_button1->WhenPressed(new Cmd1());

OI::~OI() {
  delete m_buttonCmd1;
  delete m_joystick;

frc::Joystick* OI::getJoystick() {
   return m_joystick;

Th#include “OI.h”
#include “RobotMap.h”
#include “commands/Cmd1.h”

OI::OI() {
m_joystick = new frc::Joystick(0);
m_buttonCmd1 = new frc::POVButton(m_joystick, 0, 0);
m_buttonCmd1->WhenPressed(new Cmd1());

OI::~OI() {
delete m_buttonCmd1;
delete m_joystick;

frc::Joystick* OI::getJoystick() {
return m_joystick;

The problem is the line “m_buttonCmd1 = new frc::POVButton(m_joystick, 0, 0);”

From the official WPIDocs for C++, for POVButton, POVButton has a constructor of


frc::POVButton::POVButton ( GenericHID & joystick ,
int angle ,
int povNumber = 0

Creates a POV button for triggering commands.


joystick The GenericHID object that has the POV
angle The desired angle in degrees (e.g. 90, 270)
povNumber The POV number (

See also


However, when I build, I get the following error:

> Task :compileFrcUserProgramDebugExecutableFrcUserProgramCpp
/home/user/ORION/RobotCode/src/main/cpp/OI.cpp: In constructor 'OI::OI()':
/home/user/ORION/RobotCode/src/main/cpp/OI.cpp:120:41: error: no matching function for call to 'frc::POVButton::POVButton(frc::Joystick*&, int, int)'
      new frc::POVButton(m_joystick, 0, 0);
In file included from /home/user/ORION/RobotCode/src/main/include/OI.h:45:0,
                 from /home/user/ORION/RobotCode/src/main/cpp/OI.cpp:28:
/home/user/.gradle/caches/transforms-2/files-2.1/c5183a78943591e2d1b1171ae79168f9/wpilibOldCommands-cpp-2020.2.2-headers/frc/buttons/POVButton.h:26:3: note: candidate: frc::POVButton::POVButton(frc::POVButton&&)
   POVButton(POVButton&&) = default;
/home/user/.gradle/caches/transforms-2/files-2.1/c5183a78943591e2d1b1171ae79168f9/wpilibOldCommands-cpp-2020.2.2-headers/frc/buttons/POVButton.h:26:3: note:   candidate expects 1 argument, 3 provided
/home/user/.gradle/caches/transforms-2/files-2.1/c5183a78943591e2d1b1171ae79168f9/wpilibOldCommands-cpp-2020.2.2-headers/frc/buttons/POVButton.h:23:3: note: candidate: frc::POVButton::POVButton(frc::GenericHID&, int, int)
   POVButton(GenericHID& joystick, int angle, int povNumber = 0);
/home/user/.gradle/caches/transforms-2/files-2.1/c5183a78943591e2d1b1171ae79168f9/wpilibOldCommands-cpp-2020.2.2-headers/frc/buttons/POVButton.h:23:3: note:   no known conversion for argument 1 from 'frc::Joystick*' to 'frc::GenericHID&'

The intent is to run Cmd1 when the POV top button (0 degrees) is pressed.

Any clues what’s going on? Am I reading the documentation incorrectly?

Any help would be greatly appreciated.

Please ignore the text between the OI.cpp listing and “The problem…”

It’s getting late…

m_joystick is a Joystick* and the function expects a GenericHID&. You need to dereference m_joystick (eg pass *m_joystick)

Thank you. That fixed the problem.

It’s been a while since I’ve done some C/C++ programming. I’ve forgotten the use of references, and was confusing GenericHID& (which was in the constructor) with &GenericHID (which is what my brain was seeing late a night), which m_joystick should have worked for (both being addresses). But now I’ve learned (or probably re-learned) the use of pass-by-reference.

So again, thank you for the help, and for the opportunity to refresh myself on references!

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.