2023-07-07 02:35:34 +01:00
|
|
|
module Voicemeeter
|
2023-08-29 11:21:05 +01:00
|
|
|
# Common interface with the base Remote class.
|
2023-07-27 10:58:26 +01:00
|
|
|
module IRemote
|
2023-07-16 11:08:24 +01:00
|
|
|
include Logging
|
2023-07-14 12:01:41 +01:00
|
|
|
include MetaFunctions
|
2023-07-09 05:49:08 +01:00
|
|
|
|
2023-07-07 02:35:34 +01:00
|
|
|
def initialize(remote, i = nil)
|
|
|
|
@remote = remote
|
|
|
|
@index = i
|
|
|
|
end
|
|
|
|
|
|
|
|
def to_s
|
|
|
|
"#{self.class.name.split("::").last}#{@index}#{@remote.kind}"
|
|
|
|
end
|
|
|
|
|
2023-07-16 11:08:24 +01:00
|
|
|
private
|
|
|
|
|
2023-07-07 02:35:34 +01:00
|
|
|
def getter(param, is_string = false)
|
2023-07-09 05:49:08 +01:00
|
|
|
logger.debug "getter: #{_cmd(param)}"
|
2023-07-07 02:35:34 +01:00
|
|
|
@remote.get(_cmd(param), is_string)
|
|
|
|
end
|
|
|
|
|
|
|
|
def setter(param, value)
|
2023-07-09 05:49:08 +01:00
|
|
|
logger.debug "setter: #{_cmd(param)}=#{value}"
|
2023-07-07 02:35:34 +01:00
|
|
|
@remote.set(_cmd(param), value)
|
|
|
|
end
|
|
|
|
|
|
|
|
def _cmd(param)
|
2023-07-14 01:47:36 +01:00
|
|
|
param.empty? ? identifier : "#{identifier}.#{param}"
|
2023-07-07 02:35:34 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def identifier
|
|
|
|
raise "Called abstract method: identifier"
|
|
|
|
end
|
|
|
|
|
2023-07-16 11:08:24 +01:00
|
|
|
public
|
|
|
|
|
2023-07-07 02:35:34 +01:00
|
|
|
def apply(params)
|
2023-07-09 05:49:08 +01:00
|
|
|
params.each do |key, val|
|
|
|
|
if val.is_a? Hash
|
2023-07-14 12:01:41 +01:00
|
|
|
target = send(key)
|
2023-07-09 05:49:08 +01:00
|
|
|
target.apply(val)
|
2023-07-14 12:01:41 +01:00
|
|
|
elsif key == :mode
|
|
|
|
mode.send("#{val}=", true)
|
2023-07-09 05:49:08 +01:00
|
|
|
else
|
2023-07-14 12:01:41 +01:00
|
|
|
send("#{key}=", val)
|
2023-07-09 05:49:08 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2023-07-07 02:35:34 +01:00
|
|
|
end
|
|
|
|
end
|