skmp / reicast-emulator

Reicast was a multiplatform Sega Dreamcast emulator
https://reicast.emudev.org
Other
1.1k stars 345 forks source link

Building with USE_EVDEV=1 and USE_SDL=1 causes input collision/buggy gamepad input #1431

Open Teriks opened 5 years ago

Teriks commented 5 years ago

Please Note: This form is the minimum required information for submitting bugs.
Removing this form may lead to your issue being closed until it is completed.

Platform Branch Hash CIDL
Armbian OS (Tinker Board) master Hashtag (skip if unknown) No

Description of the Issue

Building with USE_EVDEV=1 and USE_SDL=1 causes input bugs due to both input systems being used simultaneously. (Or SDL input is buggy?)

The evdev input system detects a controller, and then SDL also detects a joystick. Input is received from both input systems simultaneously. (or SDL joystick input takes over?)

I am building Reicast for Tinker Board (KMS) on Armbian OS, using a makefile patch I have created. However I believe Raspberry PI and friends will encounter the same issue.

The problem is that SDL is required to create a display on these devices, so it cannot be disabled all together.

Enabling SDL causes SDL input to be initialized, which is either buggy or trampling on evdev input by processing input events at the same time.

Is there a way to disable SDL input entirely that I am missing? Maybe from the config file?

My current hack to fix this before building is: sed -i 's|input_sdl_init();||' core/linux-dist/main.cpp

My Makefile Patch:

diff --git a/shell/linux/Makefile b/shell/linux/Makefile
index aac6efb4..10c129be 100644
--- a/shell/linux/Makefile
+++ b/shell/linux/Makefile
@@ -230,6 +230,13 @@ else ifneq (,$(findstring vero4k,$(platform)))
     USE_GLES := 1
     USE_SDL := 1

+# Tinker Board KMS
+else ifneq (,$(findstring tinker,$(platform)))
+    MFLAGS += -marm -mfloat-abi=hard -march=armv7-a -mtune=cortex-a17 -mfpu=neon-vfpv4 -mfloat-abi=hard
+    ASFLAGS += -marm -mfloat-abi=hard -march=armv7-a -mtune=cortex-a17 -mfpu=neon-vfpv4 -mfloat-abi=hard
+    CFLAGS += -D GL_GLEXT_PROTOTYPES -D TARGET_BEAGLE -D TARGET_LINUX_ARMELv7 -DARM_HARDFP -fsingle-precision-constant -funsafe-math-optimizations
+    USE_GLES := 1
+    USE_SDL := 1
 else
     $(error Unknown platform)
 endif

Built with: make -C shell/linux platform=tinker

Logs Gathered

Log snippet ends near the relevant input detection messages.


Virtual cfg config:homedir=/home/tinker
Virtual cfg x11:fullscreen=1
Virtual cfg audio:backend=oss
Virtual cfg audio:disable=0
Virtual cfg config:image=/home/tinker/RetroPie/roms/dreamcast/Star Wars - Episode I - Racer v1.001 (2000)(Lucas Arts)(NTSC)(US)[!]/Star Wars - Episode I - Racer v1.001 (2000)(Lucas Arts)(NTSC)(US)[!].gdi

Config dir is: /home/tinker/.reicast/
Data dir is:   /home/tinker/.reicast/
Personality: 00C00000
Updated personality: 00800000
ARM VFP-Run Fast (NFP) enabled !
Linux paging: 4096 00001000 00000FFF
MAP 00800000 w/ 25165824
MAP 20000000 w/ 25165824
MAP 04000000 w/ 16777216
MAP 06000000 w/ 16777216
MAP 0C000000 w/ 0
A8
vmem reserve: base: 95330000, aram: b5330000, vram: 99330000, ram: A1330000
Resetting mem
Mem alloc successful!-config : invalid parameter config, format is section:key=value
wtf config is supposed to do ?
-config : invalid parameter x11, format is section:key=value
wtf x11 is supposed to do ?
-config : invalid parameter audio, format is section:key=value
wtf audio is supposed to do ?
-config : invalid parameter audio, format is section:key=value
wtf audio is supposed to do ?
-config : invalid parameter config, format is section:key=value
wtf config is supposed to do ?

libwebsockets test server - (C) Copyright 2010-2013 Andy Green <andy@warmcat.com> - licensed under LGPL2.1
Initial logging level 7
Library version: 1.3 c11b847
IPV6 not compiled in
libev support not compiled in
 static allocation: 4452 + (12 x 1024 fds) = 16740 bytes
Malformed entry on config - ignoring @ 37(ElfFile)
Malformed entry on config - ignoring @ 40(ta.HashCheckFile)
Malformed entry on config - ignoring @ 41(ta.HashLogFile)
 canonical_hostname = tinkerboard
 per-conn mem: 116 + 1554 headers + protocol rx buf
 Listening on port 5678
