mirror of
https://github.com/onyx-and-iris/nvda-voicemeeter.git
synced 2026-03-27 04:59:11 +00:00
Nvda now longer inherits from CBindings
add wrapper methods in CBindings
This commit is contained in:
parent
5fca7da033
commit
2e3ba66b5a
@ -15,26 +15,38 @@ class CBindings:
|
||||
bind_cancel_speech = libc.nvdaController_cancelSpeech
|
||||
bind_braille_message = libc.nvdaController_brailleMessage
|
||||
|
||||
def call(self, fn, *args, ok=(0,)):
|
||||
def _call(self, fn, *args, ok=(0,)) -> int:
|
||||
retval = fn(*args)
|
||||
if retval not in ok:
|
||||
raise NVDAVMCAPIError(fn.__name__, retval)
|
||||
return retval
|
||||
|
||||
def test_if_running(self) -> int:
|
||||
return self._call(self.bind_test_if_running, ok=(ServerState.RUNNING, ServerState.UNAVAILABLE))
|
||||
|
||||
def speak_text(self, text: str) -> None:
|
||||
self._call(self.bind_speak_text, text)
|
||||
|
||||
def cancel_speech(self) -> None:
|
||||
self._call(self.bind_cancel_speech)
|
||||
|
||||
def braille_message(self, text: str) -> None:
|
||||
self._call(self.bind_braille_message, text)
|
||||
|
||||
|
||||
class Nvda:
|
||||
def __init__(self):
|
||||
self._bindings = CBindings()
|
||||
|
||||
class Nvda(CBindings):
|
||||
@property
|
||||
def is_running(self):
|
||||
return (
|
||||
self.call(self.bind_test_if_running, ok=(ServerState.RUNNING, ServerState.UNAVAILABLE))
|
||||
== ServerState.RUNNING
|
||||
)
|
||||
def is_running(self) -> bool:
|
||||
return self._bindings.test_if_running() == ServerState.RUNNING
|
||||
|
||||
def speak(self, text):
|
||||
self.call(self.bind_speak_text, text)
|
||||
def speak(self, text: str) -> None:
|
||||
self._bindings.speak_text(text)
|
||||
|
||||
def cancel_speech(self):
|
||||
self.call(self.bind_cancel_speech)
|
||||
def cancel_speech(self) -> None:
|
||||
self._bindings.cancel_speech()
|
||||
|
||||
def braille_message(self, text):
|
||||
self.call(self.bind_braille_message, text)
|
||||
def braille_message(self, text: str) -> None:
|
||||
self._bindings.braille_message(text)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user