Example #1
0
 // start gamepad in a separate task
 private void gamepadButton_Click(object sender, EventArgs e)
 {
     // only start up the gamepad if it's not already running.
     if (ds4 == null) {              // if gamepad is null,
         ds4 = new DualShock4(this); // make a new one, passing a reference to this form.
         Task t = Task.Run(() => {   // run in separate thread to not lock up the ui.
             ds4.gamepad();          // locking function. If we come out of here,
             ds4 = null;             // destroy our gamepad because we're done with it,
                                     // so maybe a new one can be made later.
         });
     }
     else { // gamepad already running, do nothing.
         log("Error: Gamepad already running!");
     }
 }
Example #2
0
        private void disconnectButton_Click(object sender, EventArgs e)
        {
            try {
                doDisconnect = true;
                socket.Close();
                log("Successfully disconnected.");
                ds4 = null;
                log("Gamepad wiped");
                recv.Dispose();

                ipCombobox.Enabled = true;
                ipCombobox.BackColor = System.Drawing.Color.White;
                buttonConnect.Enabled = true;
                disconnectButton.Enabled = false;
                disconnectButton.BackColor = System.Drawing.Color.Silver;
            }
            catch (Exception ex) {
                log("Error in disconnection function: " + ex.Message);
                return;
            }
        }