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: Hyperspin mame screen rotation and irotate display rotation script  (Read 5639 times)

0 Members and 1 Guest are viewing this topic.

USRFobiwan

  • Trade Count: (0)
  • Jr. Member
  • **
  • Offline Offline
  • Posts: 3
  • Last login:September 24, 2018, 08:34:30 am
  • I want to build my own arcade controls!
I have created a functio that handles screen/display rotation if a vertical rom is selected within hyperspin MAME. I use the listXMLinfo function of hyperlaunch to detect if the rom is a vertical or horizontal game. With this you do not have to generate/create a vertical or horizontal gamelist for MAME. It reads it from the listXMLinfo.

It's still in test phase but maybe people with rotating monitors using SMCMD or people using iRotate (or both) can test the scripts since my rotating arcrade cab is not finished yet so I cannot test.
For my tests I use a lot of logging into the script, so you can see in the actions in the /hyperlaunch/  log file when selecting mame games.

Update: Fixed loading of other systems other then mame error msg.

UserFunctions.ahk ( located in /hyperspin/hyperlaunch/lib/ )
Code: [Select]
; Use this function to define any code you want to run in every module on start
StartGlobalUserFeatures(){

Log("StartGlobalUserFeatures - Starting")

Global emupath, romName, systemName

Log("RotateFunctions - System " . systemName)

If ( systemName = "MAME" )
{
Log("RotateFunctions -  MAME:True")
ListMameTable := []
ListMameTable := ListXMLInfo%zz%(romName)
RotationAngle := ListMameTable[2]
Rotation := 0 ;horizontal

Log("RotateFunctions - Rotation:" . RotationAngle . " ROM:" . romName)

If (RotationAngle != "0")
{
Rotation :=1
Log("RotateFunctions - Rotating Vertical")
}

Runwait, %emupath%\Rotation.exe %Rotation%
Log("RotateFunctions - Rotation.exe Executed")

return
}

Log("StartGlobalUserFeatures - Ending")
}


; Use this function to define any code you may need to stop or clean up in every module on exit
StopGlobalUserFeatures(){

Log("StopGlobalUserFeatures - Starting")

Global emupath, systemName

If ( systemName = "MAME" )
{
;Unmark below if you want back to horizontal state after quiting game:
;Runwait, %emupath%\Rotation.exe "0"
;Log("RotateFunctions - Rotation.exe back to horizontal")

return
}



Log("StopGlobalUserFeatures - Ending")

}




The above script fires the rotation.exe (compiled ahk) in the hyperspin\emulators\mame\  root.
if you want to turn the monitor back to horizontal position on quiting the game, umremark the runwait in the StopGlobalUserFeatures function.


The source for Rotation.ahk that is fired by UserFunctions.ahk above. Put it in the root of hyperspin\emulators\mame\ .
You need to compile this with autoHotkey to an executable. If you have autohotkey installed, just right click the file and compile.
Code: [Select]
;[Rotation.exe]
#SingleInstance force

SetWorkingDir %A_ScriptDir%


;parsed value from UserFunctions.ahk
Rotation = %1%

;read Current state
iniread, state, %A_scriptdir%\Rotationstate.ini, Controls, PrevState

If ( Rotation = 0)
{
iniwrite, "Selected horizontal game", %A_scriptdir%\Rotationstate.ini, log, rotlog
goto horizontalRotation
}
Else If (Rotation = 1)
{
iniwrite, "Selected Vertical game", %A_scriptdir%\Rotationstate.ini, log, rotlog
goto verticalRotation
}


verticalRotation:

If ( state = 1)
{
; Monitor already vertical position.
iniwrite, "vertical state was 1", %A_scriptdir%\Rotationstate.ini, log, loging
exitapp
}
Else If ( state = 0)
{
; Rotate monitor to vertical position:
;Run, %COMSPEC% /c "smccmd --resume --speed -530", ,{enter},hide

;Or/And use iRotate:
; Run, irotate.exe /rotate=90

; Write rotation state:
iniwrite, 1, %A_scriptdir%\Rotationstate.ini, controls, PrevState
iniwrite, "vertical state was 0", %A_scriptdir%\Rotationstate.ini, log, loging

exitapp

}



