Difference between revisions of "Talk:How to get special keys to work"

From ThinkWiki
Jump to: navigation, search
(DIY Firefox 1.5 xpi)
(Can't bind Fn 12: pure ACPI events explained (no, thinkpad-acpi doesn't come in the picture))
Line 227: Line 227:
 
  action=/usr/local/sbin/hibernate  
 
  action=/usr/local/sbin/hibernate  
  
:Does not work. But from what you said, using the ibm_acpi neither of '''these strings ''' should  work? So I don't understand what is going on. [[User:Oub|Oub]] 20:28, 6 March 2006 (CET):  
+
:Does not work. But from what you said, using the ibm_acpi neither of '''these strings ''' should  work? So I don't understand what is going on. [[User:Oub|Oub]] 20:28, 6 March 2006 (CET):
 +
 
 +
----
 +
 
 +
With any reasonably new kernel (2.6.16 in Thinkpad terms :-) ) and a good DSDT (say, like the one that comes inside the T43), you can get two classes of events: ACPI events (as in native ACPI events), and ibm-acpi hotkey events.
 +
 
 +
This has nothing to do with thinkpad-acpi.
 +
 
 +
Look under /proc/acpi/buttons.  If you have sleep and maybe hibernate/suspend in there (I don't know how fn+f12 is called when properly supported through ACPI DSDT, the T43 doesn't support it like that), then your Thinkpad can, and will generate proper ACPI events without the help of ibm-acpi.  This is valid for a complete ACPI config of kernel 2.6.16 with all modules loaded.
 +
 
 +
And it will generate regular ibm-acpi hotkey events if you enable the feature and use the correct mask, which may or may not confuse the thinkpad (I am not sure the correct DSDT handlers the BIOS expect to run are called in this case).
 +
 
 +
-- [[User:Hmh|hmh]] 2006-05-26 13:20 UTC
  
 
==Turn on/off Wifi on Fn5 ==
 
==Turn on/off Wifi on Fn5 ==

Revision as of 14:26, 26 May 2006

The xmodmap step doesn't seem to work when using the "kdb" driver of xorg. Here are the changes I needed to make to my setup to get the "back" and "forward" keys to work (in diff -u format);

--- xkb/symbols/inet.oud        2004-12-01 08:36:04.000000000 +0100
+++ xkb/symbols/inet    2005-03-08 19:59:32.587636120 +0100
@@ -1875,6 +1875,16 @@
     key <I76>  {       [ XF86AudioLowerVolume  ]       };
 };
 
+// IBM ThinkPad 41 Internet Keys
+
+partial alphanumeric_keys
+xkb_symbols "tp41" {
+    name[Group1]= "IBM ThinkPad 41 Internet Keys";
+
+    key <I69>  {       [ F22           ]       };
+    key <I6A>  {       [ F21           ]       };
+};
+
 // Trust
 
 partial alphanumeric_keys
--- xkb/rules/xorg.lst.oud      2004-12-01 08:36:05.000000000 +0100
+++ xkb/rules/xorg.lst  2005-03-07 20:55:21.000000000 +0100
@@ -97,6 +97,7 @@
   sven         SVEN Ergonomic 2500
   symplon      Symplon PaceBook (tablet PC)
   toshiba_s3000        Toshiba Satellite S3000
+  tp41         IBM ThinkPad 41 Internet Keys
   trust                Trust Wireless Keyboard Classic
   trustda      Trust Direct Access Keyboard
   yahoo                Yahoo! Internet Keyboard
--- xkb/rules/xorg.oud  2004-12-01 08:36:05.000000000 +0100
+++ xkb/rules/xorg      2005-03-07 20:45:59.000000000 +0100
@@ -120,7 +120,7 @@
               qtronix \
               samsung4500 samsung4510 \
               sk1300 sk2500 sk6200 sk7100 \
-              sven symplon toshiba_s3000 trust trustda yahoo
+              sven symplon toshiba_s3000 tp41 trust trustda yahoo

 ! model         =       symbols
   $inetkbds     =       +inet(%m)
--- xkb/rules/xorg.xml.oud      2004-12-01 08:36:05.000000000 +0100
+++ xkb/rules/xorg.xml  2005-03-07 20:52:35.000000000 +0100
@@ -975,6 +975,13 @@
     </model>
     <model>
       <configItem>
