Page 1 of 1

Reboot from controller script

Posted: Wed Jun 22, 2005 5:57 am
by DBordello

My xbox does not have a keyboard or mouse hooked to it. So when ever I want to play games I need to ssh into it and reboot it. So, to alieviate this problem I wrote a simple script that reboots gentoox when i push L,R,Back,Start (look familiar?). My first thought was that the bios would catch this and reboot (without shuting down) but it doesn't.

Unfortunetly if you want to use this script it is going to be a PITA, i didn't make a pretty ebuild for you.

To install it (as root):

1. cd /usr/bin; wget
2. It needs a module called Linux::Input::Joystick. There is no ebuild for this.
2a. perl -MCPAN -e shell
2b. Answer no to question about setup.
2c. "install Linux::Input::Joystick" Follow directions. If it fails the first time try again.
3. echo "/usr/bin/ & 1> /dev/null 2> /dev/null" >> /etc/conf.d/local.start
4. /etc/init.d/local restart

Enjoy :)

ps. It only works from the 1st controller port and it has to be plugged in on bootup (i think). I got too lazy to make it work on all contoller ports and I always have a controller in port 1.

Posted: Wed Jun 22, 2005 2:41 pm
by clpalmer
doesn't that script suck up a lot of cpu time whizzing around in that while loop? I'm not sure the units on the polling delay, but even as seconds, isn't 10ms fairly short to be looping this on?

Posted: Wed Jun 22, 2005 8:14 pm
by DBordello
I thought the same thing as you at first. I have had it running for about 12 hours at it has used 0 cpu time.

Xbox root # ps x |grep perl
1563 ? S 0:00 /usr/bin/perl -w /usr/bin/

Xbox root # uptime
21:13:30 up 14:28, 1 user, load average: 0.00, 0.00, 0.00

My cpu is running mostly idle and the script never shows up on top as using cpu ussage.

I guess I could shorten it (I planned to but forgot). Oh well.

If intrested I could clean it up (ie, watch all controller ports) and it could be included in the distro. I find it very useful.


Posted: Thu Jun 23, 2005 3:48 pm
by clpalmer
Must be in the way the polling is implemented. Cool =) I might use this. I'm lookin for a way to shut down the damn thing without having to SSH in. Problem is, I never have a controller connected to it, so I'd have to tinker with it a bit to make it work when I plug in a controller. Maybe if it doesn't detect a controller, it can sleep for 10 seconds and try again or something. Hopefully gentoox now likes this bloody madcatz controller I have. Haven't tried it in ages, but it didn't work back when I did.

Posted: Thu Jun 23, 2005 7:04 pm
by DBordello
That shouldn't be too hard to do. When I get some time later today I'll get that put in.