private void ProcessButtonsAndStick(Report report) { // Read sticks this.stick = InputReportReader.ReadSticks(report, this); // Read buttons lock (buttons) { lock (_down) { for (int i = 0; i < buttons.Length; ++i) { _down[i] = buttons[i]; } } InputReportReader.ReadButtons(report, buttons); lock (buttonsUp) { lock (buttonsDown) { for (int i = 0; i < buttons.Length; ++i) { buttonsUp[i] = (_down[i] & !buttons[i]); buttonsDown[i] = (!_down[i] & buttons[i]); if (buttonsDown[i]) { if (i == (int)JoyConButton.L || i == (int)JoyConButton.R) { reset = true; } else if (i == (int)JoyConButton.ZL || i == (int)JoyConButton.ZR) { next = true; } } //Debug.Log(string.Format("Button {0} down.", (JoyConButton)i)); if (buttonsUp[i]) { if (i == (int)JoyConButton.L || i == (int)JoyConButton.R) { reset = false; } else if (i == (int)JoyConButton.ZL || i == (int)JoyConButton.ZR) { next = false; } } //Debug.Log(string.Format("Button {0} up.", (JoyConButton)i)); } } } } }
private void ProcessIMU(Report report) { this.AccDelta = InputReportReader.ReadAcc(report, this); this.GyroDelta = InputReportReader.ReadGyro(report, this); this.Acc = AccDelta[2]; if (_firstImuPacket) { _lastTime = DateTime.Now; _lastRotate = new Vector3(0, 0, 0); _firstImuPacket = false; } UpdateGyro(report, GyroDelta); }