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