2024-06-21 14:32:42 +02:00
|
|
|
#include "globals.hpp"
|
2024-06-22 15:01:47 +02:00
|
|
|
#define private public
|
2024-06-21 14:32:42 +02:00
|
|
|
#include <hyprland/src/managers/PointerManager.hpp>
|
2024-06-22 15:01:47 +02:00
|
|
|
#undef private
|
2024-06-21 14:32:42 +02:00
|
|
|
#include <hyprutils/math/Vector2D.hpp>
|
|
|
|
|
|
|
|
class CDynamicCursors;
|
|
|
|
|
|
|
|
class CDynamicCursors {
|
|
|
|
public:
|
2024-06-22 15:01:47 +02:00
|
|
|
/* hook on onCursorMoved */
|
|
|
|
void onCursorMoved(CPointerManager* pointers);
|
2024-06-26 17:14:16 +02:00
|
|
|
/* called on tick */
|
|
|
|
void onTick(CPointerManager* pointers);
|
2024-06-22 15:01:47 +02:00
|
|
|
|
2024-06-21 16:06:55 +02:00
|
|
|
/* hook on renderSoftwareCursorsFor */
|
2024-06-21 16:36:10 +02:00
|
|
|
void renderSoftware(CPointerManager* pointers, SP<CMonitor> pMonitor, timespec* now, CRegion& damage, std::optional<Vector2D> overridePos);
|
|
|
|
/* hook on damageIfSoftware*/
|
|
|
|
void damageSoftware(CPointerManager* pointers);
|
2024-06-22 15:01:47 +02:00
|
|
|
/* hook on renderHWCursorBuffer */
|
|
|
|
wlr_buffer* renderHardware(CPointerManager* pointers, SP<CPointerManager::SMonitorPointerState> state, SP<CTexture> texture);
|
|
|
|
/* hook on setHWCursorBuffer */
|
|
|
|
bool setHardware(CPointerManager* pointers, SP<CPointerManager::SMonitorPointerState> state, wlr_buffer* buf);
|
2024-06-21 14:32:42 +02:00
|
|
|
|
|
|
|
private:
|
2024-06-22 15:46:00 +02:00
|
|
|
// current angle of the cursor in radiants
|
|
|
|
double angle;
|
2024-06-27 17:21:39 +02:00
|
|
|
// current zoom value of the cursor
|
|
|
|
double zoom = 1;
|
2024-06-27 18:04:49 +02:00
|
|
|
// whether we have already locked software
|
|
|
|
bool software = false;
|
2024-06-22 15:46:00 +02:00
|
|
|
|
2024-06-26 17:14:16 +02:00
|
|
|
// calculates the current angle of the cursor, and changes the cursor shape
|
2024-06-27 20:24:37 +02:00
|
|
|
void calculate(bool tick);
|
2024-06-26 17:14:16 +02:00
|
|
|
|
|
|
|
// calculate the angle of the cursor if stick
|
|
|
|
double calculateStick();
|
2024-06-21 14:32:42 +02:00
|
|
|
// this is the end of the virtual stick
|
|
|
|
Vector2D end;
|
2024-06-26 17:14:16 +02:00
|
|
|
|
|
|
|
// calculate the angle of the cursor if air
|
|
|
|
double calculateAir();
|
|
|
|
// ring buffer of last position samples
|
|
|
|
std::vector<Vector2D> samples;
|
|
|
|
int samples_index = 0;
|
2024-06-27 17:21:39 +02:00
|
|
|
|
|
|
|
double calculateShake();
|
|
|
|
std::vector<Vector2D> shake_samples;
|
|
|
|
std::vector<double> shake_samples_distance;
|
|
|
|
int shake_samples_index = 0;
|
2024-06-21 14:32:42 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
inline std::unique_ptr<CDynamicCursors> g_pDynamicCursors;
|