1 #pragma once
2 #ifndef ES_APP_VIEWS_UI_MODE_CONTROLLER_H
3 #define ES_APP_VIEWS_UI_MODE_CONTROLLER_H
4 
5 #include <vector>
6 #include <string>
7 
8 class FileData;
9 class InputConfig;
10 class ViewController;
11 
12 struct Input;
13 
14 class UIModeController {
15 public:
16 	static UIModeController* getInstance();
17 
18 	// Monitor input for UI mode change, returns true (consumes input) when UI mode change is triggered.
19 	bool listen(InputConfig* config, Input input);
20 
21 	// Get the current Passphrase as a (unicode) formatted, comma-separated, string.
22 	std::string getFormattedPassKeyStr();
23 
24 	// Check for change in UI mode.
25 	void monitorUIMode();
26 
27 	bool isUIModeFull();
28 	bool isUIModeKid();
29 	bool isUIModeKiosk();
getUIModes()30 	inline std::vector<std::string> getUIModes() { return mUIModes; };
31 private:
32 	UIModeController();
33 	bool inputIsMatch(InputConfig * config, Input input);
34 	bool isValidInput(InputConfig * config, Input input);
35 	void logInput(InputConfig * config, Input input);
36 
37 	// Return UI mode to 'FULL'
38 	void unlockUIMode();
39 
40 	static UIModeController * sInstance;
41 	const std::vector<std::string> mUIModes = { "Full", "Kiosk", "Kid" };
42 
43 	// default passkeyseq = "uuddlrlrba", as defined in the setting 'UIMode_passkey'.
44 	std::string mPassKeySequence;
45 	int mPassKeyCounter;
46 	const std::vector<std::string> mInputVals = { "up", "down", "left", "right", "a", "b", "x", "y" };
47 	std::string mCurrentUIMode;
48 };
49 
50 #endif // ES_APP_VIEWS_UI_MODE_CONTROLLER_H
51