void ApplePS2Keyboard::setDevicePowerState( UInt32 whatToDo ) { switch ( whatToDo ) { case kPS2C_DisableDevice: // // Disable keyboard. // setKeyboardEnable( false ); break; case kPS2C_EnableDevice: // // Reset the keyboard to its default state. // PS2Request * request = _device->allocateRequest(); if (request) { request->commands[0].command = kPS2C_WriteDataPort; request->commands[0].inOrOut = kDP_SetDefaults; request->commands[1].command = kPS2C_ReadDataPortAndCompare; request->commands[1].inOrOut = kSC_Acknowledge; request->commandsCount = 2; _device->submitRequestAndBlock(request); _device->freeRequest(request); } // // Initialize the keyboard LED state. // setLEDs(_ledState); // // Enable the keyboard clock (should already be so), the keyboard // IRQ line, and the keyboard Kscan -> scan code translation mode. // setCommandByte( kCB_EnableKeyboardIRQ | kCB_TranslateMode, kCB_DisableKeyboardClock ); // // Finally, we enable the keyboard itself, so that it may start // reporting key events. // setKeyboardEnable( true ); break; } }
void ApplePS2Mouse::stop(IOService * provider) { // // The driver has been instructed to stop. Note that we must break all // connections to other service objects now (ie. no registered actions, // no pointers and retains to objects, etc), if any. // assert(_device == provider); // // Disable the mouse itself, so that it may stop reporting mouse events. // setMouseEnable(false); // // Disable the mouse clock and the mouse IRQ line. // setCommandByte(kCB_DisableMouseClock, kCB_EnableMouseIRQ); // // Uninstall the interrupt handler. // if ( _interruptHandlerInstalled ) _device->uninstallInterruptAction(); _interruptHandlerInstalled = false; // // Uninstall the power control handler. // if ( _powerControlHandlerInstalled ) _device->uninstallPowerControlAction(); _powerControlHandlerInstalled = false; // // Uinstall message handler. // if (_messageHandlerInstalled) { _device->uninstallMessageAction(); _messageHandlerInstalled = false; } // // Release the pointer to the provider object. // _device->release(); _device = 0; super::stop(provider); }
void ApplePS2Keyboard::stop(IOService * provider) { // // The driver has been instructed to stop. Note that we must break all // connections to other service objects now (ie. no registered actions, // no pointers and retains to objects, etc), if any. // assert(_device == provider); // // Disable the keyboard itself, so that it may stop reporting key events. // setKeyboardEnable(false); // // Disable the keyboard clock and the keyboard IRQ line. // setCommandByte(kCB_DisableKeyboardClock, kCB_EnableKeyboardIRQ); // // Uninstall the interrupt handler. // if ( _interruptHandlerInstalled ) _device->uninstallInterruptAction(); _interruptHandlerInstalled = false; // // Uninstall the power control handler. // if ( _powerControlHandlerInstalled ) _device->uninstallPowerControlAction(); _powerControlHandlerInstalled = false; // // Release the pointer to the provider object. // // // Unistalling our Mouse/Touchpad Notification Handler // _device->unistallPS2NotificationAction(); _mouseTouchpadNotificationHandlerInstalled = false; _device->release(); _device = 0; super::stop(provider); }
void ApplePS2SynapticsTouchPad::setDevicePowerState( UInt32 whatToDo ) { switch ( whatToDo ) { case kPS2C_DisableDevice: // // Disable touchpad (synchronous). // setTouchPadEnable( false ); break; case kPS2C_EnableDevice: // // Must not issue any commands before the device has // completed its power-on self-test and calibration. // IOSleep(1000); setTouchPadModeByte( _touchPadModeByte ); // // Enable the mouse clock (should already be so) and the // mouse IRQ line. // setCommandByte( kCB_EnableMouseIRQ, kCB_DisableMouseClock ); // // Clear packet buffer pointer to avoid issues caused by // stale packet fragments. // _packetByteCount = 0; // // Finally, we enable the trackpad itself, so that it may // start reporting asynchronous events. // setTouchPadEnable( true ); break; } }
void ApplePS2Keyboard::initKeyboard() { // // Reset the keyboard to its default state. // PS2Request * request = _device->allocateRequest(); if (request) { request->commands[0].command = kPS2C_WriteDataPort; request->commands[0].inOrOut = kDP_SetDefaults; request->commands[1].command = kPS2C_ReadDataPortAndCompare; request->commands[1].inOrOut = kSC_Acknowledge; request->commandsCount = 2; _device->submitRequestAndBlock(request); _device->freeRequest(request); } // start out with all keys up bzero(_keyBitVector, sizeof(_keyBitVector)); // // Initialize the keyboard LED state. // setLEDs(_ledState); // // Enable the keyboard clock (should already be so), the keyboard IRQ line, // and the keyboard Kscan -> scan code translation mode. // setCommandByte(kCB_EnableKeyboardIRQ | kCB_TranslateMode, kCB_DisableKeyboardClock); // // Finally, we enable the keyboard itself, so that it may start reporting // key events. // setKeyboardEnable(true); }
void ApplePS2Keyboard::setDevicePowerState( UInt32 whatToDo ) { switch ( whatToDo ) { case kPS2C_DisableDevice: // // Disable keyboard. // setKeyboardEnable( false ); break; case kPS2C_EnableDevice: // // Initialize the keyboard LED state. // setLEDs(_ledState); // // Enable the keyboard clock (should already be so), the keyboard // IRQ line, and the keyboard Kscan -> scan code translation mode. // setCommandByte( kCB_EnableKeyboardIRQ | kCB_TranslateMode, kCB_DisableKeyboardClock ); // // Finally, we enable the keyboard itself, so that it may start // reporting key events. // setKeyboardEnable( true ); break; } }
void ApplePS2Keyboard::setDevicePowerState( UInt32 whatToDo ) { switch ( whatToDo ) { case kPS2C_DisableDevice: // // Disable keyboard. // setKeyboardEnable( false ); // Work around for auto repeat keyboard sometimes after // wakeup from sleep // see: http://www.mydellmini.com/forum/general-mac-os-x-discussion/3553-fixed-zero-key-stack-after-wake-up.html // remove interrupt handler setCommandByte(kCB_DisableKeyboardClock, kCB_EnableKeyboardIRQ); if (_interruptHandlerInstalled) { _device->uninstallInterruptAction(); _interruptHandlerInstalled = false; } break; case kPS2C_EnableDevice: // re-install interrupt handler _device->installInterruptAction(this, /*(PS2InterruptAction)&ApplePS2Keyboard::interruptOccurred*/ OSMemberFunctionCast(PS2InterruptAction, this, &ApplePS2Keyboard::interruptOccurred)); _interruptHandlerInstalled = true; // // Enable keyboard and restore state. // initKeyboard(); break; } }
void ApplePS2Mouse::resetMouse() { PS2MouseId type; // // Reset the mouse to its default state. // PS2Request * request = _device->allocateRequest(); if (request) { request->commands[0].command = kPS2C_SendMouseCommandAndCompareAck; request->commands[0].inOrOut = kDP_SetDefaults; request->commandsCount = 1; _device->submitRequestAndBlock(request); _device->freeRequest(request); } // // Obtain our mouse's resolution and sampling rate. // if (_mouseInfoBytes == (UInt32)-1) { _mouseInfoBytes = getMouseInformation(); switch (_mouseInfoBytes & 0x00FF00) { case 0x0000: _resolution = (25) << 16; break; // 25 dpi case 0x0100: _resolution = (50) << 16; break; // 50 dpi case 0x0200: _resolution = (100) << 16; break; // 100 dpi case 0x0300: _resolution = (200) << 16; break; // 200 dpi default: _resolution = (150) << 16; break; // 150 dpi } } else { setMouseResolution(_mouseInfoBytes >> 8); } // // Enable the Intellimouse mode, should this be an Intellimouse. // if ( (type = setIntellimouseMode()) != kMouseTypeStandard ) { _packetLength = kPacketLengthIntellimouse; _type = type; if (_type == kMouseTypeIntellimouseExplorer) _buttonCount = 5; else _buttonCount = 3; // // Report the resolution of the scroll wheel. This property must // be present to enable acceleration for Z-axis movement. // setProperty(kIOHIDScrollResolutionKey, (10 << 16), 32); } else { _packetLength = kPacketLengthStandard; _type = kMouseTypeStandard; _buttonCount = 3; removeProperty(kIOHIDScrollResolutionKey); } _packetByteCount = 0; // // Enable the mouse clock (should already be so) and the mouse IRQ line. // setCommandByte(kCB_EnableMouseIRQ, kCB_DisableMouseClock); // // Finally, we enable the mouse itself, so that it may start reporting // mouse events. // setMouseEnable(true); }
bool ApplePS2Keyboard::start(IOService * provider) { keyi=false; // // The driver has been instructed to start. This is called after a // successful attach. // if (!super::start(provider)) return false; // // Maintain a pointer to and retain the provider object. // _device = (ApplePS2KeyboardDevice *)provider; _device->retain(); if (kOSBooleanTrue == getProperty("Make capslock into control")) { emacsMode = true; } else { emacsMode = false; } if (kOSBooleanTrue == getProperty("Swap alt and windows key")) { macintoshMode = true; } else { macintoshMode = false; } // // Install our driver's interrupt handler, for asynchronous data delivery. // _device->installInterruptAction(this, /*(PS2InterruptAction)&ApplePS2Keyboard::interruptOccurred*/ OSMemberFunctionCast(PS2InterruptAction, this, &ApplePS2Keyboard::interruptOccurred)); _interruptHandlerInstalled = true; // // Initialize the keyboard LED state. // setLEDs(_ledState); // // Enable the keyboard clock (should already be so), the keyboard IRQ line, // and the keyboard Kscan -> scan code translation mode. // setCommandByte(kCB_EnableKeyboardIRQ | kCB_TranslateMode, kCB_DisableKeyboardClock); // // Finally, we enable the keyboard itself, so that it may start reporting // key events. // setKeyboardEnable(true); // // Install our power control handler. // _device->installPowerControlAction( this, /*(PS2PowerControlAction) &ApplePS2Keyboard::setDevicePowerState*/ OSMemberFunctionCast(PS2PowerControlAction, this, &ApplePS2Keyboard::setDevicePowerState) ); _powerControlHandlerInstalled = true; return true; }
bool ApplePS2SynapticsTouchPad::start( IOService * provider ) { UInt64 gesturesEnabled; // // The driver has been instructed to start. This is called after a // successful probe and match. // if (!super::start(provider)) return false; // // Maintain a pointer to and retain the provider object. // _device = (ApplePS2MouseDevice *) provider; _device->retain(); // // Announce hardware properties. // IOLog("ApplePS2Trackpad: Synaptics TouchPad v%d.%d\n", (UInt8)(_touchPadVersion >> 8), (UInt8)(_touchPadVersion)); // // Write the TouchPad mode byte value. // setTouchPadModeByte(_touchPadModeByte); // // Advertise the current state of the tapping feature. // gesturesEnabled = (_touchPadModeByte == kModeByteValueGesturesEnabled) ? 1 : 0; setProperty("Clicking", gesturesEnabled, sizeof(gesturesEnabled)*8); // // Must add this property to let our superclass know that it should handle // trackpad acceleration settings from user space. Without this, tracking // speed adjustments from the mouse prefs panel have no effect. // setProperty(kIOHIDPointerAccelerationTypeKey, kIOHIDTrackpadAccelerationType); // // Install our driver's interrupt handler, for asynchronous data delivery. // _device->installInterruptAction(this, (PS2InterruptAction)&ApplePS2SynapticsTouchPad::interruptOccurred); _interruptHandlerInstalled = true; // // Enable the mouse clock (should already be so) and the mouse IRQ line. // setCommandByte( kCB_EnableMouseIRQ, kCB_DisableMouseClock ); // // Finally, we enable the trackpad itself, so that it may start reporting // asynchronous events. // setTouchPadEnable(true); // // Install our power control handler. // _device->installPowerControlAction( this, (PS2PowerControlAction) &ApplePS2SynapticsTouchPad::setDevicePowerState ); _powerControlHandlerInstalled = true; return true; }