00001 #ifndef _KEY_MODIFIERS_H_
00002 #define _KEY_MODIFIERS_H_
00003
00004 #include <qmap.h>
00005 #include <qtimer.h>
00006 #include <qvaluelist.h>
00007 #include <qnamespace.h>
00008
00009 #include <qpe/config.h>
00010 #include "ConfigEx.h"
00011
00012 struct ModifierInfo {
00013 public:
00014 ModifierInfo(const QString& tp, int code, int mask, bool mode)
00015 {
00016 type = tp;
00017 keycode = code;
00018 keymask = mask;
00019 pressed = false;
00020 toggled = false;
00021 toggle_mode = mode;
00022 }
00023 QString type;
00024 int keycode;
00025 int keymask;
00026 bool pressed;
00027 bool toggled;
00028 bool toggle_mode;
00029 private:
00030 } ;
00031
00032 class KeyModifiers : public QObject
00033 {
00034 Q_OBJECT
00035 public:
00036 typedef QValueList<ModifierInfo*> ModifierList;
00037
00038 KeyModifiers();
00039 virtual ~KeyModifiers();
00040 void addType(const QString& type);
00041 ModifierInfo* assign(const QString& type, int keycode,
00042 int keymask = 0, bool toggle = false);
00043 void assignRelease(int keycode);
00044 void assignRelease(ModifierInfo* info, int keycode);
00045 void setToggle();
00046 void setToggle(ModifierInfo* info);
00047
00048 bool isToggled();
00049 void resetStates();
00050 void keepToggles();
00051
00052 bool pressKey(int keycode, int modifiers);
00053 void releaseKey(int keycode);
00054 int getState();
00055 int getState(int modifiers, bool reset = false);
00056 int getMask(const QString& type);
00057 int getModifiers(int modifiers);
00058
00059 bool isModifier(int keycode);
00060
00061 void statistics();
00062
00063 void reset();
00064 public slots:
00065 void resetToggles();
00066 private:
00067 QMap<QString, int> m_types;
00068 int m_bitmask;
00069 ModifierList m_modifiers;
00070 QMap<int, ModifierList*> m_releasekeys;
00071 ModifierList m_togglekeys;
00072 ModifierInfo* m_info;
00073 QTimer* m_pTimer;
00074 int m_timeout;
00075
00076 void clear();
00077 void init();
00078 };
00079
00080 #endif