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  kEventEsc = 1 << 7
49 };
50 
51 class Keyboard {
52 private:
53  CGEEngine *_vm;
54 public:
55  Sprite *_client;
56  bool _keyAlt;
57 
58  void handleAction(Common::Event &event);
59  Sprite *setClient(Sprite *spr);
60 
61  Keyboard(CGEEngine *vm);
62  ~Keyboard();
63 };
64 
65 /*----------------- MOUSE interface -----------------*/
66 
67 struct CGEEvent {
68  uint16 _mask;
69  uint16 _x;
70  uint16 _y;
71  Sprite *_spritePtr;
72 };
73 
74 class Mouse : public Sprite {
75 public:
76  Sprite *_hold;
77  bool _active;
78  int _hx;
79  int _hy;
80  bool _exist;
81  int _buttons;
82  Sprite *_busy;
83  Mouse(CGEEngine *vm);
84  ~Mouse() override;
85  void on();
86  void off();
87  void newMouse(Common::Event &event);
88 private:
89  CGEEngine *_vm;
90 };
91 
92 /*----------------- EventManager interface -----------------*/
93 
94 class EventManager {
95 private:
96  CGEEngine *_vm;
97  Common::Event _event;
98  CGEEvent _eventQueue[kEventMax];
99  uint16 _eventQueueHead;
100  uint16 _eventQueueTail;
101 
102  void handleEvents();
103 public:
104  EventManager(CGEEngine *vm);
105  void poll();
106  void clearEvent(Sprite *spr);
107 
108  CGEEvent &getNextEvent();
109 };
110 
111 } // End of namespace CGE
112 
113 #endif
Definition: events.h:67
Definition: events.h:74
Definition: cge.h:150
Definition: events.h:51
Definition: events.h:199
Definition: vga13h.h:83
Definition: events.h:94
Definition: bitmap.h:33