reset joystick when mode shifting

This commit is contained in:
NepEgor 2022-09-24 21:00:00 +04:00
parent 3b2be18f6b
commit e19dffeacd
9 changed files with 38 additions and 0 deletions

View File

@ -43,6 +43,8 @@ class TouchControl
virtual void init(int32_t pos_x, int32_t pos_y, int32_t pos_r);
virtual void reset();
virtual TouchState touch(int8_t fid, int32_t tx, int32_t ty) = 0;
int8_t getTouching() {return touching;}

View File

@ -31,6 +31,8 @@ class TouchDpad : public TouchControl
TouchDpad(int32_t pos_x, int32_t pos_y, int32_t pos_r, DpadType dpad_type = DPAD_TYPE_SECTOR_4);
void init(int32_t pos_x, int32_t pos_y, int32_t pos_r, DpadType dpad_type = DPAD_TYPE_SECTOR_4);
void reset();
void setDeadZoneInner(int32_t dead_zone_inner);

View File

@ -35,6 +35,8 @@ class TouchJoystick : public TouchControl
void init(int32_t pos_x, int32_t pos_y, int32_t pos_r, int16_t usb_x, int16_t usb_y, int16_t usb_r);
void reset();
void setDeadZoneInner(int32_t dead_zone_inner);
void setDeadZoneOuter(int32_t dead_zone_outer);

View File

@ -23,6 +23,8 @@ class TouchMouseJoystick : public TouchJoystick
public:
void init(int32_t pos_x, int32_t pos_y, int32_t pos_r, int16_t usb_x, int16_t usb_y, int16_t usb_r);
void reset();
void setSensitivity(float sensitivity);

View File

@ -18,3 +18,9 @@ void TouchControl::init(int32_t pos_x, int32_t pos_y, int32_t pos_r)
this->touching = TS_NONE;
}
void TouchControl::reset()
{
this->finger_id = -1;
this->touching = TS_NONE;
}

View File

@ -31,6 +31,12 @@ void TouchDpad::init(int32_t pos_x, int32_t pos_y, int32_t pos_r, DpadType dpad_
this->button = 0;
}
void TouchDpad::reset()
{
TouchControl::reset();
this->button = 0;
}
void TouchDpad::setDeadZoneInner(int32_t dead_zone_inner)
{
this->dead_zone_inner = dead_zone_inner;

View File

@ -31,6 +31,13 @@ void TouchJoystick::init(int32_t pos_x, int32_t pos_y, int32_t pos_r, int16_t us
this->y = usb_y;
}
void TouchJoystick::reset()
{
TouchControl::reset();
this->x = usb_x;
this->y = usb_y;;
}
void TouchJoystick::setDeadZoneInner(int32_t dead_zone_inner)
{
this->dead_zone_inner = dead_zone_inner;

View File

@ -19,6 +19,15 @@ void TouchMouseJoystick::init(int32_t pos_x, int32_t pos_y, int32_t pos_r, int16
this->time0 = 0;
}
void TouchMouseJoystick::reset()
{
TouchJoystick::reset();
this->trackball_vel_x = 0;
this->trackball_vel_y = 0;
this->dx = 0;
this->dy = 0;
}
void TouchMouseJoystick::setSensitivity(float sensitivity)
{
this->sensitivity = this->pos2usb * sensitivity;

View File

@ -337,6 +337,8 @@ namespace InputMapper
case HardwareButtons::BUMPER_LEFT:
tcontrols[1][0]->reset();
if (value)
{
tcontrols[1][0] = &tjoystick_right_wheel;