mouse joystick min delta

gyro
NepEgor 2 years ago
parent 3204dbe371
commit bfec8c0782

@ -16,6 +16,8 @@ class TouchMouseJoystick : public TouchJoystick
float dx;
float dy;
int16_t min_delta;
float time0;
public:
@ -26,6 +28,8 @@ class TouchMouseJoystick : public TouchJoystick
void setTrackballFriction(float trackball_friction);
void setMinDelta(int16_t min_delta);
TouchState touch(int8_t fid, int32_t tx, int32_t ty, int32_t tdx, int32_t tdy, uint32_t time);
void updateTrackball(uint32_t time);

@ -14,6 +14,8 @@ void TouchMouseJoystick::init(int32_t pos_x, int32_t pos_y, int32_t pos_r, int16
this->trackball_vel_x = 0;
this->trackball_vel_y = 0;
this->min_delta = 0;
this->time0 = 0;
}
@ -27,6 +29,11 @@ void TouchMouseJoystick::setTrackballFriction(float trackball_friction)
this->trackball_friction = trackball_friction;
}
void TouchMouseJoystick::setMinDelta(int16_t min_delta)
{
this->min_delta = min_delta;
}
TouchMouseJoystick::TouchState TouchMouseJoystick::touch(int8_t fid, int32_t tx, int32_t ty, int32_t tdx, int32_t tdy, uint32_t time)
{
if (finger_id != -1 && finger_id != fid)
@ -64,6 +71,9 @@ TouchMouseJoystick::TouchState TouchMouseJoystick::touch(int8_t fid, int32_t tx,
dx = dx > usb_r? usb_r : (dx < -usb_r? -usb_r : dx);
dy = dy > usb_r? usb_r : (dy < -usb_r? -usb_r : dy);
dx = dx > -min_delta && dx < 0? -min_delta : (dx < min_delta && dx > 0? min_delta : dx);
dy = dy > -min_delta && dy < 0? -min_delta : (dy < min_delta && dy > 0? min_delta : dy);
float dt = time - time0;
time0 = time;

@ -120,6 +120,7 @@ namespace InputMapper
//tjoystick_right.setTrackballFriction(0);
tjoystick_right.setDeadZoneOuter(dead_zone_outer);
tjoystick_right.setSensitivity(10);
tjoystick_right.setMinDelta(1000);
tjoystick_right.setMappedId(1);
pos_x = 20.636 * ppmX;

Loading…
Cancel
Save