summaryrefslogtreecommitdiffstats
path: root/services/jni
diff options
context:
space:
mode:
authorJeff Brown <jeffbrown@android.com>2011-06-02 01:26:32 -0700
committerJeff Brown <jeffbrown@android.com>2011-06-02 15:39:21 -0700
commit1a84fd1fb7a51f3fe4f8865e1cdd09f3490f696c (patch)
treecf9491aedb10c8355e62ae8384db0e9f005beb1c /services/jni
parent19c97d46fb57f87ff45d9e6ea7122b4eb21ede8c (diff)
downloadframeworks_base-1a84fd1fb7a51f3fe4f8865e1cdd09f3490f696c.zip
frameworks_base-1a84fd1fb7a51f3fe4f8865e1cdd09f3490f696c.tar.gz
frameworks_base-1a84fd1fb7a51f3fe4f8865e1cdd09f3490f696c.tar.bz2
Add a preference panel for mouse speed.
Bug: 4124987 Change-Id: I3ce175d268a1d043cf5878481261b1049a15a149
Diffstat (limited to 'services/jni')
-rw-r--r--services/jni/com_android_server_InputManager.cpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/services/jni/com_android_server_InputManager.cpp b/services/jni/com_android_server_InputManager.cpp
index fef41c9..2704647 100644
--- a/services/jni/com_android_server_InputManager.cpp
+++ b/services/jni/com_android_server_InputManager.cpp
@@ -53,6 +53,11 @@
namespace android {
+// The exponent used to calculate the pointer speed scaling factor.
+// The scaling factor is calculated as 2 ^ (speed * exponent),
+// where the speed ranges from -7 to + 7 and is supplied by the user.
+static const float POINTER_SPEED_EXPONENT = 1.0f / 3;
+
static struct {
jclass clazz;
@@ -179,6 +184,7 @@ public:
void setFocusedApplication(JNIEnv* env, jobject applicationObj);
void setInputDispatchMode(bool enabled, bool frozen);
void setSystemUiVisibility(int32_t visibility);
+ void setPointerSpeed(int32_t speed);
/* --- InputReaderPolicyInterface implementation --- */
@@ -227,6 +233,9 @@ private:
// System UI visibility.
int32_t systemUiVisibility;
+ // Pointer speed.
+ int32_t pointerSpeed;
+
// Sprite controller singleton, created on first use.
sp<SpriteController> spriteController;
@@ -266,6 +275,7 @@ NativeInputManager::NativeInputManager(jobject contextObj,
mLocked.displayOrientation = ROTATION_0;
mLocked.systemUiVisibility = ASYSTEM_UI_VISIBILITY_STATUS_BAR_VISIBLE;
+ mLocked.pointerSpeed = 0;
}
sp<EventHub> eventHub = new EventHub();
@@ -429,6 +439,13 @@ void NativeInputManager::getReaderConfiguration(InputReaderConfiguration* outCon
if (!checkAndClearExceptionFromCallback(env, "getTouchSlop")) {
outConfig->pointerGestureTapSlop = touchSlop;
}
+
+ { // acquire lock
+ AutoMutex _l(mLock);
+
+ outConfig->pointerVelocityControlParameters.scale = exp2f(mLocked.pointerSpeed
+ * POINTER_SPEED_EXPONENT);
+ } // release lock
}
sp<PointerControllerInterface> NativeInputManager::obtainPointerController(int32_t deviceId) {
@@ -634,6 +651,17 @@ void NativeInputManager::updateInactivityTimeoutLocked(const sp<PointerControlle
: PointerController::INACTIVITY_TIMEOUT_NORMAL);
}
+void NativeInputManager::setPointerSpeed(int32_t speed) {
+ AutoMutex _l(mLock);
+
+ if (mLocked.pointerSpeed != speed) {
+ LOGI("Setting pointer speed to %d.", speed);
+ mLocked.pointerSpeed = speed;
+
+ mInputManager->getReader()->refreshConfiguration();
+ }
+}
+
bool NativeInputManager::isScreenOn() {
return android_server_PowerManagerService_isScreenOn();
}
@@ -1180,6 +1208,15 @@ static jboolean android_server_InputManager_nativeTransferTouchFocus(JNIEnv* env
transferTouchFocus(fromChannel, toChannel);
}
+static void android_server_InputManager_nativeSetPointerSpeed(JNIEnv* env,
+ jclass clazz, jint speed) {
+ if (checkInputManagerUnitialized(env)) {
+ return;
+ }
+
+ gNativeInputManager->setPointerSpeed(speed);
+}
+
static jstring android_server_InputManager_nativeDump(JNIEnv* env, jclass clazz) {
if (checkInputManagerUnitialized(env)) {
return NULL;
@@ -1234,6 +1271,8 @@ static JNINativeMethod gInputManagerMethods[] = {
(void*) android_server_InputManager_nativeGetInputConfiguration },
{ "nativeTransferTouchFocus", "(Landroid/view/InputChannel;Landroid/view/InputChannel;)Z",
(void*) android_server_InputManager_nativeTransferTouchFocus },
+ { "nativeSetPointerSpeed", "(I)V",
+ (void*) android_server_InputManager_nativeSetPointerSpeed },
{ "nativeDump", "()Ljava/lang/String;",
(void*) android_server_InputManager_nativeDump },
};