Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - superdan

Pages: [1]
1
THE PROBLEM
I have 1 joystick and 1 gamepad (well, actually two and two), and every time i change that kind of peripherals on my Raspberry Pi (from joystick to gamepad and vice versa) I have to re-map the controllers for Attractmode (and also attach a keyboard to hit TAB).
In short, Attractmode actually (at least, my version) is not plug-and-play and does not "remember" the joysticks/joypads that I have configured in the past to navigate inside the frontend.
Pretty much frustrating, isn't it?

THE WORKAROUND (MORE THAN THE SOLUTION)

I have decided to solve this tedious problem and I share with you how I did it.
the script is not beautiful, i know (try chat GPT if you prefer :P): I did it very quickly but it works for now... (maybe improve it!).
Consider it an alpha version at the moment.

ASSUMING:
The joystick/joypad that will control Attractmode will always be the one inserted in the upper left USB port of the Raspberry Pi and no others. No matter what model or brand it is, the number of buttons ecc. We need to find a rule that defines the main controller that will navigate into attractmode menus, games and options. This rule is that it will be always plugged to the upper left USB port (but obviously you can change if you want).

1. Turn off the raspberry (mine is 4 but should work for all versions)
2. Remove all USB devices
3. Plug in one kind of joystick/joypad into the upper left USB port
4. Start Attractmode
5. Configure your device in Attractmode (select, start, previous page, next letter etc.)
6. Discover the name of the joystick/joypad with the ssh command:

Code: [Select]
udevadm info --query=all --name=/dev/input/js0
the name after the string:

Code: [Select]
ID_SERIAL=
is what is we are looking for.

in my case is 0079_Generic_USB_Joystick

7. Create the file /home/pi/.attract/[nameofthejoystick].txt (in my case /home/pi/.attract/0079_Generic_USB_Joystick.txt)
8. Restart your raspberry
8. Copy the content of /home/pi/.attract/attract.cfg between  'input_map' and 'general' (be careful that the configurations called 'general' in the attract.cfg file are actually under the rules called 'input_map')

in my case:

Code: [Select]
        configure            Tab
add_favourite        F
left                 Joy0 Left
left                 Left
right                Joy0 Right
right                Right
prev_letter          Joy0 Button3
next_letter          Joy0 Button7
next_page            Joy0 Button6
prev_page            Joy0 Button2
up                   Up
up                   Joy0 Up
up                   Joy0 PovYneg
down                 Down
down                 Joy0 Down
down                 Joy0 PovYpos
select               Return
select               Joy0 Button4
back                 Escape
back                 Joy0 Button5
default             back exit
default             up prev_game
default             down next_game
default             left prev_filter
default             right next_filter


Be CAREFUL: at the end of the file, there MUST be two line breaks and NONE at the beginning!
Here is a working example of a right formatted file if you want to check:
https://www.cdlab.it/0079_Generic_USB_Joystick.txt
Save it to your Desktop and open it with e.g. notepad++ to check the formatting

9. Write this content in the file /home/pi/.attract/[nameofthejoystick].txt
10. Save the file /home/pi/.attract/[nameofthejoystick].txt

11. Do all the 1-10 steps for all your different type of USB CONTROLLERS (virtually infinity).

OK: last few things

1. CHECK THAT THERE ARE NO LINE BREAKS AT THE END OF YOUR /home/pi/.attract/attract.cfg FILE! IF THERE ARE, REMOVE THEM!
2. BACKUP YOUR attract.cfg (just in case).
3. Create a file called 99-joypad.rules in /etc/udev/rules.d/

4. Write inside this file the string:

Code: [Select]
ACTION=="add", SUBSYSTEM=="input", KERNEL=="js[0-9]*", ENV{ID_PATH}=="platform-fd500000.pcie-pci-0000:01:00.0-usb-0:1.3:1.0", RUN+="/home/pi/.attract/changejoypad.sh"
and save it.
This will execute the script /home/pi/.attract/changejoypad.sh at boot and every time a USB joypad/joystick (and ONLY joypads/joysticks: no HDD, NO USB PEN etc.) is plugged into the upper left USB port.

5. Make this file executable
6. Create the file /home/pi/.attract/changejoypad.sh
7  Write inside this file this script

Code: [Select]
#!/bin/bash
# Get the joypad path e.g. js0, js1, js2, js3
ID_PATH="platform-fd500000.pcie-pci-0000:01:00.0-usb-0:1.3:1.0"
input_device=$(basename $(udevadm info --query=all --name=/dev/input/by-path/platform-fd500000.pcie-pci-0000:01:00.0-usb-0:1.3:1.0-joystick | grep "N: input/" | awk '{print $2}'))
joypadSlot=$(echo $input_device | sed 's/event[0-9]*$//')
# Set joystick name into a variable
joypadName=$(udevadm info --query=all --name=/dev/input/$joypadSlot | grep ID_SERIAL= | awk -F= '{print $2}')
sudo chown pi:pi '/home/pi/.attract/attract.cfg'
sudo chmod 775 '/home/pi/.attract/attract.cfg'
file=/home/pi/.attract/attract.cfg
# Controller_Controller_Controller        8bitdo joypad name
# 0079_Generic_USB_Joystick             generic usb joystick name
replace_file="/home/pi/.attract/$joypadName.txt"
if test -f "$replace_file"; then
  if test -f /home/pi/.attract/tmpjoyfile; then
    sudo rm /home/pi/.attract/tmpjoyfile;
  fi
  touch /home/pi/.attract/tmpjoyfile
  sudo chown pi:pi '/home/pi/.attract/tmpjoyfile'
  sudo chmod 775 '/home/pi/.attract/tmpjoyfile'
  sed -i 's/input_map.*\n\n//g' /home/pi/.attract/attract.cfg
  sed -e '
  /input_map/,/general/!b
  //!d;/general/!b
  r '"$replace_file"'
  N
  ' /home/pi/.attract/attract.cfg > /home/pi/.attract/tmpjoyfile
  mv /home/pi/.attract/tmpjoyfile /home/pi/.attract/attract.cfg
fi
# restart retropie if is not on boot mode ( so Xorg is a running service ) && no emulator is running
if pgrep -f "xorg/Xorg" &> /dev/null && ! pgrep -f "RetroPie/roms" &> /dev/null
then
  #comment this if you dont want restart after a joypad is plugged in
  sudo shutdown -r now
fi

5. Make this file executable
6. Restart.

Now.

At boot and every time a gamepad/joystick is inserted into the upper left USB port of the Raspberry Pi, this script is executed and auto-changes attractmode configs for the pad plugged in and changes ONLY joypad/joystick input settings.

So you can change ALL other parameters in attract.cfg (either manually either via the TAB graphic menu settings of attractmode) without thinking about all of the things we are doing here!

If you are in attractmode and you change the joypad in the upper left usb port the raspberry reboots automatically with new input settings (but you can comment the command

Code: [Select]
sudo shutdown -r now
in changejoypad.sh and do everytime a manual restart if you prefer)
 
Note: IF any emulator is running when you change the joystick/joypad, input configs will be still modified by the script but raspberry will not auto restart (so you can complete your Bubble Boble's round 99 safely).

In this case and only in this case you should reboot manually after you exit the game because settings are changed but attractmode has not restarted so didnt reload settings.

Feel free to improve and...
if you have better solutions you are welcome to share!

2
General / reload attract.cfg
« on: January 18, 2023, 01:47:43 AM »
Hi,
i wrote a bash script that changes on-the-fly the input settings of the attract.cfg file depending on the model of joypad that is plugged into the raspberry pi 4.

Now i would like to have a bash command to reload attract.cfg settings without rebooting.

Thanks

3
Hi,
how can i restart attractmode and only attractmode (so without rebooting my raspberry) via ssh prompt commandline?
Just restart.
in autostart.sh the command is startx and no more 'attract'
when i try
Code: [Select]
pi@retropieSalottoPi4:~ $ pkill attract
pi@retropieSalottoPi4:~ $ attract

gives me the error

Code: [Select]
Failed to open X11 display; make sure the DISPLAY environment variable is set correctlyalso, if i run

Code: [Select]
./runattract
it gives me

Code: [Select]
Error: Couldn't connect to XServer passing null display
xterm: Xt error: Can't open display:
xterm: DISPLAY is not set
Xorg: no process found

I can also avoid to restart attractmode if there is a way to reload attract.cfg after I edit it via script

Thanks

4
General / Run a sh script when exiting a game
« on: September 10, 2018, 06:33:04 AM »
Hi guys,
i would like to run a bash script everytime i exit a game before returning to attractmode.
Is it possibile?
Thanks

5
General / AttractMode DONT Execute runcommand-onend.sh (BUG?)
« on: September 07, 2018, 07:03:35 AM »
Hi guys,
for some reason my retropie 4.4 + attractmode + raspberry pi3 Plus (fresh install) DONT execute

runcommand-onend.sh

when i exit a game although runcommand-onstart.sh is executed when a game is launched.

With Emulationstation both are executed like a charm.
Any idea? Maybe an AM bug?

Thanks for your answers

6
General / AM: Divide Games In A-Z MainFolders
« on: December 04, 2016, 02:21:18 PM »
Hi all!
I have almost 18.000 games for C64 and the consequence is that
its quite impossible to navigate well in this jungle of games simply via Joystick.

So my question is:

is it possible in AM to divide roms in main alphabet letter Folders like A, B, C......Z

and only THEN select a Game?
It would be really beautiful for some systems!

Thanks for your nswers!

7
General / Scraping Games names in Vice ( Commodore 64 )
« on: December 04, 2016, 01:12:02 PM »
Hi Guys!
Here is my problem
i have a BIG BIG folder of C64  Games .T64 and .D64

BUT

the names of these roms are NOT the games names, for example:

Code: [Select]
0ANDX.T64                  LUNARLA1.T64
0GRADNO0.D64               LUNARLA2.T64
0GRADNO1.D64               LUNARLA3.T64
0GRADNO2.D64               LUNARLA4.T64
0GRADNO3.D64               LUNARLA5.T64
0GRADNO4.D64               LUNARLA6.T64
1000000.T64                LUNARLA7.T64
10000MET.D64               LUNARLA8.T64
1000MIGL.D64               LUNARLA9.D64
1000MIL1.D64               LUNARLD3.T64
1000MIL2.D64               LUNARLEE.T64
1000MILE.T64               LUNAR-LG.T64
100KPYRA.D64               LUNAROUT.T64
100MDASH.T64               LUNARPIL.T64
100MILER.D64               LUNARRES.D64

How can i recover their exact names?
THANK YOU SO MUCH!!

8
General / MSX2 - lr-bluemsx Games wont start
« on: November 24, 2016, 12:35:52 PM »
Hi guys,

there is no way for me to make msx2 games working on Rey Santiago image ( Rpi3b + RetroPie + AM ).
The surprising thing is that Msx games works.

It says:
Code: [Select]
glGetError 0x500 sh: 1: commandline not found.

my msx2.cfg in
Code: [Select]
/home/pi/.attract/emulators
is:
Code: [Select]
# Generated by Attract-Mode v2.1.0
#
executable           /opt/retropie/suplemmentary/runcommand/runcommand.sh
args                 0 _SYS_ msx2 "[romfilename]"
rompath              /home/pi/RetroPie/roms/msx2
romext               .zip;.msx2
system               msx2
info_source          thegamesdb.net
artwork    flyer           /home/pi/RetroPie/roms/msx2/boxart
artwork    marquee         /home/pi/RetroPie/roms/msx2/marquee
artwork    snap            /home/pi/RetroPie/roms/msx2/snap
artwork    wheel           /home/pi/RetroPie/roms/msx2/wheel

My emulators.cfg in
Code: [Select]
/opt/retropie/configs/msx2is:
Code: [Select]
lr-bluemsx = "/opt/retropie/emulators/retroarch/bin/retroarch -L /opt/retropie/libretrocores/lr-bluemsx/bluemsx_libretro.so --config /opt/retropie/configs/msx2/retroarch.cfg %ROM%"
default = "lr-bluemsx"

Thanks yo so much for your support, im becoming crazy!

9
Hi all,
when i launch any amiga game via attract mode i have this message:

No config found for system uae4all

What' am i missing?

I have installed uae4all without any error and also ive created .uae config files in rom folder for each game via https://github.com/Douggernaut/RetroPieAssistant/tree/master/Amiga

In emulationstation it works ( it opens uae4all screen ).
Thanks for your replyes

10
Hi guys
on raspberry model 3 b and last Attract Mode: Totally NO WAY to scrape mame (advance) roms Complete Name.
I tryied with all scraping services (listxml gamesdb etc. ) but STILL got ONLY rom name.
Same story for NEO GEO.
Any suggestion?
Thanks

11
General / AM + advmame-0.94.0 + glGetError 0x500
« on: November 07, 2016, 01:28:31 PM »
Hi all, every time i exit from a game emulated by advmame-0.94.0 i have this error:

glGetError 0x500
sh: 1: commandline: not found

and then i have to re-lunch attract mode.
Any suggestion please?
THANKS

12
General / AM+Daphne: AM Keeps Focus in Fill Screen Mode
« on: November 03, 2016, 12:37:42 PM »
Hi Guys im on Raspberry Pi 3 and Daphne, Attract mode keeps focus and daphe runs in background if video mode is fill screen ( but IF AND ONLY IF video mode is setted to Full screen it works ).
The problem is that i want to be able tu run it in Fill Screen and not in Full Screen. In emulationstation works with no problem.
As an alternative, is it possible to run only Daphne games in Full Screen mode?
Any help much appreciated!

13
General / Window Mode for a single game
« on: October 30, 2016, 12:04:34 PM »
Hi all, nice to meet you.
Here is my question:
Can i change in Attract mode the window mode only for ONE single game instead of a global setting for alla games?
Thanks!!

Pages: [1]