Botón#

Los botones disponibles en un controlador V5 son los siguientes:

Controlador V5

<ul><li>`ButtonA` - El botón A.</li><li>`ButtonB` - El botón B.</li><li>`ButtonX` - El botón X.</li><li>`ButtonY` - El botón Y.</li><li>`ButtonDown` - El botón Abajo.</li><li>`ButtonUp` - El botón Arriba.</li><li>`ButtonLeft` - El botón Izquierdo.</li><li>`ButtonRight` - El botón Derecho.</li><li>`ButtonL1` - El botón L1.</li><li>`ButtonL2` - El botón L2.</li><li>`ButtonR1` - El botón R1.</li><li>`ButtonR2` - El botón R2.</li>

apretado()#

El método pressed(callback) registra una función que se llamará cuando se presione un botón.

Parámetro

Descripción

llamar de vuelta

Una función que se llamará cuando se presione el botón.

Devuelve: Una instancia de la clase Event.

// Define the buttonPressed function with a void return
// type, showing it doesn't return a value.
void buttonPressed() {
  // The Brain will print that a controller button was
  // pressed on the Brain's screen.
  Brain.Screen.print("controller button pressed");
}

int main() {
  // Initializing Robot Configuration. DO NOT REMOVE!
  vexcodeInit();

  // Run buttonPressed when the 'A' controller button is pressed.
  Controller.ButtonA.pressed(buttonPressed);
}

liberado()#

El método released(callback, arg) registra una función que se llamará cuando se suelte un botón.

Parámetro

Descripción

llamar de vuelta

Una función que se llamará cuando se suelte el botón.

arg

Opcional. Un parámetro para pasar a la función de devolución de llamada.

Devuelve: Una instancia de la clase Event.

// Define the buttonReleased function with a void return
// type, showing it doesn't return a value.
void buttonReleased() {
  // The Brain will print that a controller button was
  // released on the Brain's screen.
  Brain.Screen.print("controller button released");
}

int main() {
  // Initializing Robot Configuration. DO NOT REMOVE!
  vexcodeInit();

  // Run buttonReleased when the 'A' controller button is released.
  Controller.ButtonA.released(buttonReleased);
}

prensado()#

El método pressing() devuelve si un botón está siendo presionado actualmente.

Devuelve: Verdadero si el botón está presionado. Falso si no está presionado.