private void GetVibrationDevice(nn.hid.NpadId id, nn.hid.NpadStyle style)
    {
        vibrationValue.Clear();
        for (int i = 0; i < vibrationDeviceCount; i++)
        {
            Vibration.SendValue(vibrationDeviceHandles[i], vibrationValue);
        }

        vibrationDeviceCount = Vibration.GetDeviceHandles(
            vibrationDeviceHandles, vibrationDeviceCountMax, id, style);

        for (int i = 0; i < vibrationDeviceCount; i++)
        {
            Vibration.InitializeDevice(vibrationDeviceHandles[i]);
            Vibration.GetDeviceInfo(ref vibrationDeviceInfos[i], vibrationDeviceHandles[i]);
        }
    }
Exemplo n.º 2
0
 public static extern IrCameraHandle GetHandle(nn.hid.NpadId npadId);
    private bool UpdatePadState()
    {
        nn.hid.NpadStyle handheldStyle = Npad.GetStyleSet(nn.hid.NpadId.Handheld);
        NpadState        handheldState = new NpadState();

        nn.hid.NpadStyle no1Style = Npad.GetStyleSet(nn.hid.NpadId.No1);
        NpadState        no1State = new NpadState();

        if (playerID == 0)
        {
            if (handheldStyle != nn.hid.NpadStyle.None)
            {
                Npad.GetState(ref handheldState, nn.hid.NpadId.Handheld, handheldStyle);
                if (handheldState.buttons != nn.hid.NpadButton.None)
                {
                    if ((npadId != nn.hid.NpadId.Handheld) || (npadStyle != handheldStyle))
                    {
                        this.GetVibrationDevice(nn.hid.NpadId.Handheld, handheldStyle);
                    }
                    npadId    = nn.hid.NpadId.Handheld;
                    npadStyle = handheldStyle;
                    npadState = handheldState;
                    return(true);
                }
            }

            if (no1Style != nn.hid.NpadStyle.None)
            {
                Npad.GetState(ref no1State, nn.hid.NpadId.No1, no1Style);
                if (no1State.buttons != nn.hid.NpadButton.None)
                {
                    if ((npadId != nn.hid.NpadId.No1) || (npadStyle != no1Style))
                    {
                        this.GetVibrationDevice(nn.hid.NpadId.No1, no1Style);
                    }
                    npadId    = nn.hid.NpadId.No1;
                    npadStyle = no1Style;
                    npadState = no1State;
                    return(true);
                }
            }
        }

        nn.hid.NpadStyle no2Style = Npad.GetStyleSet(nn.hid.NpadId.No2);
        NpadState        no2State = new NpadState();

        if (playerID == 1)
        {
            if (no2Style != nn.hid.NpadStyle.None)
            {
                Npad.GetState(ref no2State, nn.hid.NpadId.No2, no2Style);
                if (no2State.buttons != nn.hid.NpadButton.None)
                {
                    if ((npadId != nn.hid.NpadId.No2) || (npadStyle != no2Style))
                    {
                        this.GetVibrationDevice(nn.hid.NpadId.No2, no2Style);
                    }
                    npadId    = nn.hid.NpadId.No2;
                    npadStyle = no2Style;
                    npadState = no2State;
                    return(true);
                }
            }
        }

        nn.hid.NpadStyle no3Style = Npad.GetStyleSet(nn.hid.NpadId.No3);
        NpadState        no3State = new NpadState();

        if (playerID == 2)
        {
            if (no3Style != nn.hid.NpadStyle.None)
            {
                Npad.GetState(ref no3State, nn.hid.NpadId.No3, no3Style);
                if (no3State.buttons != nn.hid.NpadButton.None)
                {
                    if ((npadId != nn.hid.NpadId.No3) || (npadStyle != no3Style))
                    {
                        this.GetVibrationDevice(nn.hid.NpadId.No3, no3Style);
                    }
                    npadId    = nn.hid.NpadId.No3;
                    npadStyle = no3Style;
                    npadState = no3State;
                    return(true);
                }
            }
        }

        nn.hid.NpadStyle no4Style = Npad.GetStyleSet(nn.hid.NpadId.No4);
        NpadState        no4State = new NpadState();

        if (playerID == 3)
        {
            if (no4Style != nn.hid.NpadStyle.None)
            {
                Npad.GetState(ref no4State, nn.hid.NpadId.No4, no4Style);
                if (no4State.buttons != nn.hid.NpadButton.None)
                {
                    if ((npadId != nn.hid.NpadId.No4) || (npadStyle != no4Style))
                    {
                        this.GetVibrationDevice(nn.hid.NpadId.No4, no4Style);
                    }
                    npadId    = nn.hid.NpadId.No4;
                    npadStyle = no4Style;
                    npadState = no4State;
                    return(true);
                }
            }
        }

        if (playerID == 0 && (npadId == nn.hid.NpadId.Handheld) && (handheldStyle != nn.hid.NpadStyle.None))
        {
            npadId    = nn.hid.NpadId.Handheld;
            npadStyle = handheldStyle;
            npadState = handheldState;
        }
        else if (playerID == 0 && (npadId == nn.hid.NpadId.No1) && (no1Style != nn.hid.NpadStyle.None))
        {
            npadId    = nn.hid.NpadId.No1;
            npadStyle = no1Style;
            npadState = no1State;
        }
        else if (playerID == 1 && (npadId == nn.hid.NpadId.No2) && (no2Style != nn.hid.NpadStyle.None))
        {
            npadId    = nn.hid.NpadId.No2;
            npadStyle = no2Style;
            npadState = no2State;
        }
        else if (playerID == 2 && (npadId == nn.hid.NpadId.No3) && (no3Style != nn.hid.NpadStyle.None))
        {
            npadId    = nn.hid.NpadId.No3;
            npadStyle = no3Style;
            npadState = no3State;
        }
        else if (playerID == 3 && (npadId == nn.hid.NpadId.No4) && (no4Style != nn.hid.NpadStyle.None))
        {
            npadId    = nn.hid.NpadId.No4;
            npadStyle = no4Style;
            npadState = no4State;
        }
        else
        {
            npadId    = nn.hid.NpadId.Invalid;
            npadStyle = nn.hid.NpadStyle.Invalid;
            npadState.Clear();
            return(false);
        }
        return(true);
    }