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); }
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); }
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); }