Ticket #8711: backends-lib.v3.1.patch
File backends-lib.v3.1.patch, 25.8 KB (added by , 17 years ago) |
---|
-
D:/programming/projects/gsoc/scummvm/backends/events/default/default-events.cpp
49 49 uint32 time = _boss->getMillis(); 50 50 bool result; 51 51 52 result = _boss->poll Event(event);52 result = _boss->pollMappedEvent(event); 53 53 54 54 if (result) { 55 55 event.synthetic = false; … … 128 128 return result; 129 129 } 130 130 131 void DefaultEventManager::registerActionMappings(const Common::MappingList mappings) { 132 _boss->getKeyMapper()->registerActionMappings(mappings); 133 } 134 void DefaultEventManager::unregisterActionMappings() { 135 _boss->getKeyMapper()->unregisterActionMappings(); 136 } 137 138 131 139 #endif // !defined(DISABLE_DEFAULT_EVENTMANAGER) -
D:/programming/projects/gsoc/scummvm/backends/events/default/default-events.h
67 67 68 68 virtual bool pollEvent(Common::Event &event); 69 69 70 virtual void registerActionMappings(const Common::MappingList); 71 virtual void unregisterActionMappings(); 72 70 73 virtual Common::Point getMousePos() const { return _mousePos; } 71 74 virtual int getButtonState() const { return _buttonState; } 72 75 virtual int getModifierState() const { return _modifierState; } -
D:/programming/projects/gsoc/scummvm/backends/platform/sdl/sdl.cpp
257 257 memset(&_mouseCurState, 0, sizeof(_mouseCurState)); 258 258 259 259 _inited = false; 260 261 // init keys available for the device 262 _availableKeys.push_front(Common::KEYCODE_F5); 263 _availableKeys.push_front(Common::KEYCODE_p); 264 _availableKeys.push_front(Common::KEYCODE_ESCAPE); 260 265 } 261 266 262 267 OSystem_SDL::~OSystem_SDL() { -
D:/programming/projects/gsoc/scummvm/backends/platform/sdl/events.cpp
445 445 return false; 446 446 } 447 447 448 Common::KeyCodeList OSystem_SDL::getAvailableKeys() const { 449 return _availableKeys; 450 } 451 448 452 bool OSystem_SDL::remapKey(SDL_Event &ev, Common::Event &event) { 449 453 #ifdef LINUPY 450 454 // On Yopy map the End button to quit -
D:/programming/projects/gsoc/scummvm/backends/platform/sdl/sdl-common.h
34 34 #include "graphics/scaler.h" 35 35 #include "backends/intern.h" 36 36 37 #include "backends/platform/common/common-system.h" 37 38 39 38 40 namespace Audio { 39 41 class Mixer; 40 42 } … … 66 68 }; 67 69 68 70 69 class OSystem_SDL : public OSystem {71 class OSystem_SDL : public OSystem_Common { 70 72 public: 71 73 OSystem_SDL(); 72 74 virtual ~OSystem_SDL(); … … 131 133 // Returns true if an event was retrieved. 132 134 virtual bool pollEvent(Common::Event &event); // overloaded by CE backend 133 135 136 virtual std::list<Common::KeyCode> getAvailableKeys() const; 137 134 138 // Set function that generates samples 135 139 typedef void (*SoundProc)(void *param, byte *buf, int len); 136 140 virtual bool setSoundCallback(SoundProc proc, void *param); // overloaded by CE backend … … 411 415 virtual bool remapKey(SDL_Event &ev, Common::Event &event); 412 416 413 417 void handleScalerHotkeys(const SDL_KeyboardEvent &key); 418 419 private: 420 Common::KeyCodeList _availableKeys; 414 421 }; 415 422 416 423 #endif -
D:/programming/projects/gsoc/scummvm/backends/platform/common/common-system.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 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (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, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 * 21 */ 22 23 #ifndef PLATFORM_COMMON_SYSTEM_H 24 #define PLATFORM_COMMON_SYSTEM_H 25 26 #include "common/stdafx.h" 27 #include "common/scummsys.h" 28 #include "common/system.h" 29 #include "common/keyboard.h" 30 #include "common/events.h" 31 32 #include "backends/platform/common/virtual-keyboard.h" 33 #include "backends/platform/common/key-mapper.h" 34 35 class OSystem_Common : public OSystem { 36 37 public: 38 OSystem_Common(); 39 ~OSystem_Common(); 40 41 virtual bool pollMappedEvent(Common::Event &); 42 virtual KeyMapper *getKeyMapper(); 43 44 protected: 45 46 virtual Common::KeyCodeList getAvailableKeys() const = 0; 47 48 private: 49 50 KeyMapper *_keyMapper; 51 VirtualKeyboard *_virtualKeyboard; 52 53 }; 54 55 #endif -
D:/programming/projects/gsoc/scummvm/backends/platform/common/key-mapper.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 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (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, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 * 21 */ 22 23 #ifndef COMMON_KEY_MAPPER_H 24 #define COMMON_KEY_MAPPER_H 25 26 #include "common/stdafx.h" 27 #include "common/scummsys.h" 28 #include "common/keyboard.h" 29 #include "common/events.h" 30 31 #include <list> 32 #include <map> 33 34 typedef std::map<Common::KeyState, Common::ActionMapping> KeyActionMap; 35 36 class KeyMapper { 37 38 public: 39 40 KeyMapper(Common::KeyCodeList); 41 42 virtual void registerActionMappings(const Common::MappingList); 43 virtual void unregisterActionMappings(); 44 45 void resolve(Common::Event &); 46 47 private: 48 bool _registered; 49 Common::KeyCodeList _availableKeys; // keys available on the device 50 Common::MappingList _needsMapping; // mappings which default keys are not in the available keys 51 KeyActionMap _mappings; // available keys and action mappings 52 }; 53 54 #endif 55 No newline at end of file -
D:/programming/projects/gsoc/scummvm/backends/platform/common/virtual-keyboard.cpp
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 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (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, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 * 21 */ 22 23 #include "backends/platform/common/virtual-keyboard.h" 24 25 VirtualKeyboard::VirtualKeyboard() { 26 } 27 28 void VirtualKeyboard::resolve(Common::Event &event) { 29 } -
D:/programming/projects/gsoc/scummvm/backends/platform/common/virtual-keyboard.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 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (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, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 * 21 */ 22 23 #ifndef COMMON_VIRTUAL_KEYBOARD_H 24 #define COMMON_VIRTUAL_KEYBOARD_H 25 26 #include "common/stdafx.h" 27 #include "common/scummsys.h" 28 #include "common/events.h" 29 30 class VirtualKeyboard { 31 32 public: 33 VirtualKeyboard(); 34 void resolve(Common::Event &); 35 }; 36 37 #endif 38 No newline at end of file -
D:/programming/projects/gsoc/scummvm/backends/platform/common/common-system.cpp
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 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (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, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 * 21 */ 22 #include "backends/platform/common/common-system.h" 23 24 OSystem_Common::OSystem_Common() { 25 _keyMapper = NULL; 26 _virtualKeyboard = new VirtualKeyboard(); 27 } 28 29 OSystem_Common::~OSystem_Common() { 30 if (_keyMapper) { 31 delete _keyMapper; 32 } 33 delete _virtualKeyboard; 34 } 35 bool OSystem_Common::pollMappedEvent(Common::Event &event) { 36 37 // very important -> we clean the event struct from the previous pollEvent; 38 // TODO would be nice to have accross all backends in their pollEvent functions 39 event.reset(); 40 41 bool result = true; 42 if (pollEvent(event)) { // calling virtual superclass function 43 bool lbutton = event.type == Common::EVENT_LBUTTONDOWN || event.type == Common::EVENT_LBUTTONUP; 44 if (getFeatureState(kFeatureVirtualKeyboard) && lbutton) { // possible a virtual keyboard event 45 _virtualKeyboard->resolve(event); // try to resolve a virtual keyboard event 46 } 47 getKeyMapper()->resolve(event); 48 } else { 49 result = false; 50 } 51 return result; 52 } 53 54 KeyMapper *OSystem_Common::getKeyMapper() { 55 if (!_keyMapper) { 56 _keyMapper = new KeyMapper(getAvailableKeys()); 57 } 58 return _keyMapper; 59 } -
D:/programming/projects/gsoc/scummvm/backends/platform/common/module.mk
1 MODULE := backends/platform/common 2 3 MODULE_OBJS := \ 4 common-system.o 5 6 MODULE_DIRS += \ 7 backends/platform/common/ 8 9 # We don't use the rules.mk here on purpose 10 OBJS := $(addprefix $(MODULE)/, $(MODULE_OBJS)) $(OBJS) -
D:/programming/projects/gsoc/scummvm/backends/platform/common/key-mapper.cpp
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 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (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, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 * 21 */ 22 23 #include "backends/platform/common/key-mapper.h" 24 25 KeyMapper::KeyMapper(Common::KeyCodeList availableKeys) : 26 _availableKeys(availableKeys), 27 _registered(false) { 28 } 29 30 void KeyMapper::registerActionMappings(const Common::MappingList supportedActions) { 31 this->unregisterActionMappings(); 32 // check if the backend supports any of the default keys 33 Common::MappingList tmpList = supportedActions; 34 for (Common::MappingList::iterator mIt = tmpList.begin(); mIt != tmpList.end(); mIt++) { 35 bool found = false; 36 for (Common::KeyCodeList::iterator kcIt = _availableKeys.begin(); !found && kcIt != _availableKeys.end(); kcIt++) { 37 // TODO add support for flags 38 if (mIt->defaultKey.keycode == *kcIt) { 39 // TODO check the behaviour of map. Maybe heap objects should be used 40 _mappings[mIt->defaultKey] = *mIt; 41 found = true; 42 } 43 } 44 if (!found) { 45 _needsMapping.push_back(*mIt); 46 } 47 } 48 // open the keys dialog or look up mappings in the tables for the rest of actions 49 // ... 50 _registered = true; 51 } 52 53 void KeyMapper::unregisterActionMappings() { 54 _needsMapping.clear(); 55 _mappings.clear(); 56 _registered = false; 57 } 58 59 void KeyMapper::resolve(Common::Event &event) { 60 if (!_registered || _mappings.empty()) { 61 return; 62 } 63 KeyActionMap::iterator it = _mappings.find(event.kbd); 64 if (it != _mappings.end()) { 65 event.kbd = it->second.defaultKey; 66 // TODO add functionality to set the type for engine actions like EVENT_QUIT 67 // event.type = it->second.type; 68 } 69 } -
D:/programming/projects/gsoc/scummvm/common/keyboard.h
28 28 29 29 #include "common/scummsys.h" 30 30 31 #include <list> 32 31 33 namespace Common { 32 34 33 35 enum KeyCode { … … 181 183 KEYCODE_UNDO = 322 // Atari keyboard has Undo 182 184 }; 183 185 186 typedef std::list<Common::KeyCode> KeyCodeList; 187 184 188 /** 185 189 * List of certan special and some fake 'ascii' values used in keyboard events. 186 190 * The values for the function keys listed here are based on what certain SCUMM … … 259 263 keycode = KEYCODE_INVALID; 260 264 ascii = flags = 0; 261 265 } 266 267 bool operator <(const KeyState keyState) const { 268 return keycode < keyState.keycode; 269 } 270 271 bool operator ==(const KeyState keyState) const { 272 return (keycode == keyState.keycode) && (flags == keyState.flags); 273 } 274 262 275 }; 263 276 264 277 } // End of namespace Common -
D:/programming/projects/gsoc/scummvm/common/system.h
31 31 #include "common/noncopyable.h" 32 32 #include "common/rect.h" 33 33 34 #include "backends/platform/common/key-mapper.h" 35 34 36 namespace Audio { 35 37 class Mixer; 36 38 } … … 724 726 */ 725 727 virtual bool pollEvent(Common::Event &event) = 0; 726 728 729 /** 730 * Get the next event with resolved key mapping from the event queue. 731 * @param event point to an Common::Event struct, which will be filled with the event data. 732 * @return true if an event was retrieved. 733 */ 734 virtual bool pollMappedEvent(Common::Event &event) = 0; 735 736 virtual KeyMapper *getKeyMapper() = 0; 737 727 738 public: 739 728 740 /** Get the number of milliseconds since the program was started. */ 729 741 virtual uint32 getMillis() = 0; 730 742 … … 743 755 */ 744 756 virtual Common::EventManager *getEventManager(); 745 757 758 746 759 //@} 747 760 748 761 … … 894 907 * refer to the SaveFileManager documentation. 895 908 */ 896 909 virtual Common::SaveFileManager *getSavefileManager() = 0; 897 898 910 //@} 899 911 }; 900 912 -
D:/programming/projects/gsoc/scummvm/common/events.h
28 28 29 29 #include "common/keyboard.h" 30 30 #include "common/rect.h" 31 #include "common/system.h"32 31 #include "common/noncopyable.h" 33 32 33 #include <list> 34 34 35 namespace Common { 35 36 36 37 /** … … 43 44 * indicates which button was pressed. 44 45 */ 45 46 enum EventType { 47 48 EVENT_INVALID = 0, 46 49 /** A key was pressed, details in Event::kbd. */ 47 50 EVENT_KEYDOWN = 1, 48 51 /** A key was released, details in Event::kbd. */ … … 107 110 * Keyboard data; only valid for keyboard events (EVENT_KEYDOWN and 108 111 * EVENT_KEYUP). For all other event types, content is undefined. 109 112 */ 110 KeyState kbd;113 Common::KeyState kbd; 111 114 /** 112 115 * The mouse coordinates, in virtual screen coordinates. Only valid 113 116 * for mouse events. … … 115 118 * screen area as defined by the most recent call to initSize(). 116 119 */ 117 120 Common::Point mouse; 121 122 Event(Common::EventType et = Common::EVENT_INVALID, bool s = false, 123 Common::KeyState ks = Common::KeyState(), Common::Point p = Common::Point()) { 124 125 type = et; 126 synthetic = s; 127 kbd = ks; 128 mouse = p; 129 } 130 131 void reset() { 132 type = Common::EVENT_INVALID; 133 synthetic = false; 134 kbd = Common::KeyState(); 135 mouse = Common::Point(); 136 } 118 137 }; 119 138 139 enum Priority { 140 PRIORITY_HIGHEST, 141 PRIORITY_HIGH, 142 PRIORITY_NORMAL, 143 PRIORITY_LOW, 144 PRIORITY_LOWEST 145 }; 120 146 147 struct ActionMapping { 148 Common::KeyState defaultKey; // default key combo used for mapping; includes modifier state 149 Common::EventType type; // event type like key up/down, quit, save/load 150 String description; // human readable description, for a GUI keymapping config dialog 151 Common::Priority priority; // mapping priority 152 153 ActionMapping(Common::KeyState ks = Common::KeyState(Common::KEYCODE_ESCAPE), 154 Common::EventType et = Common::EVENT_KEYDOWN, String d = "Action name", 155 Common::Priority p = Common::PRIORITY_NORMAL) { 156 157 defaultKey = ks; 158 type = et; 159 description = d; 160 priority = p; 161 } 162 163 ActionMapping(Common::KeyState ks, String d, Common::Priority p) { 164 defaultKey = ks; 165 type = Common::EVENT_INVALID; 166 description = d; 167 priority = p; 168 } 169 170 ActionMapping(Common::KeyState ks, String d) { 171 defaultKey = ks; 172 type = Common::EVENT_INVALID; 173 description = d; 174 priority = Common::PRIORITY_NORMAL; 175 } 176 177 }; 178 179 typedef std::list<Common::ActionMapping> MappingList; 180 121 181 /** 122 182 * The EventManager provides user input events to the client code. 123 183 * In addition, it keeps track of the state of various input devices, … … 166 226 // TODO: Keyboard repeat support? 167 227 168 228 // TODO: Consider removing OSystem::getScreenChangeID and 169 // replacing it by a generic getScreenChangeID method here 229 // replacing it by a generic getScreenChaneID method here 230 231 virtual void registerActionMappings(const MappingList) = 0; 232 233 virtual void unregisterActionMappings() = 0; 170 234 }; 171 235 172 236 } // End of namespace Common -
D:/programming/projects/gsoc/scummvm/engines/cruise/cruise_main.cpp
30 30 #include "cruise/cruise_main.h" 31 31 #include "cruise/cell.h" 32 32 33 #include "common/system.h" 34 33 35 namespace Cruise { 34 36 35 37 unsigned int timer = 0; -
D:/programming/projects/gsoc/scummvm/engines/sky/sky.cpp
30 30 #include "common/config-manager.h" 31 31 #include "common/file.h" 32 32 #include "common/fs.h" 33 #include "common/keyboard.h" 33 34 #include "common/events.h" 34 35 #include "common/system.h" 35 36 #include "common/timer.h" … … 183 184 184 185 SkyEngine::SkyEngine(OSystem *syst) 185 186 : Engine(syst), _fastMode(0), _debugger(0) { 187 Common::MappingList mappings; 188 189 Common::KeyState key = Common::KeyState(Common::KEYCODE_F5); 190 Common::ActionMapping mapping = Common::ActionMapping(key, "Menu"); 191 mappings.push_back(mapping); 192 193 194 key = Common::KeyState(Common::KEYCODE_ESCAPE); 195 mapping = Common::ActionMapping(key, "Esc"); 196 mappings.push_back(mapping); 197 198 key = Common::KeyState(Common::KEYCODE_p); 199 mapping = Common::ActionMapping(key, "Pause"); 200 mappings.push_back(mapping); 201 202 _eventMan->registerActionMappings(mappings); 186 203 } 187 204 188 205 SkyEngine::~SkyEngine() { -
D:/programming/projects/gsoc/scummvm/engines/gob/mult_v2.cpp
1153 1153 1154 1154 if (_multData->imdIndices[i] != -1) { 1155 1155 int fileN; 1156 char *imdFile ;1156 char *imdFile = NULL; 1157 1157 int dir; 1158 1158 int startFrame; 1159 1159 -
D:/programming/projects/gsoc/scummvm/engines/parallaction/dialogue.cpp
28 28 #include "common/events.h" 29 29 #include "parallaction/parallaction.h" 30 30 31 #include "common/system.h" 31 32 32 33 34 33 35 namespace Parallaction { 34 36 35 37 #define SKIPPED_ANSWER 1000 -
D:/programming/projects/gsoc/scummvm/engines/parallaction/parallaction.cpp
30 30 #include "common/file.h" 31 31 #include "common/util.h" 32 32 33 #include "common/system.h" 34 33 35 #include "sound/mididrv.h" 34 36 #include "sound/mixer.h" 35 37