feat: rotate mode angle offset

close #4
This commit is contained in:
Virt 2024-06-29 11:06:52 +02:00
commit bbe4709926
4 changed files with 10 additions and 0 deletions

View file

@ -34,6 +34,8 @@ This plugin is still very early in its development. There are also multiple thin
- [ ] per-shape length and starting angle (if possible) - [ ] per-shape length and starting angle (if possible)
- [X] cursor shake to find - [X] cursor shake to find
- [ ] overdue refactoring (wait for aquamarine merge) - [ ] overdue refactoring (wait for aquamarine merge)
- [ ] inverted cursor?
- [ ] hyprcursor magified shape
If anything here sounds interesting to you, don't hesitate to contribute. If anything here sounds interesting to you, don't hesitate to contribute.
@ -110,6 +112,10 @@ plugin:dynamic-cursors {
# length in px of the simulated stick used to rotate the cursor # length in px of the simulated stick used to rotate the cursor
# most realistic if this is your actual cursor size # most realistic if this is your actual cursor size
length = 20 length = 20
# clockwise offset applied to the angle in degrees
# this will apply to ALL shapes
offset = 0.0
} }
# for mode = tilt # for mode = tilt

View file

@ -12,6 +12,7 @@
#define CONFIG_SHAKE_EFFECTS "plugin:dynamic-cursors:shake:effects" #define CONFIG_SHAKE_EFFECTS "plugin:dynamic-cursors:shake:effects"
#define CONFIG_SHAKE_IPC "plugin:dynamic-cursors:shake:ipc" #define CONFIG_SHAKE_IPC "plugin:dynamic-cursors:shake:ipc"
#define CONFIG_LENGTH "plugin:dynamic-cursors:rotate:length" #define CONFIG_LENGTH "plugin:dynamic-cursors:rotate:length"
#define CONFIG_ROTATE_OFFSET "plugin:dynamic-cursors:rotate:offset"
#define CONFIG_MASS "plugin:dynamic-cursors:tilt:limit" #define CONFIG_MASS "plugin:dynamic-cursors:tilt:limit"
#define CONFIG_FUNCTION "plugin:dynamic-cursors:tilt:function" #define CONFIG_FUNCTION "plugin:dynamic-cursors:tilt:function"

View file

@ -120,6 +120,7 @@ APICALL EXPORT PLUGIN_DESCRIPTION_INFO PLUGIN_INIT(HANDLE handle) {
HyprlandAPI::addConfigValue(PHANDLE, CONFIG_MASS, Hyprlang::INT{5000}); HyprlandAPI::addConfigValue(PHANDLE, CONFIG_MASS, Hyprlang::INT{5000});
HyprlandAPI::addConfigValue(PHANDLE, CONFIG_LENGTH, Hyprlang::INT{20}); HyprlandAPI::addConfigValue(PHANDLE, CONFIG_LENGTH, Hyprlang::INT{20});
HyprlandAPI::addConfigValue(PHANDLE, CONFIG_ROTATE_OFFSET, Hyprlang::FLOAT{0});
HyprlandAPI::addConfigValue(PHANDLE, CONFIG_HW_DEBUG, Hyprlang::INT{0}); HyprlandAPI::addConfigValue(PHANDLE, CONFIG_HW_DEBUG, Hyprlang::INT{0});

View file

@ -7,6 +7,7 @@ EModeUpdate CModeRotate::strategy() {
double CModeRotate::update(Vector2D pos) { double CModeRotate::update(Vector2D pos) {
static auto* const* PLENGTH = (Hyprlang::INT* const*)HyprlandAPI::getConfigValue(PHANDLE, CONFIG_LENGTH)->getDataStaticPtr(); static auto* const* PLENGTH = (Hyprlang::INT* const*)HyprlandAPI::getConfigValue(PHANDLE, CONFIG_LENGTH)->getDataStaticPtr();
static auto* const* POFFSET = (Hyprlang::FLOAT* const*)HyprlandAPI::getConfigValue(PHANDLE, CONFIG_ROTATE_OFFSET)->getDataStaticPtr();
// translate to origin // translate to origin
end.x -= pos.x; end.x -= pos.x;
@ -25,6 +26,7 @@ double CModeRotate::update(Vector2D pos) {
double angle = -std::atan(end.x / end.y); double angle = -std::atan(end.x / end.y);
if (end.y > 0) angle += PI; if (end.y > 0) angle += PI;
angle += PI; angle += PI;
angle += **POFFSET * ((2 * PI) / 360); // convert to radiants
// translate back // translate back
end.x += pos.x; end.x += pos.x;