xref: /haiku/src/add-ons/input_server/devices/virtualkeyboard/VirtualKeyboardInputDevice.cpp (revision 07d5ef79d2cb7df8260ae1235737475e4509596d)
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 
7a9fd76aeSFreeman Lou #include <InterfaceDefs.h>
8a9fd76aeSFreeman Lou 
9c099b74eSFreeman Lou extern "C" BInputServerDevice*
instantiate_input_device()10c099b74eSFreeman Lou instantiate_input_device()
11c099b74eSFreeman Lou {
12c099b74eSFreeman Lou 	return new(std::nothrow) VirtualKeyboardInputDevice();
13c099b74eSFreeman Lou }
14c099b74eSFreeman Lou 
15c099b74eSFreeman Lou 
VirtualKeyboardInputDevice()16c099b74eSFreeman Lou VirtualKeyboardInputDevice::VirtualKeyboardInputDevice()
17c099b74eSFreeman Lou {
18c099b74eSFreeman Lou }
19c099b74eSFreeman Lou 
20c099b74eSFreeman Lou 
~VirtualKeyboardInputDevice()21a9fd76aeSFreeman Lou VirtualKeyboardInputDevice::~VirtualKeyboardInputDevice()
22c099b74eSFreeman Lou {
23c099b74eSFreeman Lou }
24c099b74eSFreeman Lou 
25c099b74eSFreeman Lou 
26c099b74eSFreeman Lou status_t
InitCheck()27c099b74eSFreeman Lou VirtualKeyboardInputDevice::InitCheck()
28c099b74eSFreeman Lou {
29*07d5ef79SOscar Lesta 	static input_device_ref keyboard = {(char*) "VirtualKeyboard",
30a9fd76aeSFreeman Lou 		B_KEYBOARD_DEVICE, (void*) this};
31a9fd76aeSFreeman Lou 	static input_device_ref* devices[2] = {&keyboard, NULL};
32a9fd76aeSFreeman Lou 
33a9fd76aeSFreeman Lou 	RegisterDevices(devices);
34a9fd76aeSFreeman Lou 	return B_OK;
35c099b74eSFreeman Lou }
36c099b74eSFreeman Lou 
37c099b74eSFreeman Lou 
38c099b74eSFreeman Lou status_t
Start(const char * name,void * cookie)39c099b74eSFreeman Lou VirtualKeyboardInputDevice::Start(const char* name, void* cookie)
40c099b74eSFreeman Lou {
41b8fe0b58SFreeman Lou 	fKeyboardWindow = new VirtualKeyboardWindow(this);
42c099b74eSFreeman Lou 	fKeyboardWindow->Show();
43a9fd76aeSFreeman Lou 	return B_OK;
44a9fd76aeSFreeman Lou }
45c099b74eSFreeman Lou 
46a9fd76aeSFreeman Lou 
47a9fd76aeSFreeman Lou status_t
Stop(const char * name,void * cookie)48a9fd76aeSFreeman Lou VirtualKeyboardInputDevice::Stop(const char* name, void* cookie)
49a9fd76aeSFreeman Lou {
50b8fe0b58SFreeman Lou 	if (fKeyboardWindow->Lock()) {
51a9fd76aeSFreeman Lou 		fKeyboardWindow->Quit();
52a9fd76aeSFreeman Lou 		fKeyboardWindow = NULL;
53a9fd76aeSFreeman Lou 	}
54a9fd76aeSFreeman Lou 	return B_OK;
55c099b74eSFreeman Lou }
562071724cSFreeman Lou 
572071724cSFreeman Lou 
582071724cSFreeman Lou status_t
Control(const char * name,void * cookie,uint32 command,BMessage * message)592071724cSFreeman Lou VirtualKeyboardInputDevice::Control(const char* name, void* cookie,
602071724cSFreeman Lou 	uint32 command, BMessage* message)
612071724cSFreeman Lou {
622071724cSFreeman Lou 	return B_OK;
632071724cSFreeman Lou }
64