The 10.6.3 os x update broke simulated key-presses for Nestopia.

Posted by Lou Z. on Stack Overflow See other posts from Stack Overflow or by Lou Z.
Published on 2010-04-01T17:43:45Z Indexed on 2010/04/01 18:53 UTC
Read the original article Hit count: 358

The iPhone app that I released is a wireless game controller, it translates touches on the device into key-presses on the networked Mac. This allowed for playing emulator (e.g. Nestopia) games using the iPhone as a controller. Of course, the day that I released it coincided with an os x update. After installing this update, the simulated key-presses no longer work in Nestopia! The crazier thing is, when I go to 'File > Open' within Nestopia, I can cycle through the file list by hitting the up-arrow on my iphone controller; i.e. the simulated key-presses work in menu items, but not in the game itself. The code that I use to simulate keys is below. Given the list of changes here, can anyone identify which change would cause this problem?

Thanks!!

#define UP  false
#define DOWN true

-(void)sendKey:(CGKeyCode)keycode andKeyDirection:(BOOL)keydirection{
  CGEventRef eventRef = CGEventCreateKeyboardEvent(NULL, keycode, keydirection);
  CGEventPost(kCGSessionEventTap, eventRef);
  CFRelease(eventRef);
}

© Stack Overflow or respective owner

Related posts about objective-c

Related posts about cocoa