From 5c6c66f243317b13451b0940c513ebe4ceafbeaa Mon Sep 17 00:00:00 2001 From: Aaron Culliney Date: Mon, 1 Dec 2014 22:39:46 -0800 Subject: [PATCH] Joystick controller fixes - only poll for joystick connectivity once per second - if keypad joystick enabled, pump the handler --- .../Classes/OSX/EmulatorJoystickController.m | 29 +++++++++++++------ 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/Apple2Mac/Apple2Mac/Classes/OSX/EmulatorJoystickController.m b/Apple2Mac/Apple2Mac/Classes/OSX/EmulatorJoystickController.m index 4531471e..4f49fe42 100644 --- a/Apple2Mac/Apple2Mac/Classes/OSX/EmulatorJoystickController.m +++ b/Apple2Mac/Apple2Mac/Classes/OSX/EmulatorJoystickController.m @@ -92,21 +92,32 @@ void gldriver_joystick_reset(void) { - (void)connectivityPoll:(NSNotification *)notification { - NSArray *joysticks = [DDHidJoystick allJoysticks]; - BOOL changed = ([joysticks count] != [self.allJoysticks count]); - for (DDHidJoystick *joystick in joysticks) + static unsigned int counter = 0; + counter = (counter+1) % 60; + if (counter == 0) { - NSString *key =[NSString stringWithFormat:@"%@-%@-%@", [joystick manufacturer], [joystick serialNumber], [joystick transport]]; - if (![self.allJoysticks objectForKey:key]) + NSArray *joysticks = [DDHidJoystick allJoysticks]; + BOOL changed = ([joysticks count] != [self.allJoysticks count]); + for (DDHidJoystick *joystick in joysticks) { - changed = YES; - break; + NSString *key =[NSString stringWithFormat:@"%@-%@-%@", [joystick manufacturer], [joystick serialNumber], [joystick transport]]; + if (![self.allJoysticks objectForKey:key]) + { + changed = YES; + break; + } + } + if (changed) + { + [self resetJoysticks]; } } - if (changed) +#ifdef KEYPAD_JOYSTICK + if (joy_mode == JOY_KPAD) { - [self resetJoysticks]; + c_keys_handle_input(-1, 0, 0); } +#endif } #pragma mark -