public NesJoypadPcKeyboardConnection(IntPtr handle, IInputSettingsJoypad settings) { DirectInput di = new DirectInput(); keyboard = new Keyboard(di); keyboard.SetCooperativeLevel(handle, CooperativeLevel.Nonexclusive | CooperativeLevel.Foreground); if (settings.ButtonUp != "") KeyUp = (SlimDX.DirectInput.Key)Enum.Parse(typeof(SlimDX.DirectInput.Key), settings.ButtonUp); if (settings.ButtonDown != "") KeyDown = (SlimDX.DirectInput.Key)Enum.Parse(typeof(SlimDX.DirectInput.Key), settings.ButtonDown); if (settings.ButtonLeft != "") KeyLeft = (SlimDX.DirectInput.Key)Enum.Parse(typeof(SlimDX.DirectInput.Key), settings.ButtonLeft); if (settings.ButtonRight != "") KeyRight = (SlimDX.DirectInput.Key)Enum.Parse(typeof(SlimDX.DirectInput.Key), settings.ButtonRight); if (settings.ButtonStart != "") KeyStart = (SlimDX.DirectInput.Key)Enum.Parse(typeof(SlimDX.DirectInput.Key), settings.ButtonStart); if (settings.ButtonSelect != "") KeySelect = (SlimDX.DirectInput.Key)Enum.Parse(typeof(SlimDX.DirectInput.Key), settings.ButtonSelect); if (settings.ButtonA != "") KeyA = (SlimDX.DirectInput.Key)Enum.Parse(typeof(SlimDX.DirectInput.Key), settings.ButtonA); if (settings.ButtonB != "") KeyB = (SlimDX.DirectInput.Key)Enum.Parse(typeof(SlimDX.DirectInput.Key), settings.ButtonB); if (settings.ButtonTurboA != "") KeyTurboA = (SlimDX.DirectInput.Key)Enum.Parse(typeof(SlimDX.DirectInput.Key), settings.ButtonTurboA); if (settings.ButtonTurboB != "") KeyTurboB = (SlimDX.DirectInput.Key)Enum.Parse(typeof(SlimDX.DirectInput.Key), settings.ButtonTurboB); }
public NesJoypadXControllerConnection(string guid, IInputSettingsJoypad settings) { switch (guid) { case "x-controller-1": x_controller = new Controller(UserIndex.One); break; case "x-controller-2": x_controller = new Controller(UserIndex.Two); break; case "x-controller-3": x_controller = new Controller(UserIndex.Three); break; case "x-controller-4": x_controller = new Controller(UserIndex.Four); break; } if (settings.ButtonUp != "") KeyUp = ParseKey(settings.ButtonUp); if (settings.ButtonDown != "") KeyDown = ParseKey(settings.ButtonDown); if (settings.ButtonLeft != "") KeyLeft = ParseKey(settings.ButtonLeft); if (settings.ButtonRight != "") KeyRight = ParseKey(settings.ButtonRight); if (settings.ButtonStart != "") KeyStart = ParseKey(settings.ButtonStart); if (settings.ButtonSelect != "") KeySelect = ParseKey(settings.ButtonSelect); if (settings.ButtonA != "") KeyA = ParseKey(settings.ButtonA); if (settings.ButtonB != "") KeyB = ParseKey(settings.ButtonB); if (settings.ButtonTurboA != "") KeyTurboA = ParseKey(settings.ButtonTurboA); if (settings.ButtonTurboB != "") KeyTurboB = ParseKey(settings.ButtonTurboB); }
public NesJoypadPcJoystickConnection(IntPtr handle, string guid, IInputSettingsJoypad settings) { DirectInput di = new DirectInput(); joystick = new Joystick(di, Guid.Parse(guid)); joystick.SetCooperativeLevel(handle, CooperativeLevel.Nonexclusive | CooperativeLevel.Foreground); if (settings.ButtonUp != "") KeyUp = ParseKey(settings.ButtonUp); if (settings.ButtonDown != "") KeyDown = ParseKey(settings.ButtonDown); if (settings.ButtonLeft != "") KeyLeft = ParseKey(settings.ButtonLeft); if (settings.ButtonRight != "") KeyRight = ParseKey(settings.ButtonRight); if (settings.ButtonStart != "") KeyStart = ParseKey(settings.ButtonStart); if (settings.ButtonSelect != "") KeySelect = ParseKey(settings.ButtonSelect); if (settings.ButtonA != "") KeyA = ParseKey(settings.ButtonA); if (settings.ButtonB != "") KeyB = ParseKey(settings.ButtonB); if (settings.ButtonTurboA != "") KeyTurboA = ParseKey(settings.ButtonTurboA); if (settings.ButtonTurboB != "") KeyTurboB = ParseKey(settings.ButtonTurboB); }
public NesJoypadXControllerConnection(string guid, IInputSettingsJoypad settings) { switch (guid) { case "x-controller-1": x_controller = new Controller(UserIndex.One); break; case "x-controller-2": x_controller = new Controller(UserIndex.Two); break; case "x-controller-3": x_controller = new Controller(UserIndex.Three); break; case "x-controller-4": x_controller = new Controller(UserIndex.Four); break; } if (settings.ButtonUp != "") { KeyUp = ParseKey(settings.ButtonUp); } if (settings.ButtonDown != "") { KeyDown = ParseKey(settings.ButtonDown); } if (settings.ButtonLeft != "") { KeyLeft = ParseKey(settings.ButtonLeft); } if (settings.ButtonRight != "") { KeyRight = ParseKey(settings.ButtonRight); } if (settings.ButtonStart != "") { KeyStart = ParseKey(settings.ButtonStart); } if (settings.ButtonSelect != "") { KeySelect = ParseKey(settings.ButtonSelect); } if (settings.ButtonA != "") { KeyA = ParseKey(settings.ButtonA); } if (settings.ButtonB != "") { KeyB = ParseKey(settings.ButtonB); } if (settings.ButtonTurboA != "") { KeyTurboA = ParseKey(settings.ButtonTurboA); } if (settings.ButtonTurboB != "") { KeyTurboB = ParseKey(settings.ButtonTurboB); } }
public NesJoypadPcJoystickConnection(IntPtr handle, string guid, IInputSettingsJoypad settings) { DirectInput di = new DirectInput(); joystick = new Joystick(di, Guid.Parse(guid)); joystick.SetCooperativeLevel(handle, CooperativeLevel.Nonexclusive | CooperativeLevel.Foreground); if (settings.ButtonUp != "") { KeyUp = ParseKey(settings.ButtonUp); } if (settings.ButtonDown != "") { KeyDown = ParseKey(settings.ButtonDown); } if (settings.ButtonLeft != "") { KeyLeft = ParseKey(settings.ButtonLeft); } if (settings.ButtonRight != "") { KeyRight = ParseKey(settings.ButtonRight); } if (settings.ButtonStart != "") { KeyStart = ParseKey(settings.ButtonStart); } if (settings.ButtonSelect != "") { KeySelect = ParseKey(settings.ButtonSelect); } if (settings.ButtonA != "") { KeyA = ParseKey(settings.ButtonA); } if (settings.ButtonB != "") { KeyB = ParseKey(settings.ButtonB); } if (settings.ButtonTurboA != "") { KeyTurboA = ParseKey(settings.ButtonTurboA); } if (settings.ButtonTurboB != "") { KeyTurboB = ParseKey(settings.ButtonTurboB); } }
private void SavePlayer1() { if (comboBox_device.SelectedIndex < 0) { Program.Settings.ControlSettings.Joypad1DeviceGuid = ""; return; } bool found = false; for (int i = 0; i < Program.Settings.ControlSettings.Joypad1Devices.Count; i++) { if (Program.Settings.ControlSettings.Joypad1Devices[i].DeviceGuid.ToLower() == devices[comboBox_device.SelectedIndex].InstanceGuid.ToString().ToLower()) { Program.Settings.ControlSettings.Joypad1DeviceGuid = Program.Settings.ControlSettings.Joypad1Devices[i].DeviceGuid; found = true; // Add the inputs Program.Settings.ControlSettings.Joypad1Devices[i].ButtonA = listView1.Items[0].SubItems[1].Text; Program.Settings.ControlSettings.Joypad1Devices[i].ButtonB = listView1.Items[1].SubItems[1].Text; Program.Settings.ControlSettings.Joypad1Devices[i].ButtonTurboA = listView1.Items[2].SubItems[1].Text; Program.Settings.ControlSettings.Joypad1Devices[i].ButtonTurboB = listView1.Items[3].SubItems[1].Text; Program.Settings.ControlSettings.Joypad1Devices[i].ButtonStart = listView1.Items[4].SubItems[1].Text; Program.Settings.ControlSettings.Joypad1Devices[i].ButtonSelect = listView1.Items[5].SubItems[1].Text; Program.Settings.ControlSettings.Joypad1Devices[i].ButtonLeft = listView1.Items[6].SubItems[1].Text; Program.Settings.ControlSettings.Joypad1Devices[i].ButtonUp = listView1.Items[7].SubItems[1].Text; Program.Settings.ControlSettings.Joypad1Devices[i].ButtonRight = listView1.Items[8].SubItems[1].Text; Program.Settings.ControlSettings.Joypad1Devices[i].ButtonDown = listView1.Items[9].SubItems[1].Text; break; } } if (!found) { // Add the device Program.Settings.ControlSettings.Joypad1DeviceGuid = devices[comboBox_device.SelectedIndex].InstanceGuid.ToString(); IInputSettingsJoypad joy1 = new IInputSettingsJoypad(); joy1.DeviceGuid = Program.Settings.ControlSettings.Joypad1DeviceGuid; joy1.ButtonA = listView1.Items[0].SubItems[1].Text; joy1.ButtonB = listView1.Items[1].SubItems[1].Text; joy1.ButtonTurboA = listView1.Items[2].SubItems[1].Text; joy1.ButtonTurboB = listView1.Items[3].SubItems[1].Text; joy1.ButtonStart = listView1.Items[4].SubItems[1].Text; joy1.ButtonSelect = listView1.Items[5].SubItems[1].Text; joy1.ButtonLeft = listView1.Items[6].SubItems[1].Text; joy1.ButtonUp = listView1.Items[7].SubItems[1].Text; joy1.ButtonRight = listView1.Items[8].SubItems[1].Text; joy1.ButtonDown = listView1.Items[9].SubItems[1].Text; Program.Settings.ControlSettings.Joypad1Devices.Add(joy1); } }
public NesJoypadPcKeyboardConnection(IntPtr handle, IInputSettingsJoypad settings) { DirectInput di = new DirectInput(); keyboard = new Keyboard(di); keyboard.SetCooperativeLevel(handle, CooperativeLevel.Nonexclusive | CooperativeLevel.Foreground); if (settings.ButtonUp != "") { KeyUp = (SlimDX.DirectInput.Key)Enum.Parse(typeof(SlimDX.DirectInput.Key), settings.ButtonUp); } if (settings.ButtonDown != "") { KeyDown = (SlimDX.DirectInput.Key)Enum.Parse(typeof(SlimDX.DirectInput.Key), settings.ButtonDown); } if (settings.ButtonLeft != "") { KeyLeft = (SlimDX.DirectInput.Key)Enum.Parse(typeof(SlimDX.DirectInput.Key), settings.ButtonLeft); } if (settings.ButtonRight != "") { KeyRight = (SlimDX.DirectInput.Key)Enum.Parse(typeof(SlimDX.DirectInput.Key), settings.ButtonRight); } if (settings.ButtonStart != "") { KeyStart = (SlimDX.DirectInput.Key)Enum.Parse(typeof(SlimDX.DirectInput.Key), settings.ButtonStart); } if (settings.ButtonSelect != "") { KeySelect = (SlimDX.DirectInput.Key)Enum.Parse(typeof(SlimDX.DirectInput.Key), settings.ButtonSelect); } if (settings.ButtonA != "") { KeyA = (SlimDX.DirectInput.Key)Enum.Parse(typeof(SlimDX.DirectInput.Key), settings.ButtonA); } if (settings.ButtonB != "") { KeyB = (SlimDX.DirectInput.Key)Enum.Parse(typeof(SlimDX.DirectInput.Key), settings.ButtonB); } if (settings.ButtonTurboA != "") { KeyTurboA = (SlimDX.DirectInput.Key)Enum.Parse(typeof(SlimDX.DirectInput.Key), settings.ButtonTurboA); } if (settings.ButtonTurboB != "") { KeyTurboB = (SlimDX.DirectInput.Key)Enum.Parse(typeof(SlimDX.DirectInput.Key), settings.ButtonTurboB); } }
public static void BuildDefaultControlSettings() { Program.Settings.ControlSettings = new ControlMappingSettings(); Program.Settings.ControlSettings.Joypad1Devices = new List <IInputSettingsJoypad>(); Program.Settings.ControlSettings.Joypad2Devices = new List <IInputSettingsJoypad>(); Program.Settings.ControlSettings.Joypad3Devices = new List <IInputSettingsJoypad>(); Program.Settings.ControlSettings.Joypad4Devices = new List <IInputSettingsJoypad>(); Program.Settings.ControlSettings.VSUnisystemDIPDevices = new List <IInputSettingsVSUnisystemDIP>(); DirectInput di = new DirectInput(); foreach (DeviceInstance ins in di.GetDevices()) { if (ins.Type == DeviceType.Keyboard) { // Player 1 joypad IInputSettingsJoypad joy1 = new IInputSettingsJoypad(); joy1.DeviceGuid = ins.InstanceGuid.ToString(); joy1.ButtonA = "X"; joy1.ButtonB = "Z"; joy1.ButtonTurboA = "S"; joy1.ButtonTurboB = "A"; joy1.ButtonDown = "DownArrow"; joy1.ButtonLeft = "LeftArrow"; joy1.ButtonRight = "RightArrow"; joy1.ButtonUp = "UpArrow"; joy1.ButtonSelect = "C"; joy1.ButtonStart = "V"; Program.Settings.ControlSettings.Joypad1Devices.Add(joy1); Program.Settings.ControlSettings.Joypad1DeviceGuid = joy1.DeviceGuid; // Player 2 joypad IInputSettingsJoypad joy2 = new IInputSettingsJoypad(); joy2.DeviceGuid = ins.InstanceGuid.ToString(); joy2.ButtonA = "K"; joy2.ButtonB = "L"; joy2.ButtonTurboA = "I"; joy2.ButtonTurboB = "O"; joy2.ButtonDown = "S"; joy2.ButtonLeft = "A"; joy2.ButtonRight = "D"; joy2.ButtonUp = "W"; joy2.ButtonSelect = "B"; joy2.ButtonStart = "N"; Program.Settings.ControlSettings.Joypad2Devices.Add(joy2); Program.Settings.ControlSettings.Joypad2DeviceGuid = joy2.DeviceGuid; IInputSettingsVSUnisystemDIP vs = new IInputSettingsVSUnisystemDIP(); // VSUnisystem vs.DeviceGuid = ins.InstanceGuid.ToString(); vs.CreditServiceButton = "End"; vs.DIPSwitch1 = "NumberPad1"; vs.DIPSwitch2 = "NumberPad2"; vs.DIPSwitch3 = "NumberPad3"; vs.DIPSwitch4 = "NumberPad4"; vs.DIPSwitch5 = "NumberPad5"; vs.DIPSwitch6 = "NumberPad6"; vs.DIPSwitch7 = "NumberPad7"; vs.DIPSwitch8 = "NumberPad8"; vs.CreditLeftCoinSlot = "Insert"; vs.CreditRightCoinSlot = "Home"; Program.Settings.ControlSettings.VSUnisystemDIPDevices.Add(vs); Program.Settings.ControlSettings.VSUnisystemDIPDeviceGuid = vs.DeviceGuid; break; } } }
public static void BuildDefaultControlSettings() { Program.Settings.ControlSettings = new ControlMappingSettings(); Program.Settings.ControlSettings.Joypad1Devices = new List<IInputSettingsJoypad>(); Program.Settings.ControlSettings.Joypad2Devices = new List<IInputSettingsJoypad>(); Program.Settings.ControlSettings.Joypad3Devices = new List<IInputSettingsJoypad>(); Program.Settings.ControlSettings.Joypad4Devices = new List<IInputSettingsJoypad>(); Program.Settings.ControlSettings.VSUnisystemDIPDevices = new List<IInputSettingsVSUnisystemDIP>(); DirectInput di = new DirectInput(); foreach (DeviceInstance ins in di.GetDevices()) { if (ins.Type == DeviceType.Keyboard) { // Player 1 joypad IInputSettingsJoypad joy1 = new IInputSettingsJoypad(); joy1.DeviceGuid = ins.InstanceGuid.ToString(); joy1.ButtonA = "X"; joy1.ButtonB = "Z"; joy1.ButtonTurboA = "S"; joy1.ButtonTurboB = "A"; joy1.ButtonDown = "DownArrow"; joy1.ButtonLeft = "LeftArrow"; joy1.ButtonRight = "RightArrow"; joy1.ButtonUp = "UpArrow"; joy1.ButtonSelect = "C"; joy1.ButtonStart = "V"; Program.Settings.ControlSettings.Joypad1Devices.Add(joy1); Program.Settings.ControlSettings.Joypad1DeviceGuid = joy1.DeviceGuid; Program.Settings.ControlSettings.Joypad1AutoSwitchBackToKeyboard = true; // Player 2 joypad IInputSettingsJoypad joy2 = new IInputSettingsJoypad(); joy2.DeviceGuid = ins.InstanceGuid.ToString(); joy2.ButtonA = "K"; joy2.ButtonB = "L"; joy2.ButtonTurboA = "I"; joy2.ButtonTurboB = "O"; joy2.ButtonDown = "S"; joy2.ButtonLeft = "A"; joy2.ButtonRight = "D"; joy2.ButtonUp = "W"; joy2.ButtonSelect = "B"; joy2.ButtonStart = "N"; Program.Settings.ControlSettings.Joypad2Devices.Add(joy2); Program.Settings.ControlSettings.Joypad2DeviceGuid = joy2.DeviceGuid; Program.Settings.ControlSettings.Joypad2AutoSwitchBackToKeyboard = true; // Player 3 Program.Settings.ControlSettings.Joypad3Devices = new List<IInputSettingsJoypad>(); Program.Settings.ControlSettings.Joypad3DeviceGuid = ""; Program.Settings.ControlSettings.Joypad3AutoSwitchBackToKeyboard = true; // Player 4 Program.Settings.ControlSettings.Joypad4Devices = new List<IInputSettingsJoypad>(); Program.Settings.ControlSettings.Joypad4DeviceGuid = ""; Program.Settings.ControlSettings.Joypad4AutoSwitchBackToKeyboard = true; // VSUnisystem IInputSettingsVSUnisystemDIP vs = new IInputSettingsVSUnisystemDIP(); vs.DeviceGuid = ins.InstanceGuid.ToString(); vs.CreditServiceButton = "End"; vs.DIPSwitch1 = "NumberPad1"; vs.DIPSwitch2 = "NumberPad2"; vs.DIPSwitch3 = "NumberPad3"; vs.DIPSwitch4 = "NumberPad4"; vs.DIPSwitch5 = "NumberPad5"; vs.DIPSwitch6 = "NumberPad6"; vs.DIPSwitch7 = "NumberPad7"; vs.DIPSwitch8 = "NumberPad8"; vs.CreditLeftCoinSlot = "Insert"; vs.CreditRightCoinSlot = "Home"; Program.Settings.ControlSettings.VSUnisystemDIPDevices.Add(vs); Program.Settings.ControlSettings.VSUnisystemDIPDeviceGuid = vs.DeviceGuid; Program.Settings.ControlSettings.VSUnisystemDIPAutoSwitchBackToKeyboard = true; break; } } }
private void SavePlayer1() { if (comboBox_device.SelectedIndex < 0) { Program.Settings.ControlSettings.Joypad1DeviceGuid = ""; return; } bool found = false; for (int i = 0; i < Program.Settings.ControlSettings.Joypad1Devices.Count; i++) { if (Program.Settings.ControlSettings.Joypad1Devices[i].DeviceGuid.ToLower() == deviceGuides[comboBox_device.SelectedIndex].ToLower()) { Program.Settings.ControlSettings.Joypad1DeviceGuid = Program.Settings.ControlSettings.Joypad1Devices[i].DeviceGuid; found = true; // Add the inputs Program.Settings.ControlSettings.Joypad1Devices[i].ButtonA = listView1.Items[0].SubItems[1].Text; Program.Settings.ControlSettings.Joypad1Devices[i].ButtonB = listView1.Items[1].SubItems[1].Text; Program.Settings.ControlSettings.Joypad1Devices[i].ButtonTurboA = listView1.Items[2].SubItems[1].Text; Program.Settings.ControlSettings.Joypad1Devices[i].ButtonTurboB = listView1.Items[3].SubItems[1].Text; Program.Settings.ControlSettings.Joypad1Devices[i].ButtonStart = listView1.Items[4].SubItems[1].Text; Program.Settings.ControlSettings.Joypad1Devices[i].ButtonSelect = listView1.Items[5].SubItems[1].Text; Program.Settings.ControlSettings.Joypad1Devices[i].ButtonLeft = listView1.Items[6].SubItems[1].Text; Program.Settings.ControlSettings.Joypad1Devices[i].ButtonUp = listView1.Items[7].SubItems[1].Text; Program.Settings.ControlSettings.Joypad1Devices[i].ButtonRight = listView1.Items[8].SubItems[1].Text; Program.Settings.ControlSettings.Joypad1Devices[i].ButtonDown = listView1.Items[9].SubItems[1].Text; break; } } if (!found) { // Add the device Program.Settings.ControlSettings.Joypad1DeviceGuid = deviceGuides[comboBox_device.SelectedIndex]; IInputSettingsJoypad joy1 = new IInputSettingsJoypad(); joy1.DeviceGuid = Program.Settings.ControlSettings.Joypad1DeviceGuid; joy1.ButtonA = listView1.Items[0].SubItems[1].Text; joy1.ButtonB = listView1.Items[1].SubItems[1].Text; joy1.ButtonTurboA = listView1.Items[2].SubItems[1].Text; joy1.ButtonTurboB = listView1.Items[3].SubItems[1].Text; joy1.ButtonStart = listView1.Items[4].SubItems[1].Text; joy1.ButtonSelect = listView1.Items[5].SubItems[1].Text; joy1.ButtonLeft = listView1.Items[6].SubItems[1].Text; joy1.ButtonUp = listView1.Items[7].SubItems[1].Text; joy1.ButtonRight = listView1.Items[8].SubItems[1].Text; joy1.ButtonDown = listView1.Items[9].SubItems[1].Text; Program.Settings.ControlSettings.Joypad1Devices.Add(joy1); } }