diff --git a/include/gamepad/controller.hpp b/include/gamepad/controller.hpp index 1c4cf9d..1c09a2b 100644 --- a/include/gamepad/controller.hpp +++ b/include/gamepad/controller.hpp @@ -72,6 +72,7 @@ class Controller { Button L1 {}, L2 {}, R1 {}, R2 {}, Up {}, Down {}, Left {}, Right {}, X {}, B {}, Y {}, A {}; float LeftX = 0, LeftY = 0, RightX = 0, RightY = 0; private: + Button Fake{}; static Button Controller::*button_to_ptr(pros::controller_digital_e_t button); void updateButton(pros::controller_digital_e_t button_id); pros::Controller controller; diff --git a/src/gamepad/controller.cpp b/src/gamepad/controller.cpp index f2a35a1..1a2e1e5 100644 --- a/src/gamepad/controller.cpp +++ b/src/gamepad/controller.cpp @@ -75,8 +75,11 @@ float Controller::operator[](pros::controller_analog_e_t axis) { case ANALOG_LEFT_X: return this->LeftX; case ANALOG_LEFT_Y: return this->LeftY; case ANALOG_RIGHT_X: return this->RightX; - case ANALOG_RIGHT_Y: return this->RightY; TODO("change handling for default") - default: std::exit(1); + case ANALOG_RIGHT_Y: return this->RightY; + default: + TODO("add error logging") + errno = EINVAL; + return 0; } } @@ -94,7 +97,10 @@ Button Controller::*Controller::button_to_ptr(pros::controller_digital_e_t butto case DIGITAL_B: return &Controller::B; case DIGITAL_Y: return &Controller::Y; case DIGITAL_A: return &Controller::A; TODO("change handling for default") - default: std::exit(1); + default: + TODO("add error logging") + errno = EINVAL; + return &Controller::Fake; } } } // namespace Gamepad \ No newline at end of file