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] [lib]
crate-type = ["staticlib", "cdylib"] crate-type = ["staticlib", "cdylib"]
[features]
use_tolk = ["tolk", "tts/use_tolk"]
[dependencies] [dependencies]
env_logger = "0.7" env_logger = "0.7"
gdnative = "0.9" gdnative = "0.9"
tts = "0.9" tts = "0.10"
[target.'cfg(windows)'.dependencies] [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: 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 * Windows
* Screen readers/SAPI via Tolk * Screen readers/SAPI via Tolk (requires `use_tolk` Cargo feature)
* WinRT * WinRT
* Linux via [Speech Dispatcher](https://freebsoft.org/speechd) * Linux via [Speech Dispatcher](https://freebsoft.org/speechd)
* MacOS * MacOS

View File

@ -121,13 +121,19 @@ impl TTS {
.done(); .done();
builder builder
.add_property("can_detect_screen_reader") .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(); .done();
#[allow(unreachable_code)] #[allow(unreachable_code)]
builder builder
.add_property("has_screen_reader") .add_property("has_screen_reader")
.with_getter(|_: &TTS, _| { .with_getter(|_: &TTS, _| {
#[cfg(windows)] #[cfg(all(windows, features = "use_tolk"))]
{ {
let tolk = tolk::Tolk::new(); let tolk = tolk::Tolk::new();
return tolk.detect_screen_reader().is_some(); return tolk.detect_screen_reader().is_some();