Untitled
unknown
c_cpp
9 months ago
1.8 kB
8
Indexable
inline void controller_move(float tarx, float tary, float screenX, float screenY, int smooth) {
float centerX = screenX / 2.0f;
float centerY = screenY / 2.0f;
float deltaX = (tarx - centerX) / smooth;
float deltaY = (tary - centerY) / smooth;
// deltaY = -deltaY;
const int min_mouse = -127;
const int max_mouse = 127;
int mouseDeltaX = static_cast<int>(std::clamp(deltaX, (float)min_mouse, (float)max_mouse));
int mouseDeltaY = static_cast<int>(std::clamp(deltaY, (float)min_mouse, (float)max_mouse));
const int min_xinput = -32768;
const int max_xinput = 32767;
const int deadzone = static_cast<int>(max_xinput * 0.2f);
float scale = (max_xinput - deadzone) / static_cast<float>(max_mouse);
int newRX, newRY;
if (mouseDeltaX > 0) {
newRX = static_cast<int>(mouseDeltaX * scale) + deadzone;
}
else if (mouseDeltaX < 0) {
newRX = static_cast<int>(mouseDeltaX * scale) - deadzone;
}
else {
newRX = 0;
}
if (mouseDeltaY > 0) {
newRY = static_cast<int>(mouseDeltaY * scale) + deadzone;
}
else if (mouseDeltaY < 0) {
newRY = static_cast<int>(mouseDeltaY * scale) - deadzone;
}
else {
newRY = 0;
}
newRX = std::clamp(newRX, min_xinput, max_xinput);
newRY = std::clamp(newRY, min_xinput, max_xinput);
{
std::lock_guard<std::mutex> lock(controllerMutex);
aimbotRightStickX = static_cast<short>(newRX);
aimbotRightStickY = static_cast<short>(newRY);
}
//std::cout << "[ControllerAim] Set Aimbot RS: tarx=" << tarx << ", tary=" << tary
//<< " | Delta=(" << deltaX << ", " << deltaY << ")"
//<< " -> newRX=" << newRX << ", newRY=" << newRY << std::endl;
UpdateVirtualController();
}Editor is loading...
Leave a Comment