def _getData(self): """Copy data from the DS task for the user. If no new data exists, it will just be returned, otherwise the data will be copied from the DS polling loop. """ # Get the status of all of the joysticks for stick in range(self.kJoystickPorts): hal.getJoystickAxes(stick, self.joystickAxesCache[stick]) hal.getJoystickPOVs(stick, self.joystickPOVsCache[stick]) hal.getJoystickButtons(stick, self.joystickButtonsCache[stick]) hal.getMatchInfo(self.matchInfoCache) # Force a control word update, to make sure the data is the newest. self._updateControlWord(True) # lock joystick mutex to swap cache data with self.cacheDataMutex: for i in range(self.kJoystickPorts): self.joystickButtonsPressed[i].buttons |= \ ~self.joystickButtons[i].buttons & self.joystickButtonsCache[i].buttons self.joystickButtonsReleased[i].buttons |= \ self.joystickButtons[i].buttons & ~self.joystickButtonsCache[i].buttons # move cache to actual data self.joystickAxes, self.joystickAxesCache = self.joystickAxesCache, self.joystickAxes self.joystickButtons, self.joystickButtonsCache = self.joystickButtonsCache, self.joystickButtons self.joystickPOVs, self.joystickPOVsCache = self.joystickPOVsCache, self.joystickPOVs self.matchInfo, self.matchInfoCache = self.matchInfoCache, self.matchInfo
def _getData(self) -> None: """Copy data from the DS task for the user. If no new data exists, it will just be returned, otherwise the data will be copied from the DS polling loop. """ # Get the status of all of the joysticks for stick in range(self.kJoystickPorts): hal.getJoystickAxes(stick, self.joystickAxesCache[stick]) hal.getJoystickPOVs(stick, self.joystickPOVsCache[stick]) hal.getJoystickButtons(stick, self.joystickButtonsCache[stick]) hal.getMatchInfo(self.matchInfoCache) # Force a control word update, to make sure the data is the newest. self._updateControlWord(True) # python-specific: decode these outside the lock eventName = self.matchInfoCache.eventName.decode("utf-8") gameSpecificMessage = self.matchInfoCache.gameSpecificMessage.decode("utf-8") # lock joystick mutex to swap cache data with self.cacheDataMutex: for i in range(self.kJoystickPorts): self.joystickButtonsPressed[i] |= ( ~self.joystickButtons[i].buttons & self.joystickButtonsCache[i].buttons ) self.joystickButtonsReleased[i] |= ( self.joystickButtons[i].buttons & ~self.joystickButtonsCache[i].buttons ) # move cache to actual data self.joystickAxes, self.joystickAxesCache = ( self.joystickAxesCache, self.joystickAxes, ) self.joystickButtons, self.joystickButtonsCache = ( self.joystickButtonsCache, self.joystickButtons, ) self.joystickPOVs, self.joystickPOVsCache = ( self.joystickPOVsCache, self.joystickPOVs, ) self.matchInfo.eventName = eventName self.matchInfo.gameSpecificMessage = gameSpecificMessage self.matchInfo.matchNumber = self.matchInfoCache.matchNumber self.matchInfo.replayNumber = self.matchInfoCache.replayNumber self.matchInfo.matchType = self.matchInfoCache.matchType with self.waitForDataCond: self.waitForDataCount += 1 self.waitForDataCond.notify_all() self._sendMatchData()
def _getData(self) -> None: """Copy data from the DS task for the user. If no new data exists, it will just be returned, otherwise the data will be copied from the DS polling loop. """ # Get the status of all of the joysticks for stick in range(self.kJoystickPorts): hal.getJoystickAxes(stick, self.joystickAxesCache[stick]) hal.getJoystickPOVs(stick, self.joystickPOVsCache[stick]) hal.getJoystickButtons(stick, self.joystickButtonsCache[stick]) hal.getMatchInfo(self.matchInfoCache) # Force a control word update, to make sure the data is the newest. self._updateControlWord(True) # python-specific: decode these outside the lock eventName = self.matchInfoCache.eventName.decode("utf-8") gameSpecificMessage = self.matchInfoCache.gameSpecificMessage.decode( "utf-8") # lock joystick mutex to swap cache data with self.cacheDataMutex: for i in range(self.kJoystickPorts): self.joystickButtonsPressed[i] |= ( ~self.joystickButtons[i].buttons & self.joystickButtonsCache[i].buttons) self.joystickButtonsReleased[i] |= ( self.joystickButtons[i].buttons & ~self.joystickButtonsCache[i].buttons) # move cache to actual data self.joystickAxes, self.joystickAxesCache = ( self.joystickAxesCache, self.joystickAxes, ) self.joystickButtons, self.joystickButtonsCache = ( self.joystickButtonsCache, self.joystickButtons, ) self.joystickPOVs, self.joystickPOVsCache = ( self.joystickPOVsCache, self.joystickPOVs, ) self.matchInfo.eventName = eventName self.matchInfo.gameSpecificMessage = gameSpecificMessage self.matchInfo.matchNumber = self.matchInfoCache.matchNumber self.matchInfo.replayNumber = self.matchInfoCache.replayNumber self.matchInfo.matchType = self.matchInfoCache.matchType with self.waitForDataCond: self.waitForDataCount += 1 self.waitForDataCond.notify_all() self._sendMatchData()
def _getData(self): """Copy data from the DS task for the user. If no new data exists, it will just be returned, otherwise the data will be copied from the DS polling loop. """ # Get the status of all of the joysticks for stick in range(self.kJoystickPorts): hal.getJoystickAxes(stick, self.joystickAxesCache[stick]) hal.getJoystickPOVs(stick, self.joystickPOVsCache[stick]) hal.getJoystickButtons(stick, self.joystickButtonsCache[stick]) # Force a control word update, to make sure the data is the newest. self._updateControlWord(True) # lock joystick mutex to swap cache data with self.joystickMutex: # move cache to actual data self.joystickAxes, self.joystickAxesCache = self.joystickAxesCache, self.joystickAxes self.joystickButtons, self.joystickButtonsCache = self.joystickButtonsCache, self.joystickButtons self.joystickPOVs, self.joystickPOVsCache = self.joystickPOVsCache, self.joystickPOVs