Do not send LED updates if nothing changed

This commit is contained in:
Lior Halphon 2020-05-30 17:58:02 +03:00
parent fa7232944f
commit 4d91081046
1 changed files with 7 additions and 0 deletions

View File

@ -164,6 +164,8 @@ typedef union {
// Used when creating inputs
JOYElement *_previousAxisElement;
uint8_t _playerLEDs;
}
@ -342,6 +344,7 @@ typedef union {
_logicallyConnected = true;
_device = (IOHIDDeviceRef)CFRetain(device);
_serialSuffix = suffix;
_playerLEDs = -1;
IOHIDDeviceRegisterInputValueCallback(device, HIDInput, (void *)self);
IOHIDDeviceScheduleWithRunLoop(device, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);
@ -709,6 +712,10 @@ typedef union {
- (void)setPlayerLEDs:(uint8_t)mask
{
mask &= 0xF;
if (mask == _playerLEDs) {
return;
}
_playerLEDs = mask;
if (_isSwitch) {
_lastVendorSpecificOutput.switchPacket.reportID = 0x1; // Rumble and LEDs
_lastVendorSpecificOutput.switchPacket.sequence++;