From 4d91081046f75efc701e0fda7787daebe982c72c Mon Sep 17 00:00:00 2001 From: Lior Halphon Date: Sat, 30 May 2020 17:58:02 +0300 Subject: [PATCH] Do not send LED updates if nothing changed --- JoyKit/JOYController.m | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/JoyKit/JOYController.m b/JoyKit/JOYController.m index 015737e..12f0d39 100644 --- a/JoyKit/JOYController.m +++ b/JoyKit/JOYController.m @@ -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++;