示例#1
0
        public void ListenToDevice(bool reversedAxis, GameProfile gameProfile)
        {
            _reverseAxis = reversedAxis;
            _gameProfile = gameProfile;

            if (_gameProfile.EmulationProfile == EmulationProfile.LuigisMansion)
            {
                _isLuigisMansion = true;
            }
            if (_gameProfile.EmulationProfile == EmulationProfile.StarTrekVoyager)
            {
                _isStarTrek = true;
            }

            _minX = _gameProfile.xAxisMin;
            _maxX = _gameProfile.xAxisMax;
            _minY = _gameProfile.yAxisMin;
            _maxY = _gameProfile.yAxisMax;

            _isFullScreen = _gameProfile.ConfigValues.Any(x => x.FieldName == "Windowed" && x.FieldValue == "0");
            _killListen   = false;
            _listenThread = new Thread(ListenThread);
            _listenThread.Start();
            _findWindowThread = new Thread(FindWindowThread);
            _findWindowThread.Start();
            _mGlobalHook            = Hook.GlobalEvents();
            _mGlobalHook.KeyDown   += MGlobalHookOnKeyDown;
            _mGlobalHook.KeyUp     += MGlobalHookOnKeyUp;
            _mouseEvents            = Hook.GlobalEvents();
            _mouseEvents.MouseMove += MouseEventsOnMouseMove;
            _mouseEvents.MouseDown += MouseEventOnMouseDown;
            _mouseEvents.MouseUp   += MouseEventsOnMouseUp;
        }
示例#2
0
        /// <summary>
        /// Serializes GameProfile class to a GameProfile.xml file.
        /// </summary>
        /// <param name="profile"></param>
        public static void SerializeGameProfile(GameProfile profile, string filename = "")
        {
            var serializer = new XmlSerializer(profile.GetType());

            using (var writer = XmlWriter.Create(filename == "" ? Path.Combine("UserProfiles", Path.GetFileName(profile.FileName)) : filename, new XmlWriterSettings {
                Indent = true
            }))
            {
                serializer.Serialize(writer, profile);
            }
        }
示例#3
0
        public void Listen(bool useSto0Z, int stoozPercent, List <JoystickButtons> joystickButtons, InputApi inputApi, GameProfile gameProfile)
        {
            try
            {
                KillMe = false;
                InputListenerXInput.KillMe      = false;
                InputListenerDirectInput.KillMe = false;
                InputListenerRawInput.KillMe    = false;
                _gameprofile = gameProfile;
                _inputApi    = inputApi;

                if (_inputApi == InputApi.DirectInput)
                {
                    var thread = new Thread(() => _inputListenerDirectInput.ListenDirectInput(joystickButtons, gameProfile));
                    thread.Start();
                }
                else if (_inputApi == InputApi.XInput)
                {
                    _xi1 = new Thread(() => _inputListenerXInput.ListenXInput(useSto0Z, stoozPercent, joystickButtons, UserIndex.One, gameProfile));
                    _xi1.Start();

                    _xi2 = new Thread(() => _inputListenerXInput.ListenXInput(useSto0Z, stoozPercent, joystickButtons, UserIndex.Two, gameProfile));
                    _xi2.Start();

                    _xi3 = new Thread(() => _inputListenerXInput.ListenXInput(useSto0Z, stoozPercent, joystickButtons, UserIndex.Three, gameProfile));
                    _xi3.Start();

                    _xi4 = new Thread(() => _inputListenerXInput.ListenXInput(useSto0Z, stoozPercent, joystickButtons, UserIndex.Four, gameProfile));
                    _xi4.Start();
                    var thread = new Thread(() => ThreadRespawnerXInput(useSto0Z, stoozPercent, joystickButtons));
                    thread.Start();
                }
                else if (_inputApi == InputApi.RawInput)
                {
                    var thread = new Thread(() => _inputListenerRawInput.ListenRawInput(joystickButtons, gameProfile));
                    thread.Start();
                }
            }
            catch (Exception)
            {
                // ignored
            }
            while (!KillMe)
            {
                Thread.Sleep(1000);
            }
        }