Example #1
0
 public void getPreviousState(ControllerState state)
 {
     pState.CopyTo(state);
 }
Example #2
0
 public void getExposedState(EAll4StateExposed expState, ControllerState state)
 {
     cState.CopyTo(state);
     expState.Accel = accel;
     expState.Gyro  = gyro;
 }
Example #3
0
 public void getCurrentState(ControllerState state)
 {
     cState.CopyTo(state);
 }
Example #4
0
        public GenericControls GetInputkeysEAll4(int ind)
        {
            ControllerState   cState = CurrentState[ind];
            EAll4StateExposed eState = ExposedState[ind];
            Mouse             tp     = touchPad[ind];

            if (controllers[ind] != null)
            {
                if (Mapping.getBoolMapping(GenericControls.A, cState, eState, tp))
                {
                    return(GenericControls.A);
                }
                else if (Mapping.getBoolMapping(GenericControls.B, cState, eState, tp))
                {
                    return(GenericControls.B);
                }
                else if (Mapping.getBoolMapping(GenericControls.Y, cState, eState, tp))
                {
                    return(GenericControls.Y);
                }
                else if (Mapping.getBoolMapping(GenericControls.X, cState, eState, tp))
                {
                    return(GenericControls.X);
                }
                else if (Mapping.getBoolMapping(GenericControls.LB, cState, eState, tp))
                {
                    return(GenericControls.LB);
                }
                else if (Mapping.getBoolMapping(GenericControls.RB, cState, eState, tp))
                {
                    return(GenericControls.RB);
                }
                else if (Mapping.getBoolMapping(GenericControls.LT, cState, eState, tp))
                {
                    return(GenericControls.LT);
                }
                else if (Mapping.getBoolMapping(GenericControls.RT, cState, eState, tp))
                {
                    return(GenericControls.RT);
                }
                else if (Mapping.getBoolMapping(GenericControls.LS, cState, eState, tp))
                {
                    return(GenericControls.LS);
                }
                else if (Mapping.getBoolMapping(GenericControls.RS, cState, eState, tp))
                {
                    return(GenericControls.RS);
                }
                else if (Mapping.getBoolMapping(GenericControls.DpadUp, cState, eState, tp))
                {
                    return(GenericControls.DpadUp);
                }
                else if (Mapping.getBoolMapping(GenericControls.DpadDown, cState, eState, tp))
                {
                    return(GenericControls.DpadDown);
                }
                else if (Mapping.getBoolMapping(GenericControls.DpadLeft, cState, eState, tp))
                {
                    return(GenericControls.DpadLeft);
                }
                else if (Mapping.getBoolMapping(GenericControls.DpadRight, cState, eState, tp))
                {
                    return(GenericControls.DpadRight);
                }
                else if (Mapping.getBoolMapping(GenericControls.Back, cState, eState, tp))
                {
                    return(GenericControls.Back);
                }
                else if (Mapping.getBoolMapping(GenericControls.Start, cState, eState, tp))
                {
                    return(GenericControls.Start);
                }
                else if (Mapping.getBoolMapping(GenericControls.Guide, cState, eState, tp))
                {
                    return(GenericControls.Guide);
                }
                else if (Mapping.getBoolMapping(GenericControls.LXPos, cState, eState, tp))
                {
                    return(GenericControls.LXPos);
                }
                else if (Mapping.getBoolMapping(GenericControls.LXNeg, cState, eState, tp))
                {
                    return(GenericControls.LXNeg);
                }
                else if (Mapping.getBoolMapping(GenericControls.LYPos, cState, eState, tp))
                {
                    return(GenericControls.LYPos);
                }
                else if (Mapping.getBoolMapping(GenericControls.LYNeg, cState, eState, tp))
                {
                    return(GenericControls.LYNeg);
                }
                else if (Mapping.getBoolMapping(GenericControls.RXPos, cState, eState, tp))
                {
                    return(GenericControls.RXPos);
                }
                else if (Mapping.getBoolMapping(GenericControls.RXNeg, cState, eState, tp))
                {
                    return(GenericControls.RXNeg);
                }
                else if (Mapping.getBoolMapping(GenericControls.RYPos, cState, eState, tp))
                {
                    return(GenericControls.RYPos);
                }
                else if (Mapping.getBoolMapping(GenericControls.RYNeg, cState, eState, tp))
                {
                    return(GenericControls.RYNeg);
                }
                else if (Mapping.getBoolMapping(GenericControls.TouchLeft, cState, eState, tp))
                {
                    return(GenericControls.TouchLeft);
                }
                else if (Mapping.getBoolMapping(GenericControls.TouchRight, cState, eState, tp))
                {
                    return(GenericControls.TouchRight);
                }
                else if (Mapping.getBoolMapping(GenericControls.TouchMulti, cState, eState, tp))
                {
                    return(GenericControls.TouchMulti);
                }
                else if (Mapping.getBoolMapping(GenericControls.TouchUpper, cState, eState, tp))
                {
                    return(GenericControls.TouchUpper);
                }
            }
            return(GenericControls.None);
        }
