ScummVM API documentation
pspkeyboard.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef PSPKEYBOARD_H
23 #define PSPKEYBOARD_H
24 
25 #include "common/events.h"
26 #include "common/stream.h"
27 #include "backends/platform/psp/display_client.h"
28 //#include "backends/platform/psp/input.h"
29 #include <pspctrl.h>
30 
31 //number of modes
32 #define MODE_COUNT 4
33 #define guiStringsSize 8 /* size of guistrings array */
34 
35 class PspEvent;
36 
37 class PSPKeyboard : public DisplayClient {
38 
39 private:
40  enum State {
41  kInvisible,
42  kDefault,
43  kCornersSelected,
44  kLTriggerDown,
45  kRTriggerDown,
46  kMove
47  };
48 
49 public:
50  PSPKeyboard();
51  ~PSPKeyboard();
52 
53  bool load(); // Load keyboard into memory
54  bool isInit() const { return _init; } // Check for initialization
55  bool isDirty() const { return _dirty; } // Check if needs redrawing
56  void setDirty() { _dirty = true; }
57  void setClean() { _dirty = false; }
58  bool isVisible() const { return _state != kInvisible; } // Check if visible
59  void setVisible(bool val);
60  bool processInput(Common::Event &event, PspEvent &pspEvent, SceCtrlData &pad); // Process input
61  void moveTo(const int newX, const int newY); // Move keyboard
62  void render(); // Draw the keyboard onscreen
63 private:
64  enum CursorDirections {
65  kUp = 0,
66  kRight,
67  kDown,
68  kLeft,
69  kCenter
70  };
71 
72  Buffer _buffers[guiStringsSize];
73  Palette _palettes[guiStringsSize];
74  GuRenderer _renderer;
75 
76  void increaseKeyboardLocationX(int amount); // Move keyboard onscreen
77  void increaseKeyboardLocationY(int amount);
78  void convertCursorToXY(CursorDirections cur, int &x, int &y);
79 
80  bool handleMoveState(SceCtrlData &pad);
81  bool handleDefaultState(Common::Event &event, SceCtrlData &pad);
82  bool handleCornersSelectedState(Common::Event &event, SceCtrlData &pad);
83  bool getInputChoice(Common::Event &event, SceCtrlData &pad);
84  void getCursorMovement(SceCtrlData &pad);
85  void handleRTriggerDownState(SceCtrlData &pad);
86  void handleLTriggerDownState(SceCtrlData &pad);
87 
88  static short _modeChar[MODE_COUNT][5][6];
89  static const char *_guiStrings[];
90  bool _init;
91  uint32 _prevButtons; // A bit pattern.
92  uint32 _buttonsChanged;
93 
94  bool _dirty; // keyboard needs redrawing
95  int _mode; // charset selected. (0 - letters or 1 - numbers)
96  int _movedX; // location we've moved the KB to onscreen
97  int _movedY;
98  bool _moved; // whether the keyboard was moved
99 
100  State _state; // State of keyboard Keyboard state machine
101  State _lastState;
102 
103  CursorDirections _oldCursor; // Point to place of last cursor
104 
105 };
106 
107 #endif /* PSPKEYBOARD_H */
Definition: input.h:45
Definition: display_client.h:172
Definition: events.h:198
Definition: pspkeyboard.h:37
Definition: display_client.h:113
Definition: display_client.h:40
Definition: display_client.h:78