Skip to content

Commit

Permalink
Implement screen reader support using AccessKit library.
Browse files Browse the repository at this point in the history
  • Loading branch information
bruvzg committed May 6, 2024
1 parent d8aa2c6 commit 1cc8a47
Show file tree
Hide file tree
Showing 146 changed files with 9,315 additions and 183 deletions.
13 changes: 12 additions & 1 deletion .github/workflows/linux_builds.yml
Expand Up @@ -6,7 +6,7 @@ on:
env:
# Used for the cache key. Add version suffix to force clean build.
GODOT_BASE_BRANCH: master
SCONSFLAGS: verbose=yes warnings=extra werror=yes module_text_server_fb_enabled=yes
SCONSFLAGS: verbose=yes warnings=extra werror=yes module_text_server_fb_enabled=yes "accesskit_sdk_path=${{github.workspace}}/accesskit_c-v0.9.0/"
DOTNET_NOLOGO: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
TSAN_OPTIONS: suppressions=misc/error_suppressions/tsan.txt
Expand Down Expand Up @@ -118,6 +118,17 @@ jobs:
- name: Setup python and scons
uses: ./.github/actions/godot-deps

- name: Download pre-built AccessKit
uses: dsaltares/fetch-gh-release-asset@1.0.0
with:
repo: AccessKit/accesskit
version: tags/accesskit_c-v0.9.0
file: accesskit_c-v0.9.0.zip
target: accesskit_c-v0.9.0/accesskit_c.zip

- name: Extract pre-built AccessKit
run: unzip -o accesskit_c-v0.9.0/accesskit_c.zip

- name: Setup GCC problem matcher
uses: ammaraskar/gcc-problem-matcher@master

Expand Down
13 changes: 12 additions & 1 deletion .github/workflows/macos_builds.yml
Expand Up @@ -6,7 +6,7 @@ on:
env:
# Used for the cache key. Add version suffix to force clean build.
GODOT_BASE_BRANCH: master
SCONSFLAGS: verbose=yes warnings=extra werror=yes module_text_server_fb_enabled=yes
SCONSFLAGS: verbose=yes warnings=extra werror=yes module_text_server_fb_enabled=yes "accesskit_sdk_path=${{github.workspace}}/accesskit_c-v0.9.0/"

concurrency:
group: ci-${{github.actor}}-${{github.head_ref || github.run_number}}-${{github.ref}}-macos
Expand Down Expand Up @@ -46,6 +46,17 @@ jobs:
- name: Setup python and scons
uses: ./.github/actions/godot-deps

- name: Download pre-built AccessKit
uses: dsaltares/fetch-gh-release-asset@1.0.0
with:
repo: AccessKit/accesskit
version: tags/accesskit_c-v0.9.0
file: accesskit_c-v0.9.0.zip
target: accesskit_c-v0.9.0/accesskit_c.zip

- name: Extract pre-built AccessKit
run: unzip -o accesskit_c-v0.9.0/accesskit_c.zip

- name: Setup Vulkan SDK
run: |
sh misc/scripts/install_vulkan_sdk_macos.sh
Expand Down
13 changes: 12 additions & 1 deletion .github/workflows/windows_builds.yml
Expand Up @@ -7,7 +7,7 @@ on:
env:
# Used for the cache key. Add version suffix to force clean build.
GODOT_BASE_BRANCH: master
SCONSFLAGS: verbose=yes warnings=extra werror=yes module_text_server_fb_enabled=yes d3d12=yes
SCONSFLAGS: verbose=yes warnings=extra werror=yes module_text_server_fb_enabled=yes d3d12=yes "accesskit_sdk_path=${{github.workspace}}/accesskit_c-v0.9.0/"
SCONS_CACHE_MSVC_CONFIG: true

concurrency:
Expand Down Expand Up @@ -54,6 +54,17 @@ jobs:
- name: Download Direct3D 12 SDK components
run: python ./misc/scripts/install_d3d12_sdk_windows.py

- name: Download pre-built AccessKit
uses: dsaltares/fetch-gh-release-asset@1.0.0
with:
repo: AccessKit/accesskit
version: tags/accesskit_c-v0.9.0
file: accesskit_c-v0.9.0.zip
target: accesskit_c-v0.9.0/accesskit_c.zip

- name: Extract pre-built AccessKit
run: Expand-Archive -Force accesskit_c-v0.9.0/accesskit_c.zip ${{github.workspace}}/

- name: Setup MSVC problem matcher
uses: ammaraskar/msvc-problem-matcher@master

