Difference between revisions of "MythGame"

From MythTV Official Wiki
Jump to: navigation, search
m (Game metadata: Typo)
(Setting Resolutions)
 
(19 intermediate revisions by the same user not shown)
Line 42: Line 42:
 
  Command: %s
 
  Command: %s
 
  Rom Path: /usr/games/scripts
 
  Rom Path: /usr/games/scripts
 +
 +
== Writing Scripts ==
 +
Scripts can be used to launch any program, it is how the script is written which results on how well it integrates with mythtv. A basic script can be as simple as:
 +
 +
#!/bin/bash
 +
CommandToRunYourGame
 +
 +
Here it will just launch the game. However even for a native Linux game there are things that can be done to improve its integration with mythtv.
 +
 +
==Setting Resolutions==
 +
 +
Some older games run at lower resolutions and if the game crashes and exits this will leave resolution different from when the game started. So to save frustration add a line that restores the resolution after the game has stopped. E.g:
 +
 +
xrandr --output HDMI-0 --mode 1920x1080
 +
 +
Note: you may need to change HDMI-0 in the line to match your display. To do this, type the following at the command line:
 +
 +
xrandr –q
 +
 +
Look for the connected device e.g:
 +
 +
DP-0 disconnected (normal left inverted right x axis y axis)
 +
 +
DP-1 disconnected (normal left inverted right x axis y axis)
 +
 +
'''HDMI-0 connected''' primary 1280x720+0+0 (normal left inverted right x axis y axis) 885mm x 498mm
 +
 +
It also shows your current resolution, in this case 1280x720 so in this case the command to add to your script is:
 +
xrandr --output HDMI-0 --mode 1280x720
 +
 +
==Game Controller Integration==
 +
 +
