diff --git a/lib/Voicemeeter.psm1 b/lib/Voicemeeter.psm1 index 10b30f3..7002acb 100644 --- a/lib/Voicemeeter.psm1 +++ b/lib/Voicemeeter.psm1 @@ -2,6 +2,7 @@ . $PSScriptRoot\meta.ps1 . $PSScriptRoot\base.ps1 . $PSScriptRoot\kinds.ps1 +. $PSScriptRoot\iremote.ps1 . $PSScriptRoot\strip.ps1 . $PSScriptRoot\bus.ps1 . $PSScriptRoot\macrobuttons.ps1 diff --git a/lib/iremote.ps1 b/lib/iremote.ps1 new file mode 100644 index 0000000..735dcb9 --- /dev/null +++ b/lib/iremote.ps1 @@ -0,0 +1,49 @@ +class IRemote { + [int]$index + [Object]$remote + + IRemote ([Object]$remote) { + $this.remote = $remote + } + + IRemote ([int]$index, [Object]$remote) { + $this.index = $index + $this.remote = $remote + } + + [single] Getter ($param) { + $this.ToString() + " Getter: $($this.Cmd($param))" | Write-Debug + return $this.remote.Getter($this.Cmd($param)) + } + + [string] Getter_String ($param) { + $this.ToString() + " Getter_String: $($this.Cmd($param))" | Write-Debug + return $this.remote.Getter_String($this.Cmd($param)) + } + + [void] Setter ($param, $val) { + $this.ToString() + " Setter: $($this.Cmd($param))=$val" | Write-Debug + if ($val -is [Boolean]) { + $this.remote.Setter($this.Cmd($param), $(if ($val) { 1 } else { 0 })) + } + else { + $this.remote.Setter($this.Cmd($param), $val) + } + } + + [string] Cmd ($param) { + if ([string]::IsNullOrEmpty($param)) { + return $this.identifier() + } + return "$($this.identifier()).$param" + } + + # Must be overridden by derived classes + [string] identifier () { + throw [System.NotImplementedException]::new("$($this.GetType().Name) must override identifier()") + } + + [string] ToString() { + return $this.GetType().Name + } +} \ No newline at end of file