omf2097 / openomf

One Must Fall 2097 Remake
http://www.openomf.org
MIT License
362 stars 35 forks source link

Demo mode can't be stopped with using only gamepads / joysticks #499

Open joyrider3774 opened 7 months ago

joyrider3774 commented 7 months ago

Hi,

It would seem demo mode where the cpu's fight each other, can't be stopped if the only input device is a game pad / joystick.

I don't know if this was also the case in the original game, but i though i'd mention it. I was testing using latest git on a RG35XX handheld which only had gamecontroller support (i edited the conf files to be able to control game) but it seems at least the demo mode i can't seem to exit using a gamecontroller only

katajakasa commented 7 months ago

Unfortunately I don't have a handheld or gamepad to test this with. Can you copypaste your mappings from the config file, and the start of the logfile (from start until "--- BEGIN GAME LOG ---") ?

joyrider3774 commented 7 months ago

i could not control the game initially (no keyboard) but i knew the name of gamepad so edited the config to only change the joy_name1 , ctrl_type1and joy_offset1 value, i did not change anything else. I can play the game fine and everything seems to work except i can't quit demo mode using the gamepad only almost seemingly as if a check on it is missing but not sure how it is all mapped internally

ctrl_type1=1
joy_name1="Deeplay-keys"
joy_offset1=0
key1_jump_up="Up"
key1_jump_right="PageUp"
key1_walk_right="Right"
key1_duck_forward="PageDown"
key1_duck="Down"
key1_duck_back="End"
key1_walk_back="Left"
key1_jump_left="Home"
key1_kick="Right Shift"
key1_punch="Return"
key1_escape="Escape"             

i also provided a gamecontrollerdb.txt file in share/games/openomf containing these values

[root@buildroot /userdata/ROMS/Ports/OpenOMF/share/games/openomf]# grep "keys" ./gamecontrollerdb.txt
19000000010000000100000000010000,Deeplay-keys,a:b3,b:b4,x:b6,y:b5,leftshoulder:b7,rightshoulder:b8,lefttrigger:b13,righttrigger:b14,guide:b9,start:b10,back:b11,dpup:h0.1,dpleft:h0.8,dpright:h0.2,dpdown:h0.4,volumedown:b1,volumeup:b2,leftx:a0,lefty:a1,leftstick:b12,rightx:a2,righty:a3,rightstick:b15,platform:Linux,
[root@buildroot /userdata/ROMS/Ports/OpenOMF/share/games/openomf]#

requested log entry:

[root@buildroot /userdata/ROMS/Ports/OpenOMF/.local/share/openomfproject/OpenOMF]# cat openomf.log
[      0][I] Starting OpenOMF v0.6.6
[      0][I] Git SHA1 hash: 4287067184d9f16d02035f6cf0abcafb0f9755be
[      0][I] Configfile read!
[      0][I] Looking for plugins ...
[      0][E] Error while attempting to open plugin directory.
[      0][I] Found SDL v2.28.4
[      0][I] Running on platform: Linux
[      0][I] Loaded built-in controller mappings
[      0][I] We currently have 498 known game controller mappings
[      0][I] Loaded external game controller mappings from /userdata/roms/ports/OpenOMF/bin/../share/games/openomf/gamecontrollerdb.txt
[      0][I] We have 498 known game controller mappings
[      0][I] Found 1 joysticks attached
[      0][I] Opened Joystick 0
[      0][I]  * Name:              Deeplay-keys
[      0][I]  * Number of Axes:    4
[      0][I]  * Number of Buttons: 17
[      0][I]  * Number of Balls:   0
[      0][I]  * Number of Hats:    1
[      0][I]  * GUID          :    19000000010000000100000000010000
[      0][I] Video Init OK
[      0][I]  * Driver: mali
[      0][I]  * Renderer: opengles2
[      0][I]  * Accelerated: Yes
[      0][I]  * VSync support: Yes
[      0][I]  * Target support: Yes
[      0][I] Using audio sink 'openal'.
[      0][I] OpenAL Audio Sink:
[      0][I]  * Vendor:      OpenAL Community
[      0][I]  * Renderer:    OpenAL Soft
[      0][I]  * Version:     1.1 ALSOFT 1.22.0
[      0][I] Audio system initialized.
[      0][I] Loaded sounds file '/userdata/roms/ports/OpenOMF/bin/../share/games/openomf/SOUNDS.DAT'.
[      0][I] Loaded language file '/userdata/roms/ports/OpenOMF/bin/../share/games/openomf/ENGLISH.DAT'.
[      0][I] Loaded font file '/userdata/roms/ports/OpenOMF/bin/../share/games/openomf/CHARSMAL.DAT'
[      0][I] Loaded font file '/userdata/roms/ports/OpenOMF/bin/../share/games/openomf/GRAPHCHR.DAT'
[      0][I] Loaded altpals file '/userdata/roms/ports/OpenOMF/bin/../share/games/openomf/ALTPALS.DAT'.
[      0][I] Engine initialization successful.
[      0][I]  --- BEGIN GAME LOG ---
joyrider3774 commented 7 months ago

I looked through the code, and found the issue, the ESCAPE key in demo is handled here but only explicit keyboard input is handled here no gamepad at all and thats why you can not exit demo if using gamepads / joysticks only. see https://github.com/omf2097/openomf/blob/05ade32f50077eac25a1baf588a8b891a3844974/src/game/scenes/arena.c#L1036 it needs a part added for gamepad controls as well

katajakasa commented 7 months ago

Right. This issue is due to the normal input code only accepting escape input from player one. Since player one is a computer in demo mode, this hack was added to get out (when using keyboard). There was no similar out added for game controllers.

To fix, this requires changes to arena_handle_events(). Another ticket to backlog.