-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
controls doesn't work #777
Comments
load a video and click the button. |
Works fine for me even for videos. And on the gif above you can see that uosc is triggering proper commands. So whatever the issue is, it doesn't seem to be uosc related. |
I don't see your console is switching hwdec mode. |
That looks more like a cursor events issue. Does something like
It's a static paused image with |
I tried
No freezing, it just does not respond my click. |
The first broken version |
Can you report what is this logging? diff --git a/src/uosc/elements/CycleButton.lua b/src/uosc/elements/CycleButton.lua
index 6059849..6d5ca85 100644
--- a/src/uosc/elements/CycleButton.lua
+++ b/src/uosc/elements/CycleButton.lua
@@ -24,6 +24,7 @@ function CycleButton:init(id, props)
self.on_click = function()
local new_state = self.states[self.current_state_index + 1] or self.states[1]
local new_value = new_state.value
+ print('current:', self.states[self.current_state_index].value, 'next:', new_value)
if self.owner then
mp.commandv('script-message-to', self.owner, 'set', self.prop, new_value)
elseif is_state_prop then |
Yeah I though this was gonna be the issue. Now to figure out why is it failing to set or select next state for you. Can you screenshot the result of this too?: print('current:', self.states[self.current_state_index].value, 'next:', new_value, 'real:', mp.get_property_native('hwdec')) |
But in this case, we should observe |
Oh my god. How do we handle this now? There's one property for reading, and another for setting? Jesus. And why does it work for me and not for you? |
#777 (comment) |
Does this work for you? diff --git a/src/uosc/elements/CycleButton.lua b/src/uosc/elements/CycleButton.lua
index 6059849..475f2e5 100644
--- a/src/uosc/elements/CycleButton.lua
+++ b/src/uosc/elements/CycleButton.lua
@@ -1,5 +1,9 @@
local Button = require('elements/Button')
+local writer_reader_map = {
+ hwdec = 'hwdec-current'
+}
+
---@alias CycleState {value: any; icon: string; active?: boolean}
---@alias CycleButtonProps {prop: string; states: CycleState[]; anchor_id?: string; tooltip?: string}
@@ -52,7 +56,7 @@ function CycleButton:init(id, props)
self['on_prop_' .. self.prop] = function(self, value) handle_change(self.prop, value) end
handle_change(self.prop, state[self.prop])
else
- self:observe_mp_property(self.prop, handle_change)
+ self:observe_mp_property(writer_reader_map[self.prop] or self.prop, handle_change)
end
end
I'll try to look. |
Try this? 😬 diff --git a/src/uosc/elements/CycleButton.lua b/src/uosc/elements/CycleButton.lua
index 6059849..61cd666 100644
--- a/src/uosc/elements/CycleButton.lua
+++ b/src/uosc/elements/CycleButton.lua
@@ -52,7 +52,7 @@ function CycleButton:init(id, props)
self['on_prop_' .. self.prop] = function(self, value) handle_change(self.prop, value) end
handle_change(self.prop, state[self.prop])
else
- self:observe_mp_property(self.prop, handle_change)
+ self:observe_mp_property(self.prop, 'string', handle_change)
end
end
diff --git a/src/uosc/elements/Element.lua b/src/uosc/elements/Element.lua
index 3e3f458..733d63e 100644
--- a/src/uosc/elements/Element.lua
+++ b/src/uosc/elements/Element.lua
@@ -182,9 +182,12 @@ end
-- Automatically registers disposer for the observer.
---@param name string
----@param callback fun(name: string, value: any)
-function Element:observe_mp_property(name, callback)
- mp.observe_property(name, 'native', callback)
+---@param type_or_callback string|fun(name: string, value: any)
+---@param callback_maybe nil|fun(name: string, value: any)
+function Element:observe_mp_property(name, type_or_callback, callback_maybe)
+ local callback = type(type_or_callback) == 'function' and type_or_callback or callback_maybe
+ local prop_type = type(type_or_callback) == 'string' and type_or_callback or 'native'
+ mp.observe_property(name, prop_type, callback)
self:register_disposer(function() mp.unobserve_property(callback) end)
end |
Yes, it works. |
controls =
cycle:developer_board_off:hwdec:no=developer_board_off/yes=memory/auto-copy=developer_board?test
It doesn't work in current git version.
The text was updated successfully, but these errors were encountered: