xref: /haiku/headers/os/interface/Input.h (revision 5d9e40fe9252c8f9c5e5e41594545bfa4419fcc7)
1 /******************************************************************************
2 /
3 /	File:			Input.h
4 /
5 /	Description:	Functions and class to manage input devices.
6 /
7 /	Copyright 1998, Be Incorporated, All Rights Reserved.
8 /
9 ******************************************************************************/
10 
11 #ifndef _INPUT_H
12 #define _INPUT_H
13 
14 #include <BeBuild.h>
15 #include <Messenger.h>
16 #include <SupportDefs.h>
17 
18 
19 enum input_method_op {
20 	B_INPUT_METHOD_STARTED			= 0,
21 	B_INPUT_METHOD_STOPPED			= 1,
22 	B_INPUT_METHOD_CHANGED	 		= 2,
23 	B_INPUT_METHOD_LOCATION_REQUEST	= 3
24 };
25 
26 
27 enum input_device_type {
28 	B_POINTING_DEVICE	= 0,
29 	B_KEYBOARD_DEVICE	= 1,
30 	B_UNDEFINED_DEVICE	= 2
31 };
32 
33 /*
34 	what == B_INPUT_DEVICES_CHANGED
35 	FindString("name", name_of_device);
36 	FindInt32("opcode", input_device_notification);
37 */
38 
39 enum input_device_notification {
40 	B_INPUT_DEVICE_ADDED 	= 0x0001,
41 	B_INPUT_DEVICE_STARTED	= 0x0002,
42 	B_INPUT_DEVICE_STOPPED	= 0x0004,
43 	B_INPUT_DEVICE_REMOVED	= 0x0008
44 };
45 
46 
47 class BInputDevice;
48 
49 
50 _IMPEXP_BE BInputDevice*	find_input_device(const char *name);
51 _IMPEXP_BE status_t			get_input_devices(BList *list);
52 _IMPEXP_BE status_t			watch_input_devices(BMessenger target, bool start);
53 
54 
55 class BInputDevice {
56 public:
57 							~BInputDevice();
58 
59 	const char*				Name() const;
60 	input_device_type		Type() const;
61 	bool					IsRunning() const;
62 
63 	status_t				Start();
64 	status_t				Stop();
65 	status_t				Control(uint32		code,
66 									BMessage	*message);
67 
68 	static status_t			Start(input_device_type type);
69 	static status_t			Stop(input_device_type type);
70 	static status_t			Control(input_device_type	type,
71 									uint32 				code,
72 									BMessage			*message);
73 
74 private:
75 	friend BInputDevice*	find_input_device(const char *name);
76 	friend status_t			get_input_devices(BList *list);
77 
78 							BInputDevice();
79 	void					set_name_and_type(const char		*name,
80 											  input_device_type	type);
81 
82 	char*					fName;
83 	input_device_type		fType;
84 	uint32					_reserved[4];
85 };
86 
87 
88 #endif
89