示例#1
0
        public static void StartListening()
        {
            string portStr    = AppController.mainForm.comboBoxPorts.GetItemText(AppController.mainForm.comboBoxPorts.SelectedItem);
            string consoleStr = AppController.mainForm.comboBoxControllerType.GetItemText(AppController.mainForm.comboBoxControllerType.SelectedItem);

            AppController.Log("NintendoSpy: Starting wrapper on: " + portStr, Constants.Enums.LogMessageType.Basic);
            try
            {
                if (consoleStr.StartsWith("NES"))
                {
                    source       = new InputSource("nes", "NES", true, false, port => new SerialControllerReader(portStr, SuperNESandNES.ReadFromPacket_NES));
                    controlStyle = ControlStyle.NES;
                }
                else if (consoleStr.StartsWith("SNES"))
                {
                    source       = new InputSource("snes", "Super SNES", true, false, port => new SerialControllerReader(portStr, SuperNESandNES.ReadFromPacket_SNES));
                    controlStyle = ControlStyle.SNES;
                }
                else if (consoleStr.StartsWith("N64"))
                {
                    source       = new InputSource("n64", "Nintendo 64", true, false, port => new SerialControllerReader(portStr, Nintendo64.ReadFromPacket));
                    controlStyle = ControlStyle.N64;
                }
                else if (consoleStr.StartsWith("GameCube"))
                {
                    source       = new InputSource("gamecube", "GameCube", true, false, port => new SerialControllerReader(portStr, GameCube.ReadFromPacket));
                    controlStyle = ControlStyle.GameCube;
                }
                _reader = source.BuildReader(portStr);
                _reader.ControllerStateChanged += reader_ControllerStateChanged;
                _reader.ControllerDisconnected += reader_ControllerDisconnected;
                AppController.Log("NintendoSpy: Wrapper Started.", Constants.Enums.LogMessageType.Basic);
            }
            catch (Exception exc)
            {
                AppController.Log("NintendoSpy: Error:\n" + exc.ToString(), Constants.Enums.LogMessageType.Error);
            }
        }