(Module, EJS)
| 1 | class EJS_GameManager { |
| 2 | constructor(Module, EJS) { |
| 3 | this.EJS = EJS; |
| 4 | this.Module = Module; |
| 5 | this.FS = this.Module.FS; |
| 6 | this.functions = { |
| 7 | restart: this.Module.cwrap("system_restart", "", []), |
| 8 | saveStateInfo: this.Module.cwrap("save_state_info", "string", []), |
| 9 | loadState: this.Module.cwrap("load_state", "number", ["string", "number"]), |
| 10 | screenshot: this.Module.cwrap("cmd_take_screenshot", "", []), |
| 11 | simulateInput: this.Module.cwrap("simulate_input", "null", ["number", "number", "number"]), |
| 12 | toggleMainLoop: this.Module.cwrap("toggleMainLoop", "null", ["number"]), |
| 13 | getCoreOptions: this.Module.cwrap("get_core_options", "string", []), |
| 14 | setVariable: this.Module.cwrap("ejs_set_variable", "null", ["string", "string"]), |
| 15 | setCheat: this.Module.cwrap("set_cheat", "null", ["number", "number", "string"]), |
| 16 | resetCheat: this.Module.cwrap("reset_cheat", "null", []), |
| 17 | toggleShader: this.Module.cwrap("shader_enable", "null", ["number"]), |
| 18 | getDiskCount: this.Module.cwrap("get_disk_count", "number", []), |
| 19 | getCurrentDisk: this.Module.cwrap("get_current_disk", "number", []), |
| 20 | setCurrentDisk: this.Module.cwrap("set_current_disk", "null", ["number"]), |
| 21 | getSaveFilePath: this.Module.cwrap("save_file_path", "string", []), |
| 22 | saveSaveFiles: this.Module.cwrap("cmd_savefiles", "", []), |
| 23 | supportsStates: this.Module.cwrap("supports_states", "number", []), |
| 24 | loadSaveFiles: this.Module.cwrap("refresh_save_files", "null", []), |
| 25 | toggleFastForward: this.Module.cwrap("toggle_fastforward", "null", ["number"]), |
| 26 | setFastForwardRatio: this.Module.cwrap("set_ff_ratio", "null", ["number"]), |
| 27 | toggleRewind: this.Module.cwrap("toggle_rewind", "null", ["number"]), |
| 28 | setRewindGranularity: this.Module.cwrap("set_rewind_granularity", "null", ["number"]), |
| 29 | toggleSlowMotion: this.Module.cwrap("toggle_slow_motion", "null", ["number"]), |
| 30 | setSlowMotionRatio: this.Module.cwrap("set_sm_ratio", "null", ["number"]), |
| 31 | getFrameNum: this.Module.cwrap("get_current_frame_count", "number", [""]), |
| 32 | setVSync: this.Module.cwrap("set_vsync", "null", ["number"]), |
| 33 | setVideoRoation: this.Module.cwrap("set_video_rotation", "null", ["number"]), |
| 34 | getVideoDimensions: this.Module.cwrap("get_video_dimensions", "number", ["string"]), |
| 35 | setKeyboardEnabled: this.Module.cwrap("ejs_set_keyboard_enabled", "null", ["number"]) |
| 36 | } |
| 37 | |
| 38 | this.writeFile("/home/web_user/.config/retroarch/retroarch.cfg", this.getRetroArchCfg()); |
| 39 | |
| 40 | this.writeConfigFile(); |
| 41 | this.initShaders(); |
| 42 | this.setupPreLoadSettings(); |
| 43 | |
| 44 | this.EJS.on("exit", () => { |
| 45 | if (!this.EJS.failedToStart) { |
| 46 | this.saveSaveFiles(); |
| 47 | this.functions.restart(); |
| 48 | this.saveSaveFiles(); |
| 49 | } |
| 50 | this.toggleMainLoop(0); |
| 51 | this.FS.unmount("/data/saves"); |
| 52 | setTimeout(() => { |
| 53 | try { |
| 54 | this.Module.abort(); |
| 55 | } catch(e) { |
| 56 | console.warn(e); |
| 57 | }; |
| 58 | }, 1000); |
| 59 | }) |
| 60 | } |
nothing calls this directly
no test coverage detected