|
|
@ -25,6 +25,15 @@ TouchJoystick tjoystick_left;
|
|
|
|
TouchDpad tdpad_right;
|
|
|
|
TouchDpad tdpad_right;
|
|
|
|
TouchDpad tdpad_left;
|
|
|
|
TouchDpad tdpad_left;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TouchControl* tcontrols[] =
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
&tjoystick_right,
|
|
|
|
|
|
|
|
&tdpad_right,
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
uint8_t num_controls = sizeof(tcontrols) / sizeof(TouchControl*);
|
|
|
|
|
|
|
|
|
|
|
|
void setup()
|
|
|
|
void setup()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Turn on LED
|
|
|
|
// Turn on LED
|
|
|
@ -57,6 +66,14 @@ void setup()
|
|
|
|
tjoystick_right.setInvertX();
|
|
|
|
tjoystick_right.setInvertX();
|
|
|
|
tjoystick_right.setInvertY();
|
|
|
|
tjoystick_right.setInvertY();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pos_x = (62.5 - 20.636) * ppmX;
|
|
|
|
|
|
|
|
pos_y = 20.636 * ppmY;
|
|
|
|
|
|
|
|
pos_r = 45 * ppmX / 2;
|
|
|
|
|
|
|
|
tdpad_right.init(pos_x, pos_y, pos_r, TouchDpad::DPAD_TYPE_SECTOR8);
|
|
|
|
|
|
|
|
tdpad_right.setDeadZoneInner(dead_zone_inner);
|
|
|
|
|
|
|
|
tdpad_right.setInvertX();
|
|
|
|
|
|
|
|
tdpad_right.setInvertY();
|
|
|
|
|
|
|
|
|
|
|
|
//tjoystick_left.init(pos_x, pos_y, pos_r, USB_Device::usb_joystick_x, USB_Device::usb_joystick_y, USB_Device::usb_joystick_r);
|
|
|
|
//tjoystick_left.init(pos_x, pos_y, pos_r, USB_Device::usb_joystick_x, USB_Device::usb_joystick_y, USB_Device::usb_joystick_r);
|
|
|
|
//tjoystick_left.setDeadZoneInner(dead_zone_inner);
|
|
|
|
//tjoystick_left.setDeadZoneInner(dead_zone_inner);
|
|
|
|
//tjoystick_left.setDeadZoneOuter(dead_zone_outer);
|
|
|
|
//tjoystick_left.setDeadZoneOuter(dead_zone_outer);
|
|
|
@ -78,48 +95,48 @@ void loop()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (fp != NULL)
|
|
|
|
if (fp != NULL)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
for (uint8_t id = 0; id < TrackPad::fingers_num; ++id)
|
|
|
|
for (int8_t id = 0; id < TrackPad::fingers_num; ++id)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (fingers_touching & (1 << id))
|
|
|
|
if (fingers_touching & (1 << id))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int8_t res = tjoystick_right.touch(fp[id].y, fp[id].x);
|
|
|
|
for (uint8_t c = 0; c < num_controls; ++c)
|
|
|
|
if (res > 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
switch(tjoystick_right.getControlType())
|
|
|
|
int8_t res = tcontrols[c]->touch(fp[id].y, fp[id].x);
|
|
|
|
|
|
|
|
if (res < 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Serial.printf("Impossible Error\n");
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch(tcontrols[c]->getControlType())
|
|
|
|
{
|
|
|
|
{
|
|
|
|
case TouchControl::CT_NONE:
|
|
|
|
case TouchControl::CT_NONE:
|
|
|
|
|
|
|
|
Serial.printf("Control type not set\n");
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case TouchControl::CT_JOYSTICK:
|
|
|
|
case TouchControl::CT_JOYSTICK:
|
|
|
|
|
|
|
|
device.joystick_left(((TouchJoystick*)tcontrols[c])->getX(), ((TouchJoystick*)tcontrols[c])->getY());
|
|
|
|
int16_t x = tjoystick_right.getX();
|
|
|
|
break;
|
|
|
|
int16_t y = tjoystick_right.getY();
|
|
|
|
|
|
|
|
device.joystick_left(x, y);
|
|
|
|
case TouchControl::CT_DPAD:
|
|
|
|
|
|
|
|
device.dpad(((TouchDpad*)tcontrols[c])->getButton());
|
|
|
|
Serial.printf("(%i, %i) (%i, %i)\n", fp[id].x, fp[id].y, x, y);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
if (res > 0)
|
|
|
|
if (res < 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
Serial.printf("Impossible Error\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
device.joystick_left(USB_Device::usb_joystick_x, USB_Device::usb_joystick_y);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
if (fingers_touching == 0)
|
|
|
|
if (fingers_touching == 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
device.joystick_left(USB_Device::usb_joystick_x, USB_Device::usb_joystick_y);
|
|
|
|
device.joystick_left(USB_Device::usb_joystick_x, USB_Device::usb_joystick_y);
|
|
|
|
|
|
|
|
device.dpad(TouchDpad::NOT_PRESSED);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
device.trigger_right(right_trigger);
|
|
|
|
device.trigger_right(right_trigger);
|
|
|
|