Qjoypad is a program where keyboard commands can be mapped to a gamepad or joystick. It is helpful for mapping mythtv navigation keys to a controller to allow the end user to navigate to their game without having to swap between the controller and a remote control/ keyboard. See the section on Qjoypad (https://www.mythtv.org/wiki/Configuring_MythGame_Emulation#Joystick_or_Gamepad_Integration) on how to install and configure it. 
 +
 +
For the writing of scripts we want to ensure the Qjoypads device list is up to date before the game starts. To do this we add this line to the script
 +
 +
qjoypad –update
 +
 +
This is just in-case the user plugs the controller after mythtv has loaded and the game has no native game controller integration. It therefore ensures the controller is ready to respond to input.
 +
 +
==Running Your Script==
 +
 +
To be able to run your script you must make it executable, there are couple ways of doing this. From the command line go to the directory using the cd command e.g
 +
 +
cd  /usr/games/scripts
 +
 +
now make the script (e.g a script called aScript.sh) executable by typing:
 +
 +
chmod u+x aScript.sh
 +
 +
If you have your script in a location that you do not have rights granted then you need to add sudo to the front of the line and then enter your password when executing the command.
 +
 +
The other method to use your desktop environment to make it executable. This can vary between desktop environments but essentially it requires you to right click on the script, select properties, then find and tick the executable box. Finally click okay to set the commit the change to the script.
 +
 +
==Script Templates==
 +
 +
There are multiple scenarios where scripts can be used for different types of games. These can be simple native games, Windows games run over wine, Steam games. Each type has some idiosyncrasies that need managing if they are to fit in well within Mythtv.
 +
 +
For each of the following templates there will be a template script and then a list of variables to replace e,g with the command to run the game.
 +
 +
Open your favorite text editor, copy and paste the script into it. Then use its find and replace feature to replace the variables and save using a name of your choice. The script must end in .sh and don’t forget to make the script executable (see above).
 +
 +
==Simple Script==
 +
 +
#!/bin/bash
 +
#update the Qjopad
 +
qjoypad –update
 +
#run the command to start the game
 +
XXXcommandXXX
 +
#Reset the resolution to what it was before.
 +
xrandr --output XXXdisplayXXX --mode XXXresolutionXXX
 +
 +
In the script replace the following variables:
 +
 +
XXXcommandXXX with the command used to launch the game.
 +
 +
XXXdisplayXXX with which display you are using (See the ‘Setting Resolutions ‘ section)
 +
 +
XXXresolutionXXX with the resolution your system is set to e.g 1920x1080 (See the ‘Setting Resolutions’ section).
 +
 +
==Windows games running via Wine==
 +
 +
#!/bin/bash
 +
XXXcommandXXX &
 +
#wait for the Game to start if this takes longer than 10 seconds carry on and the script should exit.
 +
count=0
 +
while ! pidof XXXgameExecXXX >> /dev/null ;
 +
do
 +
sleep 1
 +
((count++))
 +
if [[ $count -eq 10 ]]; then
 +
    exit
 +
  fi
 +
done
 +
#lets bring the screen forward
 +
#dcop konqueror-[] konqueror-mainwindow#1 raise
 +
export GAMEPID2=$(pgrep XXXgameExecXXX)
 +
#need to stop the script whilst KSP is running
 +
while kill -0 pgrep $GAMEPID2 2> /dev/null;
 +
do
 +
  sleep 1s;
 +
done
 +
#set the resolution back to what you had previously
 +
xrandr --output XXXdisplayXXX --mode XXXresolutionXXX
 +
 +
The trick with games that run via wine is that they often start up another process. Which means that either the script ends early, which could mean that a combined frontend and backend setup could shut down mid game. Or, if your remote has repeated a command you can have 2 instances of a game running simultatiously. If script does not stop, the script may lock, causing Mythtv to be locked after you have exited the game.
 +
 +
To get around this the above script requires the process id of the game which the script waits for it to finish before allowing the itself to complete.
 +
 +
For this to work, you need to the games process name. For windows games it is the exec file that is executed. E,g Quake.exe. The easiest way to find this is to open the .ink file that is used launch the game. Navigate to the following directory:
 +
 +
~/.wine/dosdevices/c:/ProgramData/Microsoft/Windows/Start Menu/Programs/
 +
 +
Go to the folder for the game, usually under the publishers name. Find the .ink file and open it in a text editor.  This will state which .exe file is being executed. Make a note of it so you can replace it in the script (see below). (NOTE you cannot normally copy and paste the name as .ink file is written in a different character set to your script).
 +
 +
Now replace the following variables in the template script:
 +
 +
XXXgameExecXXX with the .exe that is being executed, See above.
 +
 +
XXXcommandXXX with the command used to launch the game. (find the game in the start button/ application menu, right click on it and view properties. From there you should be able to find the start up command).
 +
 +
XXXdisplayXXX with which display you are using (See the ‘Setting Resolutions ‘ section)
 +
 +
XXXresolutionXXX with the resolution your system is set to e.g 1920x1080 (See the ‘Setting Resolutions’ section).
 +
 +
Additionally if you find the game starts up behind the Mythtv window and you are running the plasma desktop un comment line 18 to bring the game to the front.
 +
 +
==Windows games that require a CD/DVD to run==
 +
 +
#!/bin/bash
 +
#
 +
# Script to play a game that requires a DVD/ CD to run
 +
#
 +
#first set up variables checking the CD/DVD is mounted
 +
export MOUNT=XXMOUNTPOINTXX
 +
export FILE=XXFILECHECKXX
 +
#check if game drive is mounted if not mount the drive
 +
if grep -qs $MOUNT /proc/mounts; then
 +
  echo "It's mounted.";
 +
else
 +
  echo "It's not mounted."
 +
  udisks --mount XXDEVICEPATHXX & export DRIVEMOUNTING=$!
 +
  #wiat for the drive to complete mounting
 +
  wait "$DRIVEMOUNTING";
 +
fi
 +
#check the correct drive is mounted by doing a file check
 +
if [ -f $FILE ]; then
 +
#start the game
 +
XXXcommandXXX &
 +
#wait for the Game to start if this takes longer than 10 seconds carry on and the  script should exit.
 +
count=0
 +
while ! pidof XXXgameExecXXX >> /dev/null ;
 +
do
 +
sleep 1
 +
((count++))
 +
if [[ $count -eq 10 ]]; then
 +
    exit
 +
  fi
 +
done
 +
else
 +
  # the file check has failed and the disk is not inserted
 +
  echo "File $FILE does not exist incorrect drive mounted."
 +
# unmount the drive if there is any mounted
 +
  umount **DEVICEPATH**
 +
fi
 +
#lets bring the screen forward
 +
# dcop konqueror-[] konqueror-mainwindow#1 raise
 +
export GAMEPID2=$(pgrep XXXgameExecXXX)
 +
#need to stop the script whilst KSP is running
 +
while kill -0 pgrep $GAMEPID2 2> /dev/null;
 +
do
 +
  sleep 1s;
 +
done
 +
 +
Follow the guidance for games running wine with the additional instructions:  For games that require a DVD or CD to run and you either cannot copy the disk to an ISO or just don’t have the space to do so, then this script will look to see if the media is present and if not the script exits. For this to work you need to find a file on the disk that is uniquely named. The script checks for this file once the disk is mounted.  If this file is found then the game launches, If it is not found the script exits.
 +
 +
Now replace the following variables in the template:
 +
 +
XXMOUNTPOINTXX path the drive mounts to after udisk has mounted it
 +
 +
XXFILECHECKXX path of a unique file on the Disk to ensure the correct disk in the drive
 +
 +
XXDEVICEPATHXX the device path of the dvd/cd drive e.g /dev/sr0
 +
 +
XXXgameExecXXX with the .exe that is being executed, See the section ‘Windows games running via wine.
 +
 +
XXXcommandXXX with the command used to launch the game. (find the game in the start button/ application menu, right click on it and view properties. From there you should be able to find the start up command).
 +
 +
XXXdisplayXXX with which display you are using (See the ‘Setting Resolutions ‘ section)
 +
 +
XXXresolutionXXX with the resolution your system is set to e.g 1920x1080 (See the ‘Setting Resolutions’ section).
 +
 +
==Steam Games==
 +
 +
#!/bin/bash
 +
steam steam://rungameid/XXXsteamAppIDXXX &
 +
#wait for the application to strt which means waiting for steam to load if this takes longer than 10 seconds carry on and the script should exit.
 +
count=0
 +
while ! pidof XXXprocessNameXXX >> /dev/null ;
 +
do
 +
sleep 1
 +
((count++))
 +
if [[ $count -eq 10 ]]; then
 +
    exit
 +
  fi
 +
done
 +
export GAMEPID2=$(pgrep XXXprocessNameXXX)
 +
#need to stop the script whilst game is running
 +
while kill -0 pgrep $GAMEPID2 2> /dev/null;
 +
do
 +
  sleep 1s;
 +
done
 +
#exit steam so it does not bring up adverts etc interfering with mythtv
 +
steam -shutdown
 +
#reset the resolution
 +
xrandr --output HDMI-0 --mode 1280x720
 +
 +
To launch a steam game you need it’s AppID this can be obtained from the following page:
 +
 +
[Steam App Listings https://steamdb.info/apps/]
 +
 +
Steam also launches the game in a separate thread, so we need it’s process name. To get this launch the game and then bring up the system monitor for your Linux distribution e.g for Plasma it is CTRL and Esc keys. From there you should be able to establish the process name.
 +
 +
Now replace the following variables in the template:
 +
 +
XXXsteamAppIDXXX with the AppID for the game (see above)
 +
 +
XXXprocessNameXXX the name of the process for the game. (See above)
 +
 +
XXXdisplayXXX with which display you are using (See the ‘Setting Resolutions ‘ section)
 +
 +
XXXresolutionXXX with the resolution your system is set to e.g 1920x1080 (See the ‘Setting Resolutions’ section).
 +
 +
==Steam Client==
 +
 +
#!/bin/bash
 +
##update the Qjopad
 +
qjoypad –update
 +
#run the command to start the game
 +
steam -tenfoot
 +
#Reset the resolution to what it was before.
 +
xrandr --output XXXdisplayXXX --mode XXXresolutionXXX
 +
 +
Why would you want to run, the client, I hear you ask? Well if you have a game that will not run under wine or your system in your living room is not powerful enough to run the game. Steam can run the game on a separate PC and stream it to your less powerful or completely incompatible system. At the time of writing there is no command line option for streaming a game so the best way of doing this to have a script that launches the steam client in big screen mode.  The caveat here is you must exit from steam entirely when you finish otherwise mythtv will be stuck as the script will not exit. 
 +
 +
Now replace the following variables in the template:
 +
 +
XXXdisplayXXX with which display you are using (See the ‘Setting Resolutions ‘ section)
 +
 +
XXXresolutionXXX with the resolution your system is set to e.g 1920x1080 (See the ‘Setting Resolutions’ section).
 +
 +
==Emulation Scripts==
 +
 +
Although the emulator section covers games run in emulators, it does not mean you have to do it that way. You can alternatively set them up individually in scripts.  This is may be applicable if you only have a few games run by a particular emulator or you wish to group your games more by genre or publisher.  It is also helpful to have your back button on your remote maps to the escape key. (See https://www.mythtv.org/wiki/User_Manual:IR_control_via_evdev for guidance on how to do this.) As most emulators use this key to exit, this is allows you to exit out of the game gracefully using your remote.
 +
 +
These emulators can be installed using whatever package manager your distribution comes with.
 +
 +
==Dolphin Wii Games==
 +
 +
#!/bin/bash
 +
#
 +
# Script to Start Wii game via dolphin emu
 +
#
 +
#First start the game and carry on.
 +
dolphin-emu -cFalse -b -e /Storage2/isos/WiiGames/WiiFitPlus.iso 2>&1 & export  GAMEPID=$!
 +
export GAMEPID2=$(pgrep dolphin-emu)
 +
#check if the game is sill running.
 +
while kill -0 $GAMEPID2 2> /dev/null; do
 +
  sleep 3s;
 +
done
 +
sleep 1s;
 +
#Reset the resolution to what it was before.
 +
xrandr --output XXXdisplayXXX --mode XXXresolutionXXX
 +
#update the qjoyod
 +
qjoypad --update
 +
 +
When a game is launched using Dolphin, Dolphin starts in a separate thread. So this script looks for the Dolphin process and exits from the script once it has terminated.
 +
 +
In the script replace the following variables:
 +
 +
XXXloctionAndNameofISO with the location and name of the ISO for the game to be run.
 +
 +
XXXdisplayXXX with which display you are using (See the ‘Setting Resolutions ‘ section)
 +
 +
XXXresolutionXXX with the resolution your system is set to e.g 1920x1080 (See the ‘Setting Resolutions’ section)
 +
 +
==Playstation (pcsxr)==
 +
 +
#!/bin/bash
 +
##update the Qjopad
 +
qjoypad –update
 +
#Start the game
 +
pcsxr -cdfile XXXloctionAndNameofISOXXX -nogui
 +
#Set the resolution to back where it started
 +
xrandr --output XXXdisplayXXX --mode XXXresolutionXXX
 +
 +
In the script replace the following variables:
 +
 +
XXXloctionAndNameofISOXXX with the location and name of the ISO for the game to be run.
 +
 +
XXXdisplayXXX with which display you are using (See the ‘Setting Resolutions ‘ section)
 +
 +
XXXresolutionXXX with the resolution your system is set to e.g 1920x1080 (See the ‘Setting Resolutions’ section)
 +
 +
==Playstation 2==
 +
 +
#!/bin/bash
 +
#update the Qjopad
 +
qjoypad –update
 +
#Start the game
 +
env __GL_THREADED_OPTIMIZATIONS=1 PCSX2 "XXXloctionAndNameofISOXXX" --fullscreen --nogui
 +
#Set the resolution to back where it started
 +
xrandr --output XXXdisplayXXX --mode XXXresolutionXXX
 +
 +
XXXloctionAndNameofISOXXX with the location and name of the ISO for the game to be run.
 +
 +
XXXdisplayXXX with which display you are using (See the ‘Setting Resolutions ‘ section)
 +
 +
XXXresolutionXXX with the resolution your system is set to e.g 1920x1080 (See the ‘Setting Resolutions’ section)
  
 
= Game metadata =
 
= Game metadata =

Latest revision as of 21:44, 26 April 2020

This Guide is for MythGame for MythTV 0.19 or later.

This guide describes only the installation, general setup, pc games and use of MythGame. If you need a guide how to setup different emulators in MythGame look at: Configuring MythGame Emulation.

What is MythGame

MythGame is a starter for games and emulators, so they can be run from within MythTV. To use it you need a game emulator and ROMS for each game. Alternatively, you need PC-Games which can be started.

Compiling & Installation

Get the Plugins from the SVN Server:

svn co http://cvs.mythtv.org/svn/trunk/mythplugins

go into the mythplugins directory, configure, compile & install:

cd mythplugins
./configure --prefix=/usr --disable-all --enable-mythgame
make
make install

Configuration

In MythTV you can configure Mythgame. In the general Settings normally you don't need to change anything.

Input Device Setup

Most emulators that MythGame calls can use a keyboard or joystick, but some can also use an LIRC remote. Each emulator has its own quirks and are covered on the MythGame emulator setup page

Emulation Setup

To Setup different Emulators look at the guide: Configuring MythGame Emulation

PC-Game Setup

To Setup PC Games Create a Directory with Scripts which run your different PC Games. (for example: /usr/games/scripts). You also can link the game executable to this directory if you don't want to create a script.

Then you have to create a game-player which runs your scripts.

Player Name: PC-GAMES 
Type: Other
Command: %s
Rom Path: /usr/games/scripts

Writing Scripts

Scripts can be used to launch any program, it is how the script is written which results on how well it integrates with mythtv. A basic script can be as simple as:

#!/bin/bash
CommandToRunYourGame

Here it will just launch the game. However even for a native Linux game there are things that can be done to improve its integration with mythtv.

Setting Resolutions

Some older games run at lower resolutions and if the game crashes and exits this will leave resolution different from when the game started. So to save frustration add a line that restores the resolution after the game has stopped. E.g:

xrandr --output HDMI-0 --mode 1920x1080

Note: you may need to change HDMI-0 in the line to match your display. To do this, type the following at the command line:

xrandr –q

Look for the connected device e.g:

DP-0 disconnected (normal left inverted right x axis y axis)

DP-1 disconnected (normal left inverted right x axis y axis)

HDMI-0 connected primary 1280x720+0+0 (normal left inverted right x axis y axis) 885mm x 498mm

It also shows your current resolution, in this case 1280x720 so in this case the command to add to your script is: xrandr --output HDMI-0 --mode 1280x720

Game Controller Integration

Qjoypad is a program where keyboard commands can be mapped to a gamepad or joystick. It is helpful for mapping mythtv navigation keys to a controller to allow the end user to navigate to their game without having to swap between the controller and a remote control/ keyboard. See the section on Qjoypad (https://www.mythtv.org/wiki/Configuring_MythGame_Emulation#Joystick_or_Gamepad_Integration) on how to install and configure it.

For the writing of scripts we want to ensure the Qjoypads device list is up to date before the game starts. To do this we add this line to the script

qjoypad –update

This is just in-case the user plugs the controller after mythtv has loaded and the game has no native game controller integration. It therefore ensures the controller is ready to respond to input.

Running Your Script

To be able to run your script you must make it executable, there are couple ways of doing this. From the command line go to the directory using the cd command e.g

cd /usr/games/scripts

now make the script (e.g a script called aScript.sh) executable by typing:

chmod u+x aScript.sh

If you have your script in a location that you do not have rights granted then you need to add sudo to the front of the line and then enter your password when executing the command.

The other method to use your desktop environment to make it executable. This can vary between desktop environments but essentially it requires you to right click on the script, select properties, then find and tick the executable box. Finally click okay to set the commit the change to the script.

Script Templates

There are multiple scenarios where scripts can be used for different types of games. These can be simple native games, Windows games run over wine, Steam games. Each type has some idiosyncrasies that need managing if they are to fit in well within Mythtv.

For each of the following templates there will be a template script and then a list of variables to replace e,g with the command to run the game.

Open your favorite text editor, copy and paste the script into it. Then use its find and replace feature to replace the variables and save using a name of your choice. The script must end in .sh and don’t forget to make the script executable (see above).

Simple Script

#!/bin/bash
#update the Qjopad
qjoypad –update
#run the command to start the game
XXXcommandXXX
#Reset the resolution to what it was before.
xrandr --output XXXdisplayXXX --mode XXXresolutionXXX

In the script replace the following variables:

XXXcommandXXX with the command used to launch the game.

XXXdisplayXXX with which display you are using (See the ‘Setting Resolutions ‘ section)

XXXresolutionXXX with the resolution your system is set to e.g 1920x1080 (See the ‘Setting Resolutions’ section).

Windows games running via Wine

#!/bin/bash
XXXcommandXXX &
#wait for the Game to start if this takes longer than 10 seconds carry on and the script should exit.
count=0
while ! pidof XXXgameExecXXX >> /dev/null ;
do
sleep 1
((count++))
if  $count -eq 10 ; then
   exit
 fi
done
#lets bring the screen forward 
#dcop konqueror-[] konqueror-mainwindow#1 raise
export GAMEPID2=$(pgrep XXXgameExecXXX)
#need to stop the script whilst KSP is running
while kill -0 pgrep $GAMEPID2 2> /dev/null; 
do
 sleep 1s;
done
#set the resolution back to what you had previously
xrandr --output XXXdisplayXXX --mode XXXresolutionXXX 

The trick with games that run via wine is that they often start up another process. Which means that either the script ends early, which could mean that a combined frontend and backend setup could shut down mid game. Or, if your remote has repeated a command you can have 2 instances of a game running simultatiously. If script does not stop, the script may lock, causing Mythtv to be locked after you have exited the game.

To get around this the above script requires the process id of the game which the script waits for it to finish before allowing the itself to complete.

For this to work, you need to the games process name. For windows games it is the exec file that is executed. E,g Quake.exe. The easiest way to find this is to open the .ink file that is used launch the game. Navigate to the following directory:

~/.wine/dosdevices/c:/ProgramData/Microsoft/Windows/Start Menu/Programs/

Go to the folder for the game, usually under the publishers name. Find the .ink file and open it in a text editor. This will state which .exe file is being executed. Make a note of it so you can replace it in the script (see below). (NOTE you cannot normally copy and paste the name as .ink file is written in a different character set to your script).

Now replace the following variables in the template script:

XXXgameExecXXX with the .exe that is being executed, See above.

XXXcommandXXX with the command used to launch the game. (find the game in the start button/ application menu, right click on it and view properties. From there you should be able to find the start up command).

XXXdisplayXXX with which display you are using (See the ‘Setting Resolutions ‘ section)

XXXresolutionXXX with the resolution your system is set to e.g 1920x1080 (See the ‘Setting Resolutions’ section).

Additionally if you find the game starts up behind the Mythtv window and you are running the plasma desktop un comment line 18 to bring the game to the front.

Windows games that require a CD/DVD to run

#!/bin/bash
#
# Script to play a game that requires a DVD/ CD to run
#
#first set up variables checking the CD/DVD is mounted
export MOUNT=XXMOUNTPOINTXX
export FILE=XXFILECHECKXX
#check if game drive is mounted if not mount the drive
if grep -qs $MOUNT /proc/mounts; then 
 echo "It's mounted.";
else
 echo "It's not mounted." 
 udisks --mount XXDEVICEPATHXX & export DRIVEMOUNTING=$!
 #wiat for the drive to complete mounting
 wait "$DRIVEMOUNTING";
fi
#check the correct drive is mounted by doing a file check
if [ -f $FILE ]; then
#start the game
XXXcommandXXX &
#wait for the Game to start if this takes longer than 10 seconds carry on and the  script should exit.
count=0
while ! pidof XXXgameExecXXX >> /dev/null ;
do
sleep 1
((count++))
if  $count -eq 10 ; then
   exit
 fi
done
else
 # the file check has failed and the disk is not inserted
  echo "File $FILE does not exist incorrect drive mounted."
# unmount the drive if there is any mounted
  umount **DEVICEPATH** 
fi
#lets bring the screen forward 
# dcop konqueror-[] konqueror-mainwindow#1 raise
export GAMEPID2=$(pgrep XXXgameExecXXX)
#need to stop the script whilst KSP is running
while kill -0 pgrep $GAMEPID2 2> /dev/null; 
do
 sleep 1s;
done

Follow the guidance for games running wine with the additional instructions: For games that require a DVD or CD to run and you either cannot copy the disk to an ISO or just don’t have the space to do so, then this script will look to see if the media is present and if not the script exits. For this to work you need to find a file on the disk that is uniquely named. The script checks for this file once the disk is mounted. If this file is found then the game launches, If it is not found the script exits.

Now replace the following variables in the template:

XXMOUNTPOINTXX path the drive mounts to after udisk has mounted it

XXFILECHECKXX path of a unique file on the Disk to ensure the correct disk in the drive

XXDEVICEPATHXX the device path of the dvd/cd drive e.g /dev/sr0

XXXgameExecXXX with the .exe that is being executed, See the section ‘Windows games running via wine.

XXXcommandXXX with the command used to launch the game. (find the game in the start button/ application menu, right click on it and view properties. From there you should be able to find the start up command).

XXXdisplayXXX with which display you are using (See the ‘Setting Resolutions ‘ section)

XXXresolutionXXX with the resolution your system is set to e.g 1920x1080 (See the ‘Setting Resolutions’ section).

Steam Games

#!/bin/bash
steam steam://rungameid/XXXsteamAppIDXXX & 
#wait for the application to strt which means waiting for steam to load if this takes longer than 10 seconds carry on and the script should exit.
count=0
while ! pidof XXXprocessNameXXX >> /dev/null ;
do
sleep 1
((count++))
if  $count -eq 10 ; then
   exit
 fi
done
export GAMEPID2=$(pgrep XXXprocessNameXXX)
#need to stop the script whilst game is running
while kill -0 pgrep $GAMEPID2 2> /dev/null; 
do
 sleep 1s;
done
#exit steam so it does not bring up adverts etc interfering with mythtv
steam -shutdown
#reset the resolution
xrandr --output HDMI-0 --mode 1280x720

To launch a steam game you need it’s AppID this can be obtained from the following page:

[Steam App Listings https://steamdb.info/apps/]

Steam also launches the game in a separate thread, so we need it’s process name. To get this launch the game and then bring up the system monitor for your Linux distribution e.g for Plasma it is CTRL and Esc keys. From there you should be able to establish the process name.

Now replace the following variables in the template:

XXXsteamAppIDXXX with the AppID for the game (see above)

XXXprocessNameXXX the name of the process for the game. (See above)

XXXdisplayXXX with which display you are using (See the ‘Setting Resolutions ‘ section)

XXXresolutionXXX with the resolution your system is set to e.g 1920x1080 (See the ‘Setting Resolutions’ section).

Steam Client

#!/bin/bash
##update the Qjopad
qjoypad –update
#run the command to start the game
steam -tenfoot
#Reset the resolution to what it was before.
xrandr --output XXXdisplayXXX --mode XXXresolutionXXX 

Why would you want to run, the client, I hear you ask? Well if you have a game that will not run under wine or your system in your living room is not powerful enough to run the game. Steam can run the game on a separate PC and stream it to your less powerful or completely incompatible system. At the time of writing there is no command line option for streaming a game so the best way of doing this to have a script that launches the steam client in big screen mode. The caveat here is you must exit from steam entirely when you finish otherwise mythtv will be stuck as the script will not exit.

Now replace the following variables in the template:

XXXdisplayXXX with which display you are using (See the ‘Setting Resolutions ‘ section)

XXXresolutionXXX with the resolution your system is set to e.g 1920x1080 (See the ‘Setting Resolutions’ section).

Emulation Scripts

Although the emulator section covers games run in emulators, it does not mean you have to do it that way. You can alternatively set them up individually in scripts. This is may be applicable if you only have a few games run by a particular emulator or you wish to group your games more by genre or publisher. It is also helpful to have your back button on your remote maps to the escape key. (See https://www.mythtv.org/wiki/User_Manual:IR_control_via_evdev for guidance on how to do this.) As most emulators use this key to exit, this is allows you to exit out of the game gracefully using your remote.

These emulators can be installed using whatever package manager your distribution comes with.

Dolphin Wii Games

#!/bin/bash
#
# Script to Start Wii game via dolphin emu
#
#First start the game and carry on.
dolphin-emu -cFalse -b -e /Storage2/isos/WiiGames/WiiFitPlus.iso 2>&1 & export  GAMEPID=$!
export GAMEPID2=$(pgrep dolphin-emu)
#check if the game is sill running.
while kill -0 $GAMEPID2 2> /dev/null; do
 sleep 3s;
done
sleep 1s;
#Reset the resolution to what it was before.
xrandr --output XXXdisplayXXX --mode XXXresolutionXXX
#update the qjoyod
qjoypad --update

When a game is launched using Dolphin, Dolphin starts in a separate thread. So this script looks for the Dolphin process and exits from the script once it has terminated.

In the script replace the following variables:

XXXloctionAndNameofISO with the location and name of the ISO for the game to be run.

XXXdisplayXXX with which display you are using (See the ‘Setting Resolutions ‘ section)

XXXresolutionXXX with the resolution your system is set to e.g 1920x1080 (See the ‘Setting Resolutions’ section)

Playstation (pcsxr)

#!/bin/bash
##update the Qjopad
qjoypad –update
#Start the game
pcsxr -cdfile XXXloctionAndNameofISOXXX -nogui
#Set the resolution to back where it started
xrandr --output XXXdisplayXXX --mode XXXresolutionXXX

In the script replace the following variables:

XXXloctionAndNameofISOXXX with the location and name of the ISO for the game to be run.

XXXdisplayXXX with which display you are using (See the ‘Setting Resolutions ‘ section)

XXXresolutionXXX with the resolution your system is set to e.g 1920x1080 (See the ‘Setting Resolutions’ section)

Playstation 2

#!/bin/bash
#update the Qjopad
qjoypad –update
#Start the game
env __GL_THREADED_OPTIMIZATIONS=1 PCSX2 "XXXloctionAndNameofISOXXX" --fullscreen --nogui
#Set the resolution to back where it started
xrandr --output XXXdisplayXXX --mode XXXresolutionXXX

XXXloctionAndNameofISOXXX with the location and name of the ISO for the game to be run.

XXXdisplayXXX with which display you are using (See the ‘Setting Resolutions ‘ section)

XXXresolutionXXX with the resolution your system is set to e.g 1920x1080 (See the ‘Setting Resolutions’ section)

Game metadata

MythGame can retrieve additional information about games and display box art for the selected game. Some titles will automatically obtain and display the correct metadata for a particular game. If an exact match is not found, you will have to manually perform a search, press Menu (M) then select "Retrieve Details". A list of matching titles will be displayed, where you can select the appropriate one.

MythGame obtains its data from http://www.giantbomb.com using a script located at /usr/share/mythtv/metadata/Game/giantbomb.py