Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[C++ cmd] Make CommandGenericHID as a public base class of CommandXboxController #6658

Conversation

KangarooKoala
Copy link
Contributor

#6296 accidentally omitted the public specifier on CommandGenericHID in the base class section of CommandXboxController. Since CommandXboxController is declared using class, the default access for base classes is private, which prevents users outside the class from using methods declared in CommandGenericHID, which was the point of the PR.

I checked and the other files touched by that PR do not have the issue. I also confirmed locally that using methods declared in CommandGenericHID (such as Button(int)) on a CommandXboxController works with the following diff:

diff --git a/developerRobot/src/main/native/cpp/Robot.cpp b/developerRobot/src/main/native/cpp/Robot.cpp
index 238697d42..9f6075dae 100644
--- a/developerRobot/src/main/native/cpp/Robot.cpp
+++ b/developerRobot/src/main/native/cpp/Robot.cpp
@@ -3,13 +3,14 @@
 // the WPILib BSD license file in the root directory of this project.
 
 #include <frc/TimedRobot.h>
+#include <frc2/command/button/CommandXboxController.h>
 
 class Robot : public frc::TimedRobot {
   /**
    * This function is run when the robot is first started up and should be
    * used for any initialization code.
    */
-  void RobotInit() override {}
+  void RobotInit() override { m_controller.Button(0); }
 
   /**
    * This function is run once each time the robot enters autonomous mode
@@ -40,6 +41,9 @@ class Robot : public frc::TimedRobot {
    * This function is called periodically during all modes
    */
   void RobotPeriodic() override {}
+
+ private:
+  frc2::CommandXboxController m_controller{0};
 };
 
 int main() {

@KangarooKoala KangarooKoala requested a review from a team as a code owner May 25, 2024 18:00
@KangarooKoala
Copy link
Contributor Author

This does not require a corresponding Python PR because the Python version is already correct- Classes inherit from CommandGenericHID and there is no private subclassing to worry about.

@PeterJohnson PeterJohnson merged commit eb3635e into wpilibsuite:main May 25, 2024
25 of 26 checks passed
@KangarooKoala KangarooKoala deleted the fix-cpp-commandxboxcontroller-inheritance branch May 26, 2024 00:51
chauser pushed a commit to chauser/allwpilib that referenced this pull request May 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants