-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtolk.lua
71 lines (59 loc) · 1.61 KB
/
tolk.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
local ffi = require "ffi"
local encoding = require "encoding"
ffi.cdef[[
void Tolk_Load();
void Tolk_Output(const char *s, bool interrupt);
void Tolk_Silence();
void Tolk_Speak(const char *s, bool interrupt);
void Tolk_Braille(const char *s, bool interrupt);
void Tolk_TrySAPI(bool try);
void Tolk_PreferSAPI(bool prefer);
const wchar_t * Tolk_DetectScreenReader();
bool Tolk_HasSpeech();
bool Tolk_HasBraille();
bool Tolk_IsSpeaking();]]
local tolk = ffi.load("Tolk")
tolk.Tolk_Load()
local function output(s, interrupt)
interrupt=interrupt or false
tolk.Tolk_Output(encoding.to_utf16(s), interrupt)
end
local function speak(s, interrupt)
interrupt=interrupt or false
tolk.Tolk_Speak(encoding.to_utf16(s), interrupt)
end
local function braille(s)
tolk.Tolk_Braille(encoding.to_utf16(s))
end
local function silence()
tolk.Tolk_Silence()
end
local function trySAPI(try)
tolk.Tolk_TrySAPI(try)
end
local function preferSAPI(prefer)
tolk.Tolk_PreferSAPI(prefer)
end
local function isSpeaking()
return tolk.Tolk_IsSpeaking()
end
local function detectScreenReader()
--todo, need to convert the returned value to something Lua likes
end
local function hasSpeech()
return tolk.Tolk_HasSpeech()
end
local function hasBraille()
return tolk.Tolk_HasBraille()
end
return {
output=output,
speak=speak,
braille=braille,
silence=silence,
isSpeaking=isSpeaking,
trySAPI=trySAPI,
preferSAPI=preferSAPI,
detectScreenReader=detectScreenReader,
hasSpeech=hasSpeech,
hasBraille=hasBraille}