Kodi Community Forum

Full Version: [LINUX] Power button ignored without HAL
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,

I'm running xbmc 10.0 on an ArchLinux (x86), installed from the repository (Arch package version: 10.0-2). Since their last package upgrade they decided to go with upower instead of HAL for suspend and such and suspend is working fine when chosen from the menu with upower as well.

But I can't get the power button on my computer case to call the shutdown method (going to suspend for me) like it did before (with arch package version: 10.0-1, with HAL still enabled). When pressing the power button I get only this in the debug log is this:

DEBUG: SDLKeyboard: scancode: 124, sym: 0, unicode: 0, modifier: 0

Does anyone have an idea? Or is HAL required for this to work?

Kind regards,
Karsten
no hal is not required (on ubuntu)

do you have policykit-1 and have added the needed permissions.
UPower does not emit any signal on power button press hence its not hooked up in xbmc, I'm sure its a way to do it outside xbmc though. When such a signal exist we will for sure hook it up.
in the past i have used acpid to shutdown the system. that works nice and stable but you can use only one command or shell script (see post from .:B:.). Because the power button is handled as an event input device from kernel my idea was to use eventlircd (openelec uses eventlircd as an lirc replacement) for this. it works also very great. The advantage is, because i have setup the power button with "KEY_POWER" i can use the powerbutton now to go in standby modus if i change the settings in xbmc to go to standby as poweroff method. (theoretical i can use the powerbutton now also as an play/pause button or whatever i like :-) ). i am sure it works too with lirc and /dev/input/eventX as devinput/linux-input device (without the possibility to map to *any* LIRC button code)
Is this maybe a more general problem? I have quite a lot of keys that I can't get to work. From xbmc.log i get:

Code:
DEBUG: SDLKeyboard: scancode: 139, sym: 0, unicode: 0, modifier: 0
DEBUG: SDLKeyboard: scancode: 144, sym: 0, unicode: 0, modifier: 0
DEBUG: SDLKeyboard: scancode: 142, sym: 0, unicode: 0, modifier: 0
DEBUG: SDLKeyboard: scancode: 141, sym: 0, unicode: 0, modifier: 0
DEBUG: SDLKeyboard: scancode: 143, sym: 0, unicode: 0, modifier: 0
DEBUG: SDLKeyboard: scancode: 220, sym: 0, unicode: 0, modifier: 0

But according to xmodmap these are all mapped to X events (from "xmodmap -pke"):
Code:
keycode 139 = Undo NoSymbol Undo
keycode 144 = Find NoSymbol Find
keycode 142 = SunOpen NoSymbol SunOpen
keycode 141 = XF86Copy NoSymbol XF86Copy
keycode 143 = XF86Paste NoSymbol XF86Paste
keycode 220 = XF86WebCam NoSymbol XF86WebCam

I suspect this actually have to do with the input parsing in libSDL but actually I have no clue!

My setup is XBMC (2:10.00~svn35648-maverick1 from the ppa) on a minimal ubuntu 10.10 install.
sraue Wrote:in the past i have used acpid to shutdown the system. that works nice and stable but you can use only one command or shell script (see post from .:B:.). Because the power button is handled as an event input device from kernel my idea was to use eventlircd (openelec uses eventlircd as an lirc replacement) for this. it works also very great. The advantage is, because i have setup the power button with "KEY_POWER" i can use the powerbutton now to go in standby modus if i change the settings in xbmc to go to standby as poweroff method. (theoretical i can use the powerbutton now also as an play/pause button or whatever i like :-) ). i am sure it works too with lirc and /dev/input/eventX as devinput/linux-input device (without the possibility to map to *any* LIRC button code)

Your solution sounds very promising since I was looking for a xbmc-based solution rather than switching to acpid (which was my fallback option). Is it possible to use the lirc-based approach without changing xbmc code? I'm not sure if I understood completely what you're doing there... how do I get xbmc to handle the power button as an lirc input device? Thanks again.
rocktale Wrote:Your solution sounds very promising since I was looking for a xbmc-based solution rather than switching to acpid (which was my fallback option). Is it possible to use the lirc-based approach without changing xbmc code? I'm not sure if I understood completely what you're doing there... how do I get xbmc to handle the power button as an lirc input device? Thanks again.

Dont know exactly if its really possible with lirc, because lirc is very limited with handling event devices from kernel.

thats why i use eventlircd (http://code.google.com/p/eventlircd/). let me try to explain how eventlircd works:

all lirc drivers are going now to the kernel and will be removed from lirc package in the future. with kernel 2.6.36/37 nearly all drivers are now in kernel, the most used are now IR core drivers who acts as event devices (/dev/input/eventX). only some very old drivers/ rarly used drivers are in the staging area as "old known lirc drivers".

lirc does not more then read scancodes from /dev/lircX and generates a lircd socket wich will be read from xbmc. eventlircd does in general the same, but eventlircd reads /dev/input/eventX and /dev/lircX devicenodes (the difference to lirc is eventlircd can read more then one of such devicenodes at the same time). now eventlircd translates the scancodes via an simple map file and creates an lircd socket too (which can be read from xbmc). such an mapfile looks like here: https://github.com/OpenELEC/OpenELEC.tv/...nfig/evmap. Via a udev rule i can setup the the event drivers to be used from eventlircd, eventlircd watches this devises, remaps the codes, send the information to the lircd socket - and xbmc will use them. in xbmc i only have a own "devinput" section in lircmap.xml they must not be changed. most remotes works out of the box with eventlircd (mceusb, nuvoton, imon, atiusb, atiusb2...) without much further setup.

in this way i can setup (via udev) that other /dev/input/eventX devices like the power button, the sleepbutton, an Lid switch etc... will be used with eventlircd (and with xbmc's lirc implementation).

actually in openelec lirc is not used but eventlircd will be merged soon with lirc, so in the future eventlircd will be lirc :-)
sraue Wrote:in this way i can setup (via udev) that other /dev/input/eventX devices like the power button, the sleepbutton, an Lid switch etc... will be used with eventlircd (and with xbmc's lirc implementation).

Thank you for the explanation. I tried building eventlircd from source but it didn't work (some linker error). Since, Arch has inputlircd already in the AUR I thought I'd give it a shot. As far as I understand, it should work as well in this case.

However, XBMC seems to ignore the device or anything I tried. At least it shows up in the debug log:

Code:
DEBUG: LIRC: Update - NEW at 175045:74 0 KEY_POWER event2 (KEY_POWER)
DEBUG: SDLKeyboard: scancode: 124, sym: 0, unicode: 0, modifier: 0

But XBMC does not react on it. I tried adding a remote section to my custom keymap, but it doesn't work either:

Code:
<remote device="event2">
      <power>XBMC.ShutDown()</power>
    </remote>

I suspect xbmc's lirc implementation does not understand the keyboard event (KEY_POWER). I also tried the "remote control sends keyboard presses" option in the xbmc settings without effect. I feel so close but not quite there... :-)
Just for the record I use the acpid solution now which works fine. However, I'd like to see xbmc handling this again in the future without any *lirc tricks or whatever. The SDL event seems to be there and from what I've read there are only few pieces missing to get xbmc to recognize it as well. Maybe that would be an idea. :-) But besides that I still love what you guys are doing. And thanks again for the help.
sraue Wrote:Dont know exactly if its really possible with lirc, because lirc is very limited with handling event devices from kernel.

thats why i use eventlircd (http://code.google.com/p/eventlircd/). let me try to explain how eventlircd works:
...
actually in openelec lirc is not used but eventlircd will be merged soon with lirc, so in the future eventlircd will be lirc :-)

Actually, might sound stupid, but .. how to build eventlircd ? tried to build it from svn , i can understand it might need some automake or such, but cant get it to work. Any helping hand would be appreciated Smile