Example #1
0
        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);
        }
Example #2
0
        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);
        }
Example #3
0
        private void remote_ButtonReleased(object sender, PS3Remote.ButtonData e)
        {
            if (DebugLog.isLogging) DebugLog.write("Button released: " + e.button.ToString());

            if (timerRepeat.Enabled)
            {
                if (DebugLog.isLogging) DebugLog.write("Keys repeat send off: { " + String.Join(",", keyboard.lastKeysDown.ToArray()) + " }");

                timerRepeat.Enabled = false;
                return;
            }

            if (DebugLog.isLogging) DebugLog.write("Keys up: { " + String.Join(",", keyboard.lastKeysDown.ToArray()) + " }");

            keyboard.releaseLastKeys();
        }
Example #4
0
        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()) + " }");
        }
Example #5
0
        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);
        }
Example #6
0
        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);
        }