Skip to content

Commit c61ecb0

Browse files
Merge pull request #13 from BlankSourceCode/allow-negative-offset
Allow negative source positions
2 parents ac0d433 + 2243b9e commit c61ecb0

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

obs-zoom-to-mouse.lua

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -182,13 +182,13 @@ function get_monitor_info(source)
182182
end
183183
end
184184

185-
-- This works for my machine as the monitor names are given as "U2790B: 3840x2160 @ 0,0 (Primary Monitor)"
185+
-- This works for my machine as the monitor names are given as "U2790B: 3840x2160 @ -1920,0 (Primary Monitor)"
186186
-- I don't know if this holds true for other machines and/or OBS versions
187187
-- TODO: Update this with some custom FFI calls to find the monitor top-left x and y coordinates if it doesn't work for anyone else
188188
-- TODO: Refactor this into something that would work with Windows/Linux/Mac assuming we can't do it like this
189189
if found then
190190
log("Parsing display name: " .. found)
191-
local x, y = found:match("(%d+),(%d+)")
191+
local x, y = found:match("(-?%d+),(-?%d+)")
192192
local width, height = found:match("(%d+)x(%d+)")
193193

194194
info = { x = 0, y = 0, width = 0, height = 0 }
@@ -856,8 +856,7 @@ function on_settings_modified(props, prop, settings)
856856
name == "monitor_override_h" or
857857
name == "monitor_override_sx" or
858858
name == "monitor_override_sy" then
859-
local visible = obs.obs_data_get_bool(settings, "use_monitor_override")
860-
if visible and source ~= nil then
859+
if source ~= nil then
861860
monitor_info = get_monitor_info(source)
862861
end
863862
return name == "use_monitor_override"
@@ -964,8 +963,8 @@ function script_properties()
964963
"You MUST set manual source position for non-display capture sources")
965964

966965
local override = obs.obs_properties_add_bool(props, "use_monitor_override", "Set manual source position")
967-
local override_x = obs.obs_properties_add_int(props, "monitor_override_x", "X", 0, 10000, 1)
968-
local override_y = obs.obs_properties_add_int(props, "monitor_override_y", "Y", 0, 10000, 1)
966+
local override_x = obs.obs_properties_add_int(props, "monitor_override_x", "X", -10000, 10000, 1)
967+
local override_y = obs.obs_properties_add_int(props, "monitor_override_y", "Y", -10000, 10000, 1)
969968
local override_w = obs.obs_properties_add_int(props, "monitor_override_w", "Width", 0, 10000, 1)
970969
local override_h = obs.obs_properties_add_int(props, "monitor_override_h", "Height", 0, 10000, 1)
971970
local override_sx = obs.obs_properties_add_float(props, "monitor_override_sx", "Scale X ", 0, 100, 0.01)

readme.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ Inspired by [tryptech](https://github.com/tryptech)'s [obs-zoom-and-follow](http
3434
**Note:** If you don't use this form of setup for your display source (E.g. you have bounding box set to `No bounds` or you have a `Crop` set on the transform), the script will attempt to **automatically change your settings** to zoom compatible ones.
3535
This may have undesired effects on your layout (or just not work at all).
3636

37+
**Note:** If you change your desktop display properties in Windows (such as moving a monitor, changing your primary display, updating the orientation of a display), you will need to re-add your display capture source in OBS for it to update the values that the script uses for its auto calculations. You will then need to reload the script.
38+
3739
## Usage
3840
1. You can customize the following settings in the OBS Scripts window:
3941
* **Zoom Source**: The display capture in the current scene to use for zooming

0 commit comments

Comments
 (0)