+        <name>tp41</name>
+        <description>IBM Thinkpad 41 Internet Keys</description>
+        <description xml:lang="nl">IBM ThinkPad 41 internet toetsen</description>
+      </configItem>
+    </model>
+    <model>
+      <configItem>
         <name>trust</name>
         <description>Trust Wireless Keyboard Classic</description>
         <description xml:lang="fr">clavier classique Trust Wireless</description> 

Do not forget to add something like "+inet(tp41)" to /etc/X11/xorg.conf:

       (...)
       Option      "XkbLayout" "us_intl+inet(tp41)"
       (...)

Not T41 specific

These keys are hardly T41 specific, they can also be found on the T30, T40, T42 and I'm sure several other ThinkPads in the X, R and G lineup.

Actually, the above patches could be completed with the information of the other special keys found on some Thinkpads (which is listed in How_to_get_special_keys_to_work#xmodmap_configuration) and submitted as a request for enhancement with xorg's bugzilla. However, firefox doesn't yet recognize keysyms like XF86Back, XF86Forward, so then firefox still needs to be patched manually (unless an enhancement is requested for firefox too).

Fake ACPI events?

Not all keys generate ACPI events. Maybe it is feasible to have the ibm-acpi module check the CMOS (instead of having tpb checking /dev/nvram) and generate fake ACPI events for those keys. Even if it is feasible, that is probably way to hacky for a kernel module ... Still, it would be nice to only have to use scripts triggered by ACPI events and not both scripts for ACPI events and scripts for tpb.


I think something like this is possible with ibm-acpi 0.10 already. It provides a proc file from which you can derive a table of CMOS states. You'd only have to figure the who is who of CMOS bits and write a daemon (or daemon like shell script) checking them regularly. This should be about what you suggest since tpb does the same thing with the bios ram. Of course generating ACPI events can not be done like that (or can it?), but you could trigger the ACPI action scripts directly then.

Wyrfel 01:02, 14 Mar 2005 (CET)


It may be possible (I have a 770x, so don't have the special keys) to add the keys as real ACPI events, by altering the DSDT. I've done this to enable ACPI events for Fn-(every labelled F key),Home,End,PgUp,PgDn on mine, and they aren't labelled with anything physically (no thinklight and physical brightness control). The Embedded Controller reports all events, including keys, by calling one of the _Qxx functions (you'll find a whole pile in the sourcecode for the DSDT). If you then insert a fucntion in the same scope as the others like:-

Method (_Q12, 0, NotSerialized) { \_SB.HKEY.MHKQ (0x1003) } //Fn-F3

when executed, ibm-acpi will then report an acpi event numbered 0x0001003. You should find some functions, e.g. _Q1B For Fn-F12 identical to this.

I found some IBM DSDT's had functions that made MKHQ calls for EC functions _Q63, _Q64, _Q4E, _Q4F, but did nothing on mine---maybe these are a good starting point. Add a whole pile, and see if you get lucky! (At your own risk, of course... :/ But it should be pretty safe).

Yes, the above sounds pretty identical to tpb, except with /proc/ibm/ecdump instead of /dev/nvram. The above works very nicely, however there's luck involved in finding the right number, even if it exists!

lentinj


Fn+F6 does not seem to generate an event on t41p even if the mask is set to 0xffff and experimental=1 is passed to ibm_acpi tf


Bind Fn to super or hyper

Hello

Is it possible to bind Fn via Xmodmap to a key modifier such as hyper or super? Thanks Oub 13:14, 6 February 2006 (CET):


I doubt it. The event for the Fn key is generated at release (as opposed to holding it where it serves it's usual special function). Hence you can't use it as a modifier. Wyrfel 22:52, 6 February 2006 (CET)


Bind Fn 12 say to F34

Thanks Wyrfel for your reply, in order to display my question better, I use a new header: can I bind all the Fn Fx to hay F34 and the like? Oub 21:33, 10 February 2006 (CET):


You can do this with all key combinations that support xmodmap (see the table). That means you can't do it with Fn}F12, because that combination doesn't generate a key event at all (it only generates an APM/ACPI event. Hence there is nothing vor xmodmap to remap.

But what is your wider focus goal? I'm sure that what you want to do can be realized, anyway: You can write an ACPI script and event file for FnF12 and have the script start some tool that sends a F34 key to the X server. I'm sure this is possible.

Wyrfel 00:03, 11 February 2006 (CET)


Can't bind Fn 12

Hello

I am using a R51 and I have compiled ibm-acpi monolithic in the kernel (not as module, maybe this is a mistake?). Anyway, I am using suspend2, which I compiled in the kernel as well. Now I have bound to hibernate first to Fn 4, with the following script

event=button[ /]sleep  
action=/usr/local/sbin/mihibernate 

This works fine. Now I want to do the same for Fn12, so following the key table I did:

event=button[/] ibm/hotkey HKEY 00000080 0000100c  
action=/usr/local/sbin/mihibernate 

But that does not work. What is the problem? I tried even

echo enable,0xffff >/proc/acpi/ibm/hotkey 

without success. Can anybody help me? Oub 16:27, 4 March 2006 (CET):


The proper event line is

event=ibm/hotkey HKEY 00000080 0000100c

.

Also, make sure that you are not using [thinkpad-acpi]. If event=button[ /]sleep works for FnF4, that indicates that you do. It might block the ibm-acpi driver. Check your kernel config and disable any thinkpad acpi driver except ibm-acpi.

Wyrfel 21:58, 4 March 2006 (CET)


Hello
It is odd, I am pretty sure, that I do not use [thinkpad-acpi], but [ibm-acpi], although event=button[ /]sleep works for FnF4, in any case I found out that
event=(button/power|ibm/hotkey HKEY 00000080 0000100c)
Works! What do you think of adding a subsection to the How to get special keys to work page, with some examples, like the following:
from /etc/acpi/events/battery:
event=(button/power|ibm/hotkey HKEY 00000080 0000100c)  
action=/usr/local/sbin/hibernate
from /etc/acpi/events/lid
event=button/lid
action=/usr/local/bin/mysleepram
from /etc/acpi/events/sleepbtn
event=(button/sleep|ibm/hotkey HKEY 00000080 00001004)
action=/usr/local/bin/mysleepram
(Also event=button/sleep works for me)
and then restart acpi:
/etc/init.d/acpid restart
Oub 13:22, 5 March 2006 (CET):

What you do with

event=(button/power|ibm/hotkey HKEY 00000080 0000100c)  

is to make a logical nonexclusive OR between

event=button/power

and

event=ibm/hotkey HKEY 00000080 0000100c

. If the first works, the whole thing works. So that's pretty logical.

Please, do a # dmesg | grep thinkpad-acpi and do a # dmesg | ibm-acpi. What is the output in either case?

I see no sense in putting examples to the page that only confuse people because they are not correct. ibm-acpi generates the events listed in the table and nothing else. If you get something like button/sleep it's not ibm-acpi generating it. You are running Debian, right? Let's hope they didn't patch the driver to generate different events.

Also, you can always do # tail -f /var/log/acpid to have a life view of the generated events.

I am pretty sure that you are using thinkpad-acpi or - if not so - that something else must interfere.

Wyrfel 04:49, 6 March 2006 (CET)


Hi
Ok I admit everything is very odd. For the start, I seem to use
ibm-acpi. As I said I am Debian, but I compiled my own kernel :(2.6.10)(but not as a module, maybe this was a bad idee??) and I used :the ibm-acpi driver which comes shipped with that kernel. I did not :download the driver from the official http://ibm-acpi.sourceforge.net/ :site. Here is the output of
dmesg | grep acpi
Kernel command line: ro  root=/dev/hda6 acpi_sleep=s3_bios
tbxface-0118 [02] acpi_load_tables      : ACPI Tables successfully acquired
evxfevnt-0094 [03] acpi_enable           : Transition to ACPI mode successful
acpi_bus-0081 [06] acpi_bus_get_device   : Error getting context for object [df6ddaa8]
acpi_bus-0081 [06] acpi_bus_get_device   : Error getting context for object [c1464768]
acpi_bus-0081 [06] acpi_bus_get_device   : Error getting context for object [c1467328]
acpi_bus-0081 [06] acpi_bus_get_device   : Error getting context for object [c146bba8]
acpi_bus-0081 [06] acpi_bus_get_device   : Error getting context for object [c146b628]
acpi_bus-0081 [06] acpi_bus_get_device   : Error getting context for object [c146b3e8]
acpi_bus-0081 [06] acpi_bus_get_device   : Error getting context for object [c146b268]
acpi_bus-0081 [06] acpi_bus_get_device   : Error getting context for object [c146dde8]
acpi_bus-0081 [06] acpi_bus_get_device   : Error getting context for object [c1470d68]
acpi_bus-0081 [06] acpi_bus_get_device   : Error getting context for object [c1470568]
acpi_bus-0081 [06] acpi_bus_get_device   : Error getting context for object [c14719a8]
ibm_acpi: IBM ThinkPad ACPI Extras v0.8
ibm_acpi: http://ibm-acpi.sf.net/
acpi_bus-0081 [08] acpi_bus_get_device   : Error getting context for object [c1467328]
ibm_acpi: dock device not present
I don't understand the errors but anyway. Now the odd thing is that indeed the following works
event=button[ /]sleep
action=/usr/local/sbin/hibernate 
but
event=button[/]sleep  
action=/usr/local/sbin/hibernate 
Does not work. But from what you said, using the ibm_acpi neither of these strings should work? So I don't understand what is going on. Oub 20:28, 6 March 2006 (CET):

With any reasonably new kernel (2.6.16 in Thinkpad terms :-) ) and a good DSDT (say, like the one that comes inside the T43), you can get two classes of events: ACPI events (as in native ACPI events), and ibm-acpi hotkey events.

This has nothing to do with thinkpad-acpi.

Look under /proc/acpi/buttons. If you have sleep and maybe hibernate/suspend in there (I don't know how fn+f12 is called when properly supported through ACPI DSDT, the T43 doesn't support it like that), then your Thinkpad can, and will generate proper ACPI events without the help of ibm-acpi. This is valid for a complete ACPI config of kernel 2.6.16 with all modules loaded.

And it will generate regular ibm-acpi hotkey events if you enable the feature and use the correct mask, which may or may not confuse the thinkpad (I am not sure the correct DSDT handlers the BIOS expect to run are called in this case).

-- hmh 2006-05-26 13:20 UTC

Turn on/off Wifi on Fn5

Hi

I hope this is the last question. I use a crude way to activate and deactivate my wificard: I remove and insert the relevant modules, with 2 simple scripts. Now the question is how can I bind Fn5 so, that it turns on and off the wificard? With my approach I need to fire up two scripts, and that I cannot bind to one button. Thanks Oub 17:57, 5 March 2006 (CET):

Try a # cat /proc/acpi/ibm/bluetooth. Maybe it returns the state. If not, the other way would be to check if the USB bluetooth controller device is listed in /proc/bus/usb somewhere. It shouldn't be there if bluetooth is switched off and should be there if it is on.

Wyrfel 04:49, 6 March 2006 (CET)



Split page?

This page is getting too long. Maybe we should split it. I'd suggest moving the "Example applications" to a seperate page.

Paul Bolle 22:46, 3 April 2006 (CEST)

DIY Firefox 1.5 xpi

Here's how I maneged a Firefox 1.5 compatible plugin (source: google). Note that the wiki eats some of the xml tags (so look at the source too)

$ ls -1R tp41.xpi
tp41.xpi/:
chrome
chrome.manifest
install.rdf

tp41.xpi/chrome:
content

tp41.xpi/chrome/content:
tp41keysOverlay.xul
$ cat tp41.xpi/chrome.manifest
content     tp41keys    chrome/content/
overlay chrome://browser/content/browser.xul chrome://tp41keys/content/tp41keysOverlay.xul
$ cat tp41.xpi/install.rdf
<?xml version="1.0"?>

<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
     xmlns:em="http://www.mozilla.org/2004/em-rdf#">

  <Description about="urn:mozilla:install-manifest">
    <em:id>tp41keys@tp41keys.org</em:id>
    <em:version>1.0</em:version>
    <em:type>2</em:type>

    <em:targetApplication>
      <Description>
        <em:id>{ec8030f7-c20a-464f-9b0e-13a3a9e97384}</em:id>
        <em:minVersion>1.0+</em:minVersion>
        <em:maxVersion>1.5.0.*</em:maxVersion>
      </Description>
    </em:targetApplication>

    <em:name>IBM ThinkPad 41 Keys</em:name>
    <em:description>Two Browser Navigation Keys</em:description>
    <em:creator>Paul Bolle</em:creator>
    <em:homepageURL>http://www.example.com/tp41keys.xpi</em:homepageURL>
  </Description>
</RDF>
$ cat tp41.xpi/chrome/content/tp41keysOverlay.xul
<?xml version='1.0'?>
<!DOCTYPE overlay>

<overlay id='tp41keysOverlay'
    xmlns='http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul'>
    <keyset id='mainKeyset'>
        <key id='tp41BackKey' keycode='VK_F21' command='Browser:Back' />
        <key id='tp41ForwardKey' keycode='VK_F22' command='Browser:Forward' />
    </keyset>

</overlay>
$ cat .mozilla/firefox/*.default/extensions/tp41keys\@tp41keys.org 
~/tp41.xpi