Preface
In my previous article, I introduced the detailed steps of how to deploy a web-based retro game emulator based on emulatorjs's docker (see article:Use docker to deploy web-side nostalgic game emulator based on emulatorjs), but in the end there is a problem that affects the gaming experience, that is, the default key configuration is unreasonable: the up, down, left, right and right arrow keys are controlled by the four keys ↑ ↓ ← → on the right side of the full keyboard, while the regular AB keys (jump, bullet) are pressed by the X and Z keys on the leftmost side of the full keyboard. For most people, the direction is controlled by the left hand, and the jump and bullet are controlled by the right hand. Doesn't this require playing with both hands? Is this tolerable?
So I did some research and tried to modify the default configuration by modifying the key mapping in the emu-main.js file, but failed. It seems that I also need to modify the loading order of emu-main.js and emulator.js in the loader.js file, so that emulator.js should be loaded before emu-main.js. I studied it for a long time but couldn't figure it out. The disadvantage of not having a programming background was fully demonstrated... So I had to change my thinking and start from the perspective of the profile configuration file, and finally solved the problem.
Ideas
默认情况下,当你使用浏览器访问前端游戏web页面的时候,如果通过F1键进入RetroArch模拟器的配置界面并通过”Settings”-“Input”选项设置一次并保存以后,其他游戏也可以使用这个按键设置,不过前提是通过同一个浏览器访问,因为配置文件(retroarch.cfg)是和浏览器绑定的(其实还有访问的网址,严格意义上来说应该是和浏览器以及访问的网址绑定)。那么,只要能让配置文件不只存放在一个浏览器”本地”,还能”同步”到相同机器的不同浏览器,甚至不同机器的不同浏览器,就能实现按键配置跟随了。那么怎么解决这个关键问题呢?那就是profile(配置文件)。
So in fact, it is just like logging in to a specific account and then pulling the configuration. Default only pulls the configuration without logging in, so it does not actually implement the underlying modification of the default configuration, but still implements it indirectly through configuration file synchronization.