mirror of
https://github.com/virtcode/hypr-dynamic-cursors
synced 2025-09-19 16:13:21 +02:00
parent
98c006aeae
commit
3ff4c2a053
9 changed files with 37 additions and 5 deletions
|
@ -9,8 +9,10 @@ class IMode {
|
|||
public:
|
||||
/* returns the desired updating strategy for the given mode */
|
||||
virtual EModeUpdate strategy() = 0;
|
||||
/* updates the calculations and returns the new angle */
|
||||
/* updates the calculations and returns the new result */
|
||||
virtual SModeResult update(Vector2D pos) = 0;
|
||||
/* reset the internal stuff of the mode */
|
||||
virtual void reset() = 0;
|
||||
/* called on warp, an update will be sent afterwards (probably) */
|
||||
virtual void warp(Vector2D old, Vector2D pos) = 0;
|
||||
};
|
||||
|
|
|
@ -13,6 +13,12 @@ SModeResult CModeRotate::update(Vector2D pos) {
|
|||
auto length = g_pShapeRuleHandler->getIntOr(CONFIG_ROTATE_LENGTH, **PLENGTH);
|
||||
auto offset = g_pShapeRuleHandler->getFloatOr(CONFIG_ROTATE_OFFSET, **POFFSET);
|
||||
|
||||
// this mode has just started, start at upright orientation
|
||||
if (end.y == 0 && end.x == 0) {
|
||||
end.x = pos.x;
|
||||
end.y = pos.y + length;
|
||||
}
|
||||
|
||||
// translate to origin
|
||||
end.x -= pos.x;
|
||||
end.y -= pos.y;
|
||||
|
@ -49,3 +55,7 @@ SModeResult CModeRotate::update(Vector2D pos) {
|
|||
void CModeRotate::warp(Vector2D old, Vector2D pos) {
|
||||
end += (pos - old);
|
||||
}
|
||||
|
||||
void CModeRotate::reset() {
|
||||
end = {0, 0};
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ class CModeRotate : public IMode {
|
|||
public:
|
||||
virtual EModeUpdate strategy();
|
||||
virtual SModeResult update(Vector2D pos);
|
||||
virtual void reset();
|
||||
virtual void warp(Vector2D old, Vector2D pos);
|
||||
|
||||
private:
|
||||
|
|
|
@ -15,10 +15,10 @@ SModeResult CModeStretch::update(Vector2D pos) {
|
|||
|
||||
// create samples array
|
||||
int max = g_pHyprRenderer->m_pMostHzMonitor->refreshRate / 10; // 100ms worth of history
|
||||
samples.resize(max);
|
||||
samples.resize(max, pos);
|
||||
|
||||
// capture current sample
|
||||
samples[samples_index] = Vector2D{pos};
|
||||
samples[samples_index] = pos;
|
||||
int current = samples_index;
|
||||
samples_index = (samples_index + 1) % max; // increase for next sample
|
||||
int first = samples_index;
|
||||
|
@ -47,3 +47,8 @@ void CModeStretch::warp(Vector2D old, Vector2D pos) {
|
|||
for (auto& sample : samples)
|
||||
sample += delta;
|
||||
}
|
||||
|
||||
void CModeStretch::reset() {
|
||||
samples.clear();
|
||||
samples_index = 0;
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ class CModeStretch : public IMode {
|
|||
public:
|
||||
virtual EModeUpdate strategy();
|
||||
virtual SModeResult update(Vector2D pos);
|
||||
virtual void reset();
|
||||
virtual void warp(Vector2D old, Vector2D pos);
|
||||
|
||||
private:
|
||||
|
|
|
@ -15,10 +15,10 @@ SModeResult CModeTilt::update(Vector2D pos) {
|
|||
|
||||
// create samples array
|
||||
int max = g_pHyprRenderer->m_pMostHzMonitor->refreshRate / 10; // 100ms worth of history
|
||||
samples.resize(max);
|
||||
samples.resize(max, pos);
|
||||
|
||||
// capture current sample
|
||||
samples[samples_index] = Vector2D{pos};
|
||||
samples[samples_index] = pos;
|
||||
int current = samples_index;
|
||||
samples_index = (samples_index + 1) % max; // increase for next sample
|
||||
int first = samples_index;
|
||||
|
@ -37,3 +37,8 @@ void CModeTilt::warp(Vector2D old, Vector2D pos) {
|
|||
for (auto& sample : samples)
|
||||
sample += delta;
|
||||
}
|
||||
|
||||
void CModeTilt::reset() {
|
||||
samples.clear();
|
||||
samples_index = 0;
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ class CModeTilt : public IMode {
|
|||
public:
|
||||
virtual EModeUpdate strategy();
|
||||
virtual SModeResult update(Vector2D pos);
|
||||
virtual void reset();
|
||||
virtual void warp(Vector2D old, Vector2D pos);
|
||||
|
||||
private:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue