Skip to content

Commit

Permalink
refactor mouse_position()
Browse files Browse the repository at this point in the history
  • Loading branch information
Ciremun committed Jul 28, 2024
1 parent 044c7fd commit 2d6f7e4
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 26 deletions.
12 changes: 0 additions & 12 deletions freedom/features/aimbot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,6 @@

float elapsed_lerp = 0;

static inline Vector2<float> mouse_position()
{
Vector2<float> mouse_pos(.0f, .0f);
uintptr_t osu_manager = *(uintptr_t*)(osu_manager_ptr);
if (!osu_manager) return mouse_pos;
uintptr_t osu_ruleset_ptr = *(uintptr_t*)(osu_manager + OSU_MANAGER_RULESET_PTR_OFFSET);
if (!osu_ruleset_ptr) return mouse_pos;
mouse_pos.x = *(float*)(osu_ruleset_ptr + OSU_RULESET_MOUSE_X_OFFSET);
mouse_pos.y = *(float*)(osu_ruleset_ptr + OSU_RULESET_MOUSE_Y_OFFSET);
return mouse_pos;
}

static inline float lerp(float a, float b, float t)
{
return a + t * (b - a);
Expand Down
17 changes: 3 additions & 14 deletions freedom/features/relax.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,6 @@ void calc_od_timing()
}
}

Vector2<float> mouse_position()
{
Vector2<float> mouse_pos;
uintptr_t osu_manager = *(uintptr_t *)(osu_manager_ptr);
uintptr_t osu_ruleset_ptr = *(uintptr_t *)(osu_manager + OSU_MANAGER_RULESET_PTR_OFFSET);
mouse_pos.x = *(float *)(osu_ruleset_ptr + OSU_RULESET_MOUSE_X_OFFSET);
mouse_pos.y = *(float *)(osu_ruleset_ptr + OSU_RULESET_MOUSE_Y_OFFSET);

return mouse_pos;
}

void update_relax(Circle &circle, const int32_t audio_time)
{
static double keydown_time = 0.0;
Expand All @@ -68,9 +57,9 @@ void update_relax(Circle &circle, const int32_t audio_time)

auto current_time = audio_time + od_check_ms;
auto valid_timing = current_time >= circle.start_time;
auto mouse_pos = mouse_position();
Vector2 screen_pos = playfield_to_screen(circle.position);
auto scalar_dist = sqrt((mouse_pos.x - screen_pos.x) * (mouse_pos.x - screen_pos.x) + (mouse_pos.y - screen_pos.y) * (mouse_pos.y - screen_pos.y));
// auto mouse_pos = mouse_position();
// Vector2 screen_pos = playfield_to_screen(circle.position);
// auto scalar_dist = sqrt((mouse_pos.x - screen_pos.x) * (mouse_pos.x - screen_pos.x) + (mouse_pos.y - screen_pos.y) * (mouse_pos.y - screen_pos.y));
// auto valid_position = scalar_dist <= current_beatmap.scaled_hit_object_radius;

if (valid_timing)
Expand Down
12 changes: 12 additions & 0 deletions freedom/input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,18 @@ void send_keyboard_input(char wVk, DWORD dwFlags)
SendInput(1, inputs, sizeof(INPUT));
}

Vector2<float> mouse_position()
{
Vector2<float> mouse_pos(.0f, .0f);
uintptr_t osu_manager = *(uintptr_t*)(osu_manager_ptr);
if (!osu_manager) return mouse_pos;
uintptr_t osu_ruleset_ptr = *(uintptr_t*)(osu_manager + OSU_MANAGER_RULESET_PTR_OFFSET);
if (!osu_ruleset_ptr) return mouse_pos;
mouse_pos.x = *(float*)(osu_ruleset_ptr + OSU_RULESET_MOUSE_X_OFFSET);
mouse_pos.y = *(float*)(osu_ruleset_ptr + OSU_RULESET_MOUSE_Y_OFFSET);
return mouse_pos;
}

void move_mouse_to(int x, int y)
{
x += client_offset.x;
Expand Down
1 change: 1 addition & 0 deletions include/features/aimbot.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include "vector.h"
#include "input.h"

#include "ui/config.h"

Expand Down
2 changes: 2 additions & 0 deletions include/features/relax.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#pragma once

#include "input.h"

#include "ui/config.h"

extern float od_window;
Expand Down
2 changes: 2 additions & 0 deletions include/input.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "window.h"
#include "freedom.h"
#include "scan.h"
#include "vector.h"

extern uintptr_t binding_manager_code_start;
extern uintptr_t binding_manager_ptr;
Expand All @@ -14,4 +15,5 @@ extern char right_click[2];

void init_input();
void send_keyboard_input(char wVk, DWORD dwFlags);
Vector2<float> mouse_position();
void move_mouse_to(int x, int y);

0 comments on commit 2d6f7e4

Please sign in to comment.