Previous Thread
Next Thread
Print Thread
Joined: Jul 2013
Posts: 10
L
Member
OP Offline
Member
L
Joined: Jul 2013
Posts: 10
Hello everybody,

I have a little problem with mame (worries that does not seem related to the mame version) and my gamepad.

I'm using linux (gentoo) and I use mame with a CRT television to launch my games in their original resolution.

To achieve this, I use 2 techniques :
1) change the resolution of the current session
2) start a new xorg session, change its resolution, and start the game in this new session

My problem is that in case 1, my gamepad is functional while in case 2, it does not work.

Here is how I launch my 2 cases

1)
Quote:
/home/globule/bin/15khz "$MODELINE" /home/globule/mame/mame0180/mame64 -v -inipath /home/globule/mame/data $GAME


2)
Quote:
xinit /home/globule/bin/15khz "$MODELINE" /home/globule/mame/mame0180/mame64 -v -inipath /home/globule/mame/data $GAME -- :1 -nocursor -nolisten tcp -br


(15khz is just a small shell script that activates the modeline MODELINE on the current display and then launches my mame command)

The outputs of my 2 tests are identical :

Quote:
INFO: Computed modeline 6.545453 344 352 384 416 240 245 248 262 -HSync -VSync
INFO: Applied modeline
Available videodrivers: x11 dummy
Current Videodriver: x11
Display #0
Renderdrivers:
opengl (0x0)
software (0x0)
Available audio drivers:
alsa
disk
dummy
Build version: 0.180 (unknown)
Build architecure:
Build defines 1: SDLMAME_UNIX=1 SDLMAME_X11=1 SDLMAME_LINUX=1
Build defines 1: LSB_FIRST=1 PTR64=1
SDL/OpenGL defines: SDL_COMPILEDVERSION=2004 USE_OPENGL=1
Compiler defines A: __GNUC__=5 __GNUC_MINOR__=4 __GNUC_PATCHLEVEL__=0 __VERSION__="5.4.0"
Compiler defines B: __amd64__=1 __x86_64__=1 __unix__=1
Compiler defines C: __USE_FORTIFY_LEVEL=0
Enter init_monitors
Adding monitor screen0 (344 x 240)
Leave init_monitors
Enter sdlwindow_init
Using SDL multi-window OpenGL driver (SDL 2.0+)

Hints:
SDL_FRAMEBUFFER_ACCELERATION (null)
SDL_RENDER_DRIVER (null)
SDL_RENDER_OPENGL_SHADERS (null)
SDL_RENDER_SCALE_QUALITY (null)
SDL_RENDER_VSYNC (null)
SDL_VIDEO_X11_XVIDMODE (null)
SDL_VIDEO_X11_XINERAMA (null)
SDL_VIDEO_X11_XRANDR (null)
SDL_GRAB_KEYBOARD (null)
SDL_VIDEO_MINIMIZE_ON_FOCUS_LOSS (null)
SDL_IOS_IDLE_TIMER_DISABLED (null)
SDL_IOS_ORIENTATIONS (null)
SDL_XINPUT_ENABLED (null)
SDL_GAMECONTROLLERCONFIG (null)
SDL_JOYSTICK_ALLOW_BACKGROUND_EVENTS (null)
SDL_ALLOW_TOPMOST (null)
SDL_TIMER_RESOLUTION (null)
SDL_RENDER_DIRECT3D_THREADSAFE (null)
SDL_VIDEO_ALLOW_SCREENSAVER (null)
SDL_ACCELEROMETER_AS_JOYSTICK (null)
SDL_MAC_CTRL_CLICK_EMULATE_RIGHT_CLICK (null)
SDL_VIDEO_WIN_D3DCOMPILER (null)
SDL_VIDEO_WINDOW_SHARE_PIXEL_FORMAT (null)
SDL_VIDEO_MAC_FULLSCREEN_SPACES (null)
SDL_MOUSE_RELATIVE_MODE_WARP (null)
SDL_RENDER_DIRECT3D11_DEBUG (null)
SDL_VIDEO_HIGHDPI_DISABLED (null)
SDL_WINRT_PRIVACY_POLICY_URL (null)
SDL_WINRT_PRIVACY_POLICY_LABEL (null)
SDL_WINRT_HANDLE_BACK_BUTTON (null)
Leave sdlwindow_init
Enter sdl_info::create
OpenGL: nouveau
OpenGL: Gallium 0.4 on NVA8
OpenGL: 3.0 Mesa 12.0.1
OpenGL: texture rectangle supported
OpenGL: non-power-of-2 textures supported (new method)
OpenGL: vertex buffer supported
OpenGL: pixel buffers supported
OpenGL: framebuffer object supported
OpenGL: GLSL supported, but disabled
OpenGL: max texture size 8192 x 8192
Leave renderer_ogl::create
Audio: Start initialization
Audio: Driver is alsa
Audio: frequency: 48000, channels: 2, samples: 1024
sdl_create_buffers: creating stream buffer of 25600 bytes
Audio: End initialization
Keyboard: Start initialization
Input: Adding keyboard #0: System keyboard (device id: System keyboard)
Keyboard: Registered System keyboard
Keyboard: End initialization
Mouse: Start initialization
Input: Adding mouse #0: System mouse (device id: System mouse)
Mouse: Registered System mouse
Mouse: End initialization
Joystick: Start initialization
Input: Adding joystick #0: USB,2-axis8-buttongamepad (device id: USB,2-axis8-buttongamepad)
Joystick: USB,2-axis 8-button gamepad
Joystick: ... 2 axes, 8 buttons 0 hats 0 balls
Joystick: ... Physical id 0 mapped to logical id 1
Joystick: End initialization
Searching font Liberation Sans in -/home/globule/mame/data path/s
font Liberation Sans|Regular is not TrueType or BDF, using MAME default
OpenGL: VBO supported
OpenGL: PBO supported
OpenGL: FBO supported
OpenGL: using vid filter: 0
Region ':cslot1:maincpu' created
unzip: opened archive file /home/globule/mame/roms_mame/mslug.zip


