The document outlines the code for handling a PS3 gamepad, initializing button states, and reading sensor values from touch pins. It compares current sensor values to calibrated untouched values to determine which buttons are pressed and displays this information via serial output. Finally, it serializes the gamepad data for transmission to a host device and includes a delay to manage output speed.
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
3 views2 pages
Game
The document outlines the code for handling a PS3 gamepad, initializing button states, and reading sensor values from touch pins. It compares current sensor values to calibrated untouched values to determine which buttons are pressed and displays this information via serial output. Finally, it serializes the gamepad data for transmission to a host device and includes a delay to manage output speed.
// Comparar valores actuales con los valores sin pulsar (calibrados)
for (int i = 0; i < PsRESERVED_LAST_BUTTON_UNUSED; i++) { // Aplicamos el factor de reducción y comprobamos si el valor es significativamente mayor if (psCurrentValues[i] > psGamepad.buttonsUntouchedValues[i] * TOUCHED_THRESHOLD_FACTOR) { psGamepad.buttonsPressed[i] = PsPRESSED; } else { psGamepad.buttonsPressed[i] = PsNOT_PRESSED; } }
// Mostrar estado de los botones en el puerto serie
Serial.print("PS3 Botones pulsados: "); for (int i = 0; i < PsRESERVED_LAST_BUTTON_UNUSED; i++) { if (psGamepad.buttonsPressed[i] == PRESSED) { Serial.print(psButtonNames[i]); // Imprime el nombre del botón pulsado Serial.print(" "); } } Serial.println();
// Enviamos los datos al anfitrion (consola, PC...)
// Serializamos los datos contenidos en nsGamepad para su envio PSProtocolSerializePSGamepadData (psGamepad, psBuffer);