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 Nov 19, 2024
1 parent fd4c29a commit a827f5a
Show file tree
Hide file tree
Showing 145 changed files with 9,293 additions and 161 deletions.
13 changes: 12 additions & 1 deletion .github/workflows/linux_builds.yml
Original file line number Diff line number Diff line change
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 strict_checks=yes
SCONSFLAGS: verbose=yes warnings=extra werror=yes module_text_server_fb_enabled=yes strict_checks=yes "accesskit_sdk_path=${{github.workspace}}/accesskit-c-0.13.1/"
DOTNET_NOLOGO: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
TSAN_OPTIONS: suppressions=misc/error_suppressions/tsan.txt
Expand Down Expand Up @@ -133,6 +133,17 @@ jobs:
python-version: 3.8
scons-version: 4.0

- name: Download pre-built AccessKit
uses: dsaltares/[email protected]
with:
repo: AccessKit/accesskit-c
version: tags/0.13.1
file: accesskit-c-0.13.1.zip
target: accesskit-c-0.13.1/accesskit_c.zip

- name: Extract pre-built AccessKit
run: unzip -o accesskit-c-0.13.1/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
Original file line number Diff line number Diff line change
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 strict_checks=yes
SCONSFLAGS: verbose=yes warnings=extra werror=yes module_text_server_fb_enabled=yes strict_checks=yes "accesskit_sdk_path=${{github.workspace}}/accesskit-c-0.13.1/"

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

- name: Download pre-built AccessKit
uses: dsaltares/[email protected]
with:
repo: AccessKit/accesskit-c
version: tags/0.13.1
file: accesskit-c-0.13.1.zip
target: accesskit-c-0.13.1/accesskit_c.zip

- name: Extract pre-built AccessKit
run: unzip -o accesskit-c-0.13.1/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
Original file line number Diff line number Diff line change
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 strict_checks=yes "angle_libs=${{ github.workspace }}/"
SCONSFLAGS: verbose=yes warnings=extra werror=yes module_text_server_fb_enabled=yes d3d12=yes strict_checks=yes "angle_libs=${{ github.workspace }}/" "accesskit_sdk_path=${{github.workspace}}/accesskit-c-0.13.1/"
SCONS_CACHE_MSVC_CONFIG: true

concurrency:
Expand Down Expand Up @@ -86,6 +86,17 @@ jobs:
- name: Extract pre-built ANGLE static libraries
run: Expand-Archive -Force angle/angle.zip ${{ github.workspace }}/

- name: Download pre-built AccessKit
uses: dsaltares/[email protected]
with:
repo: AccessKit/accesskit-c
version: tags/0.13.1
file: accesskit-c-0.13.1.zip
target: accesskit-c-0.13.1/accesskit_c.zip

- name: Extract pre-built AccessKit
run: unzip -o accesskit-c-0.13.1/accesskit_c.zip

- name: Setup MSVC problem matcher
if: matrix.compiler == 'msvc'
uses: ammaraskar/msvc-problem-matcher@master
Expand Down
1 change: 1 addition & 0 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ opts.Add(BoolVariable("disable_exceptions", "Force disabling exception handling
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(BoolVariable("swappy", "Use Swappy Frame Pacing Library in Android builds.", False))
opts.Add(("accesskit_sdk_path", "Path to the AccessKit C SDK", ""))

# Advanced options
opts.Add(
Expand Down
3 changes: 3 additions & 0 deletions core/config/project_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1463,6 +1463,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
Original file line number Diff line number Diff line change
Expand Up @@ -2262,34 +2262,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
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,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
Original file line number Diff line number Diff line change
Expand Up @@ -1153,6 +1153,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
Loading

0 comments on commit a827f5a

Please sign in to comment.