xref: /haiku/headers/os/interface/Input.h (revision 56eb8e78cc702792e3b032e3f5f45da9e5dbea9e)
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 class BList;
19 
20 
21 enum input_method_op {
22 	B_INPUT_METHOD_STARTED			= 0,
23 	B_INPUT_METHOD_STOPPED			= 1,
24 	B_INPUT_METHOD_CHANGED	 		= 2,
25 	B_INPUT_METHOD_LOCATION_REQUEST	= 3
26 };
27 
28 
29 enum input_device_type {
30 	B_POINTING_DEVICE	= 0,
31 	B_KEYBOARD_DEVICE	= 1,
32 	B_UNDEFINED_DEVICE	= 2
33 };
34 
35 /*
36 	what == B_INPUT_DEVICES_CHANGED
37 	FindString("name", name_of_device);
38 	FindInt32("opcode", input_device_notification);
39 */
40 
41 enum input_device_notification {
42 	B_INPUT_DEVICE_ADDED 	= 0x0001,
43 	B_INPUT_DEVICE_STARTED	= 0x0002,
44 	B_INPUT_DEVICE_STOPPED	= 0x0004,
45 	B_INPUT_DEVICE_REMOVED	= 0x0008
46 };
47 
48 
49 class BInputDevice;
50 
51 
52 BInputDevice*	find_input_device(const char *name);
53 status_t		get_input_devices(BList *list);
54 status_t		watch_input_devices(BMessenger target, bool start);
55 
56 
57 class BInputDevice {
58 public:
59 							~BInputDevice();
60 
61 	const char*				Name() const;
62 	input_device_type		Type() const;
63 	bool					IsRunning() const;
64 
65 	status_t				Start();
66 	status_t				Stop();
67 	status_t				Control(uint32		code,
68 									BMessage	*message);
69 
70 	static status_t			Start(input_device_type type);
71 	static status_t			Stop(input_device_type type);
72 	static status_t			Control(input_device_type	type,
73 									uint32 				code,
74 									BMessage			*message);
75 
76 private:
77 	friend BInputDevice*	find_input_device(const char *name);
78 	friend status_t			get_input_devices(BList *list);
79 
80 							BInputDevice();
81 	void					set_name_and_type(const char		*name,
82 											  input_device_type	type);
83 
84 	char*					fName;
85 	input_device_type		fType;
86 	uint32					_reserved[4];
87 };
88 
89 
90 #endif
91