( Please let me know if this mailing list is not good mailing list for asking I/O Kit issues. )
Hello,
I implemented a feature to read keyboard states without interrupting other app.
HID_Calibrator sample project does that, so I took that as an example.
Everything works fine, but once a screen savor runs and if it requires me to login, IOHIDValueGetIntegerValue() fails with this error.
EXC_BAD_ACCESS (code = 1, address = 0x10)
However, the HID_Calibrator doesn’t have this problem.
Can someone tell me what’s wrong with the IOHIDValueGetIntegerValue()?
In my code, it obtains a value of a target ‘key’ ( on a keyboard )
code snippet is :
+————[ From Here ]——————+
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);
IOHIDDeviceGetValue(device, element, &value); // EXC_BAD_ACCESS HERE!!!!!
try {
if( IOHIDValueGetIntegerValue(value) == 1) {
isPressed = true;
break;
}
}
catch(...) {
ZLOG("IOHIDValueGetIntegerValue() failed.\n”);
}
}
return isPressed;
Is it possible that a keyboard or input method is considered to be changed at that moment?
But the project doesn’t use any of them.
Thank you.