Exemple #1
0
        private void DoMouseAnalog(int idx, int player)
        {
            ControllerDef.AddXYPair($"P{player} Mouse {{0}}", AxisPairOrientation.RightAndUp, (-256).RangeTo(255), 0);             //TODO verify direction against hardware
            var nx = $"P{player} Mouse X";
            var ny = $"P{player} Mouse Y";

            _converts.Add(() =>
            {
                _target.analog[(2 * idx) + 0] = (short)_source.AxisValue(nx);
                _target.analog[(2 * idx) + 1] = (short)_source.AxisValue(ny);
            });
        }
Exemple #2
0
        private void DoMouseAnalog(int idx, int player)
        {
            // In "Genesis Technical Bulletin #27" (last seen at http://techdocs.exodusemulator.com/Console/SegaMegaDrive/Documentation.html), some example code for the Genesis is given which describes the 32 bits of Mouse data:
            // ` ignored YXYX     XXXXXXXX YYYYYYYY`
            // `0-------_oossCMRL_########_########`
            // Each axis is represented as 10 bits: 1 `s` bit for sign, 8 bits for the value, and 1 `o` bit indicating whether the value fell outside the range (i.e. abs(val)>=256).
            // So the range -256..256 includes every normal state, though nothing outside -10..10 is at all useful based on my in-game testing. (Games probably didn't have special checks for -0 or for the overflow bit being used with a value <=255.)
            // The game in question is Eye of the Beholder, you can FFW to the main menu and get a cursor right away.
            // --yoshi
            ControllerDef.AddXYPair($"P{player} Mouse {{0}}", AxisPairOrientation.RightAndUp, (-256).RangeTo(256), 0);
            var nx = $"P{player} Mouse X";
            var ny = $"P{player} Mouse Y";

            _converts.Add(() =>
            {
                _target.analog[(2 * idx) + 0] = (short)_source.AxisValue(nx);
                _target.analog[(2 * idx) + 1] = (short)_source.AxisValue(ny);
            });
        }
Exemple #3
0
 static void AddN64StandardController(ControllerDefinition def, int player)
 {
     def.BoolButtons.AddRange(new[] { $"P{player} A Up", $"P{player} A Down", $"P{player} A Left", $"P{player} A Right", $"P{player} DPad U", $"P{player} DPad D", $"P{player} DPad L", $"P{player} DPad R", $"P{player} Start", $"P{player} Z", $"P{player} B", $"P{player} A", $"P{player} C Up", $"P{player} C Down", $"P{player} C Right", $"P{player} C Left", $"P{player} L", $"P{player} R" });
     def.AddXYPair(
         $"P{player} {{0}} Axis",
         AxisPairOrientation.RightAndUp,
         (-128).RangeTo(127),
         0,
         new CircularAxisConstraint("Natural Circle", $"P{player} Y Axis", 127.0f)
         );
 }
Exemple #4
0
        private static ControllerDefinition CreateControllerDefinition(LibAres64.ControllerType[] controllerSettings)
        {
            var ret = new ControllerDefinition("Nintendo 64 Controller");

            for (int i = 0; i < 4; i++)
            {
                if (controllerSettings[i] == LibAres64.ControllerType.Mouse)
                {
                    ret.BoolButtons.Add($"P{i + 1} Mouse Right");
                    ret.BoolButtons.Add($"P{i + 1} Mouse Left");
                    ret.AddXYPair($"P{i + 1} {{0}} Axis", AxisPairOrientation.RightAndUp, (-128).RangeTo(127), 0);
                }
                else if (controllerSettings[i] != LibAres64.ControllerType.Unplugged)
                {
                    ret.BoolButtons.Add($"P{i + 1} DPad U");
                    ret.BoolButtons.Add($"P{i + 1} DPad D");
                    ret.BoolButtons.Add($"P{i + 1} DPad L");
                    ret.BoolButtons.Add($"P{i + 1} DPad R");
                    ret.BoolButtons.Add($"P{i + 1} Start");
                    ret.BoolButtons.Add($"P{i + 1} Z");
                    ret.BoolButtons.Add($"P{i + 1} B");
                    ret.BoolButtons.Add($"P{i + 1} A");
                    ret.BoolButtons.Add($"P{i + 1} C Up");
                    ret.BoolButtons.Add($"P{i + 1} C Down");
                    ret.BoolButtons.Add($"P{i + 1} C Left");
                    ret.BoolButtons.Add($"P{i + 1} C Right");
                    ret.BoolButtons.Add($"P{i + 1} L");
                    ret.BoolButtons.Add($"P{i + 1} R");
                    ret.AddXYPair($"P{i + 1} {{0}} Axis", AxisPairOrientation.RightAndUp, (-128).RangeTo(127), 0);
                    if (controllerSettings[i] == LibAres64.ControllerType.Rumblepak)
                    {
                        ret.HapticsChannels.Add($"P{i + 1} Rumble Pak");
                    }
                }
            }
            ret.BoolButtons.Add("Reset");
            ret.BoolButtons.Add("Power");
            return(ret.MakeImmutable());
        }
Exemple #5
0
        public MelonDS(byte[] file, CoreComm comm, MelonSettings settings, MelonSyncSettings syncSettings)
        {
            _serviceProvider     = new BasicServiceProvider(this);
            ControllerDefinition = new ControllerDefinition {
                Name = "NDS Controller"
            };
            ControllerDefinition.BoolButtons.Add("Left");
            ControllerDefinition.BoolButtons.Add("Right");
            ControllerDefinition.BoolButtons.Add("Up");
            ControllerDefinition.BoolButtons.Add("Down");
            ControllerDefinition.BoolButtons.Add("A");
            ControllerDefinition.BoolButtons.Add("B");
            ControllerDefinition.BoolButtons.Add("X");
            ControllerDefinition.BoolButtons.Add("Y");
            ControllerDefinition.BoolButtons.Add("L");
            ControllerDefinition.BoolButtons.Add("R");
            ControllerDefinition.BoolButtons.Add("Start");
            ControllerDefinition.BoolButtons.Add("Select");

            ControllerDefinition.BoolButtons.Add("LidOpen");
            ControllerDefinition.BoolButtons.Add("LidClose");
            ControllerDefinition.BoolButtons.Add("Power");

            ControllerDefinition.BoolButtons.Add("Touch");
            ControllerDefinition.AddXYPair("Touch{0}", AxisPairOrientation.RightAndUp, 0.RangeTo(255), 128, 0.RangeTo(191), 96);             //TODO verify direction against hardware

            CoreComm   = comm;
            _resampler = new SpeexResampler(SpeexResampler.Quality.QUALITY_DEFAULT, 32768, 44100, 32768, 44100);

            SetUpFiles();

            PutSettings(settings as MelonSettings);
            PutSyncSettings(syncSettings as MelonSyncSettings);

            if (!Init())
            {
                throw new Exception("Failed to init NDS.");
            }
            InitMemoryDomains();

            fixed(byte *f = file)
            {
                LoadROM(f, file.Length);
            }
        }
        public static ControllerDefinition CreateControllerDefinition(SyncSettings syncSettings)
        {
            ControllerDefinition definition = new ControllerDefinition();

            definition.Name = "LibRetro Controls";             // <-- for compatibility

            foreach (var item in new[] {
                "P1 {0} Up", "P1 {0} Down", "P1 {0} Left", "P1 {0} Right", "P1 {0} Select", "P1 {0} Start", "P1 {0} Y", "P1 {0} B", "P1 {0} X", "P1 {0} A", "P1 {0} L", "P1 {0} R",
                "P2 {0} Up", "P2 {0} Down", "P2 {0} Left", "P2 {0} Right", "P2 {0} Select", "P2 {0} Start", "P2 {0} Y", "P2 {0} B", "P2 {0} X", "P2 {0} A", "P2 {0} L", "P2 {0} R",
            })
            {
                definition.BoolButtons.Add(string.Format(item, "RetroPad"));
            }

            definition.BoolButtons.Add("Pointer Pressed");             //TODO: this isnt showing up in the binding panel. I don't want to find out why.
            definition.AddXYPair("Pointer {0}", AxisPairOrientation.RightAndUp, (-32767).RangeTo(32767), 0);

            foreach (var key in new[] {
                "Key Backspace", "Key Tab", "Key Clear", "Key Return", "Key Pause", "Key Escape",
                "Key Space", "Key Exclaim", "Key QuoteDbl", "Key Hash", "Key Dollar", "Key Ampersand", "Key Quote", "Key LeftParen", "Key RightParen", "Key Asterisk", "Key Plus", "Key Comma", "Key Minus", "Key Period", "Key Slash",
                "Key 0", "Key 1", "Key 2", "Key 3", "Key 4", "Key 5", "Key 6", "Key 7", "Key 8", "Key 9",
                "Key Colon", "Key Semicolon", "Key Less", "Key Equals", "Key Greater", "Key Question", "Key At", "Key LeftBracket", "Key Backslash", "Key RightBracket", "Key Caret", "Key Underscore", "Key Backquote",
                "Key A", "Key B", "Key C", "Key D", "Key E", "Key F", "Key G", "Key H", "Key I", "Key J", "Key K", "Key L", "Key M", "Key N", "Key O", "Key P", "Key Q", "Key R", "Key S", "Key T", "Key U", "Key V", "Key W", "Key X", "Key Y", "Key Z",
                "Key Delete",
                "Key KP0", "Key KP1", "Key KP2", "Key KP3", "Key KP4", "Key KP5", "Key KP6", "Key KP7", "Key KP8", "Key KP9",
                "Key KP_Period", "Key KP_Divide", "Key KP_Multiply", "Key KP_Minus", "Key KP_Plus", "Key KP_Enter", "Key KP_Equals",
                "Key Up", "Key Down", "Key Right", "Key Left", "Key Insert", "Key Home", "Key End", "Key PageUp", "Key PageDown",
                "Key F1", "Key F2", "Key F3", "Key F4", "Key F5", "Key F6", "Key F7", "Key F8", "Key F9", "Key F10", "Key F11", "Key F12", "Key F13", "Key F14", "Key F15",
                "Key NumLock", "Key CapsLock", "Key ScrollLock", "Key RShift", "Key LShift", "Key RCtrl", "Key LCtrl", "Key RAlt", "Key LAlt", "Key RMeta", "Key LMeta", "Key LSuper", "Key RSuper", "Key Mode", "Key Compose",
                "Key Help", "Key Print", "Key SysReq", "Key Break", "Key Menu", "Key Power", "Key Euro", "Key Undo"
            })
            {
                definition.BoolButtons.Add(key);
                definition.CategoryLabels[key] = "RetroKeyboard";
            }

            return(definition);
        }
Exemple #7
0
 public static ControllerDefinition AddZapper(this ControllerDefinition def, string nameFormat)
 => def.AddXYPair(nameFormat, AxisPairOrientation.RightAndUp, 0.RangeTo(255), 128, 0.RangeTo(239), 120);                 //TODO verify direction against hardware