mirror of
https://github.com/virtcode/hypr-dynamic-cursors
synced 2025-09-19 08:03:21 +02:00
parent
31e9a46326
commit
0e0e58ca95
5 changed files with 21 additions and 5 deletions
10
README.md
10
README.md
|
@ -142,6 +142,10 @@ plugin:dynamic-cursors {
|
||||||
# negative_quadratic - negative version of the quadratic one, feels more aggressive
|
# negative_quadratic - negative version of the quadratic one, feels more aggressive
|
||||||
# see `activation` in `src/mode/utils.cpp` for how exactly the calculation is done
|
# see `activation` in `src/mode/utils.cpp` for how exactly the calculation is done
|
||||||
function = negative_quadratic
|
function = negative_quadratic
|
||||||
|
|
||||||
|
# time window (ms) over which the speed is calculated
|
||||||
|
# higher values will make slow motions smoother but more delayed
|
||||||
|
window = 100
|
||||||
}
|
}
|
||||||
|
|
||||||
# for mode = stretch
|
# for mode = stretch
|
||||||
|
@ -158,6 +162,10 @@ plugin:dynamic-cursors {
|
||||||
# negative_quadratic - negative version of the quadratic one, feels more aggressive
|
# negative_quadratic - negative version of the quadratic one, feels more aggressive
|
||||||
# see `activation` in `src/mode/utils.cpp` for how exactly the calculation is done
|
# see `activation` in `src/mode/utils.cpp` for how exactly the calculation is done
|
||||||
function = quadratic
|
function = quadratic
|
||||||
|
|
||||||
|
# time window (ms) over which the speed is calculated
|
||||||
|
# higher values will make slow motions smoother but more delayed
|
||||||
|
window = 100
|
||||||
}
|
}
|
||||||
|
|
||||||
# configure shake to find
|
# configure shake to find
|
||||||
|
@ -227,7 +235,7 @@ plugin:dynamic-cursors {
|
||||||
### shape rules
|
### shape rules
|
||||||
Shape Rules can be used to override the mode or its behaviour on a per-shape basis. They can be defined with the keyword `shaperule` in the config file, preferably in the `plugin:dynamic-cursors` section.
|
Shape Rules can be used to override the mode or its behaviour on a per-shape basis. They can be defined with the keyword `shaperule` in the config file, preferably in the `plugin:dynamic-cursors` section.
|
||||||
|
|
||||||
**Note:** Shape rules only apply to server side cursor shapes. Sadly, not everyone supports server side cursors yet, which means shape rules won't work with apps using toolkits like e.g. GTK.
|
**Note:** Shape rules only apply to server side cursor shapes. Sadly, not everyone supports server side cursors yet, which means shape rules won't work in some applications.
|
||||||
|
|
||||||
A shape rule usually consists of three parts:
|
A shape rule usually consists of three parts:
|
||||||
```
|
```
|
||||||
|
|
|
@ -29,9 +29,11 @@
|
||||||
|
|
||||||
#define CONFIG_TILT_LIMIT "tilt:limit"
|
#define CONFIG_TILT_LIMIT "tilt:limit"
|
||||||
#define CONFIG_TILT_FUNCTION "tilt:function"
|
#define CONFIG_TILT_FUNCTION "tilt:function"
|
||||||
|
#define CONFIG_TILT_WINDOW "tilt:window"
|
||||||
|
|
||||||
#define CONFIG_STRETCH_LIMIT "stretch:limit"
|
#define CONFIG_STRETCH_LIMIT "stretch:limit"
|
||||||
#define CONFIG_STRETCH_FUNCTION "stretch:function"
|
#define CONFIG_STRETCH_FUNCTION "stretch:function"
|
||||||
|
#define CONFIG_STRETCH_WINDOW "stretch:window"
|
||||||
|
|
||||||
#define CONFIG_HIGHRES_ENABLED "hyprcursor:enabled"
|
#define CONFIG_HIGHRES_ENABLED "hyprcursor:enabled"
|
||||||
#define CONFIG_HIGHRES_NEAREST "hyprcursor:nearest"
|
#define CONFIG_HIGHRES_NEAREST "hyprcursor:nearest"
|
||||||
|
|
|
@ -135,9 +135,11 @@ APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) {
|
||||||
|
|
||||||
addShapeConfig(CONFIG_TILT_FUNCTION, "negative_quadratic");
|
addShapeConfig(CONFIG_TILT_FUNCTION, "negative_quadratic");
|
||||||
addShapeConfig(CONFIG_TILT_LIMIT, 5000);
|
addShapeConfig(CONFIG_TILT_LIMIT, 5000);
|
||||||
|
addShapeConfig(CONFIG_TILT_WINDOW, 100);
|
||||||
|
|
||||||
addShapeConfig(CONFIG_STRETCH_FUNCTION, "negative_quadratic");
|
addShapeConfig(CONFIG_STRETCH_FUNCTION, "negative_quadratic");
|
||||||
addShapeConfig(CONFIG_STRETCH_LIMIT, 3000);
|
addShapeConfig(CONFIG_STRETCH_LIMIT, 3000);
|
||||||
|
addShapeConfig(CONFIG_STRETCH_WINDOW, 100);
|
||||||
|
|
||||||
addShapeConfig(CONFIG_ROTATE_LENGTH, 20);
|
addShapeConfig(CONFIG_ROTATE_LENGTH, 20);
|
||||||
addShapeConfig(CONFIG_ROTATE_OFFSET, 0.0f);
|
addShapeConfig(CONFIG_ROTATE_OFFSET, 0.0f);
|
||||||
|
|
|
@ -11,11 +11,13 @@ EModeUpdate CModeStretch::strategy() {
|
||||||
SModeResult CModeStretch::update(Vector2D pos) {
|
SModeResult CModeStretch::update(Vector2D pos) {
|
||||||
static auto const* PFUNCTION = (Hyprlang::STRING const*) getConfig(CONFIG_STRETCH_FUNCTION);
|
static auto const* PFUNCTION = (Hyprlang::STRING const*) getConfig(CONFIG_STRETCH_FUNCTION);
|
||||||
static auto* const* PLIMIT = (Hyprlang::INT* const*) getConfig(CONFIG_STRETCH_LIMIT);
|
static auto* const* PLIMIT = (Hyprlang::INT* const*) getConfig(CONFIG_STRETCH_LIMIT);
|
||||||
|
static auto* const* PWINDOW = (Hyprlang::INT* const*) getConfig(CONFIG_STRETCH_WINDOW);
|
||||||
auto function = g_pShapeRuleHandler->getStringOr(CONFIG_STRETCH_FUNCTION, *PFUNCTION);
|
auto function = g_pShapeRuleHandler->getStringOr(CONFIG_STRETCH_FUNCTION, *PFUNCTION);
|
||||||
auto limit = g_pShapeRuleHandler->getIntOr(CONFIG_STRETCH_LIMIT, **PLIMIT);
|
auto limit = g_pShapeRuleHandler->getIntOr(CONFIG_STRETCH_LIMIT, **PLIMIT);
|
||||||
|
auto window = g_pShapeRuleHandler->getIntOr(CONFIG_STRETCH_WINDOW, **PWINDOW);
|
||||||
|
|
||||||
// create samples array
|
// create samples array
|
||||||
int max = std::max(1, (int)(g_pHyprRenderer->m_mostHzMonitor->m_refreshRate / 10)); // 100ms worth of history, avoiding divide by 0
|
int max = std::max(1, (int)(g_pHyprRenderer->m_mostHzMonitor->m_refreshRate / 1000 * window)); // [window]ms worth of history, avoiding divide by 0
|
||||||
samples.resize(max, pos);
|
samples.resize(max, pos);
|
||||||
samples_index = std::min(samples_index, max - 1);
|
samples_index = std::min(samples_index, max - 1);
|
||||||
|
|
||||||
|
@ -26,7 +28,7 @@ SModeResult CModeStretch::update(Vector2D pos) {
|
||||||
int first = samples_index;
|
int first = samples_index;
|
||||||
|
|
||||||
// calculate speed and tilt
|
// calculate speed and tilt
|
||||||
Vector2D speed = (samples[current] - samples[first]) / 0.1;
|
Vector2D speed = (samples[current] - samples[first]) / window * 1000;
|
||||||
double mag = speed.size();
|
double mag = speed.size();
|
||||||
|
|
||||||
double angle = -std::atan(speed.x / speed.y) + PI;
|
double angle = -std::atan(speed.x / speed.y) + PI;
|
||||||
|
|
|
@ -11,11 +11,13 @@ EModeUpdate CModeTilt::strategy() {
|
||||||
SModeResult CModeTilt::update(Vector2D pos) {
|
SModeResult CModeTilt::update(Vector2D pos) {
|
||||||
static auto const* PFUNCTION = (Hyprlang::STRING const*) getConfig(CONFIG_TILT_FUNCTION);
|
static auto const* PFUNCTION = (Hyprlang::STRING const*) getConfig(CONFIG_TILT_FUNCTION);
|
||||||
static auto* const* PLIMIT = (Hyprlang::INT* const*) getConfig(CONFIG_TILT_LIMIT);
|
static auto* const* PLIMIT = (Hyprlang::INT* const*) getConfig(CONFIG_TILT_LIMIT);
|
||||||
|
static auto* const* PWINDOW = (Hyprlang::INT* const*) getConfig(CONFIG_TILT_WINDOW);
|
||||||
auto function = g_pShapeRuleHandler->getStringOr(CONFIG_TILT_FUNCTION, *PFUNCTION);
|
auto function = g_pShapeRuleHandler->getStringOr(CONFIG_TILT_FUNCTION, *PFUNCTION);
|
||||||
auto limit = g_pShapeRuleHandler->getIntOr(CONFIG_TILT_LIMIT, **PLIMIT);
|
auto limit = g_pShapeRuleHandler->getIntOr(CONFIG_TILT_LIMIT, **PLIMIT);
|
||||||
|
auto window = g_pShapeRuleHandler->getIntOr(CONFIG_TILT_WINDOW, **PWINDOW);
|
||||||
|
|
||||||
// create samples array
|
// create samples array
|
||||||
int max = std::max(1, (int)(g_pHyprRenderer->m_mostHzMonitor->m_refreshRate / 10)); // 100ms worth of history, avoiding divide by 0
|
int max = std::max(1, (int)(g_pHyprRenderer->m_mostHzMonitor->m_refreshRate / 1000 * window)); // [window]ms worth of history, avoiding divide by 0
|
||||||
samples.resize(max, pos);
|
samples.resize(max, pos);
|
||||||
samples_index = std::min(samples_index, max - 1);
|
samples_index = std::min(samples_index, max - 1);
|
||||||
|
|
||||||
|
@ -26,7 +28,7 @@ SModeResult CModeTilt::update(Vector2D pos) {
|
||||||
int first = samples_index;
|
int first = samples_index;
|
||||||
|
|
||||||
// calculate speed and tilt
|
// calculate speed and tilt
|
||||||
double speed = (samples[current].x - samples[first].x) / 0.1;
|
double speed = (samples[current].x - samples[first].x) / window * 1000;
|
||||||
|
|
||||||
auto result = SModeResult();
|
auto result = SModeResult();
|
||||||
result.rotation = activation(function, limit, speed) * (PI / 3); // 120° in both directions
|
result.rotation = activation(function, limit, speed) * (PI / 3); // 120° in both directions
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue