void CCAccelerometer::setDelegate(CCAccelerometerDelegate* pDelegate) { m_pAccelDelegate = pDelegate; // Enable/disable the accelerometer. // Well, there isn't one on Win32 so we don't do anything other than register // and deregister ourselves from the Windows Key handler. if (pDelegate) { // Register our handler CCEGLView::sharedOpenGLView()->setAccelerometerKeyHook( &myAccelerometerKeyHook ); } else { // De-register our handler CCEGLView::sharedOpenGLView()->setAccelerometerKeyHook( NULL ); resetAccelerometer(); } }
void Accelerometer::setDelegate(std::function<void(Acceleration*)> function) { _function = function; // Enable/disable the accelerometer. // Well, there isn't one on Win32 so we don't do anything other than register // and deregister ourselves from the Windows Key handler. if (_function) { // Register our handler EGLView::getInstance()->setAccelerometerKeyHook( &myAccelerometerKeyHook ); } else { // De-register our handler EGLView::getInstance()->setAccelerometerKeyHook( NULL ); resetAccelerometer(); } }