示例#1
0
        //Called every time the new input report has arrived
        protected virtual void On_Report(object sender, EventArgs e)
        {
            DS4Device device = (DS4Device)sender;

            int ind = -1;

            for (int i = 0; i < DS4Controllers.Length; i++)
            {
                if (device == DS4Controllers[i])
                {
                    ind = i;
                }
            }

            if (ind != -1)
            {
                device.getExposedState(ExposedState[ind], CurrentState[ind]);
                DS4State cState = CurrentState[ind];
                device.getPreviousState(PreviousState[ind]);
                DS4State pState = PreviousState[ind];
                if (pState.Battery != cState.Battery)
                {
                    Global.ControllerStatusChanged(this);
                }
                CheckForHotkeys(ind, cState, pState);
                GetInputkeys(ind);

                if (Global.getHasCustomKeysorButtons(ind))
                {
                    Mapping.MapCustom(ind, cState, MappedState[ind], ExposedState[ind]);
                    cState = MappedState[ind];
                }

                // Update the GUI/whatever.
                DS4LightBar.updateLightBar(device, ind, cState, ExposedState[ind]);

                x360Bus.Parse(cState, processingData[ind].Report, ind);
                // We push the translated Xinput state, and simultaneously we
                // pull back any possible rumble data coming from Xinput consumers.
                if (x360Bus.Report(processingData[ind].Report, processingData[ind].Rumble))
                {
                    Byte Big   = (Byte)(processingData[ind].Rumble[3]);
                    Byte Small = (Byte)(processingData[ind].Rumble[4]);

                    if (processingData[ind].Rumble[1] == 0x08)
                    {
                        setRumble(Small, Big, ind);
                    }
                }

                // Output any synthetic events.
                Mapping.Commit(ind);
                // Pull settings updates.
                device.IdleTimeout = Global.getIdleDisconnectTimeout(ind);
            }
        }
示例#2
0
 public bool Stop(bool showlog = true)
 {
     if (running)
     {
         running = false;
         if (showlog)
         {
             LogDebug(Properties.Resources.StoppingX360);
         }
         bool anyUnplugged = false;
         for (int i = 0; i < DS4Controllers.Length; i++)
         {
             if (DS4Controllers[i] != null)
             {
                 if (Global.getDCBTatStop() && !DS4Controllers[i].Charging && showlog)
                 {
                     DS4Controllers[i].DisconnectBT();
                 }
                 else
                 {
                     DS4LightBar.defualtLight = true;
                     DS4LightBar.updateLightBar(DS4Controllers[i], i, CurrentState[i], ExposedState[i], touchPad[i]);
                     System.Threading.Thread.Sleep(50);
                 }
                 CurrentState[i].Battery = PreviousState[i].Battery = 0; // Reset for the next connection's initial status change.
                 x360Bus.Unplug(i);
                 anyUnplugged      = true;
                 DS4Controllers[i] = null;
                 touchPad[i]       = null;
             }
         }
         if (anyUnplugged)
         {
             System.Threading.Thread.Sleep(XINPUT_UNPLUG_SETTLE_TIME);
         }
         x360Bus.UnplugAll();
         x360Bus.Stop();
         if (showlog)
         {
             LogDebug(Properties.Resources.StoppingDS4);
         }
         DS4Devices.stopControllers();
         if (showlog)
         {
             LogDebug(Properties.Resources.StoppedDS4Windows);
         }
         Global.ControllerStatusChanged(this);
     }
     return(true);
 }
示例#3
0
        //Called every time the new input report has arrived
        protected virtual void On_Report(object sender, EventArgs e)
        {
            DS4Device device = (DS4Device)sender;

            int ind = -1;

            for (int i = 0; i < DS4Controllers.Length; i++)
            {
                if (device == DS4Controllers[i])
                {
                    ind = i;
                }
            }

            if (ind != -1)
            {
                if (Global.getFlushHIDQueue(ind))
                {
                    device.FlushHID();
                }
                if (!string.IsNullOrEmpty(device.error))
                {
                    LogDebug(device.error);
                }
                device.getExposedState(ExposedState[ind], CurrentState[ind]);
                DS4State cState = CurrentState[ind];
                device.getPreviousState(PreviousState[ind]);
                DS4State pState = PreviousState[ind];
                if (pState.Battery != cState.Battery)
                {
                    Global.ControllerStatusChanged(this);
                }
                CheckForHotkeys(ind, cState, pState);
                GetInputkeys(ind);
                if (Global.getLSCurve(ind) + Global.getRSCurve(ind) + Global.getLSDeadzone(ind) + Global.getRSDeadzone(ind) +
                    Global.getL2Deadzone(ind) + Global.getR2Deadzone(ind) > 0) //if a curve or deadzone is in place
                {
                    cState = Mapping.SetCurveAndDeadzone(ind, cState);
                }
                if (!recordingMacro && (!string.IsNullOrEmpty(Global.tempprofilename[ind]) ||
                                        Global.getHasCustomKeysorButtons(ind) || Global.getHasShiftCustomKeysorButtons(ind)))
                {
                    Mapping.MapCustom(ind, cState, MappedState[ind], ExposedState[ind], touchPad[ind], this);
                    cState = MappedState[ind];
                }
                if (Global.getHasCustomExtras(ind))
                {
                    DoExtras(ind);
                }

                // Update the GUI/whatever.
                DS4LightBar.updateLightBar(device, ind, cState, ExposedState[ind], touchPad[ind]);

                x360Bus.Parse(cState, processingData[ind].Report, ind);
                // We push the translated Xinput state, and simultaneously we
                // pull back any possible rumble data coming from Xinput consumers.
                if (x360Bus.Report(processingData[ind].Report, processingData[ind].Rumble))
                {
                    Byte Big   = (Byte)(processingData[ind].Rumble[3]);
                    Byte Small = (Byte)(processingData[ind].Rumble[4]);

                    if (processingData[ind].Rumble[1] == 0x08)
                    {
                        setRumble(Big, Small, ind);
                    }
                }

                // Output any synthetic events.
                Mapping.Commit(ind);
                // Pull settings updates.
                device.IdleTimeout = Global.getIdleDisconnectTimeout(ind);
            }
        }