xref: /haiku/headers/os/device/Joystick.h (revision 2f470aec1c92ce6917b8a903e343795dc77af41f)
1 /********************************************************************************
2 /
3 /	File:		Joystick.h
4 /
5 /	Description:	Joystick port class header.
6 /
7 /	Copyright 1996-98, Be Incorporated, All Rights Reserved.
8 /
9 ********************************************************************************/
10 
11 
12 #ifndef	_JOYSTICK_H
13 #define	_JOYSTICK_H
14 
15 #include <BeBuild.h>
16 #include <SupportDefs.h>
17 #include <OS.h>
18 
19 class BList;
20 struct _extended_joystick;
21 class _IMPEXP_DEVICE _BJoystickTweaker;
22 
23 /* -----------------------------------------------------------------------*/
24 class BJoystick {
25 
26 public:
27 					BJoystick();
28 virtual				~BJoystick();
29 
30 		status_t	Open(const char *portName);	/* always goes for enhanced mode */
31 		status_t	Open(const char *portName, bool enter_enhanced);
32 		void		Close(void);
33 
34 		status_t	Update(void);
35 		status_t	SetMaxLatency(
36 						bigtime_t max_latency);
37 
38 		bigtime_t	timestamp;
39 		int16		horizontal;
40 		int16		vertical;
41 		bool		button1;	/* NOTE: true == off */
42 		bool		button2;
43 
44 		int32		CountDevices();
45 		status_t	GetDeviceName(int32 n, char * name,
46 						size_t bufSize = B_OS_NAME_LENGTH);
47 
48 		/* if you care about more than just the first two axes/buttons, here's where you go */
49 		bool		EnterEnhancedMode(
50 						const entry_ref * ref = NULL);
51 		int32		CountSticks();
52 		int32		CountAxes();
53 		int32		CountHats();
54 		int32		CountButtons();
55 		status_t	GetAxisValues(
56 						int16 * out_values,
57 						int32 for_stick = 0);	/* CountAxes() elements */
58 		status_t	GetHatValues(
59 						uint8 * out_hats,
60 						int32 for_stick = 0);
61 		uint32		ButtonValues(
62 						int32 for_stick = 0);		/* NOTE: Buttons() are 1 == on */
63 		status_t	GetAxisNameAt(
64 						int32 index,
65 						BString * out_name);
66 		status_t	GetHatNameAt(
67 						int32 index,
68 						BString * out_name);
69 		status_t	GetButtonNameAt(
70 						int32 index,
71 						BString * out_name);
72 		status_t	GetControllerModule(
73 						BString * out_name);
74 		status_t	GetControllerName(
75 						BString * out_name);
76 
77 		bool			IsCalibrationEnabled();
78 		status_t	EnableCalibration(
79 						bool calibrates = true);
80 
81 /* -----------------------------------------------------------------------*/
82 
83 protected:
84 
85 virtual	void			Calibrate(
86 						struct _extended_joystick * reading);
87 
88 private:
89 friend class _BJoystickTweaker;
90 
91 		struct _joystick_info;
92 
93 		void		ScanDevices(
94 						bool use_disabled = false);
95 		status_t	gather_enhanced_info(
96 						const entry_ref * ref = NULL);
97 		status_t	save_config(
98 						const entry_ref * ref = NULL);
99 
100 		void		_ReservedJoystick1();
101 virtual	void		_ReservedJoystick2();
102 virtual	void		_ReservedJoystick3();
103 
104 		bool		_mBeBoxMode;
105 		bool		_mReservedBool;
106 		int			ffd;
107 		BList *		_fDevices;
108 		_joystick_info * m_info;
109 		char * m_dev_name;
110 #if !_PR3_COMPATIBLE_
111 virtual	status_t	_Reserved_Joystick_4(void *, ...);
112 virtual	status_t	_Reserved_Joystick_5(void *, ...);
113 virtual	status_t	_Reserved_Joystick_6(void *, ...);
114 		uint32		_reserved_Joystick_[10];
115 #endif
116 };
117 
118 #endif
119