Arrow button syntax in pros

Ive been trying to use the arrow buttons on the v5 controller but cant figure it out. Ive tried a few different approaches but always comes back with an error. Anyone else figured it out? im using C++

Can u send out your code and the error? its hard to help you without any specific information. Also, im sure that the documentation could help you. (https://pros.cs.purdue.edu/v5/tutorials/topical/controller.html)

Controller.ButtonUp.pressing() Up Down Left Right.

As shown in the docs:
https://pros.cs.purdue.edu/v5/api/cpp/misc.html#get-digital
https://pros.cs.purdue.edu/v5/api/c/misc.html#controller-digital-e-t
To get the value of the up button you would do:
controller.get_digital(pros::E_CONTROLLER_DIGITAL_UP)

3 Likes

I tried the code again with chagning it and still get an error

if(controller.getDigital(pros::E_CONTROLLER_DIGITAL_UP)){
armMotor.moveVelocity(-100);

Error:
src/systems/tray.cpp:11:59: error: no matching function for call to ‘okapi::Controller::getDigital(pros::controller_digital_e_t)’
if(controller.getDigital(pros::E_CONTROLLER_DIGITAL_UP)){
^
In file included from ./include/okapi/api.hpp:47:0,
from ./include/main.h:42,
from src/systems/tray.cpp:1:
./include/okapi/impl/device/controller.hpp:55:16: note: candidate: virtual bool okapi::Controller::getDigital(okapi::ControllerDigital)
virtual bool getDigital(ControllerDigital ibutton);
^~~~~~~~~~

That only works for VexCode and VCS. PROS has a completely different API.

Oh, you’ve got the wrong controller.
pros::Controller vs. okapi::Controller.
If you need to use okapi::Controller (I know very little about that and why would Okapi reimplement the controller access), there is okapi::Controller::getDigital(ControllerDigital) that takes okapi::ControllerDigital enum values as parameters, such as okapi::ControllerDigital::up.

But you may just be having wrong include or using okapi::*; somewhere that you need to clean up (I mostly avoid importing whole namespaces like this, especially if there are conflicting generic class names involved).

2 Likes