getCurrentState() public méthode

public getCurrentState ( ) : DS4Windows.DS4State
Résultat DS4Windows.DS4State
Exemple #1
0
 public virtual void touchesMoved(object sender, TouchpadEventArgs arg)
 {
     if (!Global.UseTPforControls[deviceNum])
     {
         cursor.touchesMoved(arg, dragging || dragging2);
         wheel.touchesMoved(arg, dragging || dragging2);
     }
     else
     {
         if (!(swipeUp || swipeDown || swipeLeft || swipeRight) && arg.touches.Length == 1)
         {
             if (arg.touches[0].hwX - firstTouch.hwX > 400)
             {
                 swipeRight = true;
             }
             if (arg.touches[0].hwX - firstTouch.hwX < -400)
             {
                 swipeLeft = true;
             }
             if (arg.touches[0].hwY - firstTouch.hwY > 300)
             {
                 swipeDown = true;
             }
             if (arg.touches[0].hwY - firstTouch.hwY < -300)
             {
                 swipeUp = true;
             }
         }
         swipeUpB    = (byte)Math.Min(255, Math.Max(0, (firstTouch.hwY - arg.touches[0].hwY) * 1.5f));
         swipeDownB  = (byte)Math.Min(255, Math.Max(0, (arg.touches[0].hwY - firstTouch.hwY) * 1.5f));
         swipeLeftB  = (byte)Math.Min(255, Math.Max(0, firstTouch.hwX - arg.touches[0].hwX));
         swipeRightB = (byte)Math.Min(255, Math.Max(0, arg.touches[0].hwX - firstTouch.hwX));
     }
     if (Math.Abs(firstTouch.hwY - arg.touches[0].hwY) < 50 && arg.touches.Length == 2)
     {
         if (arg.touches[0].hwX - firstTouch.hwX > 200 && !slideleft)
         {
             slideright = true;
         }
         else if (firstTouch.hwX - arg.touches[0].hwX > 200 && !slideright)
         {
             slideleft = true;
         }
     }
     dev.getCurrentState(s);
     synthesizeMouseButtons();
 }
Exemple #2
0
        public virtual void sixaxisMoved(object sender, SixAxisEventArgs arg)
        {
            if (Global.isUsingSAforMouse(deviceNum) && Global.getGyroSensitivity(deviceNum) > 0)
            {
                triggeractivated  = true;
                useReverseRatchet = Global.getGyroTriggerTurns(deviceNum);
                int      i  = 0;
                string[] ss = Global.getSATriggers(deviceNum).Split(',');
                if (!string.IsNullOrEmpty(ss[0]))
                {
                    string s = string.Empty;
                    for (int index = 0, arlen = ss.Length; triggeractivated && index < arlen; index++)
                    //foreach (string s in ss)
                    {
                        s = ss[index];
                        if (!(int.TryParse(s, out i) && getDS4ControlsByName(i)))
                        {
                            triggeractivated = false;
                        }
                    }
                }

                if (useReverseRatchet && triggeractivated)
                {
                    cursor.sixaxisMoved(arg);
                }
                else if (!useReverseRatchet && !triggeractivated)
                {
                    cursor.sixaxisMoved(arg);
                }
                else
                {
                    cursor.mouseRemainderReset();
                }

                dev.getCurrentState(s);
            }
        }