Example #5
0
        public string GetInputkeys(int ind)
        {
            ControllerState   cState = CurrentState[ind];
            EAll4StateExposed eState = ExposedState[ind];
            Mouse             tp     = touchPad[ind];

            if (controllers[ind] != null)
            {
                if (Mapping.getBoolMapping(GenericControls.A, cState, eState, tp))
                {
                    return("A");
                }
                else if (Mapping.getBoolMapping(GenericControls.B, cState, eState, tp))
                {
                    return("B");
                }
                else if (Mapping.getBoolMapping(GenericControls.Y, cState, eState, tp))
                {
                    return("Y");
                }
                else if (Mapping.getBoolMapping(GenericControls.X, cState, eState, tp))
                {
                    return("X");
                }
                else if (Mapping.getBoolMapping(GenericControls.LB, cState, eState, tp))
                {
                    return("LB");
                }
                else if (Mapping.getBoolMapping(GenericControls.RB, cState, eState, tp))
                {
                    return("RB");
                }
                else if (Mapping.getBoolMapping(GenericControls.LT, cState, eState, tp))
                {
                    return("LT");
                }
                else if (Mapping.getBoolMapping(GenericControls.RT, cState, eState, tp))
                {
                    return("RT");
                }
                else if (Mapping.getBoolMapping(GenericControls.LS, cState, eState, tp))
                {
                    return("LS");
                }
                else if (Mapping.getBoolMapping(GenericControls.RS, cState, eState, tp))
                {
                    return("RS");
                }
                else if (Mapping.getBoolMapping(GenericControls.DpadUp, cState, eState, tp))
                {
                    return("Up");
                }
                else if (Mapping.getBoolMapping(GenericControls.DpadDown, cState, eState, tp))
                {
                    return("Down");
                }
                else if (Mapping.getBoolMapping(GenericControls.DpadLeft, cState, eState, tp))
                {
                    return("Left");
                }
                else if (Mapping.getBoolMapping(GenericControls.DpadRight, cState, eState, tp))
                {
                    return("Right");
                }
                else if (Mapping.getBoolMapping(GenericControls.Back, cState, eState, tp))
                {
                    return("Back");
                }
                else if (Mapping.getBoolMapping(GenericControls.Start, cState, eState, tp))
                {
                    return("Start");
                }
                else if (Mapping.getBoolMapping(GenericControls.Guide, cState, eState, tp))
                {
                    return("Guide");
                }
                else if (Mapping.getBoolMapping(GenericControls.LXPos, cState, eState, tp))
                {
                    return("LS Right");
                }
                else if (Mapping.getBoolMapping(GenericControls.LXNeg, cState, eState, tp))
                {
                    return("LS Left");
                }
                else if (Mapping.getBoolMapping(GenericControls.LYPos, cState, eState, tp))
                {
                    return("LS Down");
                }
                else if (Mapping.getBoolMapping(GenericControls.LYNeg, cState, eState, tp))
                {
                    return("LS Up");
                }
                else if (Mapping.getBoolMapping(GenericControls.RXPos, cState, eState, tp))
                {
                    return("RS Right");
                }
                else if (Mapping.getBoolMapping(GenericControls.RXNeg, cState, eState, tp))
                {
                    return("RS Left");
                }
                else if (Mapping.getBoolMapping(GenericControls.RYPos, cState, eState, tp))
                {
                    return("RS Down");
                }
                else if (Mapping.getBoolMapping(GenericControls.RYNeg, cState, eState, tp))
                {
                    return("RS Up");
                }
                else if (Mapping.getBoolMapping(GenericControls.TouchLeft, cState, eState, tp))
                {
                    return("Touch Left");
                }
                else if (Mapping.getBoolMapping(GenericControls.TouchRight, cState, eState, tp))
                {
                    return("Touch Right");
                }
                else if (Mapping.getBoolMapping(GenericControls.TouchMulti, cState, eState, tp))
                {
                    return("Touch Multi");
                }
                else if (Mapping.getBoolMapping(GenericControls.TouchUpper, cState, eState, tp))
                {
                    return("Touch Upper");
                }
            }
            return("nothing");
        }
Example #6
0
        public void EasterTime(int ind)
        {
            ControllerState   cState = CurrentState[ind];
            EAll4StateExposed eState = ExposedState[ind];
            Mouse             tp     = touchPad[ind];

            bool pb = false;

            foreach (GenericControls dc in dcs)
            {
                if (Mapping.getBoolMapping(dc, cState, eState, tp))
                {
                    pb = true;
                    break;
                }
            }
            int temp = eCode;

            //Looks like you found the easter egg code, since you're already cheating,
            //I scrambled the code for you :)
            if (pb && !buttonsdown[ind])
            {
                if (cState.A && eCode == 9)
                {
                    eCode++;
                }
                else if (!cState.A && eCode == 9)
                {
                    eCode = 0;
                }
                else if (cState.DpadLeft && eCode == 6)
                {
                    eCode++;
                }
                else if (!cState.DpadLeft && eCode == 6)
                {
                    eCode = 0;
                }
                else if (cState.DpadRight && eCode == 7)
                {
                    eCode++;
                }
                else if (!cState.DpadRight && eCode == 7)
                {
                    eCode = 0;
                }
                else if (cState.DpadLeft && eCode == 4)
                {
                    eCode++;
                }
                else if (!cState.DpadLeft && eCode == 4)
                {
                    eCode = 0;
                }
                else if (cState.DpadDown && eCode == 2)
                {
                    eCode++;
                }
                else if (!cState.DpadDown && eCode == 2)
                {
                    eCode = 0;
                }
                else if (cState.DpadRight && eCode == 5)
                {
                    eCode++;
                }
                else if (!cState.DpadRight && eCode == 5)
                {
                    eCode = 0;
                }
                else if (cState.DpadUp && eCode == 1)
                {
                    eCode++;
                }
                else if (!cState.DpadUp && eCode == 1)
                {
                    eCode = 0;
                }
                else if (cState.DpadDown && eCode == 3)
                {
                    eCode++;
                }
                else if (!cState.DpadDown && eCode == 3)
                {
                    eCode = 0;
                }
                else if (cState.B && eCode == 8)
                {
                    eCode++;
                }
                else if (!cState.B && eCode == 8)
                {
                    eCode = 0;
                }

                if (cState.DpadUp && eCode == 0)
                {
                    eCode++;
                }

                if (eCode == 10)
                {
                    string message = "(!)";
                    sp.Play();
                    LogDebug(message, true);
                    eCode = 0;
                }

                if (temp != eCode)
                {
                    Console.WriteLine(eCode);
                }
                buttonsdown[ind] = true;
            }
            else if (!pb)
            {
                buttonsdown[ind] = false;
            }
        }