We can see the joystick detection :
Quote:
Input: Adding joystick #0: USB,2-axis8-buttongamepad (device id: USB,2-axis8-buttongamepad)
Joystick: USB,2-axis 8-button gamepad
Joystick: ... 2 axes, 8 buttons 0 hats 0 balls
Joystick: ... Physical id 0 mapped to logical id 1
Joystick: End initialization


And the diff between both cases :

Quote:
--- trace_15khz 2016-12-06 09:11:43.614052726 +0100
+++ trace_15khz_xinit 2016-12-06 09:12:23.414049210 +0100
@@ -225,7 +225,7 @@
scale 1x1, border 0, pitch 384,320/8192], bytes/pix 4
GL texture: copy 0, shader 0, dynamic 0, 320x224 320x224 [RGB32, Equal: 1, Palette: 0,
scale 1x1, border 0, pitch 384,320/8192], bytes/pix 4
-Average speed: 101.46% (6 seconds)
+Average speed: 101.46% (7 seconds)
sdl_kill: closing audio
Sound buffer: overflows=5 underflows=0
Enter sdlwindow_exit


Do you have any idea why my gamepad is not functional in case 2 ?

Thank you very much !

PS : I use the second technique (new xorg session) with other emulators without any worries of gamepad.

Last edited by LA GLOBULE; 12/06/16 08:43 AM.
Joined: Apr 2015
Posts: 387
E
Senior Member
Offline
Senior Member
E
Joined: Apr 2015
Posts: 387
Hi,

Joystick problems in MAME are likely related to SDL. Even though
SDL_COMPILEDVERSION=2004, what does 'sdl2-config --version' say?

In case your gamepad is wireless (and since it's 2016, there's a good chance it is), it may also be worth the trouble to check your kernel version (uname -r) - support for my gamepad (Sony Dualshock 4) improved drastically after upgrading to 4.7.x

While in second mode, you could try 'jstest' to see if your gamepad works. In Debian land, this program is part of the 'joystick' package.

