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