diff --git a/core/java/android/hardware/input/InputManager.java b/core/java/android/hardware/input/InputManager.java index 3ccc9400e0260..657541cfd8543 100644 --- a/core/java/android/hardware/input/InputManager.java +++ b/core/java/android/hardware/input/InputManager.java @@ -51,6 +51,7 @@ import android.os.RemoteException; import android.os.ServiceManager; import android.os.ServiceManager.ServiceNotFoundException; import android.os.SystemClock; +import android.os.UserHandle; import android.os.VibrationEffect; import android.os.Vibrator; import android.os.VibratorManager; @@ -1163,6 +1164,7 @@ public final class InputManager { * * @hide */ + @RequiresPermission(Manifest.permission.WRITE_SETTINGS) public void setPointerSpeed(Context context, int speed) { if (speed < MIN_POINTER_SPEED || speed > MAX_POINTER_SPEED) { throw new IllegalArgumentException("speed out of range"); @@ -2183,9 +2185,9 @@ public final class InputManager { * @hide */ public int getTouchpadPointerSpeed(@NonNull Context context) { - int speed = DEFAULT_POINTER_SPEED; - // TODO: obtain the actual speed from the settings - return speed; + return Settings.System.getIntForUser(context.getContentResolver(), + Settings.System.TOUCHPAD_POINTER_SPEED, DEFAULT_POINTER_SPEED, + UserHandle.USER_CURRENT); } /** @@ -2199,31 +2201,14 @@ public final class InputManager { * * @hide */ + @RequiresPermission(Manifest.permission.WRITE_SETTINGS) public void setTouchpadPointerSpeed(@NonNull Context context, int speed) { if (speed < MIN_POINTER_SPEED || speed > MAX_POINTER_SPEED) { throw new IllegalArgumentException("speed out of range"); } - // TODO: set the right setting - } - - /** - * Changes the touchpad pointer speed temporarily, but does not save the setting. - * - * The new speed will only apply to gesture-compatible touchpads. - * Requires {@link android.Manifest.permission#SET_POINTER_SPEED}. - * - * @param speed The pointer speed as a value between {@link #MIN_POINTER_SPEED} and - * {@link #MAX_POINTER_SPEED}, or the default value {@link #DEFAULT_POINTER_SPEED}. - * - * @hide - */ - public void tryTouchpadPointerSpeed(int speed) { - if (speed < MIN_POINTER_SPEED || speed > MAX_POINTER_SPEED) { - throw new IllegalArgumentException("speed out of range"); - } - - // TODO: set the touchpad pointer speed on the gesture library + Settings.System.putIntForUser(context.getContentResolver(), + Settings.System.TOUCHPAD_POINTER_SPEED, speed, UserHandle.USER_CURRENT); } /** @@ -2267,8 +2252,8 @@ public final class InputManager { * @hide */ public boolean useTouchpadNaturalScrolling(@NonNull Context context) { - // TODO: obtain the actual behavior from the settings - return true; + return Settings.System.getIntForUser(context.getContentResolver(), + Settings.System.TOUCHPAD_NATURAL_SCROLLING, 0, UserHandle.USER_CURRENT) == 1; } /** @@ -2282,8 +2267,11 @@ public final class InputManager { * * @hide */ + @RequiresPermission(Manifest.permission.WRITE_SETTINGS) public void setTouchpadNaturalScrolling(@NonNull Context context, boolean enabled) { - // TODO: set the right setting + Settings.System.putIntForUser(context.getContentResolver(), + Settings.System.TOUCHPAD_NATURAL_SCROLLING, enabled ? 1 : 0, + UserHandle.USER_CURRENT); } /** @@ -2297,8 +2285,8 @@ public final class InputManager { * @hide */ public boolean useTouchpadTapToClick(@NonNull Context context) { - // TODO: obtain the actual behavior from the settings - return true; + return Settings.System.getIntForUser(context.getContentResolver(), + Settings.System.TOUCHPAD_TAP_TO_CLICK, 0, UserHandle.USER_CURRENT) == 1; } /** @@ -2311,8 +2299,11 @@ public final class InputManager { * * @hide */ + @RequiresPermission(Manifest.permission.WRITE_SETTINGS) public void setTouchpadTapToClick(@NonNull Context context, boolean enabled) { - // TODO: set the right setting + Settings.System.putIntForUser(context.getContentResolver(), + Settings.System.TOUCHPAD_TAP_TO_CLICK, enabled ? 1 : 0, + UserHandle.USER_CURRENT); } /** @@ -2355,8 +2346,8 @@ public final class InputManager { * @hide */ public boolean useTouchpadRightClickZone(@NonNull Context context) { - // TODO: obtain the actual behavior from the settings - return true; + return Settings.System.getIntForUser(context.getContentResolver(), + Settings.System.TOUCHPAD_RIGHT_CLICK_ZONE, 0, UserHandle.USER_CURRENT) == 1; } /** @@ -2369,8 +2360,11 @@ public final class InputManager { * * @hide */ + @RequiresPermission(Manifest.permission.WRITE_SETTINGS) public void setTouchpadRightClickZone(@NonNull Context context, boolean enabled) { - // TODO: set the right setting + Settings.System.putIntForUser(context.getContentResolver(), + Settings.System.TOUCHPAD_RIGHT_CLICK_ZONE, enabled ? 1 : 0, + UserHandle.USER_CURRENT); } /** diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java index ff57003f573f1..2c85919529fa0 100644 --- a/core/java/android/provider/Settings.java +++ b/core/java/android/provider/Settings.java @@ -5663,6 +5663,44 @@ public final class Settings { @Readable public static final String POINTER_SPEED = "pointer_speed"; + /** + * Touchpad pointer speed setting. + * This is an integer value in a range between -7 and +7, so there are 15 possible values. + * -7 = slowest + * 0 = default speed + * +7 = fastest + * @hide + */ + public static final String TOUCHPAD_POINTER_SPEED = "touchpad_pointer_speed"; + + /** + * Whether to invert the touchpad scrolling direction. + * + * If set to 1 (the default), moving two fingers downwards on the touchpad will scroll + * upwards, consistent with normal touchscreen scrolling. If set to 0, moving two fingers + * downwards will scroll downwards. + * + * @hide + */ + public static final String TOUCHPAD_NATURAL_SCROLLING = "touchpad_natural_scrolling"; + + /** + * Whether to enable tap-to-click on touchpads. + * + * @hide + */ + public static final String TOUCHPAD_TAP_TO_CLICK = "touchpad_tap_to_click"; + + /** + * Whether to enable a right-click zone on touchpads. + * + * When set to 1, pressing to click in a section on the right-hand side of the touchpad will + * result in a context click (a.k.a. right click). + * + * @hide + */ + public static final String TOUCHPAD_RIGHT_CLICK_ZONE = "touchpad_right_click_zone"; + /** * Whether lock-to-app will be triggered by long-press on recents. * @hide @@ -5849,6 +5887,10 @@ public final class Settings { PRIVATE_SETTINGS.add(DISPLAY_COLOR_MODE_VENDOR_HINT); PRIVATE_SETTINGS.add(DESKTOP_MODE); PRIVATE_SETTINGS.add(LOCALE_PREFERENCES); + PRIVATE_SETTINGS.add(TOUCHPAD_POINTER_SPEED); + PRIVATE_SETTINGS.add(TOUCHPAD_NATURAL_SCROLLING); + PRIVATE_SETTINGS.add(TOUCHPAD_TAP_TO_CLICK); + PRIVATE_SETTINGS.add(TOUCHPAD_RIGHT_CLICK_ZONE); } /** diff --git a/core/proto/android/providers/settings/system.proto b/core/proto/android/providers/settings/system.proto index e56d55e940e45..146ac9d2c4251 100644 --- a/core/proto/android/providers/settings/system.proto +++ b/core/proto/android/providers/settings/system.proto @@ -195,6 +195,17 @@ message SystemSettingsProto { optional Text text = 29; optional SettingProto time_12_24 = 30 [ (android.privacy).dest = DEST_AUTOMATIC ]; + + message Touchpad { + option (android.msg_privacy).dest = DEST_EXPLICIT; + + optional SettingProto natural_scrolling = 1 [ (android.privacy).dest = DEST_AUTOMATIC ]; + optional SettingProto pointer_speed = 2 [ (android.privacy).dest = DEST_AUTOMATIC ]; + optional SettingProto right_click_zone = 3 [ (android.privacy).dest = DEST_AUTOMATIC ]; + optional SettingProto tap_to_click = 4 [ (android.privacy).dest = DEST_AUTOMATIC ]; + } + optional Touchpad touchpad = 36; + optional SettingProto tty_mode = 31 [ (android.privacy).dest = DEST_AUTOMATIC ]; message Vibrate { @@ -252,5 +263,5 @@ message SystemSettingsProto { // Please insert fields in alphabetical order and group them into messages // if possible (to avoid reaching the method limit). - // Next tag = 36; + // Next tag = 37; } diff --git a/packages/SettingsProvider/src/android/provider/settings/backup/SystemSettings.java b/packages/SettingsProvider/src/android/provider/settings/backup/SystemSettings.java index 7c75bc42dbfc3..c9d840a77b80d 100644 --- a/packages/SettingsProvider/src/android/provider/settings/backup/SystemSettings.java +++ b/packages/SettingsProvider/src/android/provider/settings/backup/SystemSettings.java @@ -92,6 +92,10 @@ public class SystemSettings { Settings.System.CLOCKWORK_BLUETOOTH_SETTINGS_PREF, Settings.System.UNREAD_NOTIFICATION_DOT_INDICATOR, Settings.System.AUTO_LAUNCH_MEDIA_CONTROLS, - Settings.System.LOCALE_PREFERENCES + Settings.System.LOCALE_PREFERENCES, + Settings.System.TOUCHPAD_POINTER_SPEED, + Settings.System.TOUCHPAD_NATURAL_SCROLLING, + Settings.System.TOUCHPAD_TAP_TO_CLICK, + Settings.System.TOUCHPAD_RIGHT_CLICK_ZONE, }; } diff --git a/packages/SettingsProvider/src/android/provider/settings/validators/SystemSettingsValidators.java b/packages/SettingsProvider/src/android/provider/settings/validators/SystemSettingsValidators.java index bd43606f16789..c2a3ada535918 100644 --- a/packages/SettingsProvider/src/android/provider/settings/validators/SystemSettingsValidators.java +++ b/packages/SettingsProvider/src/android/provider/settings/validators/SystemSettingsValidators.java @@ -186,6 +186,10 @@ public class SystemSettingsValidators { VALIDATORS.put(System.SIP_ADDRESS_ONLY, BOOLEAN_VALIDATOR); VALIDATORS.put(System.SIP_ASK_ME_EACH_TIME, BOOLEAN_VALIDATOR); VALIDATORS.put(System.POINTER_SPEED, new InclusiveFloatRangeValidator(-7, 7)); + VALIDATORS.put(System.TOUCHPAD_POINTER_SPEED, new InclusiveIntegerRangeValidator(-7, 7)); + VALIDATORS.put(System.TOUCHPAD_NATURAL_SCROLLING, BOOLEAN_VALIDATOR); + VALIDATORS.put(System.TOUCHPAD_TAP_TO_CLICK, BOOLEAN_VALIDATOR); + VALIDATORS.put(System.TOUCHPAD_RIGHT_CLICK_ZONE, BOOLEAN_VALIDATOR); VALIDATORS.put(System.LOCK_TO_APP_ENABLED, BOOLEAN_VALIDATOR); VALIDATORS.put( System.EGG_MODE, diff --git a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProtoDumpUtil.java b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProtoDumpUtil.java index 75d28d551e6b4..25b9906946463 100644 --- a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProtoDumpUtil.java +++ b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProtoDumpUtil.java @@ -2913,6 +2913,22 @@ class SettingsProtoDumpUtil { dumpSetting(s, p, Settings.System.TIME_12_24, SystemSettingsProto.TIME_12_24); + + final long touchpadToken = p.start(SystemSettingsProto.TOUCHPAD); + dumpSetting(s, p, + Settings.System.TOUCHPAD_NATURAL_SCROLLING, + SystemSettingsProto.Touchpad.NATURAL_SCROLLING); + dumpSetting(s, p, + Settings.System.TOUCHPAD_POINTER_SPEED, + SystemSettingsProto.Touchpad.POINTER_SPEED); + dumpSetting(s, p, + Settings.System.TOUCHPAD_RIGHT_CLICK_ZONE, + SystemSettingsProto.Touchpad.RIGHT_CLICK_ZONE); + dumpSetting(s, p, + Settings.System.TOUCHPAD_TAP_TO_CLICK, + SystemSettingsProto.Touchpad.TAP_TO_CLICK); + p.end(touchpadToken); + dumpSetting(s, p, Settings.System.TTY_MODE, SystemSettingsProto.TTY_MODE); diff --git a/services/core/java/com/android/server/input/InputManagerService.java b/services/core/java/com/android/server/input/InputManagerService.java index 8c1329797d125..e2caeec114d0a 100644 --- a/services/core/java/com/android/server/input/InputManagerService.java +++ b/services/core/java/com/android/server/input/InputManagerService.java @@ -493,7 +493,11 @@ public class InputManagerService extends IInputManager.Stub // Add ourselves to the Watchdog monitors. Watchdog.getInstance().addMonitor(this); - registerPointerSpeedSettingObserver(); + registerMousePointerSpeedSettingObserver(); + registerTouchpadPointerSpeedSettingObserver(); + registerTouchpadNaturalScrollingEnabledObserver(); + registerTouchpadTapToClickEnabledObserver(); + registerTouchpadRightClickZoneEnabledObserver(); registerShowTouchesSettingObserver(); registerAccessibilityLargePointerSettingObserver(); registerLongPressTimeoutObserver(); @@ -502,14 +506,22 @@ public class InputManagerService extends IInputManager.Stub mContext.registerReceiver(new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { - updatePointerSpeedFromSettings(); + updateMousePointerSpeedFromSettings(); + updateTouchpadPointerSpeedFromSettings(); + updateTouchpadNaturalScrollingEnabledFromSettings(); + updateTouchpadTapToClickEnabledFromSettings(); + updateTouchpadRightClickZoneEnabledFromSettings(); updateShowTouchesFromSettings(); updateAccessibilityLargePointerFromSettings(); updateDeepPressStatusFromSettings("user switched"); } }, new IntentFilter(Intent.ACTION_USER_SWITCHED), null, mHandler); - updatePointerSpeedFromSettings(); + updateMousePointerSpeedFromSettings(); + updateTouchpadPointerSpeedFromSettings(); + updateTouchpadNaturalScrollingEnabledFromSettings(); + updateTouchpadTapToClickEnabledFromSettings(); + updateTouchpadRightClickZoneEnabledFromSettings(); updateShowTouchesFromSettings(); updateAccessibilityLargePointerFromSettings(); updateDeepPressStatusFromSettings("just booted"); @@ -1337,8 +1349,8 @@ public class InputManagerService extends IInputManager.Stub setPointerSpeedUnchecked(speed); } - private void updatePointerSpeedFromSettings() { - int speed = getPointerSpeedSetting(); + private void updateMousePointerSpeedFromSettings() { + int speed = getMousePointerSpeedSetting(); setPointerSpeedUnchecked(speed); } @@ -1358,18 +1370,18 @@ public class InputManagerService extends IInputManager.Stub properties -> properties.pointerIconVisible = visible); } - private void registerPointerSpeedSettingObserver() { + private void registerMousePointerSpeedSettingObserver() { mContext.getContentResolver().registerContentObserver( Settings.System.getUriFor(Settings.System.POINTER_SPEED), true, new ContentObserver(mHandler) { @Override public void onChange(boolean selfChange) { - updatePointerSpeedFromSettings(); + updateMousePointerSpeedFromSettings(); } }, UserHandle.USER_ALL); } - private int getPointerSpeedSetting() { + private int getMousePointerSpeedSetting() { int speed = InputManager.DEFAULT_POINTER_SPEED; try { speed = Settings.System.getIntForUser(mContext.getContentResolver(), @@ -1379,6 +1391,77 @@ public class InputManagerService extends IInputManager.Stub return speed; } + private void registerTouchpadPointerSpeedSettingObserver() { + mContext.getContentResolver().registerContentObserver( + Settings.System.getUriFor(Settings.System.TOUCHPAD_POINTER_SPEED), true, + new ContentObserver(mHandler) { + @Override + public void onChange(boolean selfChange) { + updateTouchpadPointerSpeedFromSettings(); + } + }, UserHandle.USER_ALL); + } + + private void updateTouchpadPointerSpeedFromSettings() { + int speed = Settings.System.getIntForUser(mContext.getContentResolver(), + Settings.System.TOUCHPAD_POINTER_SPEED, InputManager.DEFAULT_POINTER_SPEED, + UserHandle.USER_CURRENT); + speed = Math.min(Math.max(speed, InputManager.MIN_POINTER_SPEED), + InputManager.MAX_POINTER_SPEED); + mNative.setTouchpadPointerSpeed(speed); + } + + private void registerTouchpadNaturalScrollingEnabledObserver() { + mContext.getContentResolver().registerContentObserver( + Settings.System.getUriFor(Settings.System.TOUCHPAD_NATURAL_SCROLLING), true, + new ContentObserver(mHandler) { + @Override + public void onChange(boolean selfChange) { + updateTouchpadNaturalScrollingEnabledFromSettings(); + } + }, UserHandle.USER_ALL); + } + + private void updateTouchpadNaturalScrollingEnabledFromSettings() { + int setting = Settings.System.getIntForUser(mContext.getContentResolver(), + Settings.System.TOUCHPAD_NATURAL_SCROLLING, 0, UserHandle.USER_CURRENT); + mNative.setTouchpadNaturalScrollingEnabled(setting != 0); + } + + private void registerTouchpadTapToClickEnabledObserver() { + mContext.getContentResolver().registerContentObserver( + Settings.System.getUriFor(Settings.System.TOUCHPAD_TAP_TO_CLICK), true, + new ContentObserver(mHandler) { + @Override + public void onChange(boolean selfChange) { + updateTouchpadTapToClickEnabledFromSettings(); + } + }, UserHandle.USER_ALL); + } + + private void updateTouchpadTapToClickEnabledFromSettings() { + int setting = Settings.System.getIntForUser(mContext.getContentResolver(), + Settings.System.TOUCHPAD_TAP_TO_CLICK, 0, UserHandle.USER_CURRENT); + mNative.setTouchpadTapToClickEnabled(setting != 0); + } + + private void registerTouchpadRightClickZoneEnabledObserver() { + mContext.getContentResolver().registerContentObserver( + Settings.System.getUriFor(Settings.System.TOUCHPAD_RIGHT_CLICK_ZONE), true, + new ContentObserver(mHandler) { + @Override + public void onChange(boolean selfChange) { + updateTouchpadRightClickZoneEnabledFromSettings(); + } + }, UserHandle.USER_ALL); + } + + private void updateTouchpadRightClickZoneEnabledFromSettings() { + int setting = Settings.System.getIntForUser(mContext.getContentResolver(), + Settings.System.TOUCHPAD_RIGHT_CLICK_ZONE, 0, UserHandle.USER_CURRENT); + mNative.setTouchpadRightClickZoneEnabled(setting != 0); + } + private void updateShowTouchesFromSettings() { int setting = getShowTouchesSetting(0); mNative.setShowTouches(setting != 0); diff --git a/services/core/java/com/android/server/input/NativeInputManagerService.java b/services/core/java/com/android/server/input/NativeInputManagerService.java index 6fca9cc4c590b..22226e88f15f2 100644 --- a/services/core/java/com/android/server/input/NativeInputManagerService.java +++ b/services/core/java/com/android/server/input/NativeInputManagerService.java @@ -120,6 +120,14 @@ interface NativeInputManagerService { void setPointerAcceleration(float acceleration); + void setTouchpadPointerSpeed(int speed); + + void setTouchpadNaturalScrollingEnabled(boolean enabled); + + void setTouchpadTapToClickEnabled(boolean enabled); + + void setTouchpadRightClickZoneEnabled(boolean enabled); + void setShowTouches(boolean enabled); void setInteractive(boolean interactive); @@ -313,6 +321,18 @@ interface NativeInputManagerService { @Override public native void setPointerAcceleration(float acceleration); + @Override + public native void setTouchpadPointerSpeed(int speed); + + @Override + public native void setTouchpadNaturalScrollingEnabled(boolean enabled); + + @Override + public native void setTouchpadTapToClickEnabled(boolean enabled); + + @Override + public native void setTouchpadRightClickZoneEnabled(boolean enabled); + @Override public native void setShowTouches(boolean enabled); diff --git a/services/core/jni/com_android_server_input_InputManagerService.cpp b/services/core/jni/com_android_server_input_InputManagerService.cpp index 7c737680e226e..f4d1d1ef88d18 100644 --- a/services/core/jni/com_android_server_input_InputManagerService.cpp +++ b/services/core/jni/com_android_server_input_InputManagerService.cpp @@ -292,6 +292,10 @@ public: void setPointerDisplayId(int32_t displayId); void setPointerSpeed(int32_t speed); void setPointerAcceleration(float acceleration); + void setTouchpadPointerSpeed(int32_t speed); + void setTouchpadNaturalScrollingEnabled(bool enabled); + void setTouchpadTapToClickEnabled(bool enabled); + void setTouchpadRightClickZoneEnabled(bool enabled); void setInputDeviceEnabled(uint32_t deviceId, bool enabled); void setShowTouches(bool enabled); void setInteractive(bool interactive); @@ -409,6 +413,20 @@ private: // True if stylus button reporting through motion events is enabled. bool stylusButtonMotionEventsEnabled{true}; + + // The touchpad pointer speed, as a number from -7 (slowest) to 7 (fastest). + int32_t touchpadPointerSpeed{0}; + + // True to invert the touchpad scrolling direction, so that moving two fingers downwards on + // the touchpad scrolls the content upwards. + bool touchpadNaturalScrollingEnabled{true}; + + // True to enable tap-to-click on touchpads. + bool touchpadTapToClickEnabled{true}; + + // True to enable a zone on the right-hand side of touchpads where clicks will be turned + // into context (a.k.a. "right") clicks. + bool touchpadRightClickZoneEnabled{false}; } mLocked GUARDED_BY(mLock); std::atomic mInteractive; @@ -657,6 +675,11 @@ void NativeInputManager::getReaderConfiguration(InputReaderConfiguration* outCon outConfig->defaultPointerDisplayId = mLocked.pointerDisplayId; + outConfig->touchpadPointerSpeed = mLocked.touchpadPointerSpeed; + outConfig->touchpadNaturalScrollingEnabled = mLocked.touchpadNaturalScrollingEnabled; + outConfig->touchpadTapToClickEnabled = mLocked.touchpadTapToClickEnabled; + outConfig->touchpadRightClickZoneEnabled = mLocked.touchpadRightClickZoneEnabled; + outConfig->disabledDevices = mLocked.disabledInputDevices; outConfig->stylusButtonMotionEventsEnabled = mLocked.stylusButtonMotionEventsEnabled; @@ -1099,6 +1122,70 @@ void NativeInputManager::setPointerAcceleration(float acceleration) { InputReaderConfiguration::CHANGE_POINTER_SPEED); } +void NativeInputManager::setTouchpadPointerSpeed(int32_t speed) { + { // acquire lock + AutoMutex _l(mLock); + + if (mLocked.touchpadPointerSpeed == speed) { + return; + } + + ALOGI("Setting touchpad pointer speed to %d.", speed); + mLocked.touchpadPointerSpeed = speed; + } // release lock + + mInputManager->getReader().requestRefreshConfiguration( + InputReaderConfiguration::CHANGE_TOUCHPAD_SETTINGS); +} + +void NativeInputManager::setTouchpadNaturalScrollingEnabled(bool enabled) { + { // acquire lock + AutoMutex _l(mLock); + + if (mLocked.touchpadNaturalScrollingEnabled == enabled) { + return; + } + + ALOGI("Setting touchpad natural scrolling to %s.", toString(enabled)); + mLocked.touchpadNaturalScrollingEnabled = enabled; + } // release lock + + mInputManager->getReader().requestRefreshConfiguration( + InputReaderConfiguration::CHANGE_TOUCHPAD_SETTINGS); +} + +void NativeInputManager::setTouchpadTapToClickEnabled(bool enabled) { + { // acquire lock + AutoMutex _l(mLock); + + if (mLocked.touchpadTapToClickEnabled == enabled) { + return; + } + + ALOGI("Setting touchpad tap to click to %s.", toString(enabled)); + mLocked.touchpadTapToClickEnabled = enabled; + } // release lock + + mInputManager->getReader().requestRefreshConfiguration( + InputReaderConfiguration::CHANGE_TOUCHPAD_SETTINGS); +} + +void NativeInputManager::setTouchpadRightClickZoneEnabled(bool enabled) { + { // acquire lock + AutoMutex _l(mLock); + + if (mLocked.touchpadRightClickZoneEnabled == enabled) { + return; + } + + ALOGI("Setting touchpad right click zone to %s.", toString(enabled)); + mLocked.touchpadRightClickZoneEnabled = enabled; + } // release lock + + mInputManager->getReader().requestRefreshConfiguration( + InputReaderConfiguration::CHANGE_TOUCHPAD_SETTINGS); +} + void NativeInputManager::setInputDeviceEnabled(uint32_t deviceId, bool enabled) { { // acquire lock AutoMutex _l(mLock); @@ -1944,6 +2031,33 @@ static void nativeSetPointerAcceleration(JNIEnv* env, jobject nativeImplObj, jfl im->setPointerAcceleration(acceleration); } +static void nativeSetTouchpadPointerSpeed(JNIEnv* env, jobject nativeImplObj, jint speed) { + NativeInputManager* im = getNativeInputManager(env, nativeImplObj); + + im->setTouchpadPointerSpeed(speed); +} + +static void nativeSetTouchpadNaturalScrollingEnabled(JNIEnv* env, jobject nativeImplObj, + jboolean enabled) { + NativeInputManager* im = getNativeInputManager(env, nativeImplObj); + + im->setTouchpadNaturalScrollingEnabled(enabled); +} + +static void nativeSetTouchpadTapToClickEnabled(JNIEnv* env, jobject nativeImplObj, + jboolean enabled) { + NativeInputManager* im = getNativeInputManager(env, nativeImplObj); + + im->setTouchpadTapToClickEnabled(enabled); +} + +static void nativeSetTouchpadRightClickZoneEnabled(JNIEnv* env, jobject nativeImplObj, + jboolean enabled) { + NativeInputManager* im = getNativeInputManager(env, nativeImplObj); + + im->setTouchpadRightClickZoneEnabled(enabled); +} + static void nativeSetShowTouches(JNIEnv* env, jobject nativeImplObj, jboolean enabled) { NativeInputManager* im = getNativeInputManager(env, nativeImplObj); @@ -2463,6 +2577,11 @@ static const JNINativeMethod gInputManagerMethods[] = { {"transferTouch", "(Landroid/os/IBinder;I)Z", (void*)nativeTransferTouch}, {"setPointerSpeed", "(I)V", (void*)nativeSetPointerSpeed}, {"setPointerAcceleration", "(F)V", (void*)nativeSetPointerAcceleration}, + {"setTouchpadPointerSpeed", "(I)V", (void*)nativeSetTouchpadPointerSpeed}, + {"setTouchpadNaturalScrollingEnabled", "(Z)V", + (void*)nativeSetTouchpadNaturalScrollingEnabled}, + {"setTouchpadTapToClickEnabled", "(Z)V", (void*)nativeSetTouchpadTapToClickEnabled}, + {"setTouchpadRightClickZoneEnabled", "(Z)V", (void*)nativeSetTouchpadRightClickZoneEnabled}, {"setShowTouches", "(Z)V", (void*)nativeSetShowTouches}, {"setInteractive", "(Z)V", (void*)nativeSetInteractive}, {"reloadCalibration", "()V", (void*)nativeReloadCalibration},