Classes for each remote kind added.

They subclass Remote.

Factory functions now return the Remote class of a Kind.

Return Exit value -1 for DLL setup error.
This commit is contained in:
onyx-and-iris 2022-12-18 04:27:55 +00:00
parent 7e1c5616db
commit 3b1bb06c7d

View File

@ -3,31 +3,15 @@
class Remote {
[Hashtable]$kind
[System.Collections.ArrayList]$strip
[System.Collections.ArrayList]$bus
[System.Collections.ArrayList]$button
[PSCustomObject]$vban
[Object]$command
[Object]$recorder
[Object]$profiles
Remote ([String]$kind_id) {
$this.kind = GetKind($kind_id)
$this.Setup()
}
[void] Setup() {
Remote ([String]$kindId) {
if (!(Setup_DLL)) {
Exit
Exit -1
}
Login -KIND $this.kind.name
$this.kind = GetKind($kindId)
$this.profiles = Get_Profiles($this.kind.name)
$this.strip = Make_Strips($this)
$this.bus = Make_Buses($this)
$this.button = Make_Buttons
$this.vban = Make_Vban($this)
$this.command = Make_Command
$this.recorder = Make_Recorder($this)
Login -KIND $this.kind.name
}
[string] ToString() {
@ -75,16 +59,68 @@ class Remote {
[void] MDirty() { M_Dirty }
}
class RemoteBasic : Remote {
[System.Collections.ArrayList]$strip
[System.Collections.ArrayList]$bus
[System.Collections.ArrayList]$button
[PSCustomObject]$vban
[Object]$command
RemoteBasic () : base ('basic') {
$this.strip = Make_Strips($this)
$this.bus = Make_Buses($this)
$this.button = Make_Buttons
$this.vban = Make_Vban($this)
$this.command = Make_Command
}
}
class RemoteBanana : Remote {
[System.Collections.ArrayList]$strip
[System.Collections.ArrayList]$bus
[System.Collections.ArrayList]$button
[PSCustomObject]$vban
[Object]$command
[Object]$recorder
RemoteBanana () : base ('banana') {
$this.strip = Make_Strips($this)
$this.bus = Make_Buses($this)
$this.button = Make_Buttons
$this.vban = Make_Vban($this)
$this.command = Make_Command
$this.recorder = Make_Recorder($this)
}
}
class RemotePotato : Remote {
[System.Collections.ArrayList]$strip
[System.Collections.ArrayList]$bus
[System.Collections.ArrayList]$button
[PSCustomObject]$vban
[Object]$command
[Object]$recorder
RemotePotato () : base ('potato') {
$this.strip = Make_Strips($this)
$this.bus = Make_Buses($this)
$this.button = Make_Buttons
$this.vban = Make_Vban($this)
$this.command = Make_Command
$this.recorder = Make_Recorder($this)
}
}
Function Get-RemoteBasic {
return [Remote]::new('basic')
[RemoteBasic]::new()
}
Function Get-RemoteBanana {
return [Remote]::new('banana')
[RemoteBanana]::new()
}
Function Get-RemotePotato {
return [Remote]::new('potato')
[RemotePotato]::new()
}
Function Connect-Voicemeeter {
@ -100,10 +136,10 @@ Function Connect-Voicemeeter {
"potato" {
return Get-RemotePotato
}
default { throw [LoginError]::new('Unknown Voicemeeter kind') }
default { throw [LoginError]::new("Unknown Voicemeeter kind `"$Kind`"") }
}
}
catch [LoginError] {
catch [LoginError], [CAPIError] {
Write-Warning $_.Exception.ErrorMessage()
throw
}