protected override void OnMenuOptionChanged() { switch (SelectedMenuIndex) { case 0: // Region { switch (Items[0].SelectedOptionIndex) { case 0: Settings.TvSystemSetting = "auto"; break; case 1: Settings.TvSystemSetting = "ntsc"; break; case 2: Settings.TvSystemSetting = "palb"; break; case 3: Settings.TvSystemSetting = "dendy"; break; } break; } case 1: // Connect 4 players { Settings.Key_Connect4Players = Items[1].SelectedOptionIndex == 1; NesEmu.IsFourPlayers = Settings.Key_Connect4Players; break; } case 2: // Connect Zapper { Settings.Key_ConnectZapper = Items[2].SelectedOptionIndex == 1; NesEmu.IsZapperConnected = Settings.Key_ConnectZapper; if (NesEmu.IsZapperConnected) { NesEmu.SetupZapper(new SDLZapper()); SdlDotNet.Input.Mouse.ShowCursor = true; } break; } } }
public static void InitializeInput() { LoadShortcuts(); NesEmu.IsFourPlayers = Settings.Key_Connect4Players; NesEmu.IsZapperConnected = Settings.Key_ConnectZapper; IJoypadConnecter joy1 = null; IJoypadConnecter joy2 = null; IJoypadConnecter joy3 = null; IJoypadConnecter joy4 = null; IVSUnisystemDIPConnecter vsUni = null; Console.WriteLine(">Initializing input settings..."); if (Settings.Key_P1_UseJoystick || Settings.Key_P2_UseJoystick || Settings.Key_P3_UseJoystick || Settings.Key_P4_UseJoystick || Settings.Key_VS_UseJoystick) { Console.WriteLine(">Initializing joysticks..."); Joysticks.Initialize(); Console.WriteLine("->Joysticks number = " + Joysticks.NumberOfJoysticks); } Console.WriteLine(">Applying key mappings..."); #region Player 1 if (!Settings.Key_P1_UseJoystick) { joy1 = new SDL_Keyboard_Joyad(0); Console.WriteLine("->Using keyboard for player 1."); } else { if (Joysticks.IsValidJoystickNumber(Settings.Key_P1_JoystickIndex)) { joy1 = new SDL_Joystick_Joypad(Settings.Key_P1_JoystickIndex, 0); Console.WriteLine("->Using joystick for player 1."); } else { // USE keyboard ? joy1 = new SDL_Keyboard_Joyad(0); Console.WriteLine("->Joystick is not connected; using keyboard for player 1."); } } #endregion #region Player 2 if (!Settings.Key_P2_UseJoystick) { joy2 = new SDL_Keyboard_Joyad(1); Console.WriteLine("->Using keyboard for player 2."); } else { if (Joysticks.IsValidJoystickNumber(Settings.Key_P2_JoystickIndex)) { joy2 = new SDL_Joystick_Joypad(Settings.Key_P2_JoystickIndex, 1); Console.WriteLine("->Using joystick for player 2."); } else { // USE keyboard ? joy2 = new SDL_Keyboard_Joyad(1); Console.WriteLine("->Joystick is not connected; using keyboard for player 2."); } } #endregion #region Player 3 if (!Settings.Key_P3_UseJoystick) { joy3 = new SDL_Keyboard_Joyad(2); Console.WriteLine("->Using keyboard for player 3."); } else { if (Joysticks.IsValidJoystickNumber(Settings.Key_P3_JoystickIndex)) { joy3 = new SDL_Joystick_Joypad(Settings.Key_P3_JoystickIndex, 2); Console.WriteLine("->Using joystick for player 3."); } else { // USE keyboard ? joy3 = new SDL_Keyboard_Joyad(2); Console.WriteLine("->Joystick is not connected; using keyboard for player 3."); } } #endregion #region Player 4 if (!Settings.Key_P4_UseJoystick) { joy4 = new SDL_Keyboard_Joyad(3); Console.WriteLine("->Using keyboard for player 4."); } else { if (Joysticks.IsValidJoystickNumber(Settings.Key_P4_JoystickIndex)) { joy4 = new SDL_Joystick_Joypad(Settings.Key_P4_JoystickIndex, 3); Console.WriteLine("->Using joystick for player 4."); } else { // USE keyboard ? joy4 = new SDL_Keyboard_Joyad(3); Console.WriteLine("->Joystick is not connected; using keyboard for player 4."); } } #endregion #region VS Unisystem if (!Settings.Key_VS_UseJoystick) { vsUni = new SDL_Keyboard_VSUnisystem(); Console.WriteLine("->Using keyboard for VS Unisystem PID."); } else { if (Joysticks.IsValidJoystickNumber(Settings.Key_VS_JoystickIndex)) { vsUni = new SDL_Joystick_VSUnisystem(Settings.Key_VS_JoystickIndex); Console.WriteLine("->Using joystick for VS Unisystem PID."); } else { // USE keyboard ? vsUni = new SDL_Keyboard_VSUnisystem(); Console.WriteLine("->Joystick is not connected; using keyboard for VS Unisystem PID."); } } #endregion NesEmu.SetupJoypads(joy1, joy2, joy3, joy4); NesEmu.SetupVSUnisystemDIP(vsUni); NesEmu.IsZapperConnected = Settings.Key_ConnectZapper; NesEmu.IsFourPlayers = Settings.Key_Connect4Players; if (NesEmu.IsZapperConnected) { Console.WriteLine("->ZAPPER IS CONNECTED !!"); NesEmu.SetupZapper(new SDLZapper()); SdlDotNet.Input.Mouse.ShowCursor = true; } if (NesEmu.IsFourPlayers) { Console.WriteLine("->4 PLAYERS IS CONNECTED !!"); } Console.WriteLine(">Input settings initialized successfully."); }