Ticket #8711: backends-lib.v4.1.patch
File backends-lib.v4.1.patch, 58.5 KB (added by , 17 years ago) |
---|
-
D:/programming/projects/gsoc/scummvm/backends/events/default/default-events.cpp
35 35 36 36 DefaultEventManager::DefaultEventManager(OSystem *boss) : 37 37 _boss(boss), 38 _keyMapper(boss->getKeyMapper()), 39 _virtualKeyboard(boss->getVirtualKeyboard()), 38 40 _buttonState(0), 39 41 _modifierState(0), 40 42 _shouldQuit(false) { … … 52 54 result = _boss->pollEvent(event); 53 55 54 56 if (result) { 57 // check if we have to resolve virtual keyboard event 58 bool lbutton = event.type == Common::EVENT_LBUTTONDOWN || event.type == Common::EVENT_LBUTTONUP; 59 if (_boss->getFeatureState(OSystem::kFeatureVirtualKeyboard) && _virtualKeyboard && lbutton) { // possibly a virtual keyboard event 60 _virtualKeyboard->resolve(event); // try to resolve a virtual keyboard event 61 } 62 63 // check if we have to resolve key mapping 64 if (_keyMapper) { 65 _keyMapper->resolve(event); 66 } 67 55 68 event.synthetic = false; 56 69 switch (event.type) { 57 70 case Common::EVENT_KEYDOWN: … … 128 141 return result; 129 142 } 130 143 144 KeyMapper *DefaultEventManager::getKeyMapper() { 145 return _keyMapper; 146 } 147 131 148 #endif // !defined(DISABLE_DEFAULT_EVENTMANAGER) -
D:/programming/projects/gsoc/scummvm/backends/events/default/default-events.h
28 28 29 29 #include "common/stdafx.h" 30 30 #include "common/events.h" 31 #include "common/event-manager.h" 31 32 33 #include "backends/platform/common/key-mapper.h" 34 #include "backends/platform/common/virtual-keyboard.h" 35 32 36 /* 33 37 At some point we will remove pollEvent from OSystem and change 34 38 DefaultEventManager to use a "boss" derived from this class: … … 43 47 44 48 class DefaultEventManager : public Common::EventManager { 45 49 OSystem *_boss; 50 KeyMapper *_keyMapper; 51 VirtualKeyboard *_virtualKeyboard; 46 52 47 53 Common::Point _mousePos; 48 54 int _buttonState; … … 67 73 68 74 virtual bool pollEvent(Common::Event &event); 69 75 76 virtual KeyMapper *getKeyMapper(); 77 70 78 virtual Common::Point getMousePos() const { return _mousePos; } 71 79 virtual int getButtonState() const { return _buttonState; } 72 80 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 _keyMapper = new KeyMapper(); 262 _virtualKeyboard = new VirtualKeyboard(); 260 263 } 261 264 262 265 OSystem_SDL::~OSystem_SDL() { … … 271 274 delete _savefile; 272 275 delete _mixer; 273 276 delete _timer; 277 278 delete _keyMapper; 279 delete _virtualKeyboard; 274 280 } 275 281 276 282 uint32 OSystem_SDL::getMillis() { -
D:/programming/projects/gsoc/scummvm/backends/platform/sdl/events.cpp
444 444 } 445 445 return false; 446 446 } 447 KeyMapper *OSystem_SDL::getKeyMapper() { 448 return _keyMapper; 449 } 447 450 451 VirtualKeyboard *OSystem_SDL::getVirtualKeyboard() { 452 return _virtualKeyboard; 453 } 454 448 455 bool OSystem_SDL::remapKey(SDL_Event &ev, Common::Event &event) { 449 456 #ifdef LINUPY 450 457 // On Yopy map the End button to quit -
D:/programming/projects/gsoc/scummvm/backends/platform/sdl/sdl-common.h
131 131 // Returns true if an event was retrieved. 132 132 virtual bool pollEvent(Common::Event &event); // overloaded by CE backend 133 133 134 virtual KeyMapper *getKeyMapper(); 135 136 virtual VirtualKeyboard *getVirtualKeyboard(); 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 KeyMapper *_keyMapper; 421 VirtualKeyboard *_virtualKeyboard; 422 414 423 }; 415 424 416 425 #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 "common/hashmap.h" 32 33 typedef Common::HashMap<Common::KeyState, Common::UserAction, Common::KeyState_Hash> KeyActionMap; 34 35 /** 36 * Default key mapper implementation, base class for custom extensions. 37 */ 38 class KeyMapper { 39 40 public: 41 42 KeyMapper(); 43 ~KeyMapper(); 44 45 /** 46 * Adds key action mapping. 47 */ 48 virtual void addActionMapping(const Common::KeyState, const Common::UserAction); 49 50 /** 51 * Maps engine and game supported actions to their defaultKey's. 52 * This method is useful for registering a Common::ActionType to some key. 53 */ 54 virtual void addActionMappings(const Common::ActionList); 55 56 virtual const Common::KeyState *getMappingKey(const Common::UserAction); 57 58 /** 59 * Clears all currently registered action mappings. 60 */ 61 virtual void clearActionMappings(); 62 63 /** 64 * Tries to find a corresponding mapping for event.kbd. If successful, 65 * replaces the event.kbd with a defaultKey from mapped action. If the actionType of 66 * mapped action type is not Common::ACTION_INVALID, also substitutes the event.actionType. 67 */ 68 virtual void resolve(Common::Event &event); 69 70 private: 71 72 KeyActionMap _mappings; // available keys and action mappings 73 74 }; 75 76 #endif 77 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 VirtualKeyboard::~VirtualKeyboard() { 29 } 30 31 void VirtualKeyboard::resolve(Common::Event &event) { 32 } -
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 /** 31 * Default virtual keyboard implementation, base class for custom extensions. 32 */ 33 class VirtualKeyboard { 34 35 public: 36 37 VirtualKeyboard(); 38 ~VirtualKeyboard(); 39 40 /** 41 * For all mouse click events checks whether the click is 42 * in the screen range of virtual keyboard. This being true, 43 * figures out what virtual button was clicked and substitutes 44 * the mouse data in event with fake key data. 45 */ 46 virtual void resolve(Common::Event &event); 47 }; 48 49 #endif 50 No newline at end of file -
D:/programming/projects/gsoc/scummvm/backends/platform/common/module.mk
1 MODULE := backends/platform/common 2 3 MODULE_OBJS := \ 4 key-mapper.o \ 5 virtual-keyboard.o 6 7 MODULE_DIRS += \ 8 backends/platform/common/ 9 10 # We don't use the rules.mk here on purpose 11 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() { 26 } 27 28 KeyMapper::~KeyMapper() { 29 } 30 31 void KeyMapper::addActionMapping(const Common::KeyState key, const Common::UserAction action) { 32 const Common::KeyState *oldKey = getMappingKey(action); 33 if (oldKey) { 34 _mappings.erase(*oldKey); 35 } 36 _mappings[key] = action; 37 } 38 39 void KeyMapper::addActionMappings(const Common::ActionList actions) { 40 for (Common::ActionList::const_iterator mIt = actions.begin(); mIt != actions.end(); mIt++) { 41 // actions are mapped to default keys to substitute later the action associated with the event 42 addActionMapping(mIt->defaultKey, *mIt); 43 } 44 } 45 46 const Common::KeyState *KeyMapper::getMappingKey(const Common::UserAction action) { 47 const Common::KeyState *result = NULL; 48 for (KeyActionMap::const_iterator mIt = _mappings.begin(); mIt != _mappings.end(); ++mIt) { 49 if (mIt->_value == action) { 50 result = &(mIt->_key); 51 break; 52 } 53 } 54 return result; 55 } 56 57 void KeyMapper::clearActionMappings() { 58 _mappings.clear(); 59 } 60 61 void KeyMapper::resolve(Common::Event &event) { 62 if (_mappings.empty()) { 63 return; 64 } 65 66 if (_mappings.contains(event.kbd)) { 67 event.kbd = _mappings[event.kbd].defaultKey; 68 if (_mappings[event.kbd].actionType != Common::ACTION_INVALID) { 69 event.actionType = _mappings[event.kbd].actionType; 70 } 71 } 72 } 73 No newline at end of file -
D:/programming/projects/gsoc/scummvm/common/event-manager.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_EVENT_MANAGER_H 24 #define COMMON_EVENT_MANAGER_H 25 26 #include "common/events.h" 27 #include "backends/platform/common/key-mapper.h" 28 29 namespace Common { 30 31 /** 32 * The EventManager provides user input events to the client code. 33 * In addition, it keeps track of the state of various input devices, 34 * like keys, mouse position and buttons. 35 */ 36 class EventManager : NonCopyable { 37 public: 38 EventManager() {} 39 virtual ~EventManager() {} 40 41 enum { 42 LBUTTON = 1 << 0, 43 RBUTTON = 1 << 1 44 }; 45 46 /** 47 * Get the next event in the event queue. 48 * @param event point to an Event struct, which will be filled with the event data. 49 * @return true if an event was retrieved. 50 */ 51 virtual bool pollEvent(Common::Event &event) = 0; 52 53 54 /** Return the current key state */ 55 virtual Common::Point getMousePos() const = 0; 56 57 /** 58 * Return a bitmask with the button states: 59 * - bit 0: left button up=1, down=0 60 * - bit 1: right button up=1, down=0 61 */ 62 virtual int getButtonState() const = 0; 63 64 /** Get a bitmask with the current modifier state */ 65 virtual int getModifierState() const = 0; 66 67 /** 68 * Should the application terminate? Set to true if we 69 * received an EVENT_QUIT. 70 */ 71 virtual int shouldQuit() const = 0; 72 73 // Optional: check whether a given key is currently pressed ???? 74 //virtual bool isKeyPressed(int keycode) = 0; 75 76 // TODO: Keyboard repeat support? 77 78 // TODO: Consider removing OSystem::getScreenChangeID and 79 // replacing it by a generic getScreenChaneID method here 80 81 virtual KeyMapper *getKeyMapper() = 0; 82 }; 83 84 } // End of namespace Common 85 86 #endif 87 No newline at end of file -
D:/programming/projects/gsoc/scummvm/common/keyboard.h
259 259 keycode = KEYCODE_INVALID; 260 260 ascii = flags = 0; 261 261 } 262 263 bool operator <(const KeyState keyState) const { 264 bool result; 265 if (keycode != keyState.keycode) { 266 result = keycode < keyState.keycode; 267 } else { 268 result = flags < keyState.flags; 269 } 270 271 return result; 272 } 273 274 bool operator ==(const KeyState keyState) const { 275 return (keycode == keyState.keycode) && (flags == keyState.flags); 276 } 277 278 uint hash() const { 279 return 0; 280 } 281 262 282 }; 263 283 284 struct KeyState_Hash { 285 uint operator()(const KeyState& ks) const { return ks.hash(); } 286 }; 287 288 264 289 } // End of namespace Common 265 290 266 291 #endif -
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 #include "backends/platform/common/virtual-keyboard.h" 36 34 37 namespace Audio { 35 38 class Mixer; 36 39 } … … 724 727 */ 725 728 virtual bool pollEvent(Common::Event &event) = 0; 726 729 730 virtual KeyMapper *getKeyMapper() { return NULL; } 731 732 virtual VirtualKeyboard *getVirtualKeyboard() { return NULL; } 733 727 734 public: 735 728 736 /** Get the number of milliseconds since the program was started. */ 729 737 virtual uint32 getMillis() = 0; 730 738 … … 743 751 */ 744 752 virtual Common::EventManager *getEventManager(); 745 753 754 746 755 //@} 747 756 748 757 … … 894 903 * refer to the SaveFileManager documentation. 895 904 */ 896 905 virtual Common::SaveFileManager *getSavefileManager() = 0; 897 898 906 //@} 899 907 }; 900 908 -
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 "common/list.h" 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. */ … … 68 71 EVENT_PREDICTIVE_DIALOG = 12 69 72 }; 70 73 74 enum ActionType { 75 76 ACTION_INVALID = 0, 77 ACTION_QUIT = 1, 78 ACTION_SAVE = 2, 79 ACTION_LOAD = 3 80 81 }; 82 83 71 84 /** 72 85 * Data structure for an event. A pointer to an instance of Event 73 86 * can be passed to pollEvent. … … 97 110 * }; 98 111 */ 99 112 struct Event { 100 /** The type of the event . */113 /** The type of the event like key down/up. */ 101 114 EventType type; 115 116 /** The action which this event represents like quit, save, load. */ 117 ActionType actionType; 118 102 119 /** Flag to indicate if the event is real or synthetic. E.g. keyboard 103 120 * repeat events are synthetic. 104 121 */ … … 107 124 * Keyboard data; only valid for keyboard events (EVENT_KEYDOWN and 108 125 * EVENT_KEYUP). For all other event types, content is undefined. 109 126 */ 110 KeyState kbd;127 Common::KeyState kbd; 111 128 /** 112 129 * The mouse coordinates, in virtual screen coordinates. Only valid 113 130 * for mouse events. … … 115 132 * screen area as defined by the most recent call to initSize(). 116 133 */ 117 134 Common::Point mouse; 135 136 Event(Common::EventType et = Common::EVENT_INVALID, bool s = false, 137 Common::KeyState ks = Common::KeyState(), Common::Point p = Common::Point()) { 138 139 type = et; 140 synthetic = s; 141 kbd = ks; 142 mouse = p; 143 } 144 145 void reset() { 146 type = Common::EVENT_INVALID; 147 synthetic = false; 148 kbd = Common::KeyState(); 149 mouse = Common::Point(); 150 } 118 151 }; 119 152 153 enum Priority { 154 PRIORITY_HIGHEST, 155 PRIORITY_HIGH, 156 PRIORITY_NORMAL, 157 PRIORITY_LOW, 158 PRIORITY_LOWEST 159 }; 120 160 121 /**122 * The EventManager provides user input events to the client code.123 * In addition, it keeps track of the state of various input devices,124 * like keys, mouse position and buttons.125 */126 class EventManager : NonCopyable {127 public:128 EventManager() {}129 virtual ~EventManager() {}130 131 enum {132 LBUTTON = 1 << 0,133 RBUTTON = 1 << 1134 };135 161 162 struct UserAction { 163 136 164 /** 137 * Get the next event in the event queue. 138 * @param event point to an Event struct, which will be filled with the event data. 139 * @return true if an event was retrieved. 165 * Default key used in the egines an games for this action. 140 166 */ 141 virtual bool pollEvent(Common::Event &event) = 0;167 Common::KeyState defaultKey; 142 168 169 /** 170 * Event type like quit, save/load, etc. 171 */ 172 Common::ActionType actionType; 143 173 144 /** Return the current key state */145 virtual Common::Point getMousePos() const = 0;146 147 174 /** 148 * Return a bitmask with the button states: 149 * - bit 0: left button up=1, down=0 150 * - bit 1: right button up=1, down=0 175 * Human readable description for a GUI keymapping config dialog 151 176 */ 152 virtual int getButtonState() const = 0; 153 154 /** Get a bitmask with the current modifier state */ 155 virtual int getModifierState() const = 0; 177 String description; 156 178 157 179 /** 158 * Should the application terminate? Set to true if we159 * received an EVENT_QUIT.180 * Mapping priority. Actions with higher priority will be given preference for mapping 181 * in case of limited inputs. 160 182 */ 161 virtual int shouldQuit() const = 0; 162 163 // Optional: check whether a given key is currently pressed ???? 164 //virtual bool isKeyPressed(int keycode) = 0; 183 Common::Priority priority; 165 184 166 // TODO: Keyboard repeat support? 167 168 // TODO: Consider removing OSystem::getScreenChangeID and 169 // replacing it by a generic getScreenChangeID method here 185 UserAction(Common::KeyState ks = Common::KeyState(Common::KEYCODE_ESCAPE), 186 Common::ActionType at = Common::ACTION_INVALID, 187 String d = "Action name", Common::Priority p = Common::PRIORITY_NORMAL) { 188 189 defaultKey = ks; 190 actionType = at; 191 description = d; 192 priority = p; 193 } 194 195 UserAction(Common::KeyState ks, String d, Common::Priority p = Common::PRIORITY_NORMAL) { 196 defaultKey = ks; 197 actionType = Common::ACTION_INVALID; 198 description = d; 199 priority = p; 200 } 201 202 bool operator ==(const UserAction action) const { 203 return (defaultKey == action.defaultKey) && (actionType == action.actionType) && (description == action.description); 204 } 205 206 bool operator <(const UserAction action) const { 207 return priority < action.priority; 208 } 209 170 210 }; 171 211 212 typedef Common::List<Common::UserAction> ActionList; 213 172 214 } // End of namespace Common 173 215 174 216 #endif -
D:/programming/projects/gsoc/scummvm/common/list.h
33 33 * Simple double linked list, modeled after the list template of the standard 34 34 * C++ library. 35 35 */ 36 template <class T>36 template <class t_T> 37 37 class List { 38 38 protected: 39 39 #if defined (_WIN32_WCE) || defined (_MSC_VER) … … 45 45 NodeBase *_next; 46 46 }; 47 47 48 template <class T2>48 template <class t_T2> 49 49 struct Node : public NodeBase { 50 T2 _data;50 t_T2 _data; 51 51 52 Node(const T2 &x) : _data(x) {}52 Node(const t_T2 &x) : _data(x) {} 53 53 }; 54 54 55 template <class T2>55 template <class t_T2> 56 56 class Iterator { 57 friend class List< T>;57 friend class List<t_T>; 58 58 NodeBase *_node; 59 59 60 60 #if !defined (__WINSCW__) … … 67 67 Iterator() : _node(0) {} 68 68 69 69 // Prefix inc 70 Iterator< T2> &operator++() {70 Iterator<t_T2> &operator++() { 71 71 if (_node) 72 72 _node = _node->_next; 73 73 return *this; 74 74 } 75 75 // Postfix inc 76 Iterator< T2> operator++(int) {76 Iterator<t_T2> operator++(int) { 77 77 Iterator tmp(_node); 78 78 ++(*this); 79 79 return tmp; 80 80 } 81 81 // Prefix dec 82 Iterator< T2> &operator--() {82 Iterator<t_T2> &operator--() { 83 83 if (_node) 84 84 _node = _node->_prev; 85 85 return *this; 86 86 } 87 87 // Postfix dec 88 Iterator< T2> operator--(int) {88 Iterator<t_T2> operator--(int) { 89 89 Iterator tmp(_node); 90 90 --(*this); 91 91 return tmp; 92 92 } 93 T2& operator*() const {93 t_T2& operator*() const { 94 94 assert(_node); 95 95 #if (__GNUC__ == 2) && (__GNUC_MINOR__ >= 95) 96 return static_cast<List< T>::Node<T2> *>(_node)->_data;96 return static_cast<List<t_T>::Node<t_T2> *>(_node)->_data; 97 97 #else 98 return static_cast<Node< T2>*>(_node)->_data;98 return static_cast<Node<t_T2>*>(_node)->_data; 99 99 #endif 100 100 } 101 T2* operator->() const {101 t_T2* operator->() const { 102 102 return &(operator*()); 103 103 } 104 104 105 bool operator==(const Iterator< T2>& x) const {105 bool operator==(const Iterator<t_T2>& x) const { 106 106 return _node == x._node; 107 107 } 108 108 109 bool operator!=(const Iterator< T2>& x) const {109 bool operator!=(const Iterator<t_T2>& x) const { 110 110 return _node != x._node; 111 111 } 112 112 }; … … 114 114 NodeBase *_anchor; 115 115 116 116 public: 117 typedef Iterator< T> iterator;118 typedef Iterator<const T> const_iterator;117 typedef Iterator<t_T> iterator; 118 typedef Iterator<const t_T> const_iterator; 119 119 120 typedef T value_type;120 typedef t_T value_type; 121 121 122 122 public: 123 123 List() { … … 125 125 _anchor->_prev = _anchor; 126 126 _anchor->_next = _anchor; 127 127 } 128 List(const List< T>& list) {128 List(const List<t_T>& list) { 129 129 _anchor = new NodeBase; 130 130 _anchor->_prev = _anchor; 131 131 _anchor->_next = _anchor; … … 138 138 delete _anchor; 139 139 } 140 140 141 void push_front(const T& element) {141 void push_front(const t_T& element) { 142 142 insert(begin(), element); 143 143 } 144 144 145 void push_back(const T& element) {145 void push_back(const t_T& element) { 146 146 insert(end(), element); 147 147 } 148 148 149 void insert(iterator pos, const T& element) {150 NodeBase *newNode = new Node< T>(element);149 void insert(iterator pos, const t_T& element) { 150 NodeBase *newNode = new Node<t_T>(element); 151 151 152 152 newNode->_next = pos._node; 153 153 newNode->_prev = pos._node->_prev; … … 166 166 167 167 NodeBase *next = pos._node->_next; 168 168 NodeBase *prev = pos._node->_prev; 169 Node< T> *node = static_cast<Node<T> *>(pos._node);169 Node<t_T> *node = static_cast<Node<t_T> *>(pos._node); 170 170 prev->_next = next; 171 171 next->_prev = prev; 172 172 delete node; … … 178 178 179 179 NodeBase *next = pos._node->_next; 180 180 NodeBase *prev = pos._node->_prev; 181 Node< T> *node = static_cast<Node<T> *>(pos._node);181 Node<t_T> *node = static_cast<Node<t_T> *>(pos._node); 182 182 prev->_next = next; 183 183 next->_prev = prev; 184 184 delete node; … … 192 192 return last; 193 193 } 194 194 195 void remove(const T &val) {195 void remove(const t_T &val) { 196 196 iterator i = begin(); 197 197 while (i != end()) 198 198 if (val == i.operator*()) … … 202 202 } 203 203 204 204 205 List< T>& operator =(const List<T>& list) {205 List<t_T>& operator =(const List<t_T>& list) { 206 206 if (this != &list) { 207 207 iterator i; 208 208 const_iterator j; 209 209 210 210 for (i = begin(), j = list.begin(); (i != end()) && (j != list.end()) ; ++i, ++j) { 211 static_cast<Node< T> *>(i._node)->_data = static_cast<Node<T> *>(j._node)->_data;211 static_cast<Node<t_T> *>(i._node)->_data = static_cast<Node<t_T> *>(j._node)->_data; 212 212 } 213 213 214 214 if (i == end()) -
D:/programming/projects/gsoc/scummvm/engines/sword1/sword1.cpp
32 32 #include "common/fs.h" 33 33 #include "common/timer.h" 34 34 #include "common/events.h" 35 #include "common/event-manager.h" 35 36 #include "common/system.h" 36 37 37 38 #include "sword1/resman.h" -
D:/programming/projects/gsoc/scummvm/engines/sword1/credits.cpp
36 36 #include "common/file.h" 37 37 #include "common/util.h" 38 38 #include "common/events.h" 39 #include "common/event-manager.h" 39 40 #include "common/system.h" 40 41 41 42 -
D:/programming/projects/gsoc/scummvm/engines/sword1/animation.cpp
35 35 #include "common/endian.h" 36 36 #include "common/str.h" 37 37 #include "common/events.h" 38 #include "common/event-manager.h" 38 39 #include "common/system.h" 39 40 40 41 namespace Sword1 { -
D:/programming/projects/gsoc/scummvm/engines/sword1/control.cpp
28 28 #include "common/util.h" 29 29 #include "common/savefile.h" 30 30 #include "common/events.h" 31 #include "common/event-manager.h" 31 32 #include "common/system.h" 32 33 33 34 #include "gui/message.h" -
D:/programming/projects/gsoc/scummvm/engines/sword2/sword2.cpp
33 33 #include "common/file.h" 34 34 #include "common/fs.h" 35 35 #include "common/events.h" 36 #include "common/event-manager.h" 36 37 #include "common/system.h" 37 38 38 39 #include "sword2/sword2.h" -
D:/programming/projects/gsoc/scummvm/engines/sword2/mouse.cpp
28 28 #include "common/stdafx.h" 29 29 #include "common/system.h" 30 30 #include "common/events.h" 31 #include "common/event-manager.h" 31 32 32 33 #include "graphics/cursorman.h" 33 34 -
D:/programming/projects/gsoc/scummvm/engines/sword2/animation.cpp
29 29 #include "common/config-manager.h" 30 30 #include "common/file.h" 31 31 #include "common/events.h" 32 #include "common/event-manager.h" 32 33 #include "common/system.h" 33 34 34 35 #include "sword2/sword2.h" -
D:/programming/projects/gsoc/scummvm/engines/scumm/input.cpp
27 27 28 28 #include "common/config-manager.h" 29 29 #include "common/events.h" 30 #include "common/event-manager.h" 30 31 #include "common/system.h" 31 32 32 33 #include "gui/message.h" -
D:/programming/projects/gsoc/scummvm/engines/scumm/scumm.cpp
28 28 #include "common/config-manager.h" 29 29 #include "common/md5.h" 30 30 #include "common/events.h" 31 #include "common/event-manager.h" 31 32 #include "common/system.h" 32 33 33 34 #include "gui/message.h" -
D:/programming/projects/gsoc/scummvm/engines/touche/touche.cpp
26 26 #include "common/stdafx.h" 27 27 #include "common/config-manager.h" 28 28 #include "common/events.h" 29 #include "common/event-manager.h" 29 30 #include "common/system.h" 30 31 31 32 #include "graphics/cursorman.h" -
D:/programming/projects/gsoc/scummvm/engines/touche/ui.cpp
25 25 26 26 #include "common/stdafx.h" 27 27 #include "common/events.h" 28 #include "common/event-manager.h" 28 29 #include "common/system.h" 29 30 #include "common/savefile.h" 30 31 -
D:/programming/projects/gsoc/scummvm/engines/agos/cursor.cpp
26 26 #include "common/stdafx.h" 27 27 28 28 #include "common/events.h" 29 #include "common/event-manager.h" 29 30 #include "common/system.h" 30 31 31 32 #include "graphics/cursorman.h" -
D:/programming/projects/gsoc/scummvm/engines/agos/event.cpp
30 30 #include "agos/intern.h" 31 31 32 32 #include "common/events.h" 33 #include "common/event-manager.h" 33 34 #include "common/system.h" 34 35 35 36 #include "gui/about.h" -
D:/programming/projects/gsoc/scummvm/engines/agos/animation.cpp
27 27 28 28 #include "common/endian.h" 29 29 #include "common/events.h" 30 #include "common/event-manager.h" 30 31 #include "common/system.h" 31 32 32 33 #include "graphics/cursorman.h" -
D:/programming/projects/gsoc/scummvm/engines/cruise/cruise_main.cpp
26 26 #include "common/stdafx.h" 27 27 #include "common/endian.h" 28 28 #include "common/events.h" 29 #include "common/event-manager.h" 29 30 30 31 #include "cruise/cruise_main.h" 31 32 #include "cruise/cell.h" 32 33 34 #include "common/system.h" 35 33 36 namespace Cruise { 34 37 35 38 unsigned int timer = 0; -
D:/programming/projects/gsoc/scummvm/engines/drascula/drascula.cpp
27 27 28 28 #include "common/events.h" 29 29 #include "common/keyboard.h" 30 #include "common/event-manager.h" 30 31 #include "common/file.h" 31 32 #include "common/savefile.h" 32 33 #include "common/config-manager.h" -
D:/programming/projects/gsoc/scummvm/engines/agi/agi.cpp
26 26 #include "common/stdafx.h" 27 27 28 28 #include "common/events.h" 29 #include "common/event-manager.h" 29 30 #include "common/file.h" 30 31 #include "common/savefile.h" 31 32 #include "common/config-manager.h" -
D:/programming/projects/gsoc/scummvm/engines/kyra/kyra.cpp
28 28 #include "common/config-manager.h" 29 29 #include "common/file.h" 30 30 #include "common/events.h" 31 #include "common/event-manager.h" 31 32 #include "common/system.h" 32 33 #include "common/savefile.h" 33 34 -
D:/programming/projects/gsoc/scummvm/engines/kyra/gui.cpp
33 33 #include "common/config-manager.h" 34 34 #include "common/savefile.h" 35 35 #include "common/events.h" 36 #include "common/event-manager.h" 36 37 #include "common/system.h" 37 38 38 39 namespace Kyra { -
D:/programming/projects/gsoc/scummvm/engines/kyra/vqa.cpp
33 33 34 34 #include "common/stdafx.h" 35 35 #include "common/events.h" 36 #include "common/event-manager.h" 36 37 #include "common/system.h" 37 38 #include "sound/audiostream.h" 38 39 #include "sound/mixer.h" -
D:/programming/projects/gsoc/scummvm/engines/kyra/sequences_v1.cpp
34 34 #include "kyra/text.h" 35 35 36 36 #include "common/events.h" 37 #include "common/event-manager.h" 37 38 #include "common/system.h" 38 39 #include "common/savefile.h" 39 40 -
D:/programming/projects/gsoc/scummvm/engines/kyra/text.cpp
32 32 #include "kyra/sprites.h" 33 33 34 34 #include "common/events.h" 35 #include "common/event-manager.h" 35 36 #include "common/system.h" 36 37 #include "common/endian.h" 37 38 -
D:/programming/projects/gsoc/scummvm/engines/sky/sky.h
27 27 #define SKY_H 28 28 29 29 #include "common/stdafx.h" 30 #include "common/keyboard.h" 30 31 #include "common/events.h" 32 #include "common/system.h" 31 33 #include "engines/engine.h" 32 34 33 35 namespace Sky { -
D:/programming/projects/gsoc/scummvm/engines/sky/mouse.cpp
25 25 26 26 #include "common/stdafx.h" 27 27 #include "common/events.h" 28 #include "common/event-manager.h" 28 29 #include "common/system.h" 29 30 #include "graphics/cursorman.h" 30 31 #include "sky/disk.h" -
D:/programming/projects/gsoc/scummvm/engines/sky/intro.cpp
27 27 #include "common/endian.h" 28 28 #include "common/util.h" 29 29 #include "common/events.h" 30 #include "common/event-manager.h" 30 31 #include "common/system.h" 31 32 32 33 #include "sky/disk.h" -
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/events.h"34 #include "common/system.h"35 33 #include "common/timer.h" 36 34 35 #include "gui/key-mapper-dialog.h" 36 37 37 #include "sky/control.h" 38 38 #include "sky/debug.h" 39 39 #include "sky/disk.h" … … 183 183 184 184 SkyEngine::SkyEngine(OSystem *syst) 185 185 : Engine(syst), _fastMode(0), _debugger(0) { 186 187 Common::ActionList actions; 188 189 Common::KeyState key = Common::KeyState(Common::KEYCODE_F5); 190 Common::UserAction action = Common::UserAction(key, "Menu"); 191 actions.push_back(action); 192 193 194 key = Common::KeyState(Common::KEYCODE_ESCAPE); 195 action = Common::UserAction(key, "Esc"); 196 actions.push_back(action); 197 198 key = Common::KeyState(Common::KEYCODE_p); 199 action = Common::UserAction(key, "Pause"); 200 actions.push_back(action); 201 202 _eventMan->getKeyMapper()->addActionMappings(actions); 203 GUI::KeyMapperDialog::s_showKeyMapperDialog("Key mapping", syst->getEventManager(), actions); 186 204 } 187 205 188 206 SkyEngine::~SkyEngine() { -
D:/programming/projects/gsoc/scummvm/engines/sky/screen.cpp
26 26 #include "common/stdafx.h" 27 27 #include "common/endian.h" 28 28 #include "common/events.h" 29 #include "common/event-manager.h" 29 30 #include "common/system.h" 30 31 31 32 #include "sky/disk.h" -
D:/programming/projects/gsoc/scummvm/engines/sky/control.cpp
28 28 #include "common/config-manager.h" 29 29 #include "common/file.h" 30 30 #include "common/events.h" 31 #include "common/event-manager.h" 31 32 #include "common/system.h" 32 33 #include "common/savefile.h" 33 34 #include "common/util.h" -
D:/programming/projects/gsoc/scummvm/engines/lure/events.cpp
25 25 26 26 #include "common/stdafx.h" 27 27 #include "common/events.h" 28 #include "common/event-manager.h" 28 29 29 30 #include "graphics/cursorman.h" 30 31 -
D:/programming/projects/gsoc/scummvm/engines/gob/mult_v2.cpp
1173 1173 1174 1174 if (_multData->imdIndices[i] != -1) { 1175 1175 int fileN; 1176 char *imdFile ;1176 char *imdFile = NULL; 1177 1177 int dir; 1178 1178 int startFrame; 1179 1179 -
D:/programming/projects/gsoc/scummvm/engines/gob/util.cpp
25 25 26 26 #include "common/stdafx.h" 27 27 #include "common/events.h" 28 #include "common/event-manager.h" 28 29 29 30 #include "gob/gob.h" 30 31 #include "gob/util.h" -
D:/programming/projects/gsoc/scummvm/engines/parallaction/dialogue.cpp
26 26 #include "common/stdafx.h" 27 27 28 28 #include "common/events.h" 29 #include "common/event-manager.h" 29 30 #include "parallaction/parallaction.h" 30 31 32 #include "common/system.h" 31 33 32 34 35 33 36 namespace Parallaction { 34 37 35 38 #define SKIPPED_ANSWER 1000 -
D:/programming/projects/gsoc/scummvm/engines/parallaction/parallaction.cpp
27 27 28 28 #include "common/config-manager.h" 29 29 #include "common/events.h" 30 #include "common/event-manager.h" 30 31 #include "common/file.h" 31 32 #include "common/util.h" 32 33 34 #include "common/system.h" 35 33 36 #include "sound/mididrv.h" 34 37 #include "sound/mixer.h" 35 38 -
D:/programming/projects/gsoc/scummvm/engines/saga/input.cpp
34 34 #include "saga/isomap.h" 35 35 36 36 #include "common/events.h" 37 #include "common/event-manager.h" 37 38 #include "common/system.h" 38 39 39 40 namespace Saga { -
D:/programming/projects/gsoc/scummvm/engines/queen/input.h
29 29 #include "common/util.h" 30 30 #include "common/rect.h" 31 31 #include "common/events.h" 32 #include "common/event-manager.h" 32 33 #include "queen/defs.h" 33 34 34 35 class OSystem; -
D:/programming/projects/gsoc/scummvm/engines/queen/journal.cpp
25 25 26 26 #include "common/stdafx.h" 27 27 #include "common/events.h" 28 #include "common/event-manager.h" 28 29 #include "common/system.h" 29 30 #include "queen/journal.h" 30 31 -
D:/programming/projects/gsoc/scummvm/engines/cine/main_loop.cpp
26 26 #include "common/stdafx.h" 27 27 #include "common/scummsys.h" 28 28 #include "common/events.h" 29 #include "common/event-manager.h" 29 30 #include "common/system.h" 30 31 31 32 #include "cine/main_loop.h" -
D:/programming/projects/gsoc/scummvm/gui/newgui.cpp
24 24 25 25 #include "common/stdafx.h" 26 26 #include "common/events.h" 27 #include "common/event-manager.h" 27 28 #include "common/system.h" 28 29 #include "common/util.h" 29 30 #include "graphics/cursorman.h" -
D:/programming/projects/gsoc/scummvm/gui/key-mapper-dialog.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 * $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/trunk/gui/KeyMapperDialog.h $ 22 * $Id: KeyMapperDialog.h 27786 2007-06-30 12:26:59Z fingolfin $ 23 * 24 */ 25 26 #ifndef KeyMapperDialog_H 27 #define KeyMapperDialog_H 28 29 #include "gui/newgui.h" 30 #include "gui/dialog.h" 31 #include "gui/ListWidget.h" 32 #include "common/str.h" 33 #include "common/events.h" 34 #include "common/event-manager.h" 35 36 namespace GUI { 37 38 class KeyMapperDialog : public GUI::Dialog { 39 public: 40 41 virtual void handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data); 42 virtual void handleKeyUp(Common::KeyState state); 43 virtual void handleKeyDown(Common::KeyState state); 44 45 static void s_showKeyMapperDialog(const Common::String &title, Common::EventManager *, Common::ActionList); 46 47 protected: 48 49 // key mapper dialog is instantiated only in s_showKeyMapperDialog 50 // which makes sure that key mapping is enabled 51 KeyMapperDialog(const Common::String &title, Common::EventManager *, Common::ActionList); 52 ~KeyMapperDialog(); 53 54 // GUI elements 55 GUI::ListWidget *_actionsList; 56 GUI::StaticTextWidget *_actionTitle; 57 GUI::StaticTextWidget *_keyMapping; 58 59 KeyMapper *_keyMapper; 60 bool _isMappingActive; 61 Common::ActionList _actions; 62 }; 63 64 } // namespace GUI 65 66 #endif -
D:/programming/projects/gsoc/scummvm/gui/launcher.cpp
31 31 32 32 #include "common/config-manager.h" 33 33 #include "common/events.h" 34 #include "common/event-manager.h" 34 35 #include "common/fs.h" 35 36 #include "common/util.h" 36 37 #include "common/system.h" -
D:/programming/projects/gsoc/scummvm/gui/key-mapper-dialog.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 * $URL: https://scummvm.svn.sourceforge.net/svnroot/scummvm/scummvm/trunk/gui/KeyMapperDialog.cpp $ 22 * $Id: KeyMapperDialog.cpp 27825 2007-07-01 14:19:12Z robinwatts $ 23 * 24 */ 25 26 #include "common/stdafx.h" 27 #include "gui/key-mapper-dialog.h" 28 #include <SDL_keyboard.h> 29 30 #ifdef _WIN32_WCE 31 #include "CEDevice.h" 32 #endif 33 34 namespace GUI { 35 36 enum { 37 kMapCmd = 'map ', 38 kOKCmd = 'ok ' 39 }; 40 41 KeyMapperDialog::KeyMapperDialog(const Common::String &title, Common::EventManager *eventManager, 42 Common::ActionList actions) : 43 GUI::Dialog("keysdialog"), 44 _keyMapper(eventManager->getKeyMapper()), 45 _actions(actions), 46 _isMappingActive(false) { 47 48 new ButtonWidget(this, "keysdialog_map", "Map", kMapCmd, 0); 49 new ButtonWidget(this, "keysdialog_ok", "OK", kOKCmd, 0); 50 new ButtonWidget(this, "keysdialog_cancel", "Cancel", kCloseCmd, 0); 51 52 _actionsList = new ListWidget(this, "keysdialog_list"); 53 _actionsList->setNumberingMode(kListNumberingZero); 54 55 _actionTitle = new StaticTextWidget(this, "keysdialog_action", title); 56 _keyMapping = new StaticTextWidget(this, "keysdialog_mapping", "Select an action and click 'Map'"); 57 58 _actionTitle->setFlags(WIDGET_CLEARBG); 59 _keyMapping->setFlags(WIDGET_CLEARBG); 60 61 // Get actions names 62 Common::StringList l; 63 64 for (Common::ActionList::iterator i = _actions.begin(); i != _actions.end(); i++) { 65 l.push_back(i->description); 66 } 67 68 _actionsList->setList(l); 69 } 70 71 KeyMapperDialog::~KeyMapperDialog() { 72 } 73 74 void KeyMapperDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) { 75 switch (cmd) { 76 77 case kListSelectionChangedCmd: 78 if (_actionsList->getSelected() >= 0) { 79 char selection[100]; 80 81 Common::ActionList::iterator it = _actions.begin(); 82 for (int i = 0, selected = _actionsList->getSelected(); i < selected; i++) { 83 it++; 84 } 85 const Common::KeyState *keyState = _keyMapper->getMappingKey(*it); 86 uint16 key; 87 if (keyState) { 88 key = keyState->keycode; 89 } else { 90 key = it->defaultKey.keycode; 91 } 92 93 94 #ifdef __SYMBIAN32__ 95 // ScummVM mappings for F1-F9 are different from SDL so remap back to sdl 96 if (key >= Common::ASCII_F1 && key <= Common::ASCII_F9) 97 key = key - Common::ASCII_F1 + SDLK_F1; 98 #endif 99 if (key != 0) 100 sprintf(selection, "Associated key : %s", SDL_GetKeyName((SDLKey)key)); 101 else 102 sprintf(selection, "Associated key : none"); 103 104 _keyMapping->setLabel(selection); 105 _keyMapping->draw(); 106 } 107 break; 108 case kMapCmd: 109 if (_actionsList->getSelected() < 0) { 110 _actionTitle->setLabel("Please select an action"); 111 } else { 112 char selection[100]; 113 114 Common::ActionList::iterator it = _actions.begin(); 115 for (int i = 0, selected = _actionsList->getSelected(); i < selected; i++) { 116 it++; 117 } 118 const Common::KeyState *keyState = _keyMapper->getMappingKey(*it); 119 uint16 key; 120 if (keyState) { 121 key = keyState->keycode; 122 } else { 123 key = it->defaultKey.keycode; 124 } 125 126 #ifdef __SYMBIAN32__ 127 // ScummVM mappings for F1-F9 are different from SDL so remap back to sdl 128 if (key >= Common::ASCII_F1 && key <= Common::ASCII_F9) 129 key = key - Common::ASCII_F1 + SDLK_F1; 130 #endif 131 if (key != 0) 132 sprintf(selection, "Associated key : %s", SDL_GetKeyName((SDLKey)key)); 133 else 134 sprintf(selection, "Associated key : none"); 135 136 _actionTitle->setLabel("Press the key to associate"); 137 _keyMapping->setLabel(selection); 138 _keyMapping->draw(); 139 _isMappingActive = true; 140 _actionsList->setEnabled(false); 141 } 142 _actionTitle->draw(); 143 break; 144 case kOKCmd: 145 //Actions::Instance()->saveMapping(); 146 close(); 147 break; 148 case kCloseCmd: 149 //Actions::Instance()->loadMapping(); 150 close(); 151 break; 152 } 153 } 154 155 void KeyMapperDialog::handleKeyDown(Common::KeyState state){ 156 if (_isMappingActive) { 157 Dialog::handleKeyDown(state); 158 } 159 } 160 161 void KeyMapperDialog::handleKeyUp(Common::KeyState state) { 162 #ifdef __SYMBIAN32__ 163 if (_isMappingActive) { 164 #else 165 if (_isMappingActive) {//state.flags == 0xff && Actions::Instance()->mappingActive()) { // GAPI key was selected 166 #endif 167 char selection[100]; 168 169 // map action 170 171 if (state.keycode != 0) { 172 Common::ActionList::iterator it = _actions.begin(); 173 for (int i = 0, selected = _actionsList->getSelected(); i < selected; i++) { 174 it++; 175 } 176 _keyMapper->addActionMapping(state, *it); 177 sprintf(selection, "Associated key : %s", SDL_GetKeyName((SDLKey) state.keycode)); 178 } else 179 sprintf(selection, "Associated key : none"); 180 181 _actionTitle->setLabel("Choose an action to map"); 182 _keyMapping->setLabel(selection); 183 _keyMapping->draw(); 184 _actionTitle->draw(); 185 _actionsList->setEnabled(true); 186 _isMappingActive = false; 187 } else 188 Dialog::handleKeyUp(state); 189 } 190 191 void KeyMapperDialog::s_showKeyMapperDialog(const Common::String &title, Common::EventManager *em, Common::ActionList al) { 192 if (em->getKeyMapper()) { 193 GUI::KeyMapperDialog *dialog = new GUI::KeyMapperDialog(title, em, al); 194 dialog->runModal(); 195 delete dialog; 196 } 197 } 198 199 } // namespace GUI -
D:/programming/projects/gsoc/scummvm/gui/about.cpp
27 27 #include "base/plugins.h" 28 28 #include "base/version.h" 29 29 #include "common/events.h" 30 #include "common/event-manager.h" 30 31 #include "common/system.h" 31 32 #include "common/util.h" 32 33 #include "gui/about.h"