summaryrefslogtreecommitdiff
authoralwin <alwin>2004-08-02 08:19:00 (UTC)
committer alwin <alwin>2004-08-02 08:19:00 (UTC)
commiteb1b398e44c55058d65be0a8d5d8c24db9b6d874 (patch) (side-by-side diff)
tree5c7b84214e1a414f1de7d006cea49f57addabc82
parent26e22b14963afc0e75b9bfdbdf97110249ae87c5 (diff)
downloadopie-eb1b398e44c55058d65be0a8d5d8c24db9b6d874.zip
opie-eb1b398e44c55058d65be0a8d5d8c24db9b6d874.tar.gz
opie-eb1b398e44c55058d65be0a8d5d8c24db9b6d874.tar.bz2
ignore keys no actions are defined
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/applets/zkbapplet/keyzcfg/zkb.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/noncore/applets/zkbapplet/keyzcfg/zkb.cpp b/noncore/applets/zkbapplet/keyzcfg/zkb.cpp
index a357b88..3cc3669 100644
--- a/noncore/applets/zkbapplet/keyzcfg/zkb.cpp
+++ b/noncore/applets/zkbapplet/keyzcfg/zkb.cpp
@@ -166,212 +166,213 @@ State::State(State* p):parent(p), keys(0) {
State::State(const State& s) {
parent = s.parent;
keys = new Action[Key_Max * 2 + 1];
memcpy(keys, s.keys, sizeof(Action) * (Key_Max * 2 + 1));
}
State::~State() {
if (keys!=0) {
delete [] keys;
}
}
Action* State::get(int keycode, bool pressed, bool follow) const {
Action* ret = 0;
int n = translateKeycode(keycode);
if (n != -1 && keys != 0) {
if (pressed) {
n += Key_Max;
}
ret = &keys[n];
}
if (ret==0 || !ret->isDefined()) {
if (follow && parent!=0) {
ret = parent->get(keycode, pressed, follow);
}
}
return ret;
}
bool State::set(int keycode, bool pressed, Action& action) {
int n = translateKeycode(keycode);
if (n==-1 || keys==0) {
return false;
}
if (pressed) {
n += Key_Max + 1;
}
keys[n] = action;
return true;
}
State* State::getParent() const {
return parent;
}
void State::setParent(State* s) {
parent = s;
}
int State::translateKeycode(int keycode) const {
if (keycode < 0x20) {
return -1;
}
if (keycode < 0x80) {
return x1[keycode - 0x20];
}
if (keycode < 0x1000) {
return -1;
}
if (keycode < 0x1057) {
return x2[keycode - 0x1000];
}
return -1;
}
// Implementation of Keymap class
Keymap::Keymap():enabled(true), currentState(0), autoRepeatAction(0), repeater(this) {
repeatDelay=400;
repeatPeriod=80;
connect(&repeater, SIGNAL(timeout()), this, SLOT(autoRepeat()));
}
Keymap::~Keymap() {
odebug << "removing keyboard filter for zkb"<<oendl;
Opie::Core::OKeyFilter::inst()->remHandler(this);
QMap<QString, State*>::Iterator it;
for(it = states.begin(); it != states.end(); ++it) {
delete it.data();
}
states.clear();
}
bool Keymap::filter(int unicode, int keycode, int modifiers,
bool isPress, bool autoRepeat) {
- odebug << "filter: >>> unicode=" << unicode << ", keycode=" << keycode
- << ", modifiers=" << modifiers << ", ispressed=" << isPress << oendl;
-
if (!enabled) {
return false;
}
+ odebug << "filter: >>> unicode=" << unicode << ", keycode=" << keycode
+ << ", modifiers=" << modifiers << ", ispressed=" << isPress << oendl;
+
// the second check is workaround to make suspend work if
// the user pressed it right after he did resume. for some
// reason the event sent by qt has autoRepeat true in this
// case
if (autoRepeat && keycode != 4177) {
return true;
}
(void) unicode; (void) modifiers;
Action* action = currentState->get(keycode, isPress, true);
if (action==0 || !action->isDefined()) {
- return true;
+ odebug << "no action defined for that"<<oendl;
+ return false;
}
if (action->hasEvent()) {
odebug << "filter:<<< unicode=" << action->getUnicode() << ", keycode=" << action->getKeycode()
<< ", modifiers=" << action->getModifiers() << ", ispressed=" << action->isPressed() << oendl;
QWSServer::sendKeyEvent(action->getUnicode(),
action->getKeycode(), action->getModifiers(),
action->isPressed(), false);
}
if (action->isAutorepeat()) {
autoRepeatAction = action;
repeater.start(repeatDelay, TRUE);
} else {
autoRepeatAction = 0;
}
State* nstate = action->getState();
if (nstate != 0) {
setCurrentState(nstate);
QString lbl = getCurrentLabel();
if (!lbl.isEmpty()) {
emit stateChanged(lbl);
}
}
return true;
}
void Keymap::enable() {
enabled = true;
}
void Keymap::disable() {
enabled = false;
}
QStringList Keymap::listStates() {
QStringList ret;
QMap<QString, State*>::Iterator it;
for(it = states.begin(); it != states.end(); ++it) {
ret.append(it.key());
}
return ret;
}
State* Keymap::getStateByName(const QString& name) {
QMap<QString, State*>::Iterator it = states.find(name);
if (it == states.end()) {
return 0;
}
return it.data();
}
QStringList Keymap::listLabels() {
QStringList ret;
for(uint i = 0; i < labelList.count(); i++) {
ret.append(*labelList.at(i));
}
return ret;
}
State* Keymap::getStateByLabel(const QString& label) {
QMap<QString, QString>::Iterator lit = labels.find(label);
State* state = 0;
if (lit == labels.end()) {
return 0;
}
QString name = lit.data();
int n = name.find(":*");
if (n>=0 && n==(int)(name.length()-2)) {
name=name.left(name.length() - 1);
n = currentStateName.findRev(":");
if (n >= 0) {
name += currentStateName.mid(n+1);
}
}
// odebug << "look for: " << name.utf8() << "\n" << oendl;
QMap<QString, State*>::Iterator sit = states.find(name);
if (sit != states.end()) {
state = sit.data();
}