horizontalRotation:

If ( state = 0)
{
; Monitor already horizontal position.
iniwrite, "horizontal state was 0", %A_scriptdir%\Rotationstate.ini, log, loging
exitapp
}
Else If( state = 1)
{
; Rotate monitor to horizontal position:
;Run, %COMSPEC% /c "smccmd --resume --speed 520", ,{enter},hide

;Or/And use iRotate:
; Run, irotate.exe /rotate=90

; Write rotation state:
iniwrite, 0, %A_scriptdir%\Rotationstate.ini, controls, PrevState
iniwrite, "horizontal state was 1", %A_scriptdir%\Rotationstate.ini, log, loging
exitapp
}










You also need a rotationstate.ini in the hyperspin\emulators\mame\ mame*.exe root to read/write the previous state the monitor is in when launching a new game
Vertical (1) OR horizontal (0)

Code: [Select]

[Controls]
PrevState=1
[log]
loging="vertical state was 1"
rotlog="Selected Vertical game"



You also have to set the rotation mode in MAME.ini  in which way your screen rotates.
set autoror to 1 if your screen is rotating anti clockwise to vertical
set the autorol to 1 if your screen is rotating Counter-clockwise for vertical games.

#
# CORE ROTATION OPTIONS
#
autoror                   0
autorol                   0



Please let me know results.
« Last Edit: July 06, 2014, 07:05:32 am by USRFobiwan »

Dariusz

  • Trade Count: (0)
  • Full Member
  • ***
  • Offline Offline
  • Posts: 195
  • Last login:November 23, 2018, 02:41:36 pm
  • I want to Build My Own Arcade Controls!!
Re: Hyperspin mame screen rotation and irotate display rotation script
« Reply #1 on: June 25, 2014, 06:20:00 pm »
Is the above for when screens are rotated manually?

Because I intend to use for my project the Telehook TH-3050-RW flat screen wall mount bracket to rotate between horizontal and vertical games.

D

USRFobiwan

  • Trade Count: (0)
  • Jr. Member
  • **
  • Offline Offline
  • Posts: 3
  • Last login:September 24, 2018, 08:34:30 am
  • I want to build my own arcade controls!
Re: Hyperspin mame screen rotation and irotate display rotation script
« Reply #2 on: July 06, 2014, 07:03:18 am »
It is for both motordriven monitor rotation and software (visual screen) rotation with iRotate. It detects the mame game orientation
« Last Edit: July 06, 2014, 07:07:53 am by USRFobiwan »

markekehler

  • Trade Count: (0)
  • Newbie
  • *
  • Offline Offline
  • Posts: 1
  • Last login:January 31, 2015, 01:53:06 pm
  • I want to build my own arcade controls!
Re: Hyperspin mame screen rotation and irotate display rotation script
« Reply #3 on: January 31, 2015, 01:46:34 pm »
So I see your post from June... So how well does it work for you ? Can you post your scripts here for Download. Regards...

USRFobiwan

  • Trade Count: (0)
  • Jr. Member
  • **
  • Offline Offline
  • Posts: 3
  • Last login:September 24, 2018, 08:34:30 am
  • I want to build my own arcade controls!
Re: Hyperspin mame screen rotation and irotate display rotation script
« Reply #4 on: August 27, 2015, 06:54:49 am »
Sorry to bring back this old topic. Script is working fine it  'auto-rotates' every Mame Arcade game on my arcade. No separate list for horizontal and vertical games is needed. Markekehler the scripts are in the post with explanation how to implement.

Currently also implementing rotation for Taito typeX games.
Hard part with TypeX games, the screen of vertical games are flipped compared to mame games. So added a screen flipping script that completely flips the screen for typeX. I have little time at the moment duo work but I will pick this up again with the just released hyperspin 1.4 and need to test this.