ScummVM API documentation
events.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 /*
23  * This code is based on original Sfinx source code
24  * Copyright (c) 1994-1997 Janusz B. Wisniewski and L.K. Avalon
25  */
26 
27 #ifndef CGE2_EVENTS_H
28 #define CGE2_EVENTS_H
29 
30 #include "common/events.h"
31 #include "cge2/talk.h"
32 #include "cge2/vga13h.h"
33 
34 namespace CGE2 {
35 
36 /*----------------- KEYBOARD interface -----------------*/
37 
38 #define kEventMax 256
39 
40 enum EventMask {
41  kMouseRoll = 1 << 0,
42  kMouseLeftDown = 1 << 1,
43  kMouseLeftUp = 1 << 2,
44  kMouseRightDown = 1 << 3,
45  kMouseRightUp = 1 << 4,
46  kEventAttn = 1 << 5,
47  kMouseMask = (kMouseRoll | kMouseLeftDown | kMouseLeftUp | kMouseRightDown | kMouseRightUp),
48  kEventKeyb = 1 << 7
49 };
50 
51 class Keyboard {
52 private:
53  bool getKey(Common::Event &event);
54  CGE2Engine *_vm;
55 public:
56  Sprite *_client;
57 
58  void newKeyboard(Common::Event &event);
59  Sprite *setClient(Sprite *spr);
60 
61  Keyboard(CGE2Engine *vm);
62  ~Keyboard();
63 };
64 
65 /*----------------- MOUSE interface -----------------*/
66 
67 struct CGE2Event {
68  uint16 _mask;
69  uint16 _x;
70  uint16 _y;
71  Common::KeyCode _keyCode;
72  Sprite *_spritePtr;
73 };
74 
75 class Mouse : public Sprite {
76 public:
77  V2D _point;
78  Sprite *_hold;
79  bool _active;
80  int _hx;
81  int _hy;
82  bool _exist;
83  int _buttons;
84  Sprite *_busy;
85  Mouse(CGE2Engine *vm);
86  ~Mouse() override;
87  void on();
88  void off();
89  void newMouse(Common::Event &event);
90 private:
91  CGE2Engine *_vm;
92 };
93 
94 /*----------------- EventManager interface -----------------*/
95 
96 class EventManager {
97 private:
98  CGE2Engine *_vm;
99  Common::Event _event;
100  CGE2Event _eventQueue[kEventMax];
101  uint16 _eventQueueHead;
102  uint16 _eventQueueTail;
103 
104  void handleEvents();
105 public:
107  void poll();
108  void clearEvent(Sprite *spr);
109 
110  CGE2Event &getNextEvent();
111 };
112 
113 } // End of namespace CGE
114 
115 #endif // #define CGE2_EVENTS_H
Definition: cge2.h:140
Definition: events.h:75
Definition: events.h:96
Definition: vga13h.h:152
Definition: vga13h.h:94
Definition: bitmap.h:33
Definition: events.h:198
Definition: events.h:51
Definition: events.h:67