1c099b74eSFreeman Lou /* 2c099b74eSFreeman Lou * Copyright 2014 Freeman Lou <freemanlou2430@yahoo.com> 3c099b74eSFreeman Lou * All rights reserved. Distributed under the terms of the MIT license. 4c099b74eSFreeman Lou */ 5c099b74eSFreeman Lou #include "VirtualKeyboardInputDevice.h" 6c099b74eSFreeman Lou 7*a9fd76aeSFreeman Lou #include <InterfaceDefs.h> 8*a9fd76aeSFreeman Lou 9c099b74eSFreeman Lou extern "C" BInputServerDevice* 10c099b74eSFreeman Lou instantiate_input_device() 11c099b74eSFreeman Lou { 12c099b74eSFreeman Lou return new(std::nothrow) VirtualKeyboardInputDevice(); 13c099b74eSFreeman Lou } 14c099b74eSFreeman Lou 15c099b74eSFreeman Lou 16c099b74eSFreeman Lou VirtualKeyboardInputDevice::VirtualKeyboardInputDevice() 17c099b74eSFreeman Lou : 18c099b74eSFreeman Lou BInputServerDevice() 19c099b74eSFreeman Lou { 20*a9fd76aeSFreeman Lou fKeyboardWindow = new VirtualKeyboardWindow(this); 21c099b74eSFreeman Lou } 22c099b74eSFreeman Lou 23c099b74eSFreeman Lou 24*a9fd76aeSFreeman Lou VirtualKeyboardInputDevice::~VirtualKeyboardInputDevice() 25c099b74eSFreeman Lou { 26c099b74eSFreeman Lou } 27c099b74eSFreeman Lou 28c099b74eSFreeman Lou 29c099b74eSFreeman Lou status_t 30c099b74eSFreeman Lou VirtualKeyboardInputDevice::InitCheck() 31c099b74eSFreeman Lou { 32*a9fd76aeSFreeman Lou static input_device_ref keyboard = {"VirtualKeyboard", 33*a9fd76aeSFreeman Lou B_KEYBOARD_DEVICE, (void*) this}; 34*a9fd76aeSFreeman Lou static input_device_ref* devices[2] = {&keyboard, NULL}; 35*a9fd76aeSFreeman Lou 36*a9fd76aeSFreeman Lou RegisterDevices(devices); 37*a9fd76aeSFreeman Lou return B_OK; 38c099b74eSFreeman Lou } 39c099b74eSFreeman Lou 40c099b74eSFreeman Lou 41c099b74eSFreeman Lou status_t 42c099b74eSFreeman Lou VirtualKeyboardInputDevice::Start(const char* name, void* cookie) 43c099b74eSFreeman Lou { 44c099b74eSFreeman Lou fKeyboardWindow->Show(); 45*a9fd76aeSFreeman Lou return B_OK; 46*a9fd76aeSFreeman Lou } 47c099b74eSFreeman Lou 48*a9fd76aeSFreeman Lou 49*a9fd76aeSFreeman Lou status_t 50*a9fd76aeSFreeman Lou VirtualKeyboardInputDevice::Stop(const char* name, void* cookie) 51*a9fd76aeSFreeman Lou { 52*a9fd76aeSFreeman Lou if (fKeyboardWindow) { 53*a9fd76aeSFreeman Lou fKeyboardWindow->Quit(); 54*a9fd76aeSFreeman Lou fKeyboardWindow = NULL; 55*a9fd76aeSFreeman Lou } 56*a9fd76aeSFreeman Lou return B_OK; 57c099b74eSFreeman Lou } 58