nvda-addon-voicemeeter/addon/globalPlugins/voicemeeter/binds.py

42 lines
1.3 KiB
Python
Raw Normal View History

2023-09-23 22:55:58 +01:00
import ctypes as ct
from ctypes.wintypes import CHAR, FLOAT, LONG
2023-09-23 22:55:58 +01:00
from .cdll import libc
from .error import VMCAPIError
2023-09-23 22:55:58 +01:00
class Binds:
bind_login = libc.VBVMR_Login
bind_login.restype = LONG
bind_login.argtypes = None
bind_logout = libc.VBVMR_Logout
bind_logout.restype = LONG
bind_logout.argtypes = None
bind_run_voicemeeter = libc.VBVMR_RunVoicemeeter
bind_run_voicemeeter.restype = LONG
bind_run_voicemeeter.argtypes = [LONG]
bind_get_voicemeeter_type = libc.VBVMR_GetVoicemeeterType
bind_get_voicemeeter_type.restype = LONG
bind_get_voicemeeter_type.argtypes = [ct.POINTER(LONG)]
bind_is_parameters_dirty = libc.VBVMR_IsParametersDirty
bind_is_parameters_dirty.restype = LONG
bind_is_parameters_dirty.argtypes = None
bind_get_parameter_float = libc.VBVMR_GetParameterFloat
bind_get_parameter_float.restype = LONG
bind_get_parameter_float.argtypes = [ct.POINTER(CHAR), ct.POINTER(FLOAT)]
bind_set_parameter_float = libc.VBVMR_SetParameterFloat
bind_set_parameter_float.restype = LONG
bind_set_parameter_float.argtypes = [ct.POINTER(CHAR), FLOAT]
2023-09-23 22:55:58 +01:00
def call(self, fn, *args, ok=(0,)):
retval = fn(*args)
2023-09-23 22:55:58 +01:00
if retval not in ok:
raise VMCAPIError(fn.bind_namebind_, retval)
2023-09-23 22:55:58 +01:00
return retval