Exemple #3
0
 public virtual void sixaxisMoved(object sender, SixAxisEventArgs arg)
 {
     if (Global.UseSAforMouse[deviceNum] && Global.GyroSensitivity[deviceNum] > 0)
     {
         bool     triggeractivated = true;
         int      i  = 0;
         string[] ss = Global.SATriggers[deviceNum].Split(',');
         if (!string.IsNullOrEmpty(ss[0]))
         {
             foreach (string s in ss)
             {
                 if (!(int.TryParse(s, out i) && getDS4ControlsByName(i)))
                 {
                     triggeractivated = false;
                 }
             }
         }
         if (triggeractivated)
         {
             cursor.sixaxisMoved(arg);
         }
         dev.getCurrentState(s);
     }
 }
        // Called every time a 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, arlength = DS4_CONTROLLER_COUNT; ind == -1 && i < arlength; i++)
            {
                DS4Device tempDev = DS4Controllers[i];
                if (tempDev != null && device == tempDev)
                {
                    ind = i;
                }
            }

            if (ind != -1)
            {
                if (getFlushHIDQueue(ind))
                {
                    device.FlushHID();
                }

                string devError = tempStrings[ind] = device.error;
                if (!string.IsNullOrEmpty(devError))
                {
                    device.getUiContext()?.Post(new SendOrPostCallback(delegate(object state)
                    {
                        LogDebug(devError);
                    }), null);
                }

                if (inWarnMonitor[ind])
                {
                    int flashWhenLateAt = getFlashWhenLateAt();
                    if (!lag[ind] && device.Latency >= flashWhenLateAt)
                    {
                        lag[ind] = true;
                        device.getUiContext()?.Post(new SendOrPostCallback(delegate(object state)
                        {
                            LagFlashWarning(ind, true);
                        }), null);
                    }
                    else if (lag[ind] && device.Latency < flashWhenLateAt)
                    {
                        lag[ind] = false;
                        device.getUiContext()?.Post(new SendOrPostCallback(delegate(object state)
                        {
                            LagFlashWarning(ind, false);
                        }), null);
                    }
                }
                else
                {
                    if (DateTime.UtcNow - device.firstActive > TimeSpan.FromSeconds(5))
                    {
                        inWarnMonitor[ind] = true;
                    }
                }

                device.getCurrentState(CurrentState[ind]);
                DS4State cState = CurrentState[ind];
                DS4State pState = device.getPreviousStateRef();
                //device.getPreviousState(PreviousState[ind]);
                //DS4State pState = PreviousState[ind];

                if (!device.firstReport && device.IsAlive())
                {
                    device.firstReport = true;
                    device.getUiContext()?.Post(new SendOrPostCallback(delegate(object state)
                    {
                        OnDeviceStatusChanged(this, ind);
                    }), null);
                }
                else if (pState.Battery != cState.Battery || device.oldCharging != device.isCharging())
                {
                    byte tempBattery  = currentBattery[ind] = cState.Battery;
                    bool tempCharging = charging[ind] = device.isCharging();
                    device.getUiContext()?.Post(new SendOrPostCallback(delegate(object state)
                    {
                        OnBatteryStatusChange(this, ind, tempBattery, tempCharging);
                    }), null);
                }

                if (getEnableTouchToggle(ind))
                {
                    CheckForTouchToggle(ind, cState, pState);
                }

                cState = Mapping.SetCurveAndDeadzone(ind, cState);

                if (!recordingMacro && (!string.IsNullOrEmpty(tempprofilename[ind]) ||
                                        containsCustomAction(ind) || containsCustomExtras(ind) ||
                                        getProfileActionCount(ind) > 0))
                {
                    Mapping.MapCustom(ind, cState, MappedState[ind], ExposedState[ind], touchPad[ind], this);
                    cState = MappedState[ind];
                }

                if (!useDInputOnly[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   = processingData[ind].Rumble[3];
                        byte Small = processingData[ind].Rumble[4];

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

                if (_udpServer != null)
                {
                    _udpServer.NewReportIncoming(GetPadDetailForIdx(ind), CurrentState[ind]);
                }

                // Output any synthetic events.
                Mapping.Commit(ind);

                // Update the GUI/whatever.
                DS4LightBar.updateLightBar(device, ind, cState, ExposedState[ind], touchPad[ind]);
            }
        }
Exemple #5
0
        public static bool shiftMod(DS4Device device, int deviceNum, DS4State cState, DS4StateExposed eState, Mouse tp)
        {
            bool shift;

            switch (ShiftModifier[deviceNum])
            {
            case 1: shift = Mapping.getBoolMapping(DS4Controls.Cross, cState, eState, tp); break;

            case 2: shift = Mapping.getBoolMapping(DS4Controls.Circle, cState, eState, tp); break;

            case 3: shift = Mapping.getBoolMapping(DS4Controls.Square, cState, eState, tp); break;

            case 4: shift = Mapping.getBoolMapping(DS4Controls.Triangle, cState, eState, tp); break;

            case 5: shift = Mapping.getBoolMapping(DS4Controls.Options, cState, eState, tp); break;

            case 6: shift = Mapping.getBoolMapping(DS4Controls.Share, cState, eState, tp); break;

            case 7: shift = Mapping.getBoolMapping(DS4Controls.DpadUp, cState, eState, tp); break;

            case 8: shift = Mapping.getBoolMapping(DS4Controls.DpadDown, cState, eState, tp); break;

            case 9: shift = Mapping.getBoolMapping(DS4Controls.DpadLeft, cState, eState, tp); break;

            case 10: shift = Mapping.getBoolMapping(DS4Controls.DpadRight, cState, eState, tp); break;

            case 11: shift = Mapping.getBoolMapping(DS4Controls.PS, cState, eState, tp); break;

            case 12: shift = Mapping.getBoolMapping(DS4Controls.L1, cState, eState, tp); break;

            case 13: shift = Mapping.getBoolMapping(DS4Controls.R1, cState, eState, tp); break;

            case 14: shift = Mapping.getBoolMapping(DS4Controls.L2, cState, eState, tp); break;

            case 15: shift = Mapping.getBoolMapping(DS4Controls.R2, cState, eState, tp); break;

            case 16: shift = Mapping.getBoolMapping(DS4Controls.L3, cState, eState, tp); break;

            case 17: shift = Mapping.getBoolMapping(DS4Controls.R3, cState, eState, tp); break;

            case 18: shift = Mapping.getBoolMapping(DS4Controls.TouchLeft, cState, eState, tp); break;

            case 19: shift = Mapping.getBoolMapping(DS4Controls.TouchUpper, cState, eState, tp); break;

            case 20: shift = Mapping.getBoolMapping(DS4Controls.TouchMulti, cState, eState, tp); break;

            case 21: shift = Mapping.getBoolMapping(DS4Controls.TouchRight, cState, eState, tp); break;

            case 22: shift = Mapping.getBoolMapping(DS4Controls.GyroZNeg, cState, eState, tp); break;

            case 23: shift = Mapping.getBoolMapping(DS4Controls.GyroZPos, cState, eState, tp); break;

            case 24: shift = Mapping.getBoolMapping(DS4Controls.GyroXPos, cState, eState, tp); break;

            case 25: shift = Mapping.getBoolMapping(DS4Controls.GyroXNeg, cState, eState, tp); break;

            case 26: shift = device.getCurrentState().Touch1; break;

            default: shift = false; break;
            }
            return(shift);
        }