Ok. Let me write about what was wrong in my case. In the code below, the device, which is returned by IOHIDElementGetDevice(element) was null. I still don’t understand why it retrieves NULL when the element was an actual value for a keyboard key. I tried to initiate screen saver and entered my password to unlock the screen. When I check the NULL value and skipped the interested code, it didn’t cause any problem, and there was no problem in handling key stroke. So, probably it’s temporary result with the same ‘element’ value. I wondered if keyboard layout was considered to be changed, but it didn’t seem to be so. bool isPressed = false; // An individual key NSArray *keyArray = [gIOKitKeyElementToCarbonVirtualKeyDict allKeysForObject:[NSNumber numberWithUnsignedShort:carbonVirtualKey]]; for( NSValue *key in keyArray ) { IOHIDElementRef element = (IOHIDElementRef)[key pointerValue]; IOHIDValueRef value = 0; IOHIDDeviceRef device = IOHIDElementGetDevice(element); // device is NULL IOHIDDeviceGetValue(device, element, &value); try { // EXC_BAD_ACCESS HERE!!!!! if( IOHIDValueGetIntegerValue(value) == 1) { isPressed = true; break; } } catch(...) { ZLOG("IOHIDValueGetIntegerValue() failed.\n”); } } return isPressed;
On Mar 4, 2016, at 7:24 AM, Daniel J. Luke <dluke@geeklair.net> wrote:
For someone searching in the future who may have the same problem, it's nice if in your follow-up post to the list you can include the solution to the problem.
On Mar 3, 2016, at 7:16 PM, JongAm Park <jongampark@sbcglobal.net> wrote: This morning, I figured out the problem and fixed it for myself. So, please disregard my previous post.
-- Daniel J. Luke
_______________________________________________ Do not post admin requests to the list. They will be ignored. Darwin-kernel mailing list (Darwin-kernel@lists.apple.com) Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/darwin-kernel/site_archiver%40lists.... This email sent to site_archiver@lists.apple.com