Expand Down
1 change: 1 addition & 0 deletions SConstruct
Expand Up @@ -216,6 +216,7 @@ opts.Add(BoolVariable("use_volk", "Use the volk library to load the Vulkan loade
opts.Add(BoolVariable("disable_exceptions", "Force disabling exception handling code", True))
opts.Add("custom_modules", "A list of comma-separated directory paths containing custom modules to build.", "")
opts.Add(BoolVariable("custom_modules_recursive", "Detect custom modules recursively for each specified path.", True))
opts.Add(("accesskit_sdk_path", "Path to the AccessKit C SDK", ""))

# Advanced options
opts.Add(BoolVariable("dev_mode", "Alias for dev options: verbose=yes warnings=extra werror=yes tests=yes", False))
Expand Down
3 changes: 3 additions & 0 deletions core/config/project_settings.cpp
Expand Up @@ -1448,6 +1448,9 @@ ProjectSettings::ProjectSettings() {
GLOBAL_DEF("application/config/auto_accept_quit", true);
GLOBAL_DEF("application/config/quit_on_go_back", true);

GLOBAL_DEF_BASIC(PropertyInfo(Variant::INT, "accessibility/accessibility/accessibility_support", PROPERTY_HINT_ENUM, "Auto (When Screen Reader is Running),Always Active,Disabled"), 0);
GLOBAL_DEF_BASIC(PropertyInfo(Variant::INT, "accessibility/accessibility/updates_per_second", PROPERTY_HINT_RANGE, "1,100,1"), 15);

// The default window size is tuned to:
// - Have a 16:9 aspect ratio,
// - Have both dimensions divisible by 8 to better play along with video recording,
Expand Down
25 changes: 17 additions & 8 deletions core/string/ustring.cpp
Expand Up @@ -2024,34 +2024,43 @@ Error String::parse_utf8(const char *p_utf8, int p_len, bool p_skip_cr) {
}
}

CharString String::utf8() const {
CharString String::utf8(Vector<uint8_t> *r_ch_length_map) const {
int l = length();
if (!l) {
return CharString();
}

if (r_ch_length_map) {
r_ch_length_map->resize(l);
}

const char32_t *d = &operator[](0);
int fl = 0;
for (int i = 0; i < l; i++) {
uint32_t c = d[i];
int ch_w = 1;
if (c <= 0x7f) { // 7 bits.
fl += 1;
ch_w = 1;
} else if (c <= 0x7ff) { // 11 bits
fl += 2;
ch_w = 2;
} else if (c <= 0xffff) { // 16 bits
fl += 3;
ch_w = 3;
} else if (c <= 0x001fffff) { // 21 bits
fl += 4;
ch_w = 4;
} else if (c <= 0x03ffffff) { // 26 bits
fl += 5;
ch_w = 5;
print_unicode_error(vformat("Invalid unicode codepoint (%x)", c));
} else if (c <= 0x7fffffff) { // 31 bits
fl += 6;
ch_w = 6;
print_unicode_error(vformat("Invalid unicode codepoint (%x)", c));
} else {
fl += 1;
ch_w = 1;
print_unicode_error(vformat("Invalid unicode codepoint (%x), cannot represent as UTF-8", c), true);
}
fl += ch_w;
if (r_ch_length_map) {
r_ch_length_map->write[i] = ch_w;
}
}

CharString utf8s;
Expand Down
2 changes: 1 addition & 1 deletion core/string/ustring.h
Expand Up @@ -388,7 +388,7 @@ class String {
char32_t unicode_at(int p_idx) const;

CharString ascii(bool p_allow_extended = false) const;
CharString utf8() const;
CharString utf8(Vector<uint8_t> *r_ch_length_map = nullptr) const;
Error parse_utf8(const char *p_utf8, int p_len = -1, bool p_skip_cr = false);
static String utf8(const char *p_utf8, int p_len = -1);

Expand Down
3 changes: 3 additions & 0 deletions doc/classes/Control.xml
Expand Up @@ -1146,6 +1146,9 @@
<constant name="FOCUS_ALL" value="2" enum="FocusMode">
The node can grab focus on mouse click, using the arrows and the Tab keys on the keyboard, or using the D-pad buttons on a gamepad. Use with [member focus_mode].
</constant>
<constant name="FOCUS_ACCESSIBILITY" value="3" enum="FocusMode">
The node can grab focus only when screen reader is active. Use with [member focus_mode].
</constant>
<constant name="NOTIFICATION_RESIZED" value="40">
Sent when the node changes size. Use [member size] to get the new size.
</constant>
Expand Down

0 comments on commit 1cc8a47

Please sign in to comment.