|
|
|
@ -3,6 +3,8 @@
|
|
|
|
|
#include "trackpad.h"
|
|
|
|
|
#include "input_mapper.h"
|
|
|
|
|
|
|
|
|
|
//#define DISABLE_TRACKPADS
|
|
|
|
|
|
|
|
|
|
const uint8_t pin_trigger[2] = {PA1, PA0};
|
|
|
|
|
|
|
|
|
|
const uint8_t pin_button[] =
|
|
|
|
@ -10,27 +12,31 @@ const uint8_t pin_button[] =
|
|
|
|
|
PB12, 0, // START
|
|
|
|
|
PB13, 0, // SELECT
|
|
|
|
|
PB5, 0, // BUMPER_LEFT
|
|
|
|
|
PA8, 1, // BUMPER_RIGHT
|
|
|
|
|
PA8, 0, // BUMPER_RIGHT
|
|
|
|
|
PB1, 0, // HOME
|
|
|
|
|
PB14, 1, // GRIP_A
|
|
|
|
|
PB15, 1, // GRIP_B
|
|
|
|
|
PB14, 0, // GRIP_A
|
|
|
|
|
PB15, 0, // GRIP_B
|
|
|
|
|
PA4, 0, // GRIP_X
|
|
|
|
|
PB4, 0, // GRIP_Y
|
|
|
|
|
PC15, 0, // TRACKPAD_LEFT
|
|
|
|
|
PB3, 1, // TRACKPAD_RIGHT
|
|
|
|
|
PB3, 0, // TRACKPAD_RIGHT
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
uint8_t button_state[sizeof(pin_button) / 2] = {0};
|
|
|
|
|
|
|
|
|
|
const uint8_t gyro_int = PC14;
|
|
|
|
|
|
|
|
|
|
#ifndef DISABLE_TRACKPADS
|
|
|
|
|
|
|
|
|
|
const uint8_t pin_trackpad_data[2] = {PA2, PB9};
|
|
|
|
|
const uint8_t pin_trackpad_clock[2] = {PA3, PB8};
|
|
|
|
|
|
|
|
|
|
const uint8_t gyro_int = PC14;
|
|
|
|
|
|
|
|
|
|
TrackPad trackpad[2]; // 0 - left, 1 - right
|
|
|
|
|
|
|
|
|
|
int32_t trackpad_maxX, trackpad_maxY;
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
void setup()
|
|
|
|
|
{
|
|
|
|
|
// Turn on LED
|
|
|
|
@ -50,6 +56,8 @@ void setup()
|
|
|
|
|
pinMode(pin_button[i], pin_button[i + 1]? INPUT_PULLDOWN : INPUT_PULLUP);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#ifndef DISABLE_TRACKPADS
|
|
|
|
|
|
|
|
|
|
for (uint8_t i = 0; i < sizeof(pin_trackpad_clock); ++i)
|
|
|
|
|
{
|
|
|
|
|
trackpad[i].initialize(pin_trackpad_clock[i], pin_trackpad_data[i]);
|
|
|
|
@ -58,6 +66,8 @@ void setup()
|
|
|
|
|
trackpad_maxX = trackpad[0].getMaxX();
|
|
|
|
|
trackpad_maxY = trackpad[0].getMaxY();
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
InputMapper::begin();
|
|
|
|
|
|
|
|
|
|
// Turn off LED
|
|
|
|
@ -69,6 +79,8 @@ TouchEvent tevent[5];
|
|
|
|
|
|
|
|
|
|
void loop()
|
|
|
|
|
{
|
|
|
|
|
#ifndef DISABLE_TRACKPADS
|
|
|
|
|
|
|
|
|
|
for (uint8_t t = 0; t < 2; ++t)
|
|
|
|
|
{
|
|
|
|
|
if (trackpad[t].poll(tevent, tevent_size) > 0)
|
|
|
|
@ -117,7 +129,18 @@ void loop()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
uint32_t triggers[] = {analogRead(pin_trigger[0]), analogRead(pin_trigger[1])};
|
|
|
|
|
|
|
|
|
|
//Serial.print(0);
|
|
|
|
|
//Serial.print('\t');
|
|
|
|
|
//Serial.print(triggers[0]);
|
|
|
|
|
//Serial.print('\t');
|
|
|
|
|
//Serial.print(triggers[1]);
|
|
|
|
|
//Serial.print('\t');
|
|
|
|
|
//Serial.println(1000);
|
|
|
|
|
|
|
|
|
|
InputMapper::mapTriggers(triggers);
|
|
|
|
|
|
|
|
|
|
for (uint8_t i = 0; i < sizeof(pin_button); i += 2)
|
|
|
|
|