#include #include #include #include #define IPC_SHAKE_START "shakestart" #define IPC_SHAKE_UPDATE "shakeupdate" #define IPC_SHAKE_END "shakeend" using namespace Hyprutils::Math; using namespace Hyprutils::Animation; using namespace std::chrono; class CShake { public: CShake(); /* calculates the new zoom factor for the current pos */ double update(Vector2D pos); /* called when a cursor warp has happened (to avoid magnifying on warps) */ void warp(Vector2D old, Vector2D pos); /* force magnification regardless of speed now */ void force(std::optional duration, std::optional size); private: /* tracks whether the current shake has already been announced in the ipc */ bool ipc = false; bool started = false; PHLANIMVAR zoom; steady_clock::time_point end; /* ringbuffer for last samples */ std::vector samples; /* we also store the distance for each sample to the last, so we do only compute this once */ std::vector samples_distance; int samples_index = 0; };