@@ -52,7 +52,7 @@ local use_auto_follow_mouse = true
52
52
local use_follow_outside_bounds = false
53
53
local is_following_mouse = false
54
54
local force_16_9 = true
55
- local auto_start = false
55
+ local lock_in = false
56
56
local follow_speed = 0.1
57
57
local follow_border = 0
58
58
local follow_safezone_sensitivity = 10
@@ -571,7 +571,7 @@ function refresh_sceneitem(find_newest)
571
571
if is_non_display_capture then
572
572
if not use_monitor_override then
573
573
log (" ERROR: Selected Zoom Source is not a display capture source.\n " ..
574
- " You MUST enable 'Set manual source position' and set the correct override values for size and position." )
574
+ " You MUST enable 'Set manual source position' and set the correct override values for size and position." )
575
575
end
576
576
end
577
577
@@ -621,7 +621,7 @@ function refresh_sceneitem(find_newest)
621
621
source_height = monitor_info .height
622
622
else
623
623
log (" ERROR: Something went wrong determining source size.\n " ..
624
- " Try using the 'Set manual source position' option and adding override values" )
624
+ " Try using the 'Set manual source position' option and adding override values" )
625
625
end
626
626
else
627
627
log (" Using source size: " .. source_width .. " , " .. source_height )
@@ -1148,10 +1148,8 @@ function on_settings_modified(props, prop, settings)
1148
1148
end
1149
1149
end
1150
1150
1151
- if auto_start then
1152
- on_toggle_zoom (true , true )
1153
- else
1154
- on_toggle_zoom (true , false )
1151
+ if lock_in ~= nil then
1152
+ on_toggle_zoom (true , lock_in )
1155
1153
end
1156
1154
return false
1157
1155
end
@@ -1182,7 +1180,7 @@ function log_current_settings()
1182
1180
socket_poll = socket_poll ,
1183
1181
debug_logs = debug_logs ,
1184
1182
force_16_9 = force_16_9 ,
1185
- auto_start = auto_start ,
1183
+ lock_in = lock_in ,
1186
1184
version = VERSION
1187
1185
}
1188
1186
@@ -1258,7 +1256,9 @@ function script_properties()
1258
1256
-- Add the rest of the settings UI
1259
1257
local zoom = obs .obs_properties_add_float (props , " zoom_value" , " Zoom Factor" , 1 , 5 , 0.5 )
1260
1258
local zoom_speed = obs .obs_properties_add_float_slider (props , " zoom_speed" , " Zoom Speed" , 0.01 , 1 , 0.01 )
1261
- local auto_start = obs .obs_properties_add_bool (props , " auto_start" , " Auto start " )
1259
+ local lock_in = obs .obs_properties_add_bool (props , " lock_in" , " Lock-In " )
1260
+ obs .obs_property_set_long_description (lock_in ,
1261
+ " When enabled, auto zoom feature cannot be disabled manually, and auto zoom restarts with OBS too" )
1262
1262
local force_16_9 = obs .obs_properties_add_bool (props , " force_16_9" , " Force 16:9 aspect ratio " )
1263
1263
local follow = obs .obs_properties_add_bool (props , " follow" , " Auto follow mouse " )
1264
1264
obs .obs_property_set_long_description (follow ,
@@ -1395,7 +1395,7 @@ function script_load(settings)
1395
1395
socket_port = obs .obs_data_get_int (settings , " socket_port" )
1396
1396
socket_poll = obs .obs_data_get_int (settings , " socket_poll" )
1397
1397
debug_logs = obs .obs_data_get_bool (settings , " debug_logs" )
1398
- auto_start = obs .obs_data_get_bool (settings , " auto_start " )
1398
+ lock_in = obs .obs_data_get_bool (settings , " lock_in " )
1399
1399
force_16_9 = obs .obs_data_get_bool (settings , " force_16_9" )
1400
1400
1401
1401
obs .obs_frontend_add_event_callback (on_frontend_event )
@@ -1456,7 +1456,7 @@ function script_unload()
1456
1456
stop_server ()
1457
1457
end
1458
1458
1459
- if auto_start then
1459
+ if lock_in then
1460
1460
on_toggle_zoom (true , false )
1461
1461
end
1462
1462
end
@@ -1486,7 +1486,7 @@ function script_defaults(settings)
1486
1486
obs .obs_data_set_default_int (settings , " socket_poll" , 10 )
1487
1487
obs .obs_data_set_default_bool (settings , " debug_logs" , false )
1488
1488
obs .obs_data_set_default_bool (settings , " force_16_9" , true )
1489
- obs .obs_data_set_default_bool (settings , " auto_start " , false )
1489
+ obs .obs_data_set_default_bool (settings , " lock_in " , false )
1490
1490
end
1491
1491
1492
1492
function script_save (settings )
@@ -1544,7 +1544,7 @@ function script_update(settings)
1544
1544
socket_poll = obs .obs_data_get_int (settings , " socket_poll" )
1545
1545
debug_logs = obs .obs_data_get_bool (settings , " debug_logs" )
1546
1546
force_16_9 = obs .obs_data_get_bool (settings , " force_16_9" )
1547
- auto_start = obs .obs_data_get_bool (settings , " auto_start " )
1547
+ lock_in = obs .obs_data_get_bool (settings , " lock_in " )
1548
1548
1549
1549
-- Only do the expensive refresh if the user selected a new source
1550
1550
if source_name ~= old_source_name and is_obs_loaded then
@@ -1578,10 +1578,20 @@ function script_update(settings)
1578
1578
start_server ()
1579
1579
end
1580
1580
1581
- if auto_start then
1582
- on_toggle_zoom (true , true )
1583
- else
1584
- on_toggle_zoom (true , false )
1581
+ if lock_in ~= nil and source == nil then
1582
+ local timer_interval = math.floor (obs .obs_get_frame_interval_ns () / 100000 )
1583
+ obs .timer_add (wait_for_auto_start , timer_interval )
1584
+ elseif lock_in ~= nil and source ~= nil then
1585
+ on_toggle_zoom (true , lock_in )
1586
+ end
1587
+ end
1588
+
1589
+ function wait_for_auto_start ()
1590
+ local found_source = obs .obs_get_source_by_name (source_name )
1591
+ if found_source ~= nil then
1592
+ source = found_source
1593
+ on_toggle_zoom (true , lock_in )
1594
+ obs .remove_current_callback ()
1585
1595
end
1586
1596
end
1587
1597
0 commit comments