1/*
2 * Copyright 2007-2008 Haiku.
3 * Distributed under the terms of the MIT License.
4 *
5 * Authors:
6 *		Oliver Ruiz Dorantes	oliver.ruiz.dorantes_at_gmail.com
7 *		Ryan Leavengood			leavengood@gmail.com
8 *		Fredrik Mod��en 			fredrik@modeen.se
9 */
10
11#ifndef _JOY_WIN_H
12#define _JOY_WIN_H
13
14#include <Window.h>
15
16class BJoystick;
17class BCheckBox;
18class BStringView;
19class BListView;
20class PortItem;
21class BButton;
22class BEntry;
23class BFile;
24
25class JoyWin : public BWindow {
26	public:
27		JoyWin(BRect frame,const char *title);
28		virtual         ~JoyWin();
29		virtual	void	MessageReceived(BMessage *message);
30		virtual	bool	QuitRequested();
31
32	private:
33		status_t		_AddToList(BListView *list, uint32 command,
34							const char* rootPath, BEntry *rootEntry = NULL);
35
36		status_t		_Calibrate();
37		status_t		_PerformProbe(const char* path);
38		status_t		_ApplyChanges();
39		status_t		_GetSettings();
40		status_t		_CheckJoystickExist(const char* path);
41
42		/*Show Alert Boxes*/
43		status_t		_ShowProbeMesage(const char* str);
44		status_t		_ShowCantFindFileMessage(const char* port);
45		void	 		_ShowNoDeviceConnectedMessage(const char* joy,
46							const char* port);
47		void			_ShowNoCompatibleJoystickMessage();
48
49		/*Util*/
50		BString			_FixPathToName(const char* port);
51		BString			_BuildDisabledJoysticksFile();
52		PortItem*		_GetSelectedItem(BListView* list);
53		void			_SelectDeselectJoystick(BListView* list, bool enable);
54		int32			_FindStringItemInList(BListView *view,
55						PortItem *item);
56		BString			_FindFilePathForSymLink(const char* symLinkPath,
57						PortItem *item);
58		status_t		_FindStick(const char* name);
59		const char*		_FindSettingString(const char* name, const char* strPath);
60		bool 			_GetLine(BString& string);
61
62	//this one are used when we select joystick when portare selected
63		bool 			fSystemUsedSelect;
64
65		BJoystick*		fJoystick;
66		BCheckBox*		fCheckbox;
67		BStringView*	fGamePortS;
68		BStringView*	fConControllerS;
69		BListView*		fGamePortL;
70		BListView*		fConControllerL;
71		BButton*		fCalibrateButton;
72		BButton*		fProbeButton;
73
74		BFile*			fFileTempProbeJoystick;
75//		int32  			fSourceEncoding;
76   		char    		fBuffer[4096];
77   		off_t   		fPositionInBuffer;
78   		ssize_t 		fAmtRead;
79};
80
81#endif	/* _JOY_WIN_H */
82