diff --git a/lib/touch_controls/include/touch_mouse_joystick.h b/lib/touch_controls/include/touch_mouse_joystick.h index f39bda4..cb1f891 100644 --- a/lib/touch_controls/include/touch_mouse_joystick.h +++ b/lib/touch_controls/include/touch_mouse_joystick.h @@ -7,13 +7,15 @@ class TouchMouseJoustick : public TouchJoystick { protected: - float delta2usb; + float sensitivity; float trackball_friction; 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 setSensitivity(float sensitivity); + void setTrackballFriction(float trackball_friction); int8_t touch(int8_t fid, int32_t tx, int32_t ty, int32_t tdx, int32_t tdy); diff --git a/lib/touch_controls/src/touch_mouse_joystick.cpp b/lib/touch_controls/src/touch_mouse_joystick.cpp index a37e673..d8cc992 100644 --- a/lib/touch_controls/src/touch_mouse_joystick.cpp +++ b/lib/touch_controls/src/touch_mouse_joystick.cpp @@ -8,7 +8,12 @@ void TouchMouseJoustick::init(int32_t pos_x, int32_t pos_y, int32_t pos_r, int16 this->control_type = CT_MOUSE_JOYSTICK; - this->delta2usb = this->pos2usb * 30; + this->sensitivity = this->pos2usb; +} + +void TouchMouseJoustick::setSensitivity(float sensitivity) +{ + this->sensitivity = this->pos2usb * sensitivity; } void TouchMouseJoustick::setTrackballFriction(float trackball_friction) @@ -45,11 +50,14 @@ int8_t TouchMouseJoustick::touch(int8_t fid, int32_t tx, int32_t ty, int32_t tdx if (t2 <= dead_zone_outer2) { - int32_t x32 = -tdx * delta2usb + usb_x; - int32_t y32 = -tdy * delta2usb + usb_y; + int32_t x32 = -tdx * sensitivity; + int32_t y32 = -tdy * sensitivity; x = x32 > usb_r? usb_r : (x32 < -usb_r? -usb_r : x32); y = y32 > usb_r? usb_r : (y32 < -usb_r? -usb_r : y32); + + x + usb_x; + y + usb_y; } else // in bounds outside of outer dead zone - edge spin { diff --git a/src/input_mapper.cpp b/src/input_mapper.cpp index d6b5ebf..ced311a 100644 --- a/src/input_mapper.cpp +++ b/src/input_mapper.cpp @@ -29,7 +29,7 @@ namespace InputMapper }; const uint8_t num_controls = sizeof(tcontrols) / sizeof(TouchControl*[2]); - + /* uint16_t button_map[] = { USB_Device::START, @@ -44,6 +44,22 @@ namespace InputMapper USB_Device::FACE_X, USB_Device::FACE_Y, }; + */ + // Genshin map + uint16_t button_map[] = + { + USB_Device::START, + USB_Device::SELECT, + USB_Device::FACE_B, + USB_Device::FACE_X, + USB_Device::BUMPER_LEFT, + USB_Device::BUMPER_RIGHT, + USB_Device::HOME, + USB_Device::FACE_A, + USB_Device::JOYSTICK_RIGHT, + USB_Device::FACE_A, + USB_Device::JOYSTICK_LEFT, + }; uint16_t dpad_left_map[] = { @@ -90,6 +106,7 @@ namespace InputMapper tjoystick_right.init(pos_x, pos_y, pos_r, USB_Device::usb_joystick_x, USB_Device::usb_joystick_y, USB_Device::usb_joystick_r); //tjoystick_right.setDeadZoneInner(dead_zone_inner); tjoystick_right.setDeadZoneOuter(dead_zone_outer); + tjoystick_right.setSensitivity(10); pos_x = 20.636 * ppmX; pos_y = 20.636 * ppmY;