Add support for separating Tolk dependency for use on UWP.

This commit is contained in:
Nolan Darilek 2020-10-08 20:44:05 -05:00
parent f7a2ac7760
commit e19d154b99
3 changed files with 15 additions and 5 deletions

View File

@ -7,10 +7,14 @@ edition = "2018"
[lib]
crate-type = ["staticlib", "cdylib"]
[features]
use_tolk = ["tolk", "tts/use_tolk"]
[dependencies]
env_logger = "0.7"
gdnative = "0.9"
tts = "0.9"
tts = "0.10"
[target.'cfg(windows)'.dependencies]
tolk = ">= 0.2.1"
tolk = { version = ">= 0.2.1", optional = true }

View File

@ -7,7 +7,7 @@ This addon was primarily developed for the [Godot Accessibility addon](https://g
Text-to-speech is complicated, and some features may not work everywhere. Most optional features have an associated boolean property used to determine if the feature is available. Further, while I do attempt to ensure that this addon works as well as possible on all platforms, there may be bugs, and pull requests are welcome. Known supported platforms include:
* Windows
* Screen readers/SAPI via Tolk
* Screen readers/SAPI via Tolk (requires `use_tolk` Cargo feature)
* WinRT
* Linux via [Speech Dispatcher](https://freebsoft.org/speechd)
* MacOS

View File

@ -121,13 +121,19 @@ impl TTS {
.done();
builder
.add_property("can_detect_screen_reader")
.with_getter(|_: &TTS, _| if cfg!(windows) { true } else { false })
.with_getter(|_: &TTS, _| {
if cfg!(all(windows, features = "use_tolk")) {
true
} else {
false
}
})
.done();
#[allow(unreachable_code)]
builder
.add_property("has_screen_reader")
.with_getter(|_: &TTS, _| {
#[cfg(windows)]
#[cfg(all(windows, features = "use_tolk"))]
{
let tolk = tolk::Tolk::new();
return tolk.detect_screen_reader().is_some();