Beispiel #1
0
        public void SetButton(XBButton_t buttonCode, XBTarget_t buttonState)
        {
            Int16 actionKey  = EVA_NewActionKey((Int16)Device_t.XBox, (Int16)buttonState);
            Int16 actionCode = EVA_NewAction((Int16)actionKey, (Int16)buttonCode);

            // 'A'ction <Int16>
            Command('A', ReverseBytes(BitConverter.GetBytes(actionCode)));
        }
Beispiel #2
0
        public void SetTrigger(XBTarget_t targetCode, float triggerState)
        {
            float wiperState = triggerState * byte.MaxValue;

            wiperState = (float)byte.MaxValue - wiperState;
            wiperState = Math.Max(wiperState, (float)byte.MinValue);
            wiperState = Math.Min(wiperState, (float)byte.MaxValue);

            Int16 wiperValue = Convert.ToInt16(wiperState);
            Int16 actionKey  = EVA_NewActionKey((Int16)Device_t.XBox, (Int16)targetCode);
            Int16 actionCode = EVA_NewAction((Int16)actionKey, (Int16)wiperValue);

            // 'A'ction <Int16>
            Command('A', ReverseBytes(BitConverter.GetBytes(actionCode)));
        }
Beispiel #3
0
        public void SetThumbStick(XBTarget_t targetCode, float targetState)
        {
            float wiperState = (targetState + 1.0F) / 2 * (float)byte.MaxValue;

            if (targetCode == XBTarget_t.LeftStickX || targetCode == XBTarget_t.RightStickX)
            {
                wiperState = (float)byte.MaxValue - wiperState;
            }
            wiperState = Math.Max(wiperState, (float)byte.MinValue);
            wiperState = Math.Min(wiperState, (float)byte.MaxValue);

            Int16 wiperValue = Convert.ToInt16(wiperState);
            Int16 actionKey  = EVA_NewActionKey((Int16)Device_t.XBox, (Int16)targetCode);
            Int16 actionCode = EVA_NewAction((Int16)actionKey, (Int16)wiperValue);

            // 'A'ction <Int16>
            Command('A', ReverseBytes(BitConverter.GetBytes(actionCode)));
        }
Beispiel #4
0
        // NOTE: The concept of a "page" is used to simplify the implementation of pg3b <-> PC comms,
        // and as a unit of reference for statically assigned blocks of EEPROM data.
        //
        // Calibration data is written to consecutive pages. Pages are nominally 32 bytes each. A
        // calibration record is 256 bytes, or 8 sequential pages.
        //
        // Pages 1 -  8: LeftStickX
        //       9 - 16: LeftStickY
        //      17 - 24: RightStickX
        //      25 - 32: RightStickY
        //      33 - 40: LeftTrigger
        //      41 - 48: RightTrigger

        public void UpdateCalibration(XBTarget_t xboxTarget, byte[] calibrationData)
        {
            byte[] pageData       = new byte[PageSize];
            int    pagesPerRecord = calibrationData.Length / PageSize;
            int    firstPage      = ((int)xboxTarget * pagesPerRecord) + 1;

            for (int pageCount = 0; pageCount < calibrationData.Length / PageSize; pageCount++)
            {
                for (int pageOffset = 0; pageOffset < PageSize; pageOffset++)
                {
                    pageData[pageOffset] = calibrationData[pageCount * PageSize + pageOffset];
                }
                xboxConnection.WritePage((byte)(firstPage + pageCount), pageData);
            }

            byte[] xboxConfiguration = GetConfigPage();
            xboxConfiguration[CalibrationOffset] |= (byte)(1 << (int)xboxTarget);
            xboxConfiguration[CrcOffset]          = XBoxConnection.CalculateCrc(xboxConfiguration, CrcOffset + 1, xboxConfiguration[SizeOffset] - 1);
            xboxConnection.WritePage(ConfigPage, xboxConfiguration);
        }
Beispiel #5
0
 public XBoxVector2(XBoxConnection _xboxConnection, XBTarget_t _targetCodeX, XBTarget_t _targetCodeY)
 {
     xboxConnection = _xboxConnection;
     targetCodeX    = _targetCodeX;
     targetCodeY    = _targetCodeY;
 }
Beispiel #6
0
 public XBoxVector2(XBoxConnection _xboxConnection, XBTarget_t _targetCodeX, XBTarget_t _targetCodeY)
 {
     xboxConnection = _xboxConnection;
     targetCodeX = _targetCodeX;
     targetCodeY = _targetCodeY;
 }
Beispiel #7
0
        public void SetTrigger(XBTarget_t targetCode, float triggerState)
        {
            float wiperState = triggerState * byte.MaxValue;
            wiperState = (float)byte.MaxValue - wiperState;
            wiperState = Math.Max(wiperState, (float)byte.MinValue);
            wiperState = Math.Min(wiperState, (float)byte.MaxValue);

            Int16 wiperValue = Convert.ToInt16(wiperState);
            Int16 actionKey = EVA_NewActionKey((Int16)Device_t.XBox, (Int16)targetCode);
            Int16 actionCode = EVA_NewAction((Int16)actionKey, (Int16)wiperValue);

            // 'A'ction <Int16>
            Command('A', ReverseBytes(BitConverter.GetBytes(actionCode)));
        }
Beispiel #8
0
        public void SetThumbStick(XBTarget_t targetCode, float targetState)
        {
            float wiperState = (targetState + 1.0F) / 2 * (float)byte.MaxValue;
            if (targetCode == XBTarget_t.LeftStickX || targetCode == XBTarget_t.RightStickX)
                wiperState = (float)byte.MaxValue - wiperState;
            wiperState = Math.Max(wiperState, (float)byte.MinValue);
            wiperState = Math.Min(wiperState, (float)byte.MaxValue);

            Int16 wiperValue = Convert.ToInt16(wiperState);
            Int16 actionKey = EVA_NewActionKey((Int16)Device_t.XBox, (Int16)targetCode);
            Int16 actionCode = EVA_NewAction((Int16)actionKey, (Int16)wiperValue);

            // 'A'ction <Int16>
            Command('A', ReverseBytes(BitConverter.GetBytes(actionCode)));
        }
Beispiel #9
0
        public void SetButton(XBButton_t buttonCode, XBTarget_t buttonState)
        {
            Int16 actionKey = EVA_NewActionKey((Int16)Device_t.XBox, (Int16)buttonState);
            Int16 actionCode = EVA_NewAction((Int16)actionKey, (Int16)buttonCode);

            // 'A'ction <Int16>
            Command('A', ReverseBytes(BitConverter.GetBytes(actionCode)));
        }
Beispiel #10
0
        // NOTE: The concept of a "page" is used to simplify the implementation of pg3b <-> PC comms,
        // and as a unit of reference for statically assigned blocks of EEPROM data.
        //
        // Calibration data is written to consecutive pages. Pages are nominally 32 bytes each. A
        // calibration record is 256 bytes, or 8 sequential pages.
        //
        // Pages 1 -  8: LeftStickX
        //       9 - 16: LeftStickY
        //      17 - 24: RightStickX
        //      25 - 32: RightStickY
        //      33 - 40: LeftTrigger
        //      41 - 48: RightTrigger
        public void UpdateCalibration(XBTarget_t xboxTarget, byte[] calibrationData)
        {
            byte[] pageData = new byte[PageSize];
            int pagesPerRecord = calibrationData.Length / PageSize;
            int firstPage = ((int)xboxTarget * pagesPerRecord) + 1;
            for( int pageCount = 0; pageCount < calibrationData.Length / PageSize; pageCount++)
            {
                for (int pageOffset = 0; pageOffset < PageSize; pageOffset++)
                    pageData[pageOffset] = calibrationData[pageCount * PageSize + pageOffset];
                xboxConnection.WritePage((byte)(firstPage + pageCount), pageData);
            }

            byte[] xboxConfiguration = GetConfigPage();
            xboxConfiguration[CalibrationOffset] |= (byte)(1 << (int)xboxTarget);
            xboxConfiguration[CrcOffset] = XBoxConnection.CalculateCrc(xboxConfiguration, CrcOffset + 1, xboxConfiguration[SizeOffset] - 1);
            xboxConnection.WritePage(ConfigPage, xboxConfiguration);
        }