joystick id mapping

gyro
NepEgor 2 years ago
parent 95689796bb
commit e26b2900f5

@ -26,6 +26,8 @@ class TouchJoystick : public TouchControl
bool invert_x;
bool invert_y;
uint8_t mapped_id;
public:
TouchJoystick() {}
@ -39,6 +41,9 @@ class TouchJoystick : public TouchControl
void setInvertX(bool invert_x = true);
void setInvertY(bool invert_y = true);
void setMappedId(uint8_t mapped_id);
uint8_t getMappedId() {return mapped_id;}
int8_t touch(int8_t fid, int32_t tx, int32_t ty);
int16_t getX() {return x;}

@ -55,6 +55,11 @@ void TouchJoystick::setInvertY(bool invert_y)
this->invert_y = invert_y;
}
void TouchJoystick::setMappedId(uint8_t mapped_id)
{
this->mapped_id = mapped_id;
}
int8_t TouchJoystick::touch(int8_t fid, int32_t tx, int32_t ty)
{
if (finger_id != -1 && finger_id != fid)

@ -96,6 +96,7 @@ namespace InputMapper
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.setDeadZoneOuter(dead_zone_outer);
tjoystick_left.setMappedId(0);
pos_x = 31.25 * ppmX;
pos_y = (103.9 - 31.25) * ppmY;
@ -107,6 +108,7 @@ namespace InputMapper
//tjoystick_right.setTrackballFriction(0);
tjoystick_right.setDeadZoneOuter(dead_zone_outer);
tjoystick_right.setSensitivity(10);
tjoystick_right.setMappedId(1);
pos_x = 20.636 * ppmX;
pos_y = 20.636 * ppmY;
@ -192,7 +194,7 @@ namespace InputMapper
res = tjoy->touch(fid, x, y);
device.joystick(id, tjoy->getX(), tjoy->getY());
device.joystick(tjoy->getMappedId(), tjoy->getX(), tjoy->getY());
}
break;
@ -202,7 +204,7 @@ namespace InputMapper
res = tmjoy->touch(fid, x, y, dx, dy, time);
device.joystick(id, tmjoy->getX(), tmjoy->getY());
device.joystick(tmjoy->getMappedId(), tmjoy->getX(), tmjoy->getY());
}
break;
@ -243,7 +245,7 @@ namespace InputMapper
tmjoy->updateTrackball(time);
device.joystick(id, tmjoy->getX(), tmjoy->getY());
device.joystick(tmjoy->getMappedId(), tmjoy->getX(), tmjoy->getY());
}
break;
@ -258,7 +260,7 @@ namespace InputMapper
void mapTriggers(uint32_t value[2])
{
static const uint32_t max = 70;
static const uint32_t min = 2;
static const uint32_t min = 13;
uint8_t mapped_value[2];

Loading…
Cancel
Save