Example #7
0
        private void DoExtras(int ind)
        {
            ControllerState   cState   = CurrentState[ind];
            EAll4StateExposed eState   = ExposedState[ind];
            Mouse             tp       = touchPad[ind];
            GenericControls   helddown = GenericControls.None;

            foreach (KeyValuePair <GenericControls, string> p in Global.getCustomExtras(ind))
            {
                if (Mapping.getBoolMapping(p.Key, cState, eState, tp))
                {
                    helddown = p.Key;
                    break;
                }
            }
            if (helddown != GenericControls.None)
            {
                string   p      = Global.getCustomExtras(ind)[helddown];
                string[] extraS = p.Split(',');
                int[]    extras = new int[extraS.Length];
                for (int i = 0; i < extraS.Length; i++)
                {
                    int b;
                    if (int.TryParse(extraS[i], out b))
                    {
                        extras[i] = b;
                    }
                }
                held[ind] = true;
                try
                {
                    if (!(extras[0] == extras[1] && extras[1] == 0))
                    {
                        setRumble((byte)extras[0], (byte)extras[1], ind);
                    }
                    if (extras[2] == 1)
                    {
                        EAll4Color color = new EAll4Color {
                            Red = (byte)extras[3], Green = (byte)extras[4], Blue = (byte)extras[5]
                        };
                        EAll4LightBar.forcedColor[ind] = color;
                        EAll4LightBar.forcedFlash[ind] = (byte)extras[6];
                        EAll4LightBar.forcelight[ind]  = true;
                    }
                    if (extras[7] == 1)
                    {
                        if (oldmouse[ind] == -1)
                        {
                            oldmouse[ind] = Global.ButtonMouseSensitivity[ind];
                        }
                        Global.ButtonMouseSensitivity[ind] = extras[8];
                    }
                }
                catch { }
            }
            else if (held[ind])
            {
                EAll4LightBar.forcelight[ind]      = false;
                EAll4LightBar.forcedFlash[ind]     = 0;
                Global.ButtonMouseSensitivity[ind] = oldmouse[ind];
                oldmouse[ind] = -1;
                setRumble(0, 0, ind);
                held[ind] = false;
            }
        }
Example #8
0
        //Called every time the new input report has arrived
        protected virtual void On_Report(object sender, EventArgs e)
        {
            var ieAll4Device = (IEAll4Device)sender;

            int ind = -1;

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

            if (ind != -1)
            {
                if (Global.FlushHIDQueue[ind])
                {
                    ieAll4Device.FlushHID();
                }
                if (!string.IsNullOrEmpty(ieAll4Device.error))
                {
                    LogDebug(ieAll4Device.error);
                }
                if (DateTime.UtcNow - ieAll4Device.firstActive > TimeSpan.FromSeconds(5))
                {
                    if (ieAll4Device.Latency >= 10 && !lag[ind])
                    {
                        LagFlashWarning(ind, true);
                    }
                    else if (ieAll4Device.Latency < 10 && lag[ind])
                    {
                        LagFlashWarning(ind, false);
                    }
                }
                ieAll4Device.getExposedState(ExposedState[ind], CurrentState[ind]);
                ControllerState cState = CurrentState[ind];
                ieAll4Device.getPreviousState(PreviousState[ind]);
                ControllerState pState = PreviousState[ind];
                if (pState.Battery != cState.Battery)
                {
                    Global.ControllerStatusChanged(this);
                }
                CheckForHotkeys(ind, cState, pState);
                if (eastertime)
                {
                    EasterTime(ind);
                }
                GetInputkeys(ind);
                if (Global.LSCurve[ind] != 0 || Global.RSCurve[ind] != 0 || Global.LSDeadzone[ind] != 0 || Global.RSDeadzone[ind] != 0 ||
                    Global.L2Deadzone[ind] != 0 || Global.R2Deadzone[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) || Global.ProfileActions[ind].Count > 0))
                {
                    Mapping.MapCustom(ind, cState, MappedState[ind], ExposedState[ind], touchPad[ind], this);
                    cState = MappedState[ind];
                }
                if (Global.getHasCustomExtras(ind))
                {
                    DoExtras(ind);
                }

                // Update the GUI/whatever.
                EAll4LightBar.updateLightBar(ieAll4Device, 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.
                ieAll4Device.IdleTimeout = Global.IdleDisconnectTimeout[ind];
            }
        }