Created SDL Window (640x480) and GL Context successfully
Loaded /home/tinker/.reicast/data/dc_boot.bin as bootrom

Loaded /home/tinker/.reicast/data/dc_nvmem.bin as nvram

GDI : 5 tracks
file[1] "track01.bin": FAD:0, CTRL:4, SSIZE:2352, OFFSET:0
file[2] "track02.raw": FAD:753, CTRL:0, SSIZE:2352, OFFSET:0
file[3] "track03.bin": FAD:45000, CTRL:4, SSIZE:2352, OFFSET:0
file[4] "track04.raw": FAD:356454, CTRL:0, SSIZE:2352, OFFSET:0
file[5] "track05.bin": FAD:357055, CTRL:4, SSIZE:2352, OFFSET:0
gdrom: Opened image "/home/tinker/RetroPie/roms/dreamcast/Star Wars - Episode I - Racer v1.001 (2000)(Lucas Arts)(NTSC)(US)[!]/Star Wars - Episode I - Racer v1.001 (2000)(Lucas Arts)(NTSC)(US)[!].gdi"

     ARM7_TCB addr: 0x556000 | from: 0x5551dc | addr here: 0x550d5c
Using Recompiler
Initializing audio backend "oss" (Open Sound System)...
OSD: 6
Error opening /home/tinker/.reicast/data/buttons.png
sound enabled, dsp opened for write
set Frequency to 44100, return 0 (rate=44100)
set dsp to stereo (2 => 0)
set dsp to 16bits signed audio (16/16 => 0)
recSh4 Init
@@  ngen_ResetBlocks()
Freeing fpcb

     CodeCache addr: 0x6ad000 | from: 0x6ad000 | addr here: 0x6abb08
readm helpers: up to 006AD250
evdev: Trying to open device at '/dev/input/event3'
evdev: Found 'Logitech Gamepad F310' at '/dev/input/event3'
evdev: user defined custom mapping found (/home/tinker/mapping1.cfg)
evdev: reading mapping file: '/home/tinker/mapping1.cfg'
btn_a = BTN_SOUTH (304)
btn_b = BTN_EAST (305)
btn_c = BTN_THUMBL (317)
btn_d = BTN_THUMBR (318)
btn_x = BTN_NORTH (307)
btn_y = BTN_WEST (308)
WARNING: dreamcast/btn_z not configured!
btn_start = BTN_START (315)
btn_escape = BTN_SELECT (314)
WARNING: dreamcast/btn_dpad1_left not configured!
WARNING: dreamcast/btn_dpad1_right not configured!
WARNING: dreamcast/btn_dpad1_up not configured!
WARNING: dreamcast/btn_dpad1_down not configured!
WARNING: dreamcast/btn_dpad2_left not configured!
WARNING: dreamcast/btn_dpad2_right not configured!
WARNING: dreamcast/btn_dpad2_up not configured!
WARNING: dreamcast/btn_dpad2_down not configured!
btn_trigger_left = BTN_TL (310)
btn_trigger_right = BTN_TR (311)
axis_dpad1_x = ABS_HAT0X (16)
axis_dpad1_y = ABS_HAT0Y (17)
WARNING: compat/axis_dpad2_x not configured!
WARNING: compat/axis_dpad2_y not configured!
axis_x = ABS_X (0)
axis_y = ABS_Y (1)
WARNING: dreamcast/axis_trigger_left not configured!
WARNING: dreamcast/axis_trigger_right not configured!
evdev: Using 'Logitech Gamepad F310' mapping
evdev: range of axis 0 is from -32768 to 32767
evdev: range of axis 1 is from -32768 to 32767
Unsupported configuration (-1) for Maple Device, using VMU
Unsupported configuration (-1) for Maple Device, using VMU
evdev: Controller 2 disabled by config.
evdev: Controller 3 disabled by config.
evdev: Controller 4 disabled by config.
Number of Joysticks found = 1
Joystick opened
SDK: Found 'Logitech Gamepad F310' joystick with 4 axes and 13 buttons
Sh4 Reset
baka0815 commented 5 years ago

I am working on #1371 and one part of that is splitting SDL input and SDL GUI into separate defines.

The SDL input currently does not work that well, like evdev does, because there is no possibility to configure the controllers. That is also part of #1371.

Teriks commented 5 years ago

Ah, perhaps a config option to choose between evdev and SDL input at runtime might be useful as well if they are both compiled in (in addition to separating the build time option for SDL input/video).

My quick fix is working for me for now on Tinker, feel free to close this or leave open for reference.

Here's a more complete way to disable SDL input in the mean time (for others):

sed -i 's|input_sdl_init();||; s|input_sdl_handle(port);||' core/linux-dist/main.cpp
baka0815 commented 5 years ago

To make the input devices more configurable is a long-term goal of mine, but not in the near future. I leave this open for now.