But since MAME (and only MAME strangely) was still having problems recognizing certain button presses consistently in my case, I resorted to a program called MoltenGamepad (https://github.com/jgeumlek/MoltenGamepad), which resolved all problems for me.

Good luck!

Joined: Jul 2013
Posts: 10
L
Member
OP Offline
Member
L
Joined: Jul 2013
Posts: 10
I have version 2.0.4 of the libsdl2.

My gamepad is not wireless, and jstest detect without worries my gamepad events (in both cases).

Quote:
12:26:11 [mamebox] globule /dev/input $ ll
total 0
0 drwxr-xr-x 2 root root 80 Dec 6 12:22 by-id
0 drwxr-xr-x 2 root root 140 Dec 6 12:22 by-path
0 crw-rw---- 1 root input 13, 64 Dec 6 12:22 event0
0 crw-rw---- 1 root input 13, 65 Dec 6 12:22 event1
0 crw-rw---- 1 root input 13, 66 Dec 6 12:22 event2
0 crw-rw---- 1 root input 13, 67 Dec 6 12:22 event3
0 crw-rw---- 1 root input 13, 68 Dec 6 12:22 event4
0 crw-rw-r-- 1 root input 13, 0 Dec 6 12:22 js0
0 crw-rw---- 1 root input 13, 63 Dec 6 12:22 mice
0 crw-rw---- 1 root input 13, 32 Dec 6 12:22 mouse0

12:26:12 [mamebox] globule /dev/input $ ll by-id/
total 0
0 lrwxrwxrwx 1 root root 9 Dec 6 12:22 usb-0583_USB_2-axis_8-button_gamepad-event-joystick -> ../event4
0 lrwxrwxrwx 1 root root 6 Dec 6 12:22 usb-0583_USB_2-axis_8-button_gamepad-joystick -> ../js0

12:26:18 [mamebox] globule /dev/input $ ll by-path/
total 0
0 lrwxrwxrwx 1 root root 9 Dec 6 12:22 pci-0000:00:1a.2-usb-0:2:1.0-event-joystick -> ../event4
0 lrwxrwxrwx 1 root root 6 Dec 6 12:22 pci-0000:00:1a.2-usb-0:2:1.0-joystick -> ../js0
0 lrwxrwxrwx 1 root root 9 Dec 6 12:22 platform-i8042-serio-0-event-kbd -> ../event2
0 lrwxrwxrwx 1 root root 9 Dec 6 12:22 platform-i8042-serio-1-event-mouse -> ../event3
0 lrwxrwxrwx 1 root root 9 Dec 6 12:22 platform-i8042-serio-1-mouse -> ../mouse0


All seems correct frown

I will try MoltenGamepad, I would tell you if I have succeeded.

Thank you.

Joined: Jul 2013
Posts: 10
L
Member
OP Offline
Member
L
Joined: Jul 2013
Posts: 10
I give up...

All software using SDL2 works without problem, except mame smirk

Last edited by LA GLOBULE; 12/12/16 09:04 PM.
Joined: Jul 2013
Posts: 10
L
Member
OP Offline
Member
L
Joined: Jul 2013
Posts: 10
I found the solution smile

After reading some c++ code files (osd/modules/input/) and after writing some printf trace, i have understand something.

Without window focus, mame doesn't poll the joystick event.

If i force the window focus (as could be done with a window manager), my gamepad work fine on case 2 smile

Joined: Mar 2001
Posts: 16,910
Likes: 56
R
Very Senior Member
Offline
Very Senior Member
R
Joined: Mar 2001
Posts: 16,910
Likes: 56
Ahh, that's interesting. I'll talk to our input guy Brad about that.

Joined: Apr 2015
Posts: 387
E
Senior Member
Offline
Senior Member
E
Joined: Apr 2015
Posts: 387
Good catch.

What's odd is that you didn't mention keyboard problems while running MAME in a dedicated xorg session, so window focus doesn't appear to be a problem in that case.

Joined: Jul 2013
Posts: 10
L
Member
OP Offline
Member
L
Joined: Jul 2013
Posts: 10
My keyboard was running fine during my dedicated xorg session (I could play game with him without any problem).

I "have handling" the problem with a little bash script (launch in background just before launching MAME in my dedicated xorg session) :

Quote:
#!/bin/bash

# MAME start an OpenGL test before launch game
sleep 1

while true;
do
WINDOW_ID=`DISPLAY=:1 xwininfo -root -children | grep -A1 'child' | grep -v 'child' | cut -d ' ' -f6`
if [ -n "${WINDOW_ID}" ]
then
echo "Window found : ${WINDOW_ID} - set focus"
DISPLAY=:1 xdotool windowfocus ${WINDOW_ID}
exit
fi
done


It's not sexy, but with this, all works fine for me (I don't have the C++ knowledge to patch directly MAME.)

Last edited by LA GLOBULE; 12/13/16 08:41 AM.
Joined: Apr 2015
Posts: 387
E
Senior Member
Offline
Senior Member
E
Joined: Apr 2015
Posts: 387
What's also odd is that, in a regular window-managed xsession, MAME doesn't even need focus to pick up gamepad input, while it does need focus for keyboard input, which is the expected behavior. In fact, I need to explicitly toggle joystick input on my desktop media player whenever I launch MAME or any other game that uses the joystick.


Link Copied to Clipboard
Who's Online Now
0 members (), 26 guests, and 2 robots.
Key: Admin, Global Mod, Mod
ShoutChat
Comment Guidelines: Do post respectful and insightful comments. Don't flame, hate, spam.
Forum Statistics
Forums9
Topics9,085
Posts119,077
Members5,014
Most Online890
Jan 17th, 2020
Our Sponsor
These forums are sponsored by Superior Solitaire, an ad-free card game collection for macOS and iOS. Download it today!

Superior Solitaire
Forum hosted by www.retrogamesformac.com