Accessibility: add first Android version
This commit is contained in:
parent
8b213d3c0d
commit
b4ed4b58d6
|
@ -2092,6 +2092,10 @@ static void frontend_unix_init(void *data)
|
||||||
"getVolumePath", "(Ljava/lang/String;)Ljava/lang/String;");
|
"getVolumePath", "(Ljava/lang/String;)Ljava/lang/String;");
|
||||||
GET_METHOD_ID(env, android_app->inputGrabMouse, class,
|
GET_METHOD_ID(env, android_app->inputGrabMouse, class,
|
||||||
"inputGrabMouse", "(Z)V");
|
"inputGrabMouse", "(Z)V");
|
||||||
|
GET_METHOD_ID(env, android_app->isScreenReaderEnabled, class,
|
||||||
|
"isScreenReaderEnabled", "()Z");
|
||||||
|
GET_METHOD_ID(env, android_app->accessibilitySpeak, class,
|
||||||
|
"accessibilitySpeak", "(Ljava/lang/String;)V");
|
||||||
|
|
||||||
GET_OBJECT_CLASS(env, class, obj);
|
GET_OBJECT_CLASS(env, class, obj);
|
||||||
GET_METHOD_ID(env, android_app->getStringExtra, class,
|
GET_METHOD_ID(env, android_app->getStringExtra, class,
|
||||||
|
@ -2961,6 +2965,33 @@ end:
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef ANDROID
|
||||||
|
static bool is_narrator_running_android(void)
|
||||||
|
{
|
||||||
|
JNIEnv *env = jni_thread_getenv();
|
||||||
|
jboolean jbool = JNI_FALSE;
|
||||||
|
|
||||||
|
if (env != NULL)
|
||||||
|
CALL_BOOLEAN_METHOD(env, jbool,
|
||||||
|
g_android->activity->clazz, g_android->isScreenReaderEnabled);
|
||||||
|
|
||||||
|
return jbool == JNI_TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool accessibility_speak_android(int speed,
|
||||||
|
const char* speak_text, int priority)
|
||||||
|
{
|
||||||
|
JNIEnv *env = jni_thread_getenv();
|
||||||
|
|
||||||
|
if (env != NULL)
|
||||||
|
CALL_VOID_METHOD_PARAM(env, g_android->activity->clazz,
|
||||||
|
g_android->accessibilitySpeak,
|
||||||
|
(*env)->NewStringUTF(env, speak_text));
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
frontend_ctx_driver_t frontend_ctx_unix = {
|
frontend_ctx_driver_t frontend_ctx_unix = {
|
||||||
frontend_unix_get_env, /* get_env */
|
frontend_unix_get_env, /* get_env */
|
||||||
frontend_unix_init, /* init */
|
frontend_unix_init, /* init */
|
||||||
|
@ -3018,8 +3049,8 @@ frontend_ctx_driver_t frontend_ctx_unix = {
|
||||||
is_narrator_running_unix, /* is_narrator_running */
|
is_narrator_running_unix, /* is_narrator_running */
|
||||||
accessibility_speak_unix, /* accessibility_speak */
|
accessibility_speak_unix, /* accessibility_speak */
|
||||||
#else
|
#else
|
||||||
NULL, /* is_narrator_running */
|
is_narrator_running_android, /* is_narrator_running */
|
||||||
NULL, /* accessibility_speak */
|
accessibility_speak_android, /* accessibility_speak */
|
||||||
#endif
|
#endif
|
||||||
#ifdef FERAL_GAMEMODE
|
#ifdef FERAL_GAMEMODE
|
||||||
frontend_unix_set_gamemode,
|
frontend_unix_set_gamemode,
|
||||||
|
|
|
@ -180,6 +180,9 @@ struct android_app
|
||||||
jmethodID getVolumePath;
|
jmethodID getVolumePath;
|
||||||
jmethodID inputGrabMouse;
|
jmethodID inputGrabMouse;
|
||||||
|
|
||||||
|
jmethodID isScreenReaderEnabled;
|
||||||
|
jmethodID accessibilitySpeak;
|
||||||
|
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
unsigned width, height;
|
unsigned width, height;
|
||||||
|
|
|
@ -17,6 +17,7 @@ import android.os.Bundle;
|
||||||
import android.os.storage.StorageManager;
|
import android.os.storage.StorageManager;
|
||||||
import android.os.storage.StorageVolume;
|
import android.os.storage.StorageVolume;
|
||||||
import android.system.Os;
|
import android.system.Os;
|
||||||
|
import android.view.accessibility.AccessibilityManager;
|
||||||
import android.view.HapticFeedbackConstants;
|
import android.view.HapticFeedbackConstants;
|
||||||
import android.view.InputDevice;
|
import android.view.InputDevice;
|
||||||
import android.view.Surface;
|
import android.view.Surface;
|
||||||
|
@ -608,4 +609,16 @@ public class RetroActivityCommon extends NativeActivity
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isScreenReaderEnabled() {
|
||||||
|
getWindow().getDecorView().announceForAccessibility("Hello world!");
|
||||||
|
AccessibilityManager accessibilityManager = (AccessibilityManager) getSystemService(ACCESSIBILITY_SERVICE);
|
||||||
|
boolean isAccessibilityEnabled = accessibilityManager.isEnabled();
|
||||||
|
boolean isExploreByTouchEnabled = accessibilityManager.isTouchExplorationEnabled();
|
||||||
|
return isAccessibilityEnabled && isExploreByTouchEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void accessibilitySpeak(String message) {
|
||||||
|
getWindow().getDecorView().announceForAccessibility(message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue