frameworks/base
修订版 | 10daba9deff926610e60096657d8509675e1bfd7 (tree) |
---|---|
时间 | 2009-07-21 10:14:16 |
作者 | Yi Sun <beyounn@gmai...> |
Commiter | Yi Sun |
check in mouse wheel support for Kevin Jseng
@@ -31,6 +31,9 @@ import android.view.WindowManagerPolicy; | ||
31 | 31 | |
32 | 32 | public abstract class KeyInputQueue { |
33 | 33 | static final String TAG = "KeyInputQueue"; |
34 | + static final int UPKEY_KEYWORD = 19; | |
35 | + static final int DOWNKEY_KEYWORD = 20; | |
36 | + | |
34 | 37 | |
35 | 38 | SparseArray<InputDevice> mDevices = new SparseArray<InputDevice>(); |
36 | 39 |
@@ -271,7 +274,11 @@ public abstract class KeyInputQueue { | ||
271 | 274 | final int scancode = ev.scancode; |
272 | 275 | send = false; |
273 | 276 | |
274 | - // Is it a key event? | |
277 | + if(false){ | |
278 | + Log.i(TAG, "Device class : " + classes + "; Event type: " + type + | |
279 | + "; Scancode: " + scancode + " Value: " + ev.value + "; keycode: " + ev.keycode); | |
280 | + } | |
281 | + // Is it a key event? | |
275 | 282 | if (type == RawInputEvent.EV_KEY && |
276 | 283 | (classes&RawInputEvent.CLASS_KEYBOARD) != 0 && |
277 | 284 | (scancode < RawInputEvent.BTN_FIRST || |
@@ -324,9 +331,8 @@ public abstract class KeyInputQueue { | ||
324 | 331 | di.mAbs.changed = true; |
325 | 332 | di.mAbs.size = ev.value; |
326 | 333 | } |
327 | - | |
328 | 334 | } else if (ev.type == RawInputEvent.EV_REL ) { |
329 | - if ((classes&RawInputEvent.CLASS_TRACKBALL) != 0) { | |
335 | + if ((classes&RawInputEvent.CLASS_TRACKBALL) != 0) { | |
330 | 336 | // Add this relative movement into our totals. |
331 | 337 | if (ev.scancode == RawInputEvent.REL_X) { |
332 | 338 | di.mRel.changed = true; |
@@ -336,26 +342,51 @@ public abstract class KeyInputQueue { | ||
336 | 342 | di.mRel.y += ev.value; |
337 | 343 | } |
338 | 344 | } else if ((classes&RawInputEvent.CLASS_MOUSE) != 0) { |
339 | - if (ev.scancode == RawInputEvent.REL_X) { | |
340 | - di.mAbs.changed = true; | |
341 | - mCx = mCx + (int)ev.value; | |
342 | - mCx = ((mCx < 0) ? 0 :(mCx >= mDisplay.getWidth() ?(mDisplay.getWidth()-1):mCx)); | |
343 | - di.mAbs.x = mCx; | |
344 | - } else if (ev.scancode == RawInputEvent.REL_Y) { | |
345 | - di.mAbs.changed = true; | |
346 | - mCy = mCy + (int)ev.value; | |
347 | - mCy = ((mCy < 0) ? 0 :(mCy >= mDisplay.getHeight()?(mDisplay.getHeight() - 1):mCy)); | |
348 | - di.mAbs.y = mCy; | |
349 | - } | |
350 | - } | |
351 | - } | |
352 | - | |
345 | + // Log.i(TAG, "Reaches Mouse X,Y code"); | |
346 | + if (ev.scancode == RawInputEvent.REL_X) { | |
347 | + di.mAbs.changed = true; | |
348 | + mCx = mCx + (int)ev.value; | |
349 | + mCx = ((mCx < 0) ? 0 :(mCx >= mDisplay.getWidth() ?(mDisplay.getWidth()-1):mCx)); | |
350 | + di.mAbs.x = mCx; | |
351 | + } else if (ev.scancode == RawInputEvent.REL_Y) { | |
352 | + di.mAbs.changed = true; | |
353 | + mCy = mCy + (int)ev.value; | |
354 | + mCy = ((mCy < 0) ? 0 :(mCy >= mDisplay.getHeight()?(mDisplay.getHeight() - 1):mCy)); | |
355 | + di.mAbs.y = mCy; | |
356 | + } else if ((classes&RawInputEvent.CLASS_MOUSE) != 0) { | |
357 | + // Log.i(TAG,"Reaches Mouse Wheel code"); | |
358 | + if (ev.scancode == RawInputEvent.REL_WHEEL){ | |
359 | + boolean down; | |
360 | + int keycode; | |
361 | + if (ev.value != 0) { | |
362 | + down = true; | |
363 | + di.mDownTime = curTime; | |
364 | + } | |
365 | + else { | |
366 | + down = false; | |
367 | + } | |
368 | + if (ev.value < 0){ | |
369 | + keycode = rotateKeyCodeLocked(DOWNKEY_KEYWORD); | |
370 | + } else if(ev.value > 0){ | |
371 | + keycode = rotateKeyCodeLocked(UPKEY_KEYWORD); | |
372 | + } else { | |
373 | + keycode = rotateKeyCodeLocked(ev.keycode); | |
374 | + } | |
375 | + addLocked(di, curTime, ev.flags, | |
376 | + RawInputEvent.CLASS_KEYBOARD, | |
377 | + newKeyEvent(di, di.mDownTime, curTime, down, | |
378 | + keycode, 0, scancode, | |
379 | + ((ev.flags & WindowManagerPolicy.FLAG_WOKE_HERE) != 0) | |
380 | + ? KeyEvent.FLAG_WOKE_HERE : 0)); | |
381 | + } | |
382 | + } | |
383 | + } | |
384 | + } | |
353 | 385 | if (send || ev.type == RawInputEvent.EV_SYN) { |
354 | 386 | if (mDisplay != null) { |
355 | 387 | if (!mHaveGlobalMetaState) { |
356 | 388 | computeGlobalMetaStateLocked(); |
357 | 389 | } |
358 | - | |
359 | 390 | MotionEvent me; |
360 | 391 | me = di.mAbs.generateMotion(di, curTime, true, |
361 | 392 | mDisplay, mOrientation, mGlobalMetaState); |