Main Restorations Software Audio/Jukebox/MP3 Everything Else Buy/Sell/Trade
Project Announcements Monitor/Video GroovyMAME Merit/JVL Touchscreen Meet Up Retail Vendors
Driving & Racing Woodworking Software Support Forums Consoles Project Arcade Reviews
Automated Projects Artwork Frontend Support Forums Pinball Forum Discussion Old Boards
Raspberry Pi & Dev Board controls.dat Linux Miscellaneous Arcade Wiki Discussion Old Archives
Lightguns Arcade1Up Try the site in https mode Site News

Unread posts | New Replies | Recent posts | Rules | Chatroom | Wiki | File Repository | RSS | Submit news

  

Author Topic: Shut Down Windows with Joystick?  (Read 4475 times)

0 Members and 1 Guest are viewing this topic.

allroy1975

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 980
  • Last login:November 11, 2023, 08:51:48 pm
  • I'm a dork!
    • Matt's Mame
Shut Down Windows with Joystick?
« on: February 12, 2010, 11:59:42 pm »
I hacked an XBOX controller to USB and loaded the drivers.  So I have a USB joystick.  anyone know of a trick to shut down a PC by a series of Joystick buttons or something?

I just have mouse and joystick and don't really want to hack a keyboard or add a $40 encoder for a couple more buttons that I can easily solder into my xbox controller hack.

They have the FAST Ms. Pac-Man!  MOM!  Can I have a quarter!??

Necro

  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 1031
  • Last login:November 29, 2022, 08:22:22 pm
  • Building a 'Classic' MAME Cab
Re: Shut Down Windows with Joystick?
« Reply #1 on: February 13, 2010, 12:10:16 am »
I'm pretty sure you could get something to work using AutoHotKey.

Havok

  • Keeper of the __Blue_Stars___
  • Trade Count: (+17)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 4530
  • Last login:Today at 02:34:22 am
  • Insufficient facts always invite danger.
Re: Shut Down Windows with Joystick?
« Reply #2 on: February 15, 2010, 09:28:58 am »
Do you really want to do that though? I can see a heated game of Street Fighter going, and then all of the sudden... The system turns off...

 :angry:

Just use a cheap momentary contact switch wired to the power button connection on the motherboard. Setup Windows to power off when the button is pressed, and you're all set.

Level42

  • Wiki Contributor
  • Trade Count: (+5)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 5965
  • Last login:November 13, 2018, 01:56:39 am
  • A Suzo stick is a joy forever...
Re: Shut Down Windows with Joystick?
« Reply #3 on: February 15, 2010, 05:21:35 pm »
I actually think using a joystick to shut down Windows is an excellent idea. May I suggest a Berzerk joystick and a throwing distance of about 3 meters ?
 :angel:


allroy1975

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 980
  • Last login:November 11, 2023, 08:51:48 pm
  • I'm a dork!
    • Matt's Mame
Re: Shut Down Windows with Joystick?
« Reply #4 on: February 15, 2010, 05:47:25 pm »
Do you really want to do that though? I can see a heated game of Street Fighter going, and then all of the sudden... The system turns off...

 :angry:

Just use a cheap momentary contact switch wired to the power button connection on the motherboard. Setup Windows to power off when the button is pressed, and you're all set.

It's a road Blasters cab.  Only a steering wheel, 4 buttons and a pedal.  Wanted to hook up the admin buttons for that.  although..I'm thinking about putting a spy hunter shifter on it...so maybe a few more buttons.  Just not sure if I can get it configured well...
They have the FAST Ms. Pac-Man!  MOM!  Can I have a quarter!??

DeLuSioNal29

  • Global Moderator
  • Trade Count: (+6)
  • Full Member
  • *****
  • Offline Offline
  • Posts: 4779
  • Last login:July 11, 2025, 09:17:44 am
  • Build the impossible -"There is no Spoon"
    • DeLuSioNaL's YouTube Videos
Re: Shut Down Windows with Joystick?
« Reply #5 on: February 15, 2010, 06:29:20 pm »
The Front End Maximus Arcade supports this feature.

Simply map the keys/buttons you want to shut down (#10 in diagram):  How to map keys

Then set a delay so that when you hold down those keys/buttons it will shut down (#3 in diagram):  How to set delays

DeLuSioNaL29
« Last Edit: February 15, 2010, 06:33:01 pm by DeLuSioNal29 »
Stop by my Youtube channel and leave a comment:

allroy1975

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 980
  • Last login:November 11, 2023, 08:51:48 pm
  • I'm a dork!
    • Matt's Mame
Re: Shut Down Windows with Joystick?
« Reply #6 on: February 21, 2010, 06:42:38 pm »
I'm pretty sure you could get something to work using AutoHotKey.

Quote
You can define a custom combination of two keys (except joystick buttons) by using " & " between them. In the below example, you would hold down Numpad0 then press the second key to trigger the hotkey:
Damn  this is exactly what I wanted to do.

The Front End Maximus Arcade supports this feature.

Do I really need a front end for 1 game?  ;)

I currently have a batch file in the startup folder on this cab that reads:

mame roadblstr
shutdown -s -t 00

so it starts the game, then when you hit escape it shuts down windows.  That'd be great...if I had a way of hitting escape.  I could have used mouse buttons, but at this point....the mouse buttons are wired into the buttons on the steering wheel.  I'm just not gonna redo all that.  it was a pain in the A the first time.

any other ideas?
They have the FAST Ms. Pac-Man!  MOM!  Can I have a quarter!??

allroy1975

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 980
  • Last login:November 11, 2023, 08:51:48 pm
  • I'm a dork!
    • Matt's Mame
Re: Shut Down Windows with Joystick?
« Reply #7 on: February 21, 2010, 11:17:12 pm »
I'm pretty sure you could get something to work using AutoHotKey.

anyone good at this?  Can't figure out why this isn't working:
Code: [Select]
~Joy1::
tt=0 ; set time to 0
loop,10000 ; check every 30 ms
{
      GetKeyState, state , Joy1, p 
   if state=U
       Break   
   tt+=30
   sleep 30
}
if tt>5000  ; if key pressed more than 5 secs
{
   Send {Esc}
   sleep 2000
}
Tooltip
return

Works fine in Windows..but when I'm in MAME, it doesn't get the "esc" keypress.  pretty frustrating.
They have the FAST Ms. Pac-Man!  MOM!  Can I have a quarter!??

allroy1975

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 980
  • Last login:November 11, 2023, 08:51:48 pm
  • I'm a dork!
    • Matt's Mame
Re: Shut Down Windows with Joystick?
« Reply #8 on: February 21, 2010, 11:32:08 pm »
well, it's ugly...but...it works.  if the coin button (Joy1) is held down for more than 5 seconds, it kills mame, then my batch file finished running..shutting down windows.

I could of course just change the batch file to not shut down windows and instead set the script to
run, shutdown -s -t 00

but..whatever
Code: [Select]
~Numpad1::
tt=0 ; set time to 0
loop,10000 ; check every 30 ms
{
      GetKeyState, state , Numpad1, p 
   if state=U
       Break   
   tt+=30
   sleep 30
}
if tt>5000  ; if key pressed more than 5 secs
{
Run, taskkill /IM mame.exe   
sleep 2000
}
Tooltip
return
They have the FAST Ms. Pac-Man!  MOM!  Can I have a quarter!??

allroy1975

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 980
  • Last login:November 11, 2023, 08:51:48 pm
  • I'm a dork!
    • Matt's Mame
Re: Shut Down Windows with Joystick?
« Reply #9 on: February 25, 2010, 10:29:34 am »
not sure if anyone here cares really....but....running this script was killing mame and in Road Blasters, it wasn't saving my high scores.  weak.

So I'm documenting (for myself) and sharing in case anyone else wants such a script.....

I changed my AHK to run:
Quote
~Joy1::
tt=0 ; set time to 0
loop,10000 ; check every 10 seconds
{
      GetKeyState, state , Joy1, p 
   if state=U
       Break   
   tt+=30
   sleep 30
}
if tt>5000  ; if key pressed more than 5 secs
{
   IfWinExist, MAME
       WinActivate
         Send {Esc Down}
         sleep 1000
         run, shutdown -s -t 00
}
return
They have the FAST Ms. Pac-Man!  MOM!  Can I have a quarter!??

bkenobi

  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 1668
  • Last login:August 16, 2021, 10:41:52 pm
Re: Shut Down Windows with Joystick?
« Reply #10 on: February 25, 2010, 11:20:55 am »
Does that last script send the escape key to MAME correctly?  I wasn't aware that you could send keys from AHK to MAME with the RAW input system.  If it works, that would be really nice to know!  I was pretty sure you needed to compile MAME with the RAW input system disabled, but of course if this does work then I'm wrong!   :cheers:

allroy1975

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 980
  • Last login:November 11, 2023, 08:51:48 pm
  • I'm a dork!
    • Matt's Mame
Re: Shut Down Windows with Joystick?
« Reply #11 on: February 25, 2010, 03:57:05 pm »
I was just reading in another long winded thread about "new versions of mame only take raw input" or something when talking about passing coin input from a FE to the mame exe.  That was the first I had heard of it.

I was running into speed issues with the newer versions of mame, so I dropped back to like .85 and it seems to be working fine.

but..in older versions (where you can skip the legal info and rom info  :applaud: ) it seems to work. 

you should be able to replace "Joy1" with anything.  A key on the KB or whatever. 

I was going nuts last night with this...instead of using {Esc Down} I was sending it like... 500 escape keypresses..sometimes it would work and sometimes it wouldn't.  I was going nuts.  then i remembered the down (holds the button down) and bam.   success.  I love figuring stuff like that out..but I wasted literally HOURS trying to do it the wrong way. :dizzy:
They have the FAST Ms. Pac-Man!  MOM!  Can I have a quarter!??

bkenobi

  • Trade Count: (+1)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 1668
  • Last login:August 16, 2021, 10:41:52 pm
Re: Shut Down Windows with Joystick?
« Reply #12 on: February 26, 2010, 03:24:18 am »
Yes, this will work with versions of MAME older than ~0.117.  If you try it with versions more recent than that, you will not see any input to MAME from the AHK script unless you compile your own version of MAME to not use the RAW input scheme.  I was just making sure things hadn't been changed somehow.  Thanks for the response!   8)

allroy1975

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 980
  • Last login:November 11, 2023, 08:51:48 pm
  • I'm a dork!
    • Matt's Mame
Re: Shut Down Windows with Joystick?
« Reply #13 on: February 26, 2010, 12:35:57 pm »
now...I don't know what I'm talking about...but this AHK script is REALLY cool in my opinion.  I always have kids...(and some adults  ::) ) pushing buttons all over the place.  I usually set up button combo's to do admin features.  That way only I can access them.

Unfortunately someone will hit the same buttons I have set up.  So having a script that says you have to do something for X seconds seems like a more stable options.   People don't set their drinks down...ON BUTTONS!

so...I don't know if this would work, but AHK does have a SendRaw option.  I haven't tested but it's simply adding 3 more characters to the script:
Code: [Select]
~Joy1::
tt=0 ; set time to 0
loop,10000 ; check every 10 seconds
{
      GetKeyState, state , Joy1, p 
   if state=U
       Break   
   tt+=30
   sleep 30
}
if tt>5000  ; if key pressed more than 5 secs
{
   IfWinExist, MAME
       WinActivate
         SendRaw {Esc Down}
         sleep 1000
         run, shutdown -s -t 00
}
return

any idea if that would work on newer mame builds?
They have the FAST Ms. Pac-Man!  MOM!  Can I have a quarter!??