Author Topic: how to exit model 2 emulator  (Read 9246 times)

gleegum

  • Newbie
  • *
  • Posts: 9
    • View Profile
how to exit model 2 emulator
« on: January 10, 2019, 07:57:06 PM »
Hi guys, I would like to know if there's a proper way to exit this Model 2 emulator.
I have to press ALT + F4 to exit it, but I want to do this only with a couple of buttons. I've used JoyToKey in the past, but I don't remember how to do this.
Also I want to use the ALT+F4 only for this emulator, because I have MAME too, and it's working fine.
I'm not sure if this is possible using just Attract Mode.

Something like this is what I need:

Press Button 1 + Button 2 (only in this emulator)---> exit Model 2 emulator (ALT + F4)

Thankss

rand0m

  • Sr. Member
  • ****
  • Posts: 343
    • View Profile
Re: how to exit model 2 emulator
« Reply #1 on: January 10, 2019, 08:04:38 PM »
Press Button 1 + Button 2 (only in this emulator)---> exit Model 2 emulator (ALT + F4)

In \emulators\[emulator name].cfg you can enter a line
exit_hotkey          Button1+Button2

Where Button1 & 2 are actual keyboard/ gamepad inputs. If that doesn't work and emulator has a built-in command for quitting you'll have to use JoytoKey or some variant.

You can make these changes from with AM (Options/ Settings > Emulators > [Emulator Name] > Exit Hot Key (Here you can input the keys). IF that doesn't work Antimicro is the best joytokey variant I have seen. Its available on both *nix and Windows platforms and can be tweaked to

1- point any joypad key press to keyboard
2- Start with a specific game and shutdown once game is quit via AM.

« Last Edit: January 10, 2019, 08:16:13 PM by rand0m »

hermine.potter

  • Hero Member
  • *****
  • Posts: 767
    • View Profile
Re: how to exit model 2 emulator
« Reply #2 on: January 11, 2019, 04:20:28 AM »
I'm using autoit for this.
By pushing SELECT + START + DPAD DOWN + L + R on a snes pad, the process OpenBOR.exe will be closed. (see section OPENBor here)



Source as follows here: ($coord[7] == "240" means the sum of L + R + START + SELECT together / simultaneously pressed (16 + 32 + 128 + 64 = 240 )

(thanks to Ejoc and Adam1213 for original and customized sourcecode and thanks to osrevad for Ascii-Art:

Code: [Select]
; from here :
; https://www.autoitscript.com/forum/topic/10953-joystick-udf/?tab=comments#comment-323294
; original script from POST#1 doesnt works. tooked script from POST#4
;____________________________________________________________________
;       Original program by Ejoc                                    ;
;       Improved by Adam1213 (autoit 3.2 compatiblity + improved labels         ;
;____________________________________________________________________

#include <GUIConstants.au3>
#include <Misc.au3>

;_________________ SETUP_____________________________________
Local $joy,$coor,$h,$s,$msg

$joy    = _JoyInit()

dim $labels_text[8]=['X', 'Y', 'Z', 'R', 'U', 'V', 'POV', 'Buttons']
dim $labels_no=UBound($labels_text)
dim $labels[$labels_no]
dim $labels_value[$labels_no]
;__________ CONFIG ____________________________________________
;---------- Find the max length of the longest label --------------
$label_len=0
for $text in $labels_text
    $len=stringlen($text)
    if $len>$label_len then
        $label_len=$len
    endif
next
$label_len*=6
;_____________ GUI _______________________________________________
;~ GUICreate('Joystick Test', 200, 200)
;~ GUICtrlCreateLabel('Joystick', 40, 20, 100, 20)

;~ for $i=0 to $labels_no-1
;~     GuiCtrlCreatelabel($labels_text[$i]&':', 10, 60+$i*12, $label_len, 12)
;~     $labels[$i]=GuiCtrlCreatelabel('', 10+$label_len, 60+$i*12, 70, 12)
;~     $labels_value[$i]=''
;~ next
;~ GUISetState()
;~ ;_____________________________________________________________________

while 1
    $coord=_GetJoy($joy,0)
    for $i=0 to UBound($coord)-1
        if $coord[$i]<>$labels_value[$i] then
            GUICtrlSetData($labels[$i], $coord[$i])
            $labels_value[$i]=$coord[$i]
        endif
next
sleep(10)

;SNES PAD
;           L __                      | |                        __ R
;               \  ___________________|_|_____________________  /
;              _,-'                                      ____ '-._
;            ,'             S U P E R  N I T E N D O _,-'    `-._ `.
;          ,'       ___     -ENTERTAINMENT SYSTEM- ,'     __ X   `. `.
;         /        |   |                          /      /  \      \  \
;        /      ___|   |___                      /   __  \__/  __ A \  \
;        |     |           |        ,.       ,.  |  /  \      /  \   | !
;        !     |___     ___|      ,','     ,','  |  \__/  __  \__/   | |
;        \         |   |         ','      '.'    \ Y     /  \       /  /
;         \        |___|         SELECT   START   \      \__/      /  /
;          `.                  ___________________ `._  B       _,' ,'
;            `-._          _.'`                   `-._`'~-.,-~'`_.'`
;                `'~-.,-~'`                           `'~-.,-~'`
;
;DPAD
;           U
;          ___
;    UL   |   |    UR
;      ___|   |___
;  L  |           |  R
;     |___     ___|
;    DL   |   |    DR
;         |___|
;           D

;~ ;L
;~ If $coord[7] == "16" Then
;~ msgbox(0, "", "L")

;~ ;R
;~ ElseIf $coord[7] == "32" Then
;~ msgbox(0, "", "R")

;~ ;Y
;~ ElseIf $coord[7] == "4" Then
;~ msgbox(0, "", "Y")

;~ ;X
;~ ElseIf $coord[7] == "8" Then
;~ msgbox(0, "", "X")

;~ ;B
;~ ElseIf $coord[7] == "1" Then
;~ msgbox(0, "", "B")

;~ ;A
;~ ElseIf $coord[7] == "2" Then
;~ msgbox(0, "", "A")

;~ ;START
;~ ElseIf $coord[7] == "64" Then
;~ msgbox(0, "", "START")

;~ ;SELECT
;~ ElseIf $coord[7] == "128" Then
;~ msgbox(0, "", "SELECT")

;~ ; DPAD UP
;~ ElseIf $coord[6] == "0" Then
;~ msgbox(0, "", "U")

;~ ; DPAD UP / RIGHT
;~ ElseIf $coord[6] == "4500" Then
;~ msgbox(0, "", "UR")

;~ ; DPAD RIGHT
;~ ElseIf $coord[6] == "9000" Then
;~ msgbox(0, "", "R")

;~ ; DPAD DOWN / RIGHT
;~ ElseIf $coord[6] == "13500" Then
;~ msgbox(0, "", "DR")

;~ ; DPAD DOWN
;~ ElseIf $coord[6] == "18000" Then
;~ msgbox(0, "", "D")

;~ ; DPAD DOWN / LEFT
;~ ElseIf $coord[6] == "22500" Then
;~ msgbox(0, "", "DL")

;~ ;DPAD LEFT
;~ ElseIf $coord[6] == "27000" Then
;~ msgbox(0, "", "L")

;~ ;DPAD UP / LEFT
;~ ElseIf $coord[6] == "31500" Then
;~ msgbox(0, "", "UL")

;~ ;START + SELECT
;~ ElseIf $coord[7] == "192" Then
;~ msgbox(0, "", "START + SELECT")

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; EDIT HERE ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;START + SELECT + L + R + DPAD DOWN
 If $coord[7] == "240" AND $coord[6] = "18000" Then
 ;msgbox(0, "", "EXIT")
ProcessClose("OpenBOR.exe")
Exit
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; END EDIT HERE ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

EndIf

$msg =GUIGetMSG()
    if $msg = $GUI_EVENT_CLOSE Then Exitloop
WEnd

$lpJoy=0 ; Joyclose

;======================================
;   _JoyInit()
;======================================
Func _JoyInit()
    Local $joy
    Global $JOYINFOEX_struct    = "dword[13]"

    $joy=DllStructCreate($JOYINFOEX_struct)
    if @error Then Return 0
    DllStructSetData($joy, 1, DllStructGetSize($joy), 1);dwSize = sizeof(struct)
    DllStructSetData($joy, 1, 255, 2)              ;dwFlags = GetAll
    return $joy
EndFunc

;======================================
;   _GetJoy($lpJoy,$iJoy)
;   $lpJoy  Return from _JoyInit()
;   $iJoy   Joystick # 0-15
;   Return  Array containing X-Pos, Y-Pos, Z-Pos, R-Pos, U-Pos, V-Pos,POV
;           Buttons down
;
;           *POV This is a digital game pad, not analog joystick
;           65535   = Not pressed
;           0       = U
;           4500    = UR
;           9000    = R
;           Goes around clockwise increasing 4500 for each position
;======================================
Func _GetJoy($lpJoy,$iJoy)
    Local $coor,$ret

    Dim $coor[8]
    DllCall("Winmm.dll","int","joyGetPosEx", _
            "int",$iJoy, _
            "ptr",DllStructGetPtr($lpJoy))

    if Not @error Then
        $coor[0]    = DllStructGetData($lpJoy,1,3)
        $coor[1]    = DllStructGetData($lpJoy,1,4)
        $coor[2]    = DllStructGetData($lpJoy,1,5)
        $coor[3]    = DllStructGetData($lpJoy,1,6)
        $coor[4]    = DllStructGetData($lpJoy,1,7)
        $coor[5]    = DllStructGetData($lpJoy,1,8)
        $coor[6]    = DllStructGetData($lpJoy,1,11)
        $coor[7]    = DllStructGetData($lpJoy,1,9)
    EndIf


    return $coor
 EndFunc

If you want to edit & customize, see section ;;; EDIT HERE ;;; at line #148:



If you want loop script, simply set Exit to comment:
Code: [Select]
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; EDIT HERE ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;START + SELECT + L + R + DPAD DOWN
 If $coord[7] == "240" AND $coord[6] = "18000" Then
 ;msgbox(0, "", "EXIT")
ProcessClose("OpenBOR.exe")
;Exit
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; END EDIT HERE ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;



If you want to send ALT + F4, if a specific windows is in front / focus (for example Windows Notepad / Editor):
Code: [Select]
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; EDIT HERE ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;START + SELECT + L + R + DPAD DOWN
 If $coord[7] == "240" AND $coord[6] = "18000" Then
 ;msgbox(0, "", "EXIT")
WinWaitActive("Untitled - Notepad","")
WinWait("Untitled - Notepad","")
Send("!+{F4}",0)
Exit
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; END EDIT HERE ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;



If you want to close a collection of emulator systems / more than one application:

create a file called : emulators.txt

fill it with the names of tasks from taskmanager. for example:

vlc.exe
zsnes.exe
scummvm.exe
notepad.exe
calc.exe

Code: [Select]
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; EDIT HERE ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;START + SELECT + L + R + DPAD DOWN
 If $coord[7] == "240" AND $coord[6] = "18000" Then
;msgbox(0, "", "EXIT")
$file = FileOpen("emulators.txt", 0)
While 1
    Local $line = FileReadLine($file)
    If @error = -1 Then ExitLoop
;   MsgBox(0, "", $line)
ProcessClose ( $line )
WEnd
FileClose($file)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; END EDIT HERE ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

all the enclosed tasks will be closed at the same time
« Last Edit: January 11, 2019, 04:50:23 AM by hermine.potter »
AM Version : 2.6.1
Input : Mad Catz Brawlstick; Mouse; Keyboard; Xbox360 Wireless
Cabinet : Yes
OS : Windows10 Pro
System : Dell Precision T3500 ; Intel X5650 ; 12GB RAM