PDA

View Full Version : Joypad combination use to exit emulator - How to



followthereaper
07-28-2011, 01:56 AM
Hey there, want to exit your emulator through your joypad (ie: 360 controller) but don't want to do it accidentally? I've had a heck of a time figuring this out but finally found a solution online.


Joy1:: ; This can be any *one* of the four buttons.
Loop
{
GetKeyState, JoyTrigger, %A_ThisHotkey%
if JoyTrigger = U ; Main button released before the others were pressed.
return ; End this thread to start waiting again for a new triggering.

GetKeyState, JoyState2, Joy2 ; Replace these digits with your chosen buttons.
GetKeyState, JoyState3, Joy3
GetKeyState, JoyState4, Joy4

JoyStates = %JoyState2%%JoyState3%%JoyState4%
if JoyStates = DDD ; The other three are all down now, so break out of the loop.
break
else ; Keep waiting, but do a Sleep to prevent heavy load on CPU:
Sleep, 10
}
; Since the loop above didn't "return", all four buttons are now down.
Send {Esc}
return


Have fun! I hope I helped out someone as I've needed way too much help getting this program to work (that and xbmc).

Source: autohotkey (DOT) com/forum/topic1556 (DOT) html

Hypnoziz
07-28-2011, 12:46 PM
You can use Xpadder (or another program that simulates key presses from a joypad) to pull this off as well.

followthereaper
07-28-2011, 01:25 PM
That's what I originally did but had a ton of problems with it. The nice thing about using the script above is that it will always work as long as Hyperspin is working.

Hypnoziz
07-28-2011, 01:28 PM
Very cool. Thanks for sharing. Might I add for anyone reading this, that this is in fact an Autohotkey script and will need to be compiled into Hyperlaunch.exe for it to run.

forahobby
07-28-2011, 01:56 PM
Hi followthereaper,

Cool script, and thank you. I was just looking into writing my own but you beat me to it.. Do you need to disable the existing emulator exit settings in the HyperLaunch.ahk file before you re-compile?

My current settings are:



exitEmulatorKey = Esc & Joy7 ;This key/key combo will close any emulators
;that do not have normal closing methods.



Maybe you have an example .ahk script in full you can provide us.. thanks

followthereaper
07-28-2011, 03:21 PM
No I didn't, escape still works. I just placed this exact script at the very bottom of HyperLaunch.akh. The original will escape when you press 1, 2, 3, and 4; this below version one escapes when you press 7 and 8 which are my 360's back and start buttons.


Joy7:: ; This can be any *one* of the four buttons.
Loop
{
GetKeyState, JoyTrigger, %A_ThisHotkey%
if JoyTrigger = U ; Main button released before the others were pressed.
return ; End this thread to start waiting again for a new triggering.

GetKeyState, JoyState8, Joy8 ; Replace these digits with your chosen buttons.


JoyStates = %JoyState10%
if JoyStates = D ; The other three are all down now, so break out of the loop.
break
else ; Keep waiting, but do a Sleep to prevent heavy load on CPU:
Sleep, 10
}
; Since the loop above didn't "return", all four buttons are now down.
Send {Esc}
return

r0man0
03-24-2012, 06:46 AM
thank you , you really help me , but your last script have an error :


JoyStates = %JoyState10%


instead you have to type :
JoyStates = %JoyState8%