2024-08-25 20:00:16 +02:00
|
|
|
#include "src/helpers/AnimatedVariable.hpp"
|
2024-06-28 14:08:13 +02:00
|
|
|
#include <hyprutils/math/Vector2D.hpp>
|
|
|
|
#include <vector>
|
|
|
|
|
2024-06-28 18:03:59 +02:00
|
|
|
#define IPC_SHAKE_START "shakestart"
|
|
|
|
#define IPC_SHAKE_UPDATE "shakeupdate"
|
|
|
|
#define IPC_SHAKE_END "shakeend"
|
|
|
|
|
2024-06-28 14:08:13 +02:00
|
|
|
using namespace Hyprutils::Math;
|
2024-08-25 20:00:16 +02:00
|
|
|
using namespace std::chrono;
|
2024-06-28 14:08:13 +02:00
|
|
|
|
|
|
|
class CShake {
|
|
|
|
public:
|
2024-08-25 20:00:16 +02:00
|
|
|
CShake();
|
|
|
|
~CShake();
|
|
|
|
|
2024-06-28 14:08:13 +02:00
|
|
|
/* calculates the new zoom factor for the current pos */
|
|
|
|
double update(Vector2D pos);
|
2024-08-25 22:58:55 +02:00
|
|
|
/* called when a cursor warp has happened (to avoid magnifying on warps) */
|
|
|
|
void warp(Vector2D old, Vector2D pos);
|
2024-06-28 14:08:13 +02:00
|
|
|
|
|
|
|
private:
|
2024-06-28 18:03:59 +02:00
|
|
|
/* tracks whether the current shake has already been announced in the ipc */
|
|
|
|
bool ipc = false;
|
2024-06-28 14:08:13 +02:00
|
|
|
|
2024-08-25 20:00:16 +02:00
|
|
|
bool started = false;
|
|
|
|
CAnimatedVariable<float> zoom;
|
|
|
|
steady_clock::time_point end;
|
2024-07-03 17:51:19 +02:00
|
|
|
|
2024-06-28 14:08:13 +02:00
|
|
|
/* ringbuffer for last samples */
|
|
|
|
std::vector<Vector2D> samples;
|
|
|
|
/* we also store the distance for each sample to the last, so we do only compute this once */
|
|
|
|
std::vector<double> samples_distance;
|
|
|
|
int samples_index = 0;
|
|
|
|
};
|