Thread Rating:
  • 1 Vote(s) - 4 Average
PC Power button not working in XBMC
pashdown Wrote:This has fixed the shutdown/suspend problem for me.
Shutdown/suspend is no problem for me. It hadn't been working, and your fix got that working. But the front powerbutton on the case is still having no effect within XBMC when run as an individual program.

When run standalone in it's own session, it works, and did so before too.

Well, I had temporarily circumvented the problem by opening xbmc-standalone in a second session at startup. ( sudo startx -- :1 ) with .xinitrc = "xbmc-standalone"

That way I could have the full xbmc session and still have desktop running.

It's not really perfect as I prefer to be able to watch and browse side by side, but still have the system boot into a remote control only type setup for the wife and kid.

I'll do some more testing, but I think it's time to enter a trac request that the "front powerbutton action" setting come back to us.

It's fairly obvious that this isn't exactly a bug, just a side effect of choices and changes made.
When you set loglevel to 2 one can see the KeyPress events. Usually the logfile contains two messages:

1. SDLKeyboard for the lowlevel Keyboard Event
2. OnKey for recognized Keyboard events that can be assigned an action via keyboard.xml

When I press the PC Case powerbutton (or the Fn-Power combination on my MF-Keyboard) I only see the first message (SDLKeyboard) with a scancode of 124 (PC Case Powerbutton) or 150 (Fn-Power combination) .

There is no OnKey message - so changing the keyboard.xml does not help.

I dug into the source and found that the problem lies in the function LookupKeyMapping (KeyboardStat.cpp).

LookupKeyMapping simply does not assign a m_VKey for the scancode received by SDLKeyboard. The reason is probably that the
static XBMC_KeyMapping g_mapping_evdev structure is garbled (does not reflect the structure definition and does not contain the scancodes my powerbutton sends.

The same is true for static XBMC_KeyMapping g_mapping_ubuntu[].

So adding my scancodes to the static XBMC_KeyMapping g_mapping_evdev structure or static XBMC_KeyMapping g_mapping_ubuntu does not work.

So what I did to verify my assumptions:

1. I hardcoded the assignement to m_VKey into LookupKeyMapping:

+ if((source == 150) || (source == 124))
return false;

2. I checked the logfile and now found an OnKey Line reading:
DEBUG: OnKey: 61504 pressed, action is 0

3. I edited keyboard.xml so that the key 61504 gives the correct action:
<key id='61504'>XBMC.ShutDown()</key>

4. I checked that it works (PC power button -> XBMC Quits

5. checked the logfile
DEBUG: OnKey: 61504 pressed, action is 122

Maybe a developer can look into this - I dont feel comfortable enough with this source code to propose a fix for this problem. However I think I nailed it down to the very function where I think the error lies.

BTW: I used the git source from 2010/01/31
I resolved the problem for me. Even though I don't exactly know why the problem only arises in all versions of xbmc (standalone, live, xbmc.bin).

I start xbmc.bin from the gnome desktop via autostart at login.

BTW: my system is a ZOTAC MAG HD-ND01 (Atom330 / Ion)

According to XFree86, the keycodes for PM functions are defined as:

124 XF86PowerOff
150 XF86Sleep
213 XF86Suspend

As I wrote in my previous post, these keycodes are properly sent by the powerbutton on the pc case (124) and the Sleep combination of my logitech cordless desktop (Fn-POWER: 150).

Sleep works fine when I am on the GNOME desktop. However when I am in XBMC, the button codes don't reach the gnome powermanager. They do however appear as SDLKeyboard events in the xbmc.log.

Even tough they are recognized as keyboard events, they are not assigned to XBMC Keyboard events. Somehow there is no proper mapping for this.

What I did, is hardcode this mapping from SDL Keyboard events to XBMC keyboard events in KeyboardStat.cpp. (see my previous post)

Then it is easy to assign an action to the power button.

Now, everything was done with the xbmc 9.11 source tarball.
im having this same issue with my current htpc.

its running ubuntu 9.10 and one of the later SVNs of XBMC.

the weird thing is, my ion based htpc functions normally.

the problematic computer has a ma780gm mobo if it makes a difference.

same symptoms as most everyone else: front panel power button will put the computer into standby no issue. as soon as xbmc is running, it no longer functions.
This is seriously retarded... Why was the functionality broken in the first place, and how come it's been a year and nobody fixed it?

Here's what worked for me: I edited /etc/acpi/, and commented out a bunch of code in the middle, so that effectively this line would trigger:

/sbin/shutdown -h now "Power button pressed"

one might as well just move this line to the top. This, however, effectively breaks a lot of stuff in Ubuntu itself though, so use with caution. I would also imagine that apt-get update would overwrite this file. I just needed power button to work, 'cuz I'm not shutting down HTPC manually
Well, that worked for me. I edited the file, and I can now shut down from the remote. Of course I shouldn't have to do that, but at least it's working again.

Many times I've found the computer has been on all night because somebody forgot that you have to quit XBMC before pushing the off button on the remote....
Worked for me ^^.
@galets: What exactly did you comment out?
I am also intrigued by this.

I am running an Acer 3610 with Ubuntu 10.04, XBMC running as a standard application from Gnome.

If I try to click the hard power button on the case when in XBMC full screen, nothing happens.
If I try it when XBMC is running within a gnome window, or when XBMC is closed - system hibernates.

I searched the forum and I found at least 5 threads with the same problem, but no solution.

Anyone has a clean solution?

Well, I'll modify the .sh too! But, then why o why XBMC makes the physical power button useless? Smile

PC Power button not working in XBMC41