Esempio n. 1
0
        private void Buttons_Changed(object sender, NotifyCollectionChangedEventArgs e)
        {
            //= on press
            if (e.NewItems != null)
            {
                foreach (int key in e.NewItems)
                {
                    //listen only to supported keys
                    if (KeyCodes.Contains(key))
                    {
                        int      loc     = Array.IndexOf(KeyCodes, key);
                        string   keyname = KeyNames[loc];
                        string[] _binds  = ControlXMLParser.Binds(keyname, CurrentHash);

                        if (_binds.Length >= 0)
                        {
                            var i = 0;
                            foreach (string bind in _binds)
                            {
                                ushort _key = (ushort)Convert.ToUInt32(_binds[i]);
                                CPUCore.PressButton(_key);
                                i++;
                            }
                        }
                    }
                }
            }

            //= on depress
            if (e.OldItems != null)
            {
                foreach (int key in e.OldItems)
                {
                    if (KeyCodes.Contains(key))
                    {
                        int      loc     = Array.IndexOf(KeyCodes, key);
                        string   keyname = KeyNames[loc];
                        string[] _binds  = ControlXMLParser.Binds(keyname, CurrentHash);

                        if (_binds.Length >= 0)
                        {
                            var i = 0;
                            foreach (string bind in _binds)
                            {
                                ushort _key = (ushort)Convert.ToUInt32(_binds[i]);
                                CPUCore.UnpressButton(_key);
                                i++;
                            }
                        }
                    }
                }
            }
        }
Esempio n. 2
0
        private void CreateGamepadBindings(string gameHash)
        {
            Console.WriteLine("Clearing gamepad bindings");
            GamepadBinds = new Dictionary <string, ushort>();

            Console.WriteLine($"{AppDomain.CurrentDomain.BaseDirectory}profiles\\{gameHash}\\Gamepad.xml");
            if (File.Exists($"{AppDomain.CurrentDomain.BaseDirectory}profiles\\{gameHash}\\Gamepad.xml"))
            {
                Console.WriteLine($"Loading custom gamepad scheme for {gameHash}");
                GamepadBinds = ControlXMLParser.GamepadBinds(gameHash);
            }
        }