aarddict / android

Aard Dictionary for Android
GNU General Public License v3.0
86 stars 43 forks source link

support Sony PRS-T1 hardware buttons #30

Open bardo84 opened 12 years ago

bardo84 commented 12 years ago

Page Turn Buttons on Rooted PRS-T1 .. The page turn arrows are, to the Android system, buttons 105 and 106 and are mapped as DPAD_LEFT and DPAD_RIGHT. The Sony apps are written in such a way that these "keyboard" commands have meaning. Most other apps don't give them a roll or at least a useful one, though someone has been kind enough to tweak FBReader to use them (see the Rooting and Modding Wiki). .. Source: http://www.mobileread.com/forums/showthread.php?t=163458

bardo84 commented 12 years ago

The PRS-T1 page turn arrows are, to the Android system, buttons 105 and 106 and are mapped as DPAD_LEFT and DPAD_RIGHT. So the following code: (thnx NdrU!!) should be adapted accordingly.

@Override public boolean dispatchKeyEvent(KeyEvent event) { int action = event.getAction(); int keyCode = event.getKeyCode(); WebView scrollView = (WebView) findViewById(R.id.ch01);
switch (keyCode) { case KeyEvent.KEYCODE_VOLUME_UP: if (action == KeyEvent.ACTION_DOWN) { scrollView.pageUp(false);
} return true; case KeyEvent.KEYCODE_VOLUME_DOWN: if (action == KeyEvent.ACTION_DOWN) { scrollView.pageDown(false); } return true; default: return super.dispatchKeyEvent(event); } }