User Tools

Site Tools


doc:howto:hardware.button

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
doc:howto:hardware.button [2013/07/03 10:46]
lorema
doc:howto:hardware.button [2015/01/21 17:25] (current)
karlp more info on procd buttons
Line 1: Line 1:
 ====== Attach functions to a push button ====== ====== Attach functions to a push button ======
 +There several ways for controlling buttons in OpenWrt.
 +  * [[#procd buttons| buttons using procd]]
 +  * [[#​Hotplug.Buttons|Hotplug buttons]], using the hotplug daemon or procd in compatibility mode (hotplug itself was phased out with r36003).
 +  * [[#​HID.buttons|HID buttons]], using ///​dev/​input/​event//​ with an application like triggerhappy.
 +
 +
  
 | {{:​meta:​icons:​tango:​dialog-information.png?​nolink}} | **Kernel configuration**\\ If a target platform is known to support buttons, appropriate kernel modules are selected by default.\\ If a platform is not known to support buttons, you are required to install various kernel modules yourself such as ''​diag'',​ ''​input-gpio-buttons'',​ ''​gpio-button-hotplug'',​ and others.\\ However, installing various modules will not necessarily yield a successful result. | | {{:​meta:​icons:​tango:​dialog-information.png?​nolink}} | **Kernel configuration**\\ If a target platform is known to support buttons, appropriate kernel modules are selected by default.\\ If a platform is not known to support buttons, you are required to install various kernel modules yourself such as ''​diag'',​ ''​input-gpio-buttons'',​ ''​gpio-button-hotplug'',​ and others.\\ However, installing various modules will not necessarily yield a successful result. |
  
-|  {{:​meta:​icons:​tango:​48px-outdated.svg.png?​nolink}} | Please note the introduction of **''​[[doc:​techref:​procd]]''** into OpenWrt; In [[https://dev.openwrt.org/changeset/​37132|r37132]] the package ​''​hotplug2'' was removed from the default packages; this howto may need to be updated. | +===== procd buttons ===== 
-| FIXME | Please read the articles [[doc/​howto/​wifitoggle]],​ [[/​toh/​tp-link/​tl-wr741nd#​buttons]] and [[toh/​linksys/​nslu2/​nslu2.hardware.button]] and eventually merge them into this one article ​ |+native button handling in procd is handled by scripts in '''/​etc/rc.button/*'''​
  
 +These scripts receive the **same** environment as older style hotplug buttons received. ​ However, the script files have to be named after the button. ​ I am unaware of a way of getting the button name.  (Other than using hotplug compatible scripts with procd ;)
  
-===== Preliminary steps ===== 
-The first step is to make Hotplug execute scripts in /​etc/​hotplug.d/​button when a button is clicked. Modify /​etc/​hotplug2.rules --- remove '​^'​ before '​button'​ as follow: 
  
-<code bash> +===== Hotplug Buttons ===== 
-$include ​/etc/hotplug2-common.rules+|  {{:​meta:​icons:​tango:​48px-outdated.svg.png?​nolink}} | Note that after the introduction of **''​[[doc:​techref:​procd]]''​** into OpenWrt in [[https://dev.openwrt.org/​changeset/​37132|r37132]] the package ''​hotplug2''​ has been removed from the default packages ​However at the time of writing, [[https://​dev.openwrt.org/​changeset/​37336|r37336:​ procd: make old button hotplug ​rules work until all packages are migrated]] is still in effect. ​ See also [[#​procd.buttons]] | 
 +| FIXME | Please read the articles [[doc/​howto/​wifitoggle]],​ [[/​toh/​tp-link/​tl-wr741nd#​buttons]] and [[toh/​linksys/​nslu2/​nslu2.hardware.button]] and eventually merge them into this one article ​ |
  
-SUBSYSTEM ~~ (^net$|^input$|button$|^usb$|^ieee1394$|^block$|^atm$|^zaptel$|^tty$) { +==== Preliminary steps ====
- exec /​sbin/​hotplug-call %SUBSYSTEM% +
-+
- +
-DEVICENAME ​== watchdog { +
- exec /​sbin/​watchdog -t 5 /​dev/​watchdog +
- next-event +
-+
-</​code>​+
  
-The second ​step is to find out the internal name of the button you want to use: some images use generic names such as ''​BTN_1'',​ ''​BTN_2'',​ others have more specific ones like ''​reset'',​ ''​wps'',​ etc. Run the following:+The first step is to find out the internal name of the button you want to use: some images use generic names such as ''​BTN_1'',​ ''​BTN_2'',​ others have more specific ones like ''​reset'',​ ''​wps'',​ etc. Run the following:
  
 <code bash> <code bash>
Line 33: Line 31:
 <code bash> <code bash>
 #!/bin/sh #!/bin/sh
-logger $BUTTON +logger ​the button was $BUTTON ​and the action was $ACTION ​
-logger ​$ACTION ​+
 </​code>​ </​code>​
  
Line 57: Line 54:
 </​code>​ </​code>​
  
-===== Using Atheros'​ 00-button + UCI =====+==== Using Atheros'​ 00-button + UCI ====
 If you've installed the full version of ''​wget'',​ run the following: If you've installed the full version of ''​wget'',​ run the following:
  
Line 110: Line 107:
 You may need to reboot the router the make the change effective (mine would work with the simple shell script just fine but wouldn'​t budge when using the 00-button script --- //Frex 2011/03/25 22:29//). If this works, you can change the handler to something more useful, and add more button handlers. You may need to reboot the router the make the change effective (mine would work with the simple shell script just fine but wouldn'​t budge when using the 00-button script --- //Frex 2011/03/25 22:29//). If this works, you can change the handler to something more useful, and add more button handlers.
  
-==== Examples ​====+=== Examples ===
  
 **Example 1:** //Toggle Wi-Fi radio with a button press// **Example 1:** //Toggle Wi-Fi radio with a button press//
Line 244: Line 241:
 </​code>​ </​code>​
  
-=====Leftovers from a previous version=====+==== Leftovers from a previous version ====
  
 FIXME FIXME
Line 277: Line 274:
 </​code>​ </​code>​
  
-===== WR1043ND ​=====+==== WR1043ND ====
 If you decide to use the ''​wifitoggle''​ package, you will need to change a few things on the default configuration. The following will work and make the QSS led blink "​slowly"​ when wifi is on: If you decide to use the ''​wifitoggle''​ package, you will need to change a few things on the default configuration. The following will work and make the QSS led blink "​slowly"​ when wifi is on:
  
Line 294: Line 291:
  
 :!: //You can probably get similar behaviour with [[doc:​uci:​system#​wifi.activity|phy0tpt]] trigger.// :!: //You can probably get similar behaviour with [[doc:​uci:​system#​wifi.activity|phy0tpt]] trigger.//
 +===== HID buttons =====
  
-===== triggerhappy ​===== +==== triggerhappy ==== 
-To manage the router buttons and also other HID buttons (i.e pad buttons of an usb device) we can use an application like triggerhappy. +To manage the router buttons and also other **HID buttons** (i.e pad buttons ​or keys of an usb device) we can use an application like triggerhappy. 
- +=== Installation === 
-First list your available buttons: +  - Install the **triggerhappy** package and the **kmod-hid** kernel module 
-<code bash>thd --dump /​dev/​input/​event*</​code>​ +  - list your available buttons: ​execute<code bash>thd --dump /​dev/​input/​event*</​code>​press your buttons \\ ''​EV_KEY ​ KEY_WPS_BUTTON ​ 1       /​dev/​input/​event0
-press your buttons \\ +
-''​EV_KEY ​ KEY_WPS_BUTTON ​ 1       /​dev/​input/​event0+
 # KEY_WPS_BUTTON ​       1       ​command # KEY_WPS_BUTTON ​       1       ​command
 EV_KEY ​ KEY_WPS_BUTTON ​ 0       /​dev/​input/​event0 EV_KEY ​ KEY_WPS_BUTTON ​ 0       /​dev/​input/​event0
Line 309: Line 305:
 EV_KEY ​ KEY_VOLUMEDOWN ​ 0       /​dev/​input/​event1 EV_KEY ​ KEY_VOLUMEDOWN ​ 0       /​dev/​input/​event1
 # KEY_VOLUMEDOWN ​       0       ​command''​ # KEY_VOLUMEDOWN ​       0       ​command''​
- +  - Now associate your buttons to commands or scripts \\ //path /​etc/​triggerhappy/​triggers.d/​example.conf//​ <code bash>​KEY_WPS_BUTTON 1 /​etc/​mywifiscript.sh
-Now associate your buttons to commands or scripts \\ +
-//path /​etc/​triggerhappy/​triggers.d/​example.conf// ​\\ +
-<code bash>​KEY_WPS_BUTTON 1 /​etc/​mywifiscript.sh+
 KEY_VOLUMEUP 1 amixer -q set Speaker 3%+ KEY_VOLUMEUP 1 amixer -q set Speaker 3%+
 KEY_VOLUMEDOWN 1 amixer -q set Speaker 3%-</​code>​ KEY_VOLUMEDOWN 1 amixer -q set Speaker 3%-</​code>​
-and run triggerhappy \\ +  - run triggerhappy \\ <code bash>/​etc/​init.d/​triggerhappy start</​code>​ 
-<code bash>/​etc/​init.d/​triggerhappy start</​code>​+  - enable triggerhappy permanently\\ <code bash>/​etc/​init.d/​triggerhappy enable</​code>​ 
 + 
 +==== Notes ==== 
 +  * triggerhappy repeats commands twice: see bug https://​dev.openwrt.org/​ticket/​14995 
 +  * kernel modules: ​ **kmod-hid** and **kmod-hid-generic** both should be installed\\ The kmod-hid-generic kernel module must be installed for buttons on USB devices such as USB sound cards to work in OpenWrt trunk. Only then the /​dev/​input/​event0 node for the buttons was created on the DIR-505 router with attached USB sound card. <​code>​ 
 +[   ​31.720000] input: C-Media USB Headphone Set   as /​devices/​platform/​ehci-platform/​usb1/​1-1/​1-1:​1.3/​input/​input0 
 +[   ​31.760000] hid-generic 0003:​0D8C:​000C.0001:​ input,​hidraw0:​ USB HID v1.00 Device [C-Media USB Headphone Set  ] on usb-ehci-platform-1/​input3 
 +[   ​31.800000] usbcore: registered new interface driver usbhid 
 +[   ​31.800000] usbhid: USB HID core driver 
 +</​code>​This is also noted in https://​dev.openwrt.org/​ticket/​12631
  
-**cmdpad** is another ​simpler application to manage buttons.+==== cmdpad ​==== 
 +Another ​simpler application to manage buttons.
doc/howto/hardware.button.1372841192.txt.bz2 · Last modified: 2013/07/03 10:46 by lorema