mozilla-b2g/gaia — pull request #2423 by davidflanagan (2012-07-14 00:26:57+00:00)
Title: hardware button manager [do not merge without Bug #762362]

This pull request goes with https://bugzilla.mozilla.org/show_bug.cgi?id=762362 That patch modifies shell.js so that hardware buttons are no longer sent as key events. Instead shell.js converts the hardware button key events into mozChromeEvents.

This pull request adds a new system module apps/system/js/hardware_buttons.js that processes the mozChromeEvents. The mozChromeEvents are low-level events that just indicate that a button was pressed or released. This hardware_buttons.js module processes these input events with a finite state machine and generates higher-level events as output. The code in the new module takes care of all timing issues for press vs long press on the home and sleep buttons, and also handles autorepeat for the volume buttons. Also, it handles key combinations home+sleep for screenshots and home+volume for view source.

All other system modules that used to have key event handlers to listen for home, sleep, volume, etc., have been modified to listen for the new events generated by hardware_buttons.js. A lot of system modules are substantially simplified because of this.

This pull request should fix several bugs including: #1398, #1663, #1751, #1752

It makes screenshots work again (I don't think there was an open bug on this, however).

It changes view source to use the key combo home+volume (either up or down) per an irc conversation with @cgjones.

It adds autorepeat back to the volume keys. Note, however, that this pull request has not yet been tested against the https://bugzilla.mozilla.org/show_bug.cgi?id=767311 Without that patch the actual volume never changes.

@vingtetun or @timdream please review