private void AssignColor(ButtonMapping buttonMapping) { if (buttonMapping.IsActionBarButton) { var outlineColor = Color.white; var fillColor = Color.white * FillBrightness; fillColor.a = FillAlpha; buttonMapping.DisplayButton.Fill.color = fillColor; buttonMapping.DisplayButton.Outline.gameObject.SetActive(true); buttonMapping.DisplayButton.Outline.color = outlineColor; if (buttonMapping.DisplayButton is InputDisplayKey key) { key.MainLabel.color = key.AltLabel.color = outlineColor; } } else if (buttonMapping.ActionMapping != null) { var outlineColor = Color.HSVToRGB(buttonMapping.ActionMapping.Hue, Saturation, 1); var fillColor = Color.HSVToRGB(buttonMapping.ActionMapping.Hue, 1, FillBrightness); fillColor.a = FillAlpha; buttonMapping.DisplayButton.Fill.color = fillColor; buttonMapping.DisplayButton.Outline.gameObject.SetActive(true); buttonMapping.DisplayButton.Outline.color = outlineColor; if (buttonMapping.DisplayButton is InputDisplayKey key) { key.MainLabel.color = key.AltLabel.color = outlineColor; } } else { AssignUnboundColor(buttonMapping.DisplayButton); } }
//converts a ButtonMapping in the right KeyCode enum protected static KeyCode BToCode(int playerNumber, ButtonMapping buttonName) { //This is because for Unity Player0 is the owner of Joypad1 playerNumber++; //1-based return((KeyCode)Enum.Parse(typeof(KeyCode), "Joystick" + playerNumber + "Button" + (int)buttonName)); }
private void InitButtonMappingCombobox(ComboBox combobox, ushort value, ButtonMapping defaultMapping, bool allowTurnCharacter = true) { InitButtonMappingComboboxSingle(combobox, ZoomIn, defaultMapping); InitButtonMappingComboboxSingle(combobox, ZoomOut, defaultMapping); InitButtonMappingComboboxSingle(combobox, ZoomInOut, defaultMapping); InitButtonMappingComboboxSingle(combobox, ResetCamera, defaultMapping); if (allowTurnCharacter) { InitButtonMappingComboboxSingle(combobox, TurnCharacter, defaultMapping); } InitButtonMappingComboboxSingle(combobox, ChangeLeaderNext, defaultMapping); InitButtonMappingComboboxSingle(combobox, ChangeLeaderPrevious, defaultMapping); InitButtonMappingComboboxSingle(combobox, Dash, defaultMapping); InitButtonMappingComboboxSingle(combobox, Walk, defaultMapping); bool foundValue = false; foreach (ButtonMapping bm in combobox.Items) { if (bm.InGameId == ((int)value)) { combobox.SelectedItem = bm; foundValue = true; break; } } if (!foundValue) { combobox.Items.Add(LeaveUnchanged); combobox.SelectedItem = LeaveUnchanged; } }
public InputMappings() { ButtonMapping = new ButtonMapping(); AxisMapping = new AxisMapping(); ControllerId = 0; EmulationMapping = new EmulationButtonMapping(); }
private void remote_ButtonDown(object sender, PS3Remote.ButtonData e) { if (DebugLog.isLogging) { DebugLog.write("Button down: " + e.button.ToString()); } ButtonMapping mapping = buttonMappings[(int)e.button]; if (mapping.repeat) { keyboard.sendKeysDown(mapping.keysMapped); keyboard.releaseLastKeys(); if (DebugLog.isLogging) { DebugLog.write("Keys repeat send on : { " + String.Join(",", mapping.keysMapped.ToArray()) + " }"); } timerRepeat.Enabled = true; return; } keyboard.sendKeysDown(mapping.keysMapped); if (DebugLog.isLogging) { DebugLog.write("Keys down: { " + String.Join(",", mapping.keysMapped.ToArray()) + " }"); } }
public override bool OnKeyUp(Keycode keyCode, KeyEvent e) { InputDevice device = e.Device; if (device != null && device.Id == current_device_id) { int index = ButtonMapping.OrdinalValue(keyCode); if (index >= 0) { buttons[index] = 0; if (index == 7) { Tello.takeOff(); } if (index == 6) { Tello.land(); } axes[4] = buttons[5]; Tello.setAxis(axes); //controller_view.Invalidate(); } return(true); } return(base.OnKeyUp(keyCode, e)); }
private void WriteBackButtonMapping(ButtonMapping mapping, ref ushort value) { if (mapping.InGameId == -1) { return; } value = (ushort)mapping.InGameId; }
/// <summary> /// Remaps a XInput button mapped to a buton struct to the controller button map struct. /// </summary> /// <param name="timeoutSeconds">The timeout in seconds for the controller assignment.</param> /// <param name="currentTimeout">The current amount of time left in seconds, use this to update the GUI.</param> /// <param name="buttonToMap">Specififies the button variable where the index of the pressed button will be written to. Either a member of Controller_Button_Mapping or Emulation_Button_Mapping</param> /// <param name="cancellationToken">The method polls on this boolean such that if it is set to true, the method will exit.</param> /// <returns>True if a new button has successfully been assigned by the user.</returns> private bool XInputRemapButton(int timeoutSeconds, out float currentTimeout, ref byte buttonToMap, ref bool cancellationToken) { // Cast Controller to DInput Controller XInputController xInputController = (XInputController)Controller; // Retrieve Joystick State bool[] buttonState = xInputController.GetButtons(); // Initialize Timeout int pollAttempts = timeoutSeconds * MillisecondsInSecond / SleepTimePolling; int pollCounter = 0; // Poll the controller properties. while (pollCounter < pollAttempts) { // Get new JoystickState bool[] buttonStateNew = xInputController.GetButtons(); // Iterate over all buttons. for (int x = 0; x < buttonStateNew.Length; x++) { if (buttonState[x] != buttonStateNew[x]) { // Retrieve the button mapping. ButtonMapping buttonMapping = Controller.InputMappings.ButtonMapping; // Assign requested button. buttonToMap = (byte)x; // Reassign button mapping. Controller.InputMappings.ButtonMapping = buttonMapping; // Set timeout to 0 currentTimeout = 0; // Return return(true); } } // Increase counter, calculate new time left. pollCounter += 1; currentTimeout = timeoutSeconds - pollCounter * SleepTimePolling / (float)MillisecondsInSecond; // Check exit condition if (cancellationToken) { return(false); } // Sleep Thread.Sleep(SleepTimePolling); } // Assign the current timeout. currentTimeout = 0; return(false); }
public PlayerData(int n, Color c, ButtonMapping controls) { number = n; color = c; realDirectionInput = controls.realDirectionInput; jumpButton = controls.jumpButton; meleeButton = controls.meleeButton; shootButton = controls.shootButton; }
public SettingsForm() { for (int i = 0; i < buttonMappings.Length; i++) { buttonMappings[i] = new ButtonMapping(); } InitializeComponent(); ListViewItem lvItem; foreach (PS3Remote.Button button in Enum.GetValues(typeof(PS3Remote.Button))) { lvItem = new ListViewItem(); lvItem.SubItems.Add(button.ToString()); lvItem.SubItems.Add(""); lvButtons.Items.Add(lvItem); } foreach (SendInputAPI.Keyboard.KeyCode key in Enum.GetValues(typeof(SendInputAPI.Keyboard.KeyCode))) { lvKeys.Items.Add(new ListViewItem(key.ToString())); } if (!loadSettings()) { saveSettings(); } timerRepeat = new System.Timers.Timer(); timerRepeat.Interval = int.Parse(txtRepeatInterval.Text); timerRepeat.Elapsed += new System.Timers.ElapsedEventHandler(timerRepeat_Elapsed); try { remote = new PS3Remote(int.Parse(txtVendorId.Text.Remove(0, 2), System.Globalization.NumberStyles.HexNumber), int.Parse(txtProductId.Text.Remove(0, 2), System.Globalization.NumberStyles.HexNumber), cbHibernation.Checked); remote.BatteryLifeChanged += new EventHandler<EventArgs>(remote_BatteryLifeChanged); remote.ButtonDown += new EventHandler<PS3Remote.ButtonData>(remote_ButtonDown); remote.ButtonReleased += new EventHandler<PS3Remote.ButtonData>(remote_ButtonReleased); remote.Connected += new EventHandler<EventArgs>(remote_Connected); remote.Disconnected += new EventHandler<EventArgs>(remote_Disconnected); remote.connect(); } catch { MessageBox.Show("An error occured whilst attempting to load the remote.", "PS3BluMote: Remote error!", MessageBoxButtons.OK, MessageBoxIcon.Error); } int mouseSpeed = 0; try { mouseSpeed = int.Parse(txtMouseSpeed.Text); } catch {} keyboard = new SendInputAPI.Keyboard(cbSms.Checked, mouseSpeed); }
private void InitButtonMappingComboboxSingle(ComboBox combobox, ButtonMapping mapping, ButtonMapping defaultMapping) { if (mapping.InGameId == defaultMapping.InGameId) { combobox.Items.Add(new ButtonMapping(mapping.InGameId, mapping.DisplayString + " (default)")); } else { combobox.Items.Add(mapping); } }
private ButtonMapping MapMouseButton(InputDisplayButton button, string path) { var mapping = new ButtonMapping { Button = new InputLayoutMouseButton { Path = path }, DisplayButton = button }; AssignUnboundColor(mapping.DisplayButton); return(mapping); }
// ButtonJustReleased public bool ButtonJustReleased(int gameButton) { for (int i = 0; i < ButtonMappings[gameButton].Count; ++i) { ButtonMapping inputMapping = ButtonMappings[gameButton][i]; if (inputMapping.Device.ButtonJustReleased(inputMapping.Button)) { return(true); } } return(false); }
// ButtonAutoRepeat public bool ButtonAutoRepeat(int gameButton, float initialDelay, float repeatTime) { for (int i = 0; i < ButtonMappings[gameButton].Count; ++i) { ButtonMapping inputMapping = ButtonMappings[gameButton][i]; if (inputMapping.Device.ButtonAutoRepeat(inputMapping.Button, initialDelay, repeatTime)) { return(true); } } return(false); }
public SettingsForm() { for (int i = 0; i < buttonMappings.Length; i++) { buttonMappings[i] = new ButtonMapping(); } InitializeComponent(); ListViewItem lvItem; foreach (PS3Remote.Button button in Enum.GetValues(typeof(PS3Remote.Button))) { lvItem = new ListViewItem(); lvItem.SubItems.Add(button.ToString()); lvItem.SubItems.Add(""); lvButtons.Items.Add(lvItem); } foreach (SendInputAPI.Keyboard.KeyCode key in Enum.GetValues(typeof(SendInputAPI.Keyboard.KeyCode))) { lvKeys.Items.Add(new ListViewItem(key.ToString())); } if (!loadSettings()) { saveSettings(); } timerRepeat = new System.Timers.Timer(); timerRepeat.Interval = int.Parse(txtRepeatInterval.Text); timerRepeat.Elapsed += new System.Timers.ElapsedEventHandler(timerRepeat_Elapsed); try { remote = new PS3Remote(int.Parse(txtVendorId.Text.Remove(0, 2), System.Globalization.NumberStyles.HexNumber), int.Parse(txtProductId.Text.Remove(0, 2), System.Globalization.NumberStyles.HexNumber), cbHibernation.Checked); remote.BatteryLifeChanged += new EventHandler <EventArgs>(remote_BatteryLifeChanged); remote.ButtonDown += new EventHandler <PS3Remote.ButtonData>(remote_ButtonDown); remote.ButtonReleased += new EventHandler <PS3Remote.ButtonData>(remote_ButtonReleased); remote.Connected += new EventHandler <EventArgs>(remote_Connected); remote.Disconnected += new EventHandler <EventArgs>(remote_Disconnected); remote.connect(); } catch { MessageBox.Show("An error occured whilst attempting to load the remote.", "PS3BluMote: Remote error!", MessageBoxButtons.OK, MessageBoxIcon.Error); } keyboard = new SendInputAPI.Keyboard(cbSms.Checked); }
// ButtonHeldTimePrev public float ButtonHeldTimePrev(int gameButton) { float heldTimePrev = 0.0f; for (int i = 0; i < ButtonMappings[gameButton].Count; ++i) { ButtonMapping inputMapping = ButtonMappings[gameButton][i]; float buttonHeldTimePrev = inputMapping.Device.ButtonHeldTimePrev(inputMapping.Button); if (buttonHeldTimePrev > heldTimePrev) { heldTimePrev = buttonHeldTimePrev; } } return(heldTimePrev); }
// ButtonValue public float ButtonValue(int gameButton) { float value = 0.0f; for (int i = 0; i < ButtonMappings[gameButton].Count; ++i) { ButtonMapping inputMapping = ButtonMappings[gameButton][i]; float buttonValue = inputMapping.Device.ButtonValue(inputMapping.Button); if (buttonValue > value) { value = buttonValue; } } return(value); }
public GameBoyViewModel(IGameBoy gameBoy, IDispatcher dispatcher, IWindow window, IOpenFileDialogFactory fileDialogFactory, IKeyboardHandler keyboardHandler) { _gameBoy = gameBoy; _dispatcher = dispatcher; _window = window; _keyboardHandler = keyboardHandler; _keyboardHandler.KeyDown += OnKeyDown; _keyboardHandler.KeyUp += OnKeyUp; _window.OnClosing += HandleClosing; _buttonMapping = new ButtonMapping(); _memory = new MemoryViewModel(_gameBoy.Memory, "Memory View"); _cpu = new CPUViewModel(_gameBoy, _dispatcher); // TODO(aaecheve): Should this be another function handling this? _gameBoy.CPU.BreakpointFound += BreakpointHandler; _gameBoy.CPU.InterruptHappened += InterruptHandler; _gameBoy.ErrorEvent += _gameBoy_ErrorEvent; _interrupt = new InterruptManagerViewModel(_gameBoy, _dispatcher); _ioRegisters = new IORegistersManagerViewModel(_gameBoy, _dispatcher); _soundChannelInternals = new SoundChannelInternalsViewModel(_gameBoy); _display = new DisplayViewModel(_gameBoy, _gameBoy.Display, _gameBoy.Memory, _dispatcher); _gameBoyGamePad = new GameBoyGamePadViewModel(_gameBoy, _dispatcher); _breakpoints = new BreakpointsViewModel(_gameBoy); _dissasemble = new DissasembleViewModel(_breakpoints, _gameBoy); _instructionHistogram = new InstructionHistogramViewModel(_gameBoy, _dispatcher); _apu = new APUViewModel(_gameBoy, _dispatcher); _memoryImage = new MemoryImageViewModel(_gameBoy, _dispatcher); _soundRecording = new SoundRecordingViewModel(_gameBoy); _controls = new ControlsViewModel(this, _buttonMapping); // Gameboy Controller events _gameBoyController = new GameBoyContollerViewModel(_gameBoy, fileDialogFactory, _breakpoints); _gameBoyController.OnFileLoaded += FileLoadedHandler; _gameBoyController.OnStep += StepHandler; _gameBoyController.OnRun += RunHandler; _gameBoyController.OnPause += PauseHandler; }
private void ConnectButtonToLabel(ButtonMapping buttonMapping) { if (buttonMapping.ActionMapping != null) { var keyBounds = buttonMapping.DisplayButton.Outline.rectTransform.GetBounds(BoxLineExpand); var labelPoint = (Vector2)buttonMapping.ActionMapping.Label.Label.rectTransform.GetBounds().ClosestPoint(keyBounds.center); var keyPoint = (Vector2)keyBounds.ClosestPoint(labelPoint); labelPoint /= _canvas.scaleFactor; keyPoint /= _canvas.scaleFactor; buttonMapping.LabelLine ??= LinePrototype.Instantiate <UILineRenderer>(); buttonMapping.LabelLine.color = buttonMapping.ActionMapping.Label.Label.color; buttonMapping.LabelLine.Points = new[] { keyPoint, labelPoint }; } else { buttonMapping.LabelLine?.GetComponent <Prototype>().ReturnToPool(); buttonMapping.LabelLine = null; } }
public override bool OnKeyDown(Keycode keyCode, KeyEvent e) { InputDevice device = e.Device; if (device != null && device.Id == current_device_id) { if (IsGamepad(device)) { int index = ButtonMapping.OrdinalValue(keyCode); if (index >= 0) { buttons[index] = 1; //controller_view.Invalidate(); axes[4] = buttons[5]; Tello.setAxis(axes); } return(true); } } return(base.OnKeyDown(keyCode, e)); }
private IEnumerator ListenForJoin() { while (phase == Phase.Joining) { for (int i = 0; i < numControllers; ++i) { if (!hasPlayerJoined[i] && Input.GetButtonDown("Join" + i)) { hasPlayerJoined[i] = true; ButtonMapping buttons = defaultControls.GetMapping(i); PlayerData player = new PlayerData(i, playerColors[0], buttons); playerColors.RemoveAt(0); players.Add(player); if (OnPlayersChanged != null) { OnPlayersChanged(players); } } } yield return(null); } }
/// <summary> /// Initializes a new instance of the ControlsViewModel class. /// </summary> public ControlsViewModel(GameBoyViewModel gameboyViewModel, ButtonMapping mapping) { _gameboyViewModel = gameboyViewModel; _mapping = mapping; SetMode = false; }
private void HandleKeyDown(InputKey key) { switch (key) { case InputKey.Escape: // binding cancelled this.onClose(); return; //case InputKey.OemTilde: case InputKey.Control: case InputKey.Alt: this.Message = string.Format(MessageCannotBindToKey, InputKeyNameHelper.GetKeyText(key, returnPlaceholderIfNone: false)); return; } if (this.lastPressedKey != key) { // player pressed another key - verify if there are collisions with other mapped buttons this.lastPressedKey = key; var buttons = ClientInputManager.GetButtonForKey( key, this.viewModelMapping.ButtonInfo.Category); foreach (var button in buttons) { if (button.Equals(this.buttonToRebind)) { // pressed a key already bound to this button - allow rebinding break; } // pressed a different key this.Message = string.Format(MessageFormatKeyAlreadyBound, ClientInputManager.GetButtonInfo(button).Title); return; } } // do remapping var mapping = ClientInputManager.GetMappingForAbstractButton(this.buttonToRebind); if (this.isSecondaryKey) { var secondaryKey = key; var primaryKey = mapping.PrimaryKey != secondaryKey ? mapping.PrimaryKey : InputKey.None; mapping = new ButtonMapping(primaryKey, secondaryKey); } else { var primaryKey = key; var secondaryKey = mapping.SecondaryKey != primaryKey ? mapping.SecondaryKey : InputKey.None; mapping = new ButtonMapping(primaryKey, secondaryKey); } ClientInputManager.SetAbstractButtonMapping(this.buttonToRebind, mapping); Api.GetProtoEntity <ControlsOptionsCategory>().NotifyModified(); this.onClose(); }
public static bool GetButtonDown(int playerNumber, ButtonMapping buttonName) { return(Input.GetKeyDown(BToCode(playerNumber, buttonName))); }
public void KeyUp(ButtonMapping mapping, KeyEventArgs args) { foreach(Key key in mapping.Keys) { if (args.Key == key) { _gameBoy.ReleaseButton(mapping[key]); } } }
public SettingsForm() { for (int i = 0; i < buttonMappings.Length; i++) { buttonMappings[i] = new ButtonMapping(); } InitializeComponent(); ListViewItem lvItem; foreach (PS3Remote.Button button in Enum.GetValues(typeof(PS3Remote.Button))) { lvItem = new ListViewItem(); lvItem.SubItems.Add(button.ToString()); lvItem.SubItems.Add(""); lvButtons.Items.Add(lvItem); } foreach (SendInputAPI.Keyboard.KeyCode key in Enum.GetValues(typeof(SendInputAPI.Keyboard.KeyCode))) { lvKeys.Items.Add(new ListViewItem(key.ToString())); } if (!loadSettings()) { saveSettings(); } timerRepeat = new System.Timers.Timer(); timerRepeat.Interval = int.Parse(txtRepeatInterval.Text); timerRepeat.Elapsed += new System.Timers.ElapsedEventHandler(timerRepeat_Elapsed); buttonDump.Visible = DebugLog.isLogging; // Finding BT Address of the remote for Hibernation if (comboBtAddr.Text.Length != 12 && comboBtAddr.Text.Length != 17) { UpdateBtAddrList(1000); } else { comboBtAddr.Items.Clear(); comboBtAddr.Items.Add(comboBtAddr.Text); comboBtAddr.Items.Add("Search again"); comboBtAddr.Enabled = true; } // Saving Device Insertion sounds try { string s; bool save=false; s = RegUtils.GetDevConnectedSound(); if (insertSound.Length == 0 || (insertSound != s && s.Length > 0)) { insertSound = s; save = true; } s = RegUtils.GetDevDisconnectedSound(); if (removeSound.Length == 0 || (removeSound != s && s.Length > 0)) { removeSound = s; save = true; } if (save) saveSettings(); } catch { if (DebugLog.isLogging) DebugLog.write("Unexpected error while trying to save Devices insertion/remove sounds."); } // Restoring Device Insertion sounds in case they have been left blank try { string s; s = RegUtils.GetDevConnectedSound(); if (s.Length == 0 && insertSound.Length > 0) RegUtils.SetDevConnectedSound(insertSound); s = RegUtils.GetDevDisconnectedSound(); if (s.Length == 0 && removeSound.Length > 0) RegUtils.SetDevDisconnectedSound(removeSound); } catch { if (DebugLog.isLogging) DebugLog.write("Unexpected error while trying to restore Devices insertion/remove sounds."); } try { int hibMs; try { hibMs = System.Convert.ToInt32(txtMinutes.Text) * 60 * 1000; } catch { if (DebugLog.isLogging) DebugLog.write("Error while parsing Hibernation Interval, taking Default 3 Minutes"); txtMinutes.Text = "3"; hibMs = 180000; } remote = new PS3Remote(int.Parse(txtVendorId.Text.Remove(0, 2), System.Globalization.NumberStyles.HexNumber), int.Parse(txtProductId.Text.Remove(0, 2), System.Globalization.NumberStyles.HexNumber)); remote.BatteryLifeChanged += new EventHandler<EventArgs>(remote_BatteryLifeChanged); remote.ButtonDown += new EventHandler<PS3Remote.ButtonData>(remote_ButtonDown); remote.ButtonReleased += new EventHandler<PS3Remote.ButtonData>(remote_ButtonReleased); remote.Connected += new EventHandler<EventArgs>(remote_Connected); remote.Disconnected += new EventHandler<EventArgs>(remote_Disconnected); remote.Hibernated += new EventHandler<EventArgs>(remote_Hibernated); remote.Awake += new EventHandler<EventArgs>(remote_Connected); remote.connect(); remote.btAddress = comboBtAddr.Text; remote.hibernationInterval = hibMs; remote.hibernationEnabled = cbHibernation.Enabled && cbHibernation.Checked; } catch { MessageBox.Show("An error occured whilst attempting to load the remote.", "PS3BluMote: Remote error!", MessageBoxButtons.OK, MessageBoxIcon.Error); } keyboard = new SendInputAPI.Keyboard(cbSms.Checked); }
public SettingsForm() { for (int i = 0; i < buttonMappings.Length; i++) { buttonMappings[i] = new ButtonMapping(); } InitializeComponent(); ListViewItem lvItem; foreach (PS3Remote.Button button in Enum.GetValues(typeof(PS3Remote.Button))) { lvItem = new ListViewItem(); lvItem.SubItems.Add(button.ToString()); lvItem.SubItems.Add(""); lvButtons.Items.Add(lvItem); } foreach (SendInputAPI.Keyboard.KeyCode key in Enum.GetValues(typeof(SendInputAPI.Keyboard.KeyCode))) { lvKeys.Items.Add(new ListViewItem(key.ToString())); } if (!loadSettings()) { saveSettings(); } timerRepeat = new System.Timers.Timer(); timerRepeat.Interval = int.Parse(txtRepeatInterval.Text); timerRepeat.Elapsed += new System.Timers.ElapsedEventHandler(timerRepeat_Elapsed); buttonDump.Visible = DebugLog.isLogging; // Finding BT Address of the remote for Hibernation if (comboBtAddr.Text.Length != 12 && comboBtAddr.Text.Length != 17) { UpdateBtAddrList(1000); } else { comboBtAddr.Items.Clear(); comboBtAddr.Items.Add(comboBtAddr.Text); comboBtAddr.Items.Add("Search again"); comboBtAddr.Enabled = true; } // Saving Device Insertion sounds try { string s; bool save = false; s = RegUtils.GetDevConnectedSound(); if (insertSound.Length == 0 || (insertSound != s && s.Length > 0)) { insertSound = s; save = true; } s = RegUtils.GetDevDisconnectedSound(); if (removeSound.Length == 0 || (removeSound != s && s.Length > 0)) { removeSound = s; save = true; } if (save) { saveSettings(); } } catch { if (DebugLog.isLogging) { DebugLog.write("Unexpected error while trying to save Devices insertion/remove sounds."); } } // Restoring Device Insertion sounds in case they have been left blank try { string s; s = RegUtils.GetDevConnectedSound(); if (s.Length == 0 && insertSound.Length > 0) { RegUtils.SetDevConnectedSound(insertSound); } s = RegUtils.GetDevDisconnectedSound(); if (s.Length == 0 && removeSound.Length > 0) { RegUtils.SetDevDisconnectedSound(removeSound); } } catch { if (DebugLog.isLogging) { DebugLog.write("Unexpected error while trying to restore Devices insertion/remove sounds."); } } try { int hibMs; try { hibMs = System.Convert.ToInt32(txtMinutes.Text) * 60 * 1000; } catch { if (DebugLog.isLogging) { DebugLog.write("Error while parsing Hibernation Interval, taking Default 3 Minutes"); } txtMinutes.Text = "3"; hibMs = 180000; } remote = new PS3Remote(int.Parse(txtVendorId.Text.Remove(0, 2), System.Globalization.NumberStyles.HexNumber), int.Parse(txtProductId.Text.Remove(0, 2), System.Globalization.NumberStyles.HexNumber)); remote.BatteryLifeChanged += new EventHandler <EventArgs>(remote_BatteryLifeChanged); remote.ButtonDown += new EventHandler <PS3Remote.ButtonData>(remote_ButtonDown); remote.ButtonReleased += new EventHandler <PS3Remote.ButtonData>(remote_ButtonReleased); remote.Connected += new EventHandler <EventArgs>(remote_Connected); remote.Disconnected += new EventHandler <EventArgs>(remote_Disconnected); remote.Hibernated += new EventHandler <EventArgs>(remote_Hibernated); remote.Awake += new EventHandler <EventArgs>(remote_Connected); remote.connect(); remote.btAddress = comboBtAddr.Text; remote.hibernationInterval = hibMs; remote.hibernationEnabled = cbHibernation.Enabled && cbHibernation.Checked; } catch { MessageBox.Show("An error occured whilst attempting to load the remote.", "PS3BluMote: Remote error!", MessageBoxButtons.OK, MessageBoxIcon.Error); } keyboard = new SendInputAPI.Keyboard(cbSms.Checked); }
public void KeyDown(ButtonMapping mapping, KeyEventArgs args) { foreach(Key key in mapping.Keys) { if (args.Key == key) { _gameBoy.PressButton(mapping[key]); } } }
protected bool GetButton(int playerNumber, ButtonMapping buttonName) { return(Input.GetKey(BToCode(playerNumber, buttonName))); }
/// <summary> /// Returns the index of the button that is to be checked within the controller's mapping configuration. /// </summary> /// <param name="button">The requested button whose index is to be obtained.</param> /// <param name="buttonMappings">The button mapping for the specified controller.</param> /// <returns></returns> public static int DInputGetMappedButtonIndex(ControllerButtonsGeneric button, ButtonMapping buttonMappings) { // Stores the button that is to be checked. int buttonToTest = ButtonNull; // Switch statement checks the mapping of each button to the virtual xbox button. switch (button) { case ControllerButtonsGeneric.ButtonA: buttonToTest = buttonMappings.ButtonA; break; case ControllerButtonsGeneric.ButtonB: buttonToTest = buttonMappings.ButtonB; break; case ControllerButtonsGeneric.ButtonX: buttonToTest = buttonMappings.ButtonX; break; case ControllerButtonsGeneric.ButtonY: buttonToTest = buttonMappings.ButtonY; break; case ControllerButtonsGeneric.ButtonLb: buttonToTest = buttonMappings.ButtonLb; break; case ControllerButtonsGeneric.ButtonRb: buttonToTest = buttonMappings.ButtonRb; break; case ControllerButtonsGeneric.ButtonLs: buttonToTest = buttonMappings.ButtonLs; break; case ControllerButtonsGeneric.ButtonRs: buttonToTest = buttonMappings.ButtonRs; break; case ControllerButtonsGeneric.ButtonBack: buttonToTest = buttonMappings.ButtonBack; break; case ControllerButtonsGeneric.ButtonStart: buttonToTest = buttonMappings.ButtonStart; break; case ControllerButtonsGeneric.ButtonGuide: buttonToTest = buttonMappings.ButtonGuide; break; } // Return the button that is to be checked. return(buttonToTest); }
public void MapAction(string actionName, ButtonMapping button) { mappedActions[actionName] = button; }
protected static KeyCode BToCode(int playerNumber, ButtonMapping buttonName) { playerNumber++; //1-based return((KeyCode)Enum.Parse(typeof(KeyCode), "Joystick" + playerNumber + "Button" + (int)buttonName)); }