Ticket #8711: backends-lib.v4.1.patch

File backends-lib.v4.1.patch, 58.5 KB (added by (none), 13 years ago)

key mapper dialog added

  • D:/programming/projects/gsoc/scummvm/backends/events/default/default-events.cpp

     
    3535
    3636DefaultEventManager::DefaultEventManager(OSystem *boss) :
    3737        _boss(boss),
     38        _keyMapper(boss->getKeyMapper()),
     39        _virtualKeyboard(boss->getVirtualKeyboard()),
    3840        _buttonState(0),
    3941        _modifierState(0),
    4042        _shouldQuit(false) {
     
    5254        result = _boss->pollEvent(event);
    5355       
    5456        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
    5568                event.synthetic = false;
    5669                switch (event.type) {
    5770                case Common::EVENT_KEYDOWN:
     
    128141        return result;
    129142}
    130143
     144KeyMapper *DefaultEventManager::getKeyMapper() {
     145        return _keyMapper;
     146}
     147
    131148#endif // !defined(DISABLE_DEFAULT_EVENTMANAGER)
  • D:/programming/projects/gsoc/scummvm/backends/events/default/default-events.h

     
    2828
    2929#include "common/stdafx.h"
    3030#include "common/events.h"
     31#include "common/event-manager.h"
    3132
     33#include "backends/platform/common/key-mapper.h"
     34#include "backends/platform/common/virtual-keyboard.h"
     35
    3236/*
    3337At some point we will remove pollEvent from OSystem and change
    3438DefaultEventManager to use a "boss" derived from this class:
     
    4347
    4448class DefaultEventManager : public Common::EventManager {
    4549        OSystem *_boss;
     50        KeyMapper *_keyMapper;
     51        VirtualKeyboard *_virtualKeyboard;
    4652
    4753        Common::Point _mousePos;
    4854        int _buttonState;
     
    6773
    6874        virtual bool pollEvent(Common::Event &event);
    6975
     76        virtual KeyMapper *getKeyMapper();
     77
    7078        virtual Common::Point getMousePos() const { return _mousePos; }
    7179        virtual int getButtonState() const { return _buttonState; }
    7280        virtual int getModifierState() const { return _modifierState; }
  • D:/programming/projects/gsoc/scummvm/backends/platform/sdl/sdl.cpp

     
    257257        memset(&_mouseCurState, 0, sizeof(_mouseCurState));
    258258
    259259        _inited = false;
     260
     261        _keyMapper = new KeyMapper();
     262        _virtualKeyboard = new VirtualKeyboard();
    260263}
    261264
    262265OSystem_SDL::~OSystem_SDL() {
     
    271274        delete _savefile;
    272275        delete _mixer;
    273276        delete _timer;
     277
     278        delete _keyMapper;
     279        delete _virtualKeyboard;
    274280}
    275281
    276282uint32 OSystem_SDL::getMillis() {
  • D:/programming/projects/gsoc/scummvm/backends/platform/sdl/events.cpp

     
    444444        }
    445445        return false;
    446446}
     447KeyMapper *OSystem_SDL::getKeyMapper() {
     448        return _keyMapper;
     449}
    447450
     451VirtualKeyboard *OSystem_SDL::getVirtualKeyboard() {
     452        return _virtualKeyboard;
     453}
     454
    448455bool OSystem_SDL::remapKey(SDL_Event &ev, Common::Event &event) {
    449456#ifdef LINUPY
    450457        // On Yopy map the End button to quit
  • D:/programming/projects/gsoc/scummvm/backends/platform/sdl/sdl-common.h

     
    131131        // Returns true if an event was retrieved.
    132132        virtual bool pollEvent(Common::Event &event); // overloaded by CE backend
    133133
     134        virtual KeyMapper *getKeyMapper();
     135
     136        virtual VirtualKeyboard *getVirtualKeyboard();
     137
    134138        // Set function that generates samples
    135139        typedef void (*SoundProc)(void *param, byte *buf, int len);
    136140        virtual bool setSoundCallback(SoundProc proc, void *param); // overloaded by CE backend
     
    411415        virtual bool remapKey(SDL_Event &ev, Common::Event &event);
    412416
    413417        void handleScalerHotkeys(const SDL_KeyboardEvent &key);
     418
     419private:
     420        KeyMapper *_keyMapper;
     421        VirtualKeyboard *_virtualKeyboard;
     422
    414423};
    415424
    416425#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
     33typedef Common::HashMap<Common::KeyState, Common::UserAction, Common::KeyState_Hash> KeyActionMap;
     34
     35/**
     36 * Default key mapper implementation, base class for custom extensions.
     37 */
     38class KeyMapper {
     39
     40public:
     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
     70private:
     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
     25VirtualKeyboard::VirtualKeyboard() {
     26}
     27
     28VirtualKeyboard::~VirtualKeyboard() {
     29}
     30
     31void 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 */
     33class VirtualKeyboard {
     34
     35public:
     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

     
     1MODULE := backends/platform/common
     2
     3MODULE_OBJS := \
     4        key-mapper.o \
     5        virtual-keyboard.o
     6
     7MODULE_DIRS += \
     8        backends/platform/common/
     9
     10# We don't use the rules.mk here on purpose
     11OBJS := $(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
     25KeyMapper::KeyMapper() {
     26}
     27
     28KeyMapper::~KeyMapper() {
     29}
     30
     31void 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
     39void 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
     46const 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
     57void KeyMapper::clearActionMappings() {
     58        _mappings.clear();
     59}
     60
     61void 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
     29namespace 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 */
     36class EventManager : NonCopyable {
     37public:
     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

     
    259259                keycode = KEYCODE_INVALID;
    260260                ascii = flags = 0;
    261261        }
     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
    262282};
    263283
     284struct KeyState_Hash {
     285        uint operator()(const KeyState& ks) const { return ks.hash(); }
     286};
     287
     288
    264289} // End of namespace Common
    265290
    266291#endif
  • D:/programming/projects/gsoc/scummvm/common/system.h

     
    3131#include "common/noncopyable.h"
    3232#include "common/rect.h"
    3333
     34#include "backends/platform/common/key-mapper.h"
     35#include "backends/platform/common/virtual-keyboard.h"
     36
    3437namespace Audio {
    3538        class Mixer;
    3639}
     
    724727         */
    725728        virtual bool pollEvent(Common::Event &event) = 0;
    726729
     730        virtual KeyMapper *getKeyMapper() { return NULL; }
     731
     732        virtual VirtualKeyboard *getVirtualKeyboard() { return NULL; }
     733
    727734public:
     735
    728736        /** Get the number of milliseconds since the program was started. */
    729737        virtual uint32 getMillis() = 0;
    730738
     
    743751         */
    744752        virtual Common::EventManager *getEventManager();
    745753
     754
    746755        //@}
    747756
    748757
     
    894903         * refer to the SaveFileManager documentation.
    895904         */
    896905        virtual Common::SaveFileManager *getSavefileManager() = 0;
    897 
    898906        //@}
    899907};
    900908
  • D:/programming/projects/gsoc/scummvm/common/events.h

     
    2828
    2929#include "common/keyboard.h"
    3030#include "common/rect.h"
    31 #include "common/system.h"
    3231#include "common/noncopyable.h"
    3332
     33#include "common/list.h"
     34
    3435namespace Common {
    3536
    3637/**
     
    4344 *       indicates which button was pressed.
    4445 */
    4546enum EventType {
     47
     48        EVENT_INVALID = 0,
    4649        /** A key was pressed, details in Event::kbd. */
    4750        EVENT_KEYDOWN = 1,
    4851        /** A key was released, details in Event::kbd. */
     
    6871        EVENT_PREDICTIVE_DIALOG = 12
    6972};
    7073
     74enum ActionType {
     75
     76        ACTION_INVALID = 0,
     77        ACTION_QUIT = 1,
     78        ACTION_SAVE = 2,
     79        ACTION_LOAD = 3
     80
     81};
     82
     83
    7184/**
    7285 * Data structure for an event. A pointer to an instance of Event
    7386 * can be passed to pollEvent.
     
    97110 *       };
    98111 */
    99112struct Event {
    100         /** The type of the event. */
     113        /** The type of the event like key down/up. */
    101114        EventType type;
     115
     116        /** The action which this event represents like quit, save, load. */
     117        ActionType actionType;
     118
    102119        /** Flag to indicate if the event is real or synthetic. E.g. keyboard
    103120          * repeat events are synthetic.
    104121          */
     
    107124          * Keyboard data; only valid for keyboard events (EVENT_KEYDOWN and
    108125          * EVENT_KEYUP). For all other event types, content is undefined.
    109126          */
    110         KeyState kbd;
     127        Common::KeyState kbd;
    111128        /**
    112129         * The mouse coordinates, in virtual screen coordinates. Only valid
    113130         * for mouse events.
     
    115132         * screen area as defined by the most recent call to initSize().
    116133         */
    117134        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        }
    118151};
    119152
     153enum Priority {
     154        PRIORITY_HIGHEST,
     155        PRIORITY_HIGH,
     156        PRIORITY_NORMAL,
     157        PRIORITY_LOW,
     158        PRIORITY_LOWEST
     159};
    120160
    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 << 1
    134         };
    135161
     162struct UserAction {
     163
    136164        /**
    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.
    140166         */
    141         virtual bool pollEvent(Common::Event &event) = 0;
     167        Common::KeyState defaultKey;
    142168
     169        /**
     170         * Event type like quit, save/load, etc.
     171         */
     172        Common::ActionType actionType;
    143173
    144         /** Return the current key state */
    145         virtual Common::Point getMousePos() const = 0;
    146        
    147174        /**
    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
    151176         */
    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;
    156178
    157179        /**
    158          * Should the application terminate? Set to true if we
    159          * received an EVENT_QUIT.
     180         * Mapping priority. Actions with higher priority will be given preference for mapping
     181         * in case of limited inputs.
    160182         */
    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;
    165184
    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
    170210};
    171211
     212typedef Common::List<Common::UserAction> ActionList;
     213
    172214} // End of namespace Common
    173215
    174216#endif
  • D:/programming/projects/gsoc/scummvm/common/list.h

     
    3333 * Simple double linked list, modeled after the list template of the standard
    3434 * C++ library.
    3535 */
    36 template <class T>
     36template <class t_T>
    3737class List {
    3838protected:
    3939#if defined (_WIN32_WCE) || defined (_MSC_VER)
     
    4545                NodeBase *_next;
    4646        };
    4747       
    48         template <class T2>
     48        template <class t_T2>
    4949        struct Node : public NodeBase {
    50                 T2 _data;
     50                t_T2 _data;
    5151               
    52                 Node(const T2 &x) : _data(x) {}
     52                Node(const t_T2 &x) : _data(x) {}
    5353        };
    5454
    55         template <class T2>
     55        template <class t_T2>
    5656        class Iterator {
    57                 friend class List<T>;
     57                friend class List<t_T>;
    5858                NodeBase *_node;
    5959
    6060#if !defined (__WINSCW__)
     
    6767                Iterator() : _node(0) {}
    6868
    6969                // Prefix inc
    70                 Iterator<T2> &operator++() {
     70                Iterator<t_T2> &operator++() {
    7171                        if (_node)
    7272                                _node = _node->_next;
    7373                        return *this;
    7474                }
    7575                // Postfix inc
    76                 Iterator<T2> operator++(int) {
     76                Iterator<t_T2> operator++(int) {
    7777                        Iterator tmp(_node);
    7878                        ++(*this);
    7979                        return tmp;
    8080                }
    8181                // Prefix dec
    82                 Iterator<T2> &operator--() {
     82                Iterator<t_T2> &operator--() {
    8383                        if (_node)
    8484                                _node = _node->_prev;
    8585                        return *this;
    8686                }
    8787                // Postfix dec
    88                 Iterator<T2> operator--(int) {
     88                Iterator<t_T2> operator--(int) {
    8989                        Iterator tmp(_node);
    9090                        --(*this);
    9191                        return tmp;
    9292                }
    93                 T2& operator*() const {
     93                t_T2& operator*() const {
    9494                        assert(_node);
    9595#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;
    9797#else
    98                         return static_cast<Node<T2>*>(_node)->_data;
     98                        return static_cast<Node<t_T2>*>(_node)->_data;
    9999#endif
    100100                }
    101                 T2* operator->() const {
     101                t_T2* operator->() const {
    102102                        return &(operator*());
    103103                }
    104104               
    105                 bool operator==(const Iterator<T2>& x) const {
     105                bool operator==(const Iterator<t_T2>& x) const {
    106106                        return _node == x._node;
    107107                }
    108108               
    109                 bool operator!=(const Iterator<T2>& x) const {
     109                bool operator!=(const Iterator<t_T2>& x) const {
    110110                        return _node != x._node;
    111111                }
    112112        };
     
    114114        NodeBase *_anchor;
    115115
    116116public:
    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;
    119119
    120         typedef T value_type;
     120        typedef t_T value_type;
    121121
    122122public:
    123123        List() {
     
    125125                _anchor->_prev = _anchor;
    126126                _anchor->_next = _anchor;
    127127        }
    128         List(const List<T>& list) {
     128        List(const List<t_T>& list) {
    129129                _anchor = new NodeBase;
    130130                _anchor->_prev = _anchor;
    131131                _anchor->_next = _anchor;
     
    138138                delete _anchor;
    139139        }
    140140
    141         void push_front(const T& element) {
     141        void push_front(const t_T& element) {
    142142                insert(begin(), element);
    143143        }
    144144
    145         void push_back(const T& element) {
     145        void push_back(const t_T& element) {
    146146                insert(end(), element);
    147147        }
    148148
    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);
    151151               
    152152                newNode->_next = pos._node;
    153153                newNode->_prev = pos._node->_prev;
     
    166166
    167167                NodeBase *next = pos._node->_next;
    168168                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);
    170170                prev->_next = next;
    171171                next->_prev = prev;
    172172                delete node;
     
    178178
    179179                NodeBase *next = pos._node->_next;
    180180                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);
    182182                prev->_next = next;
    183183                next->_prev = prev;
    184184                delete node;
     
    192192                return last;
    193193        }
    194194
    195         void remove(const T &val) {
     195        void remove(const t_T &val) {
    196196                iterator i = begin();
    197197                while (i != end())
    198198                        if (val == i.operator*())
     
    202202        }
    203203
    204204
    205         List<T>& operator  =(const List<T>& list) {
     205        List<t_T>& operator  =(const List<t_T>& list) {
    206206                if (this != &list) {
    207207                        iterator i;
    208208                        const_iterator j;
    209209
    210210                        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;
    212212                        }
    213213
    214214                        if (i == end())
  • D:/programming/projects/gsoc/scummvm/engines/sword1/sword1.cpp

     
    3232#include "common/fs.h"
    3333#include "common/timer.h"
    3434#include "common/events.h"
     35#include "common/event-manager.h"
    3536#include "common/system.h"
    3637
    3738#include "sword1/resman.h"
  • D:/programming/projects/gsoc/scummvm/engines/sword1/credits.cpp

     
    3636#include "common/file.h"
    3737#include "common/util.h"
    3838#include "common/events.h"
     39#include "common/event-manager.h"
    3940#include "common/system.h"
    4041
    4142
  • D:/programming/projects/gsoc/scummvm/engines/sword1/animation.cpp

     
    3535#include "common/endian.h"
    3636#include "common/str.h"
    3737#include "common/events.h"
     38#include "common/event-manager.h"
    3839#include "common/system.h"
    3940
    4041namespace Sword1 {
  • D:/programming/projects/gsoc/scummvm/engines/sword1/control.cpp

     
    2828#include "common/util.h"
    2929#include "common/savefile.h"
    3030#include "common/events.h"
     31#include "common/event-manager.h"
    3132#include "common/system.h"
    3233
    3334#include "gui/message.h"
  • D:/programming/projects/gsoc/scummvm/engines/sword2/sword2.cpp

     
    3333#include "common/file.h"
    3434#include "common/fs.h"
    3535#include "common/events.h"
     36#include "common/event-manager.h"
    3637#include "common/system.h"
    3738
    3839#include "sword2/sword2.h"
  • D:/programming/projects/gsoc/scummvm/engines/sword2/mouse.cpp

     
    2828#include "common/stdafx.h"
    2929#include "common/system.h"
    3030#include "common/events.h"
     31#include "common/event-manager.h"
    3132
    3233#include "graphics/cursorman.h"
    3334
  • D:/programming/projects/gsoc/scummvm/engines/sword2/animation.cpp

     
    2929#include "common/config-manager.h"
    3030#include "common/file.h"
    3131#include "common/events.h"
     32#include "common/event-manager.h"
    3233#include "common/system.h"
    3334
    3435#include "sword2/sword2.h"
  • D:/programming/projects/gsoc/scummvm/engines/scumm/input.cpp

     
    2727
    2828#include "common/config-manager.h"
    2929#include "common/events.h"
     30#include "common/event-manager.h"
    3031#include "common/system.h"
    3132
    3233#include "gui/message.h"
  • D:/programming/projects/gsoc/scummvm/engines/scumm/scumm.cpp

     
    2828#include "common/config-manager.h"
    2929#include "common/md5.h"
    3030#include "common/events.h"
     31#include "common/event-manager.h"
    3132#include "common/system.h"
    3233
    3334#include "gui/message.h"
  • D:/programming/projects/gsoc/scummvm/engines/touche/touche.cpp

     
    2626#include "common/stdafx.h"
    2727#include "common/config-manager.h"
    2828#include "common/events.h"
     29#include "common/event-manager.h"
    2930#include "common/system.h"
    3031
    3132#include "graphics/cursorman.h"
  • D:/programming/projects/gsoc/scummvm/engines/touche/ui.cpp

     
    2525
    2626#include "common/stdafx.h"
    2727#include "common/events.h"
     28#include "common/event-manager.h"
    2829#include "common/system.h"
    2930#include "common/savefile.h"
    3031
  • D:/programming/projects/gsoc/scummvm/engines/agos/cursor.cpp

     
    2626#include "common/stdafx.h"
    2727
    2828#include "common/events.h"
     29#include "common/event-manager.h"
    2930#include "common/system.h"
    3031
    3132#include "graphics/cursorman.h"
  • D:/programming/projects/gsoc/scummvm/engines/agos/event.cpp

     
    3030#include "agos/intern.h"
    3131
    3232#include "common/events.h"
     33#include "common/event-manager.h"
    3334#include "common/system.h"
    3435
    3536#include "gui/about.h"
  • D:/programming/projects/gsoc/scummvm/engines/agos/animation.cpp

     
    2727
    2828#include "common/endian.h"
    2929#include "common/events.h"
     30#include "common/event-manager.h"
    3031#include "common/system.h"
    3132
    3233#include "graphics/cursorman.h"
  • D:/programming/projects/gsoc/scummvm/engines/cruise/cruise_main.cpp

     
    2626#include "common/stdafx.h"
    2727#include "common/endian.h"
    2828#include "common/events.h"
     29#include "common/event-manager.h"
    2930
    3031#include "cruise/cruise_main.h"
    3132#include "cruise/cell.h"
    3233
     34#include "common/system.h"
     35
    3336namespace Cruise {
    3437
    3538unsigned int timer = 0;
  • D:/programming/projects/gsoc/scummvm/engines/drascula/drascula.cpp

     
    2727
    2828#include "common/events.h"
    2929#include "common/keyboard.h"
     30#include "common/event-manager.h"
    3031#include "common/file.h"
    3132#include "common/savefile.h"
    3233#include "common/config-manager.h"
  • D:/programming/projects/gsoc/scummvm/engines/agi/agi.cpp

     
    2626#include "common/stdafx.h"
    2727
    2828#include "common/events.h"
     29#include "common/event-manager.h"
    2930#include "common/file.h"
    3031#include "common/savefile.h"
    3132#include "common/config-manager.h"
  • D:/programming/projects/gsoc/scummvm/engines/kyra/kyra.cpp

     
    2828#include "common/config-manager.h"
    2929#include "common/file.h"
    3030#include "common/events.h"
     31#include "common/event-manager.h"
    3132#include "common/system.h"
    3233#include "common/savefile.h"
    3334
  • D:/programming/projects/gsoc/scummvm/engines/kyra/gui.cpp

     
    3333#include "common/config-manager.h"
    3434#include "common/savefile.h"
    3535#include "common/events.h"
     36#include "common/event-manager.h"
    3637#include "common/system.h"
    3738
    3839namespace Kyra {
  • D:/programming/projects/gsoc/scummvm/engines/kyra/vqa.cpp

     
    3333
    3434#include "common/stdafx.h"
    3535#include "common/events.h"
     36#include "common/event-manager.h"
    3637#include "common/system.h"
    3738#include "sound/audiostream.h"
    3839#include "sound/mixer.h"
  • D:/programming/projects/gsoc/scummvm/engines/kyra/sequences_v1.cpp

     
    3434#include "kyra/text.h"
    3535
    3636#include "common/events.h"
     37#include "common/event-manager.h"
    3738#include "common/system.h"
    3839#include "common/savefile.h"
    3940
  • D:/programming/projects/gsoc/scummvm/engines/kyra/text.cpp

     
    3232#include "kyra/sprites.h"
    3333
    3434#include "common/events.h"
     35#include "common/event-manager.h"
    3536#include "common/system.h"
    3637#include "common/endian.h"
    3738
  • D:/programming/projects/gsoc/scummvm/engines/sky/sky.h

     
    2727#define SKY_H
    2828
    2929#include "common/stdafx.h"
     30#include "common/keyboard.h"
    3031#include "common/events.h"
     32#include "common/system.h"
    3133#include "engines/engine.h"
    3234
    3335namespace Sky {
  • D:/programming/projects/gsoc/scummvm/engines/sky/mouse.cpp

     
    2525
    2626#include "common/stdafx.h"
    2727#include "common/events.h"
     28#include "common/event-manager.h"
    2829#include "common/system.h"
    2930#include "graphics/cursorman.h"
    3031#include "sky/disk.h"
  • D:/programming/projects/gsoc/scummvm/engines/sky/intro.cpp

     
    2727#include "common/endian.h"
    2828#include "common/util.h"
    2929#include "common/events.h"
     30#include "common/event-manager.h"
    3031#include "common/system.h"
    3132
    3233#include "sky/disk.h"
  • D:/programming/projects/gsoc/scummvm/engines/sky/sky.cpp

     
    3030#include "common/config-manager.h"
    3131#include "common/file.h"
    3232#include "common/fs.h"
    33 #include "common/events.h"
    34 #include "common/system.h"
    3533#include "common/timer.h"
    3634
     35#include "gui/key-mapper-dialog.h"
     36
    3737#include "sky/control.h"
    3838#include "sky/debug.h"
    3939#include "sky/disk.h"
     
    183183
    184184SkyEngine::SkyEngine(OSystem *syst)
    185185        : 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);
    186204}
    187205
    188206SkyEngine::~SkyEngine() {
  • D:/programming/projects/gsoc/scummvm/engines/sky/screen.cpp

     
    2626#include "common/stdafx.h"
    2727#include "common/endian.h"
    2828#include "common/events.h"
     29#include "common/event-manager.h"
    2930#include "common/system.h"
    3031
    3132#include "sky/disk.h"
  • D:/programming/projects/gsoc/scummvm/engines/sky/control.cpp

     
    2828#include "common/config-manager.h"
    2929#include "common/file.h"
    3030#include "common/events.h"
     31#include "common/event-manager.h"
    3132#include "common/system.h"
    3233#include "common/savefile.h"
    3334#include "common/util.h"
  • D:/programming/projects/gsoc/scummvm/engines/lure/events.cpp

     
    2525
    2626#include "common/stdafx.h"
    2727#include "common/events.h"
     28#include "common/event-manager.h"
    2829
    2930#include "graphics/cursorman.h"
    3031
  • D:/programming/projects/gsoc/scummvm/engines/gob/mult_v2.cpp

     
    11731173
    11741174                if (_multData->imdIndices[i] != -1) {
    11751175                        int fileN;
    1176                         char *imdFile;
     1176                        char *imdFile = NULL;
    11771177                        int dir;
    11781178                        int startFrame;
    11791179
  • D:/programming/projects/gsoc/scummvm/engines/gob/util.cpp

     
    2525
    2626#include "common/stdafx.h"
    2727#include "common/events.h"
     28#include "common/event-manager.h"
    2829
    2930#include "gob/gob.h"
    3031#include "gob/util.h"
  • D:/programming/projects/gsoc/scummvm/engines/parallaction/dialogue.cpp

     
    2626#include "common/stdafx.h"
    2727
    2828#include "common/events.h"
     29#include "common/event-manager.h"
    2930#include "parallaction/parallaction.h"
    3031
     32#include "common/system.h"
    3133
    3234
     35
    3336namespace Parallaction {
    3437
    3538#define SKIPPED_ANSWER             1000
  • D:/programming/projects/gsoc/scummvm/engines/parallaction/parallaction.cpp

     
    2727
    2828#include "common/config-manager.h"
    2929#include "common/events.h"
     30#include "common/event-manager.h"
    3031#include "common/file.h"
    3132#include "common/util.h"
    3233
     34#include "common/system.h"
     35
    3336#include "sound/mididrv.h"
    3437#include "sound/mixer.h"
    3538
  • D:/programming/projects/gsoc/scummvm/engines/saga/input.cpp

     
    3434#include "saga/isomap.h"
    3535
    3636#include "common/events.h"
     37#include "common/event-manager.h"
    3738#include "common/system.h"
    3839
    3940namespace Saga {
  • D:/programming/projects/gsoc/scummvm/engines/queen/input.h

     
    2929#include "common/util.h"
    3030#include "common/rect.h"
    3131#include "common/events.h"
     32#include "common/event-manager.h"
    3233#include "queen/defs.h"
    3334
    3435class OSystem;
  • D:/programming/projects/gsoc/scummvm/engines/queen/journal.cpp

     
    2525
    2626#include "common/stdafx.h"
    2727#include "common/events.h"
     28#include "common/event-manager.h"
    2829#include "common/system.h"
    2930#include "queen/journal.h"
    3031
  • D:/programming/projects/gsoc/scummvm/engines/cine/main_loop.cpp

     
    2626#include "common/stdafx.h"
    2727#include "common/scummsys.h"
    2828#include "common/events.h"
     29#include "common/event-manager.h"
    2930#include "common/system.h"
    3031
    3132#include "cine/main_loop.h"
  • D:/programming/projects/gsoc/scummvm/gui/newgui.cpp

     			
     
    2424
    2525#include "common/stdafx.h"
    2626#include "common/events.h"
     27#include "common/event-manager.h"
    2728#include "common/system.h"
    2829#include "common/util.h"
    2930#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
     36namespace GUI {
     37
     38class KeyMapperDialog : public GUI::Dialog {
     39public:
     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
     47protected:
     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

     
    3131
    3232#include "common/config-manager.h"
    3333#include "common/events.h"
     34#include "common/event-manager.h"
    3435#include "common/fs.h"
    3536#include "common/util.h"
    3637#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
     34namespace GUI {
     35
     36enum {
     37        kMapCmd = 'map ',
     38        kOKCmd  = 'ok  '
     39};
     40
     41KeyMapperDialog::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
     71KeyMapperDialog::~KeyMapperDialog() {
     72}
     73
     74void 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
     155void KeyMapperDialog::handleKeyDown(Common::KeyState state){
     156        if (_isMappingActive) {
     157                Dialog::handleKeyDown(state);
     158        }
     159}
     160
     161void 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
     191void 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

     
    2727#include "base/plugins.h"
    2828#include "base/version.h"
    2929#include "common/events.h"
     30#include "common/event-manager.h"
    3031#include "common/system.h"
    3132#include "common/util.h"
    3233#include "gui/about.h"