16 changed files with 175 additions and 4 deletions
@ -0,0 +1,25 @@
|
||||
include(functions/FetchContent_MakeAvailableExcludeFromAll) |
||||
|
||||
include(FetchContent) |
||||
FetchContent_Declare(Tolk |
||||
URL https://github.com/sig-a11y/tolk/archive/89de98779e3b6365dc1688538d5de4ecba3fdbab.tar.gz |
||||
URL_HASH MD5=724f6022186573dd9c5c2c92ed9e21e6 |
||||
) |
||||
FetchContent_MakeAvailableExcludeFromAll(Tolk) |
||||
|
||||
target_include_directories(Tolk PUBLIC ${libTolk_SOURCE_DIR}/src) |
||||
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 4) |
||||
set(TOLK_LIB_DIR "${Tolk_SOURCE_DIR}/libs/x86") |
||||
else() |
||||
set(TOLK_LIB_DIR "${Tolk_SOURCE_DIR}/libs/x64") |
||||
endif() |
||||
file(GLOB TOLK_DLLS |
||||
LIST_DIRECTORIES false |
||||
"${TOLK_LIB_DIR}/*.dll" |
||||
"${TOLK_LIB_DIR}/*.ini") |
||||
foreach(_TOLK_DLL_PATH ${TOLK_DLLS}) |
||||
install(FILES "${_TOLK_DLL_PATH}" |
||||
DESTINATION "." |
||||
) |
||||
endforeach() |
||||
@ -0,0 +1,17 @@
|
||||
# find speech-dispatcher library and header if available |
||||
# Copyright (c) 2009, Jeremy Whiting <jpwhiting@kde.org> |
||||
# Copyright (c) 2011, Raphael Kubo da Costa <kubito@gmail.com> |
||||
# This module defines |
||||
# SPEECHD_INCLUDE_DIR, where to find libspeechd.h |
||||
# SPEECHD_LIBRARIES, the libraries needed to link against speechd |
||||
# SPEECHD_FOUND, If false, speechd was not found |
||||
# |
||||
# Redistribution and use is allowed according to the terms of the BSD license. |
||||
# For details see the accompanying COPYING-CMAKE-SCRIPTS file. |
||||
|
||||
find_path(SPEECHD_INCLUDE_DIR libspeechd.h PATH_SUFFIXES speech-dispatcher) |
||||
|
||||
find_library(SPEECHD_LIBRARIES NAMES speechd) |
||||
|
||||
include(FindPackageHandleStandardArgs) |
||||
find_package_handle_standard_args(Speechd REQUIRED_VARS SPEECHD_INCLUDE_DIR SPEECHD_LIBRARIES) |
||||
@ -0,0 +1,54 @@
|
||||
#include "utils/screen_reader.hpp" |
||||
|
||||
#include <string> |
||||
#include <string_view> |
||||
|
||||
#ifdef _WIN32 |
||||
#include "utils/file_util.h" |
||||
#include <Tolk.h> |
||||
#else |
||||
#include <speech-dispatcher/libspeechd.h> |
||||
#endif |
||||
|
||||
namespace devilution { |
||||
|
||||
#ifndef _WIN32 |
||||
SPDConnection *Speechd; |
||||
#endif |
||||
|
||||
void InitializeScreenReader() |
||||
{ |
||||
#ifdef _WIN32 |
||||
Tolk_Load(); |
||||
#else |
||||
Speechd = spd_open("DevilutionX", "DevilutionX", NULL, SPD_MODE_SINGLE); |
||||
#endif |
||||
} |
||||
|
||||
void ShutDownScreenReader() |
||||
{ |
||||
#ifdef _WIN32 |
||||
Tolk_Unload(); |
||||
#else |
||||
spd_close(Speechd); |
||||
#endif |
||||
} |
||||
|
||||
void SpeakText(std::string_view text) |
||||
{ |
||||
static std::string SpokenText; |
||||
|
||||
if (SpokenText == text) |
||||
return; |
||||
|
||||
SpokenText = text; |
||||
|
||||
#ifdef _WIN32 |
||||
const auto textUtf16 = ToWideChar(SpokenText); |
||||
Tolk_Output(&textUtf16[0], true); |
||||
#else |
||||
spd_say(Speechd, SPD_TEXT, SpokenText.c_str()); |
||||
#endif |
||||
} |
||||
|
||||
} // namespace devilution
|
||||
@ -0,0 +1,25 @@
|
||||
#pragma once |
||||
|
||||
#include <string_view> |
||||
|
||||
namespace devilution { |
||||
|
||||
#ifdef SCREEN_READER_INTEGRATION |
||||
void InitializeScreenReader(); |
||||
void ShutDownScreenReader(); |
||||
void SpeakText(std::string_view text); |
||||
#else |
||||
constexpr void InitializeScreenReader() |
||||
{ |
||||
} |
||||
|
||||
constexpr void ShutDownScreenReader() |
||||
{ |
||||
} |
||||
|
||||
constexpr void SpeakText(std::string_view text) |
||||
{ |
||||
} |
||||
#endif |
||||
|
||||
} // namespace devilution
|
||||
Loading…
Reference in new issue