From 14ca83ddceb8fde39908baf11280698836c2288f Mon Sep 17 00:00:00 2001 From: Alexey Nurgaliev Date: Fri, 4 Aug 2023 19:24:06 +0300 Subject: [PATCH] segaMS, segaGG, segaSaturn controls and virtual gamepad + segaMD virtual gamepad update + gb controls --- data/emulator.js | 94 ++++++++++++++++++++++++++++++++++++++++++-- data/emulator.min.js | 2 +- 2 files changed, 92 insertions(+), 4 deletions(-) diff --git a/data/emulator.js b/data/emulator.js index 3caac9a..ad10f34 100644 --- a/data/emulator.js +++ b/data/emulator.js @@ -1774,7 +1774,7 @@ class EmulatorJS { body.classList.add("ejs_control_body"); let buttons; - if ('nes' === this.getCore(true)) { + if (['nes', 'gb'] === this.getCore(true)) { buttons = [ {id: 8, label: 'A'}, {id: 0, label: 'B'}, @@ -1867,6 +1867,50 @@ class EmulatorJS { {id: 25, label: this.localization('QUICK LOAD STATE')}, {id: 26, label: this.localization('CHANGE STATE SLOT')}, ]; + } else if ('segaMS' === this.getCore(true)) { + buttons = [ + {id: 0, label: 'BUTTON 1 / START'}, + {id: 8, label: 'BUTTON 2'}, + {id: 4, label: 'UP'}, + {id: 5, label: 'DOWN'}, + {id: 6, label: 'LEFT'}, + {id: 7, label: 'RIGHT'}, + {id: 24, label: this.localization('QUICK SAVE STATE')}, + {id: 25, label: this.localization('QUICK LOAD STATE')}, + {id: 26, label: this.localization('CHANGE STATE SLOT')}, + ]; + } else if ('segaGG' === this.getCore(true)) { + buttons = [ + {id: 0, label: 'BUTTON 1'}, + {id: 8, label: 'BUTTON 2'}, + {id: 3, label: 'START'}, + {id: 4, label: 'UP'}, + {id: 5, label: 'DOWN'}, + {id: 6, label: 'LEFT'}, + {id: 7, label: 'RIGHT'}, + {id: 24, label: this.localization('QUICK SAVE STATE')}, + {id: 25, label: this.localization('QUICK LOAD STATE')}, + {id: 26, label: this.localization('CHANGE STATE SLOT')}, + ]; + } else if ('segaSaturn' === this.getCore(true)) { + buttons = [ + {id: 1, label: 'A'}, + {id: 0, label: 'B'}, + {id: 8, label: 'C'}, + {id: 9, label: 'X'}, + {id: 10, label: 'Y'}, + {id: 11, label: 'Z'}, + {id: 12, label: 'L'}, + {id: 13, label: 'R'}, + {id: 3, label: 'START'}, + {id: 4, label: 'UP'}, + {id: 5, label: 'DOWN'}, + {id: 6, label: 'LEFT'}, + {id: 7, label: 'RIGHT'}, + {id: 24, label: this.localization('QUICK SAVE STATE')}, + {id: 25, label: this.localization('QUICK LOAD STATE')}, + {id: 26, label: this.localization('CHANGE STATE SLOT')}, + ]; } else { buttons = [ {id: 0, label: 'B'}, @@ -2349,9 +2393,53 @@ class EmulatorJS { } else if (this.getCore(true) === "snes") { info = [{"type":"button","text":"X","id":"x","location":"right","left":40,"bold":true,"input_value":9},{"type":"button","text":"Y","id":"y","location":"right","top":40,"bold":true,"input_value":1},{"type":"button","text":"A","id":"a","location":"right","left":81,"top":40,"bold":true,"input_value":8},{"type":"button","text":"B","id":"b","location":"right","left":40,"top":80,"bold":true,"input_value":0},{"type":"dpad","location":"left","left":"50%","top":"50%","joystickInput":false,"inputValues":[4,5,6,7]},{"type":"button","text":"Start","id":"start","location":"center","left":60,"fontSize":15,"block":true,"input_value":3},{"type":"button","text":"Select","id":"select","location":"center","left":-5,"fontSize":15,"block":true,"input_value":2},{"type":"button","text":"L","id":"l","location":"left","left":3,"top":-100,"bold":true,"block":true,"input_value":10},{"type":"button","text":"R","id":"r","location":"right","right":3,"top":-100,"bold":true,"block":true,"input_value":11}]; } else if (['segaMD', 'segaCD', 'sega32x'].includes(this.getCore(true))) { - info = [{"type":"button","text":"A","id":"a","location":"right","right":130,"top":70,"bold":true,"input_value":9}, {"type":"button","text":"B","id":"b","location":"right","right":60,"top":70,"bold":true,"input_value":0}, {"type":"button","text":"C","id":"c","location":"right","right":-10,"top":70,"bold":true,"input_value":8}, {"type":"button","text":"X","id":"x","location":"right","right":130,"top":0,"bold":true,"input_value":10}, {"type":"button","text":"Y","id":"y","location":"right","right":60,"top":0,"bold":true,"input_value":9}, {"type":"button","text":"Z","id":"z","location":"right","right":-10,"top":0,"bold":true,"input_value":11}, {"type":"dpad","location":"left","left":"50%","right":"50%","joystickInput":false,"inputValues":[4,5,6,7]}, {"type":"button","text":"Start","id":"start","location":"center","left":30,"fontSize":15,"block":true,"input_value":3}]; + info = [ + {"type":"button","text":"A","id":"a","location":"right","right":145,"top":70,"bold":true,"input_value":9}, + {"type":"button","text":"B","id":"b","location":"right","right":75,"top":70,"bold":true,"input_value":0}, + {"type":"button","text":"C","id":"c","location":"right","right":5,"top":70,"bold":true,"input_value":8}, + {"type":"button","text":"X","id":"x","location":"right","right":145,"top":0,"bold":true,"input_value":10}, + {"type":"button","text":"Y","id":"y","location":"right","right":75,"top":0,"bold":true,"input_value":9}, + {"type":"button","text":"Z","id":"z","location":"right","right":5,"top":0,"bold":true,"input_value":11}, + {"type":"dpad","location":"left","left":"50%","right":"50%","joystickInput":false,"inputValues":[4,5,6,7]}, + {"type":"button","text":"Mode","id":"mode","location":"center","left":-5,"fontSize":15,"block":true,"input_value":2}, + {"type":"button","text":"Start","id":"start","location":"center","left":60,"fontSize":15,"block":true,"input_value":3} + ]; + } else if ("segaMS" === this.getCore(true)) { + info = [ + {"type":"button","text":"1","id":"button1","location":"right","left":10,"top":40,"bold":true,"input_value":0}, + {"type":"button","text":"2","id":"button2","location":"right","left":81,"top":40,"bold":true,"input_value":8}, + {"type":"dpad","location":"left","left":"50%","right":"50%","joystickInput":false,"inputValues":[4,5,6,7]} + ]; + } else if ("segaGG" === this.getCore(true)) { + info = [ + {"type":"button","text":"1","id":"button1","location":"right","left":10,"top":70,"bold":true,"input_value":0}, + {"type":"button","text":"2","id":"button2","location":"right","left":81,"top":40,"bold":true,"input_value":8}, + {"type":"dpad","location":"left","left":"50%","top":"50%","joystickInput":false,"inputValues":[4,5,6,7]}, + {"type":"button","text":"Start","id":"start","location":"center","left":30,"fontSize":15,"block":true,"input_value":3} + ]; + } else if ("segaSaturn" === this.getCore(true)) { + info = [ + {"type":"button","text":"A","id":"a","location":"right","right":145,"top":70,"bold":true,"input_value":1}, + {"type":"button","text":"B","id":"b","location":"right","right":75,"top":70,"bold":true,"input_value":0}, + {"type":"button","text":"C","id":"c","location":"right","right":5,"top":70,"bold":true,"input_value":8}, + {"type":"button","text":"X","id":"x","location":"right","right":145,"top":0,"bold":true,"input_value":9}, + {"type":"button","text":"Y","id":"y","location":"right","right":75,"top":0,"bold":true,"input_value":10}, + {"type":"button","text":"Z","id":"z","location":"right","right":5,"top":0,"bold":true,"input_value":11}, + {"type":"dpad","location":"left","left":"50%","right":"50%","joystickInput":false,"inputValues":[4,5,6,7]}, + {"type":"button","text":"L","id":"l","location":"center","left":-60,"top":-10,"bold":true,"input_value":12}, + {"type":"button","text":"R","id":"r","location":"center","left":120,"top":-10,"bold":true,"input_value":13}, + {"type":"button","text":"Start","id":"start","location":"center","left":30,"fontSize":15,"block":true,"input_value":3} + ]; } else { - info = [{"type":"button","text":"Y","id":"y","location":"right","left":40,"bold":true,"input_value":9},{"type":"button","text":"X","id":"X","location":"right","top":40,"bold":true,"input_value":1},{"type":"button","text":"B","id":"b","location":"right","left":81,"top":40,"bold":true,"input_value":8},{"type":"button","text":"A","id":"a","location":"right","left":40,"top":80,"bold":true,"input_value":0},{"type":"zone","location":"left","left":"50%","top":"50%","joystickInput":false,"inputValues":[4,5,6,7]},{"type":"button","text":"Start","id":"start","location":"center","left":60,"fontSize":15,"block":true,"input_value":3},{"type":"button","text":"Select","id":"select","location":"center","left":-5,"fontSize":15,"block":true,"input_value":2}]; + info = [ + {"type":"button","text":"Y","id":"y","location":"right","left":40,"bold":true,"input_value":9}, + {"type":"button","text":"X","id":"X","location":"right","top":40,"bold":true,"input_value":1}, + {"type":"button","text":"B","id":"b","location":"right","left":81,"top":40,"bold":true,"input_value":8}, + {"type":"button","text":"A","id":"a","location":"right","left":40,"top":80,"bold":true,"input_value":0}, + {"type":"zone","location":"left","left":"50%","top":"50%","joystickInput":false,"inputValues":[4,5,6,7]}, + {"type":"button","text":"Start","id":"start","location":"center","left":60,"fontSize":15,"block":true,"input_value":3}, + {"type":"button","text":"Select","id":"select","location":"center","left":-5,"fontSize":15,"block":true,"input_value":2} + ]; } info = JSON.parse(JSON.stringify(info)); diff --git a/data/emulator.min.js b/data/emulator.min.js index fe5e363..40825bf 100644 --- a/data/emulator.min.js +++ b/data/emulator.min.js @@ -1 +1 @@ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("nipplejs",[],t):"object"==typeof exports?exports.nipplejs=t():e.nipplejs=t()}(window,function(){return n=[function(e,t,n){"use strict";n.r(t);function _(e,t){var n=t.x-e.x,t=t.y-e.y;return Math.sqrt(n*n+t*t)}function T(e){return e*(Math.PI/180)}function o(e){f.has(e)&&clearTimeout(f.get(e)),f.set(e,setTimeout(e,100))}function s(e,t,n){for(var i,o=t.split(/[ ,]+/g),s=0;sthis.options.threshold){var r,l={};for(r in this.direction)this.direction.hasOwnProperty(r)&&(l[r]=this.direction[r]);var c={};for(r in this.direction={x:n,y:i,angle:t},e.direction=this.direction,l)l[r]===this.direction[r]&&(c[r]=!0);if(c.x&&c.y&&c.angle)return e;c.x&&c.y||this.trigger("plain",e),c.x||this.trigger("plain:"+n,e),c.y||this.trigger("plain:"+i,e),c.angle||this.trigger("dir dir:"+t,e)}else this.resetDirection();return e};var x=w;function E(e,t){this.nipples=[],this.idles=[],this.actives=[],this.ids=[],this.pressureIntervals={},this.manager=e,this.id=E.id,E.id+=1,this.defaults={zone:document.body,multitouch:!1,maxNumberOfNipples:10,mode:"dynamic",position:{top:0,left:0},catchDistance:200,size:100,threshold:.1,color:"white",fadeTime:250,dataOnly:!1,restJoystick:!0,restOpacity:.5,lockX:!1,lockY:!1,shape:"circle",dynamicPage:!1,follow:!1},this.config(t),"static"!==this.options.mode&&"semi"!==this.options.mode||(this.options.multitouch=!1),this.options.multitouch||(this.options.maxNumberOfNipples=1);e=getComputedStyle(this.options.zone.parentElement);return e&&"flex"===e.display&&(this.parentIsFlex=!0),this.updateBox(),this.prepareNipples(),this.bindings(),this.begin(),this.nipples}E.prototype=new m,(E.constructor=E).id=0,E.prototype.prepareNipples=function(){var i=this.nipples;i.on=this.on.bind(this),i.off=this.off.bind(this),i.options=this.options,i.destroy=this.destroy.bind(this),i.ids=this.ids,i.id=this.id,i.processOnMove=this.processOnMove.bind(this),i.processOnEnd=this.processOnEnd.bind(this),i.get=function(e){if(void 0===e)return i[0];for(var t=0,n=i.length;t