Skip to content

Commit

Permalink
Add option to disable battery status report
Browse files Browse the repository at this point in the history
  • Loading branch information
ClassicOldSong committed Jul 14, 2024
1 parent eed71b1 commit 9dd06fa
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3263,7 +3263,11 @@ else if (vibratorManager != null || vibrator != null) {
reportedType, supportedButtonFlags, capabilities);

// After reporting arrival to the host, send initial battery state and begin monitoring
backgroundThreadHandler.post(batteryStateUpdateRunnable);
// Might result in stutter in pointer device input. The problem happens within Android framework,
// Here we can only provide a workaround by disabling this option if user wishes.
if (prefConfig.enableBatteryReport) {
backgroundThreadHandler.post(batteryStateUpdateRunnable);
}
}

public void migrateContext(InputDeviceContext oldContext) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public enum AnalogStickForScrolling {
private static final String GAMEPAD_MOTION_SENSORS_PREF_STRING = "checkbox_gamepad_motion_sensors";
private static final String GAMEPAD_MOTION_FALLBACK_PREF_STRING = "checkbox_gamepad_motion_fallback";

private static final String CHECKBOX_ENABLE_BATTERY_REPORT = "checkbox_enable_battery_report";
private static final String CHECKBOX_FORCE_QWERTY = "checkbox_force_qwerty";
private static final String CHECKBOX_BACK_AS_META = "checkbox_back_as_meta";

Expand Down Expand Up @@ -128,6 +129,7 @@ public enum AnalogStickForScrolling {
private static final boolean DEFAULT_GAMEPAD_TOUCHPAD_AS_MOUSE = false;
private static final boolean DEFAULT_GAMEPAD_MOTION_SENSORS = true;
private static final boolean DEFAULT_GAMEPAD_MOTION_FALLBACK = false;
private static final boolean DEFAULT_GAMEPAD_ENABLE_BATTERY_REPORT = true;
private static final boolean DEFAULT_FORCE_QWERTY = true;
private static final boolean DEFAULT_SEND_META_ON_PHYSICAL_BACK = false;

Expand Down Expand Up @@ -155,6 +157,7 @@ public enum AnalogStickForScrolling {
public String language;
public boolean smallIconMode, multiController, usbDriver, flipFaceButtons;
public boolean onscreenController;
public boolean enableBatteryReport;
public boolean forceQwerty;
public boolean backAsMeta;
public boolean onlyL3R3;
Expand Down Expand Up @@ -732,6 +735,7 @@ else if (audioConfig.equals("51")) {
config.touchPadYSensitity=prefs.getInt("seekbar_touchpad_sensitivity_y_opacity",100);

config.absoluteMouseMode = prefs.getBoolean(ABSOLUTE_MOUSE_MODE_PREF_STRING, DEFAULT_ABSOLUTE_MOUSE_MODE);
config.enableBatteryReport = prefs.getBoolean(CHECKBOX_ENABLE_BATTERY_REPORT, DEFAULT_GAMEPAD_ENABLE_BATTERY_REPORT);
config.forceQwerty = prefs.getBoolean(CHECKBOX_FORCE_QWERTY, DEFAULT_FORCE_QWERTY);
config.backAsMeta = prefs.getBoolean(CHECKBOX_BACK_AS_META, DEFAULT_SEND_META_ON_PHYSICAL_BACK);
config.enableAudioFx = prefs.getBoolean(ENABLE_AUDIO_FX_PREF_STRING, DEFAULT_ENABLE_AUDIO_FX);
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -438,4 +438,6 @@
<string name="perf_overlay_lite_packet_loss">丢包率</string>
<string name="quick_menu_title">快捷菜单</string>
<string name="wrong_import_format">自定义导入格式出错了,请检查!</string>
<string name="title_checkbox_gamepad_enable_battery_report">启用手柄电池状态报告</string>
<string name="summary_checkbox_gamepad_enable_battery_report">在可用时汇报手柄电池状态。如果在使用触摸屏/触摸板/手写笔/鼠标时偶尔有卡顿现象发生,关闭此选项可能会有用。</string>
</resources>
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,8 @@
<string name="perf_overlay_lite_packet_loss">Packet loss</string>
<string name="quick_menu_title">Quick Menu</string>
<string name="wrong_import_format">Wrong import format, please check!</string>
<string name="title_checkbox_gamepad_enable_battery_report">Enable battery status report for gamepad</string>
<string name="summary_checkbox_gamepad_enable_battery_report">Report gamepad battery status when possible. Disable this option might help if you experience stutter with touch screen/touch pad/stylus/mouse input occasionally.</string>

</resources>

5 changes: 5 additions & 0 deletions app/src/main/res/xml/preferences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,11 @@
android:title="@string/title_checkbox_gamepad_motion_fallback"
android:summary="@string/summary_checkbox_gamepad_motion_fallback"
android:defaultValue="false" />
<CheckBoxPreference
android:defaultValue="true"
android:key="checkbox_gamepad_enable_battery_report"
android:summary="@string/summary_checkbox_gamepad_enable_battery_report"
android:title="@string/title_checkbox_gamepad_enable_battery_report" />
</PreferenceCategory>
<PreferenceCategory android:title="@string/category_input_settings"
android:key="category_input_settings">
Expand Down

0 comments on commit 9dd06fa

Please sign in to comment.