Mobileread
PRS-T1 Hack: App-dependent Left/Right button mapping
#1  altruizine 08-04-2012, 06:13 PM
Buttonmap: Use the Left / Right keys in all reader apps

Various reader apps recognize different buttons for turning to the next or previous page. The wiki offers various static button mappings for the Left / Right keys, but none of the static mappings is sufficient for all reader apps.

Inspired by this hack on the XDA forum, I've modified the pgdn program provided there to work for the PRS-T1. With this hack, it's possible to remap the Left / Right keys dynamically, depending on which app is currently running, to Dpad Left/Right, Volume Up/Down, nothing (needed for Sony's built-in reader app), or whichever other key is needed.

The Buttonmap app wraps the pgdn daemon and the default configuration file into an easily installable package.

The default configuration file allows using the Left / Right keys for the following apps (tested): Reader (built-in), Browser (built-in), Aldiko Reader, Amazon Kindle for Android, FBReader, InstaFetch Pro, Google Reader, Google Books (old 1.x versions), CoolReader.

Installation:
  1. Download the Buttonmap.apk file and install it on the Reader.
  2. Reboot. If your “su” uses the Superuser app, grant Buttonmap permanent root privileges when the superuser request pops up. This occurs shortly after reboot; don’t let the request time out, or you will have to reboot again.
Configuration:

The pgdn configuration file is /sdcard/.pgdn. Buttonmap creates an example configuration file as /sdcard/.pgdn.dist. It also creates a new /sdcard/.pgdn file if it does not yet exist, but it does not overwrite an existing one. When you upgrade, you can copy the contents of .pgdn.dist to .pgdn or simply delete your the old .pgdn.

When you change the .pgdn config file, you need to restart the pgdn daemon as root (“killall pgdn && /data/data/com.github.altruizine.Buttonmap/files/pgdn”), or just reboot the system.

Please find the source code of this program at https://github.com/altruizine/pgdn. Bug reports / enhancements welcome!

Edits (in reverse order):Archived: Installation notes for pgdn daemon without Buttonmap app:
Spoiler Warning below






  1. Make sure you're rooted and have root adb access.
  2. Copy the provided pgdn binary to /data/local/bin/pgdn and make sure it's executable.
    Code
     adb push pgdn /data/local/bin/pgdn adb shell chmod 755 /data/local/bin/pgdn
  3. Copy the attached dot.pgdn config file to /sdcard/.pgdn (mind the dot). Customize this file to add keyboard mappings for other reader apps.
    Code
     adb push dot.pgdn /sdcard/.pgdn
  4. Make sure pgdn is run as root at boot. I'm using the SManager app to do this. Reportedly, the Autostart app works as well (see comments below).
[zip] Buttonmap.apk.zip (23.9 KB, 613 views)
[zip] pgdn.zip (9.6 KB, 498 views)
Reply 

#2  dennisMe 08-06-2012, 05:17 AM
Thank you! This is really nice, a must have in fact! I just installed it without using ADB by just copying everything over using root explorer. I'm on a lInux host which preserves flags. I didn't know SManager before but it works well!
Now at least I can use the hardware keys and don't need to swipe in most apps.
Great little add on, it should be incorporated in the root hacks as standard.
Reply 

#3  graboluk 08-06-2012, 09:48 AM
How does it affect the battery?
Reply 

#4  altruizine 08-06-2012, 09:58 AM
Quote graboluk
How does it affect the battery?
The pgdn daemon shouldn't affect battery life much, if at all. I've verified using strace that it sits idle doing nothing unless you press a button.

I haven't profiled the SManager app I'm using to run the daemon at boot, but I can imagine more lightweight methods of running a program at boot. Nonetheless, I haven't observed a difference in battery life.

@dennisMe, I'm glad you like it!
Reply 

#5  uboot 08-06-2012, 11:25 AM
Great work, altruizine!

There's no need for SManager.

As we did with the fixpermissions script (http://www.mobileread.com/forums/sho...48&postcount=9), you can invoke the daemon via /etc/install-recovery.sh

Just make sure that install-recovery.sh is executable.

If existent, install-recovery.sh is called on every boot by /init.rc

I don't know how to create an apk package, but as an alternative one could modify one of the existing flash packages and put all necessary commands like creating/modifying install_recovery.sh into do_update.sh.


But let's wait for rupor to discover this thread! I'm pretty sure he'll integrate it into his root package
Reply 

#6  altruizine 08-06-2012, 12:16 PM
Thanks four your comments, uboot!

I know about the install-recovery.sh method, but I'm afraid it does not work in this case: Presently, the pgdn daemon reads a configuration file from the (internal) SD card, which (I think) has not been mounted yet when the install-recovery.sh script runs.

The idea of an APK would be not only to ease installation, but also to run the pgdn daemon once boot has been completed and the SD card has been mounted.
Reply 

#7  uboot 08-06-2012, 02:12 PM
hm... you're right... only data, system, preload, dic, ... partitions are mounted before install_recovery.sh

but maybe you can modify the daemon to look in several places for the cfg file: /etc, /data/etc, /mnt/sdcard, ...
Reply 

#8  uboot 08-18-2012, 08:02 AM
This seems to be a lighter alternative to run scripts at boot time:

https://play.google.com/store/apps/details?id=nk.bla.android.autostart
Reply 

#9  uboot 08-19-2012, 10:12 AM
Update: I definitely works via install_recovery.sh - I just tried it - and internal sdcard is already mounted.

But the Autostart app I mentioned does not work...
Reply 

#10  tartanpion 08-20-2012, 03:06 PM
Autostart app works for me with
Code
su -c "/data/local/bin/pgdn"
in autostart.sh. (tested with moonreader and fbreader)

Need to add
Code
profile org.coolreader 0 0
in ".pgdn" for compatibility with coolreader.
Reply 

  Next »  Last »  (1/4)
Today's Posts | Search this Thread | Login | Register