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_cancel_speech = libc.nvdaController_cancelSpeech
|
||||||
bind_braille_message = libc.nvdaController_brailleMessage
|
bind_braille_message = libc.nvdaController_brailleMessage
|
||||||
|
|
||||||
def call(self, fn, *args, ok=(0,)):
|
def _call(self, fn, *args, ok=(0,)) -> int:
|
||||||
retval = fn(*args)
|
retval = fn(*args)
|
||||||
if retval not in ok:
|
if retval not in ok:
|
||||||
raise NVDAVMCAPIError(fn.__name__, retval)
|
raise NVDAVMCAPIError(fn.__name__, retval)
|
||||||
return 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
|
@property
|
||||||
def is_running(self):
|
def is_running(self) -> bool:
|
||||||
return (
|
return self._bindings.test_if_running() == ServerState.RUNNING
|
||||||
self.call(self.bind_test_if_running, ok=(ServerState.RUNNING, ServerState.UNAVAILABLE))
|
|
||||||
== ServerState.RUNNING
|
|
||||||
)
|
|
||||||
|
|
||||||
def speak(self, text):
|
def speak(self, text: str) -> None:
|
||||||
self.call(self.bind_speak_text, text)
|
self._bindings.speak_text(text)
|
||||||
|
|
||||||
def cancel_speech(self):
|
def cancel_speech(self) -> None:
|
||||||
self.call(self.bind_cancel_speech)
|
self._bindings.cancel_speech()
|
||||||
|
|
||||||
def braille_message(self, text):
|
def braille_message(self, text: str) -> None:
|
||||||
self.call(self.bind_braille_message, text)
|
self._bindings.braille_message(text)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user