MCPcopy Index your code
hub / github.com/EmulatorJS/EmulatorJS / simulateInput

Method simulateInput

data/src/GameManager.js:248–292  ·  view source on GitHub ↗
(player, index, value)

Source from the content-addressed store, hash-verified

246 })();
247 }
248 simulateInput(player, index, value) {
249 if (this.EJS.isNetplay) {
250 this.EJS.netplay.simulateInput(player, index, value);
251 return;
252 }
253 if ([24, 25, 26, 27, 28, 29].includes(index)) {
254 if (index === 24 && value === 1) {
255 const slot = this.EJS.settings["save-state-slot"] ? this.EJS.settings["save-state-slot"] : "1";
256 if (this.quickSave(slot)) {
257 this.EJS.displayMessage(this.EJS.localization("SAVED STATE TO SLOT") + " " + slot);
258 } else {
259 this.EJS.displayMessage(this.EJS.localization("FAILED TO SAVE STATE"));
260 }
261 }
262 if (index === 25 && value === 1) {
263 const slot = this.EJS.settings["save-state-slot"] ? this.EJS.settings["save-state-slot"] : "1";
264 this.quickLoad(slot);
265 this.EJS.displayMessage(this.EJS.localization("LOADED STATE FROM SLOT") + " " + slot);
266 }
267 if (index === 26 && value === 1) {
268 let newSlot;
269 try {
270 newSlot = parseFloat(this.EJS.settings["save-state-slot"] ? this.EJS.settings["save-state-slot"] : "1") + 1;
271 } catch(e) {
272 newSlot = 1;
273 }
274 if (newSlot > 9) newSlot = 1;
275 this.EJS.displayMessage(this.EJS.localization("SET SAVE STATE SLOT TO") + " " + newSlot);
276 this.EJS.changeSettingOption("save-state-slot", newSlot.toString());
277 }
278 if (index === 27) {
279 this.functions.toggleFastForward(this.EJS.isFastForward ? !value : value);
280 }
281 if (index === 29) {
282 this.functions.toggleSlowMotion(this.EJS.isSlowMotion ? !value : value);
283 }
284 if (index === 28) {
285 if (this.EJS.rewindEnabled) {
286 this.functions.toggleRewind(value);
287 }
288 }
289 return;
290 }
291 this.functions.simulateInput(player, index, value);
292 }
293 getFileNames() {
294 if (this.EJS.getCore() === "picodrive") {
295 return ["bin", "gen", "smd", "md", "32x", "cue", "iso", "sms", "68k", "chd"];

Callers 4

keyChangeMethod · 0.80
gamepadEventMethod · 0.80
setVirtualGamepadMethod · 0.80

Calls 6

quickSaveMethod · 0.95
quickLoadMethod · 0.95
displayMessageMethod · 0.80
localizationMethod · 0.80
toggleFastForwardMethod · 0.80
toggleSlowMotionMethod · 0.80

Tested by

no test coverage detected