Permalink
Browse files

add PressDownKeys

  • Loading branch information...
1 parent bd18dbe commit ea5ba7b64bf67bab05c6d2686c4f09803814d1a2 @tekezo committed with tekezo Sep 6, 2008
View
@@ -0,0 +1 @@
+Public Domain
@@ -65,6 +65,7 @@ org_pqrs_driver_KeyRemap4MacBook::init(OSDictionary *dict)
hookedPointing[i].pointing = NULL;
}
org_pqrs_KeyRemap4MacBook::clickWatcher.reset();
+ org_pqrs_KeyRemap4MacBook::pressDownKeys.initialize();
KeyRemap4MacBook_client::initialize();
@@ -746,15 +747,15 @@ org_pqrs_driver_KeyRemap4MacBook::keyboardEventCallBack(OSObject *target,
charSet, origCharCode, origCharSet, keyboardType, repeat,
ts, sender, refcon);
org_pqrs_KeyRemap4MacBook::listFireExtraKey.fire(p->origEventCallback, target, charSet, origCharCode, origCharSet, keyboardType, ts, sender, refcon);
-
- // reset modifiers
- if (org_pqrs_KeyRemap4MacBook::allFlagStatus.numHeldDownKeys <= 0) {
- org_pqrs_KeyRemap4MacBook::RemapUtil::fireModifiers(0, p->origEventCallback, target, keyboardType, ts, sender, refcon);
- }
}
p->setExtraRepeatInfo(ex_extraRepeatFunc, ex_extraRepeatFlags, keyboardType, ts, target, refcon);
p->setRepeatInfo(eventType, flags, key, charCode, charSet, origCharCode, origCharSet, keyboardType, ts, target, refcon);
+
+ if (org_pqrs_KeyRemap4MacBook::allFlagStatus.numHeldDownKeys <= 0) {
+ org_pqrs_KeyRemap4MacBook::RemapUtil::fireModifiers(0, p->origEventCallback, target, keyboardType, ts, sender, refcon);
+ org_pqrs_KeyRemap4MacBook::pressDownKeys.clear(p->origEventCallback, target, ts, sender, refcon);
+ }
}
void
@@ -19,6 +19,8 @@
348ED83A0CE4682000E179EC /* version.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 348ED8390CE4682000E179EC /* version.hpp */; };
348ED8470CE47D9400E179EC /* RemapUtil.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 348ED8460CE47D9400E179EC /* RemapUtil.cpp */; };
348ED8490CE47D9D00E179EC /* RemapUtil.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 348ED8480CE47D9D00E179EC /* RemapUtil.hpp */; };
+ 349581080E7232A5003773EC /* PressDownKeys.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 349581060E7232A5003773EC /* PressDownKeys.cpp */; };
+ 349581090E7232A5003773EC /* PressDownKeys.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 349581070E7232A5003773EC /* PressDownKeys.hpp */; };
34C7A9A20CE45EA400C98397 /* Config.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 34C7A9A10CE45EA400C98397 /* Config.cpp */; };
34C7A9B00CE4605B00C98397 /* Config.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 34C7A9AF0CE4605B00C98397 /* Config.hpp */; };
34FB835F0CE5DBFF00BD6A24 /* base.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 34FB835E0CE5DBFF00BD6A24 /* base.hpp */; };
@@ -27,7 +29,7 @@
/* Begin PBXFileReference section */
089C167EFE841241C02AAC07 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/InfoPlist.strings; sourceTree = "<group>"; };
1A224C3FFF42367911CA2CB7 /* KeyRemap4MacBook.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = KeyRemap4MacBook.cpp; sourceTree = "<group>"; };
- 32D94FCF0562CBF700B6AF17 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = Info.plist; sourceTree = "<group>"; };
+ 32D94FCF0562CBF700B6AF17 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
32D94FD00562CBF700B6AF17 /* KeyRemap4MacBook.kext */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = KeyRemap4MacBook.kext; sourceTree = BUILT_PRODUCTS_DIR; };
3452BE010AD6BCAF009D9E15 /* KeyRemap4MacBook.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = KeyRemap4MacBook.hpp; sourceTree = "<group>"; };
345B06AB0DB21A88000023FD /* Client.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Client.cpp; sourceTree = "<group>"; };
@@ -39,6 +41,8 @@
348ED8390CE4682000E179EC /* version.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = version.hpp; sourceTree = "<group>"; };
348ED8460CE47D9400E179EC /* RemapUtil.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RemapUtil.cpp; sourceTree = "<group>"; };
348ED8480CE47D9D00E179EC /* RemapUtil.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = RemapUtil.hpp; sourceTree = "<group>"; };
+ 349581060E7232A5003773EC /* PressDownKeys.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = PressDownKeys.cpp; path = util/PressDownKeys.cpp; sourceTree = "<group>"; };
+ 349581070E7232A5003773EC /* PressDownKeys.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = PressDownKeys.hpp; path = util/PressDownKeys.hpp; sourceTree = "<group>"; };
34C7A9A10CE45EA400C98397 /* Config.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Config.cpp; sourceTree = "<group>"; };
34C7A9AF0CE4605B00C98397 /* Config.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Config.hpp; sourceTree = "<group>"; };
34FB835E0CE5DBFF00BD6A24 /* base.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = base.hpp; sourceTree = "<group>"; };
@@ -87,6 +91,8 @@
247142CAFF3F8F9811CA285C /* Source */ = {
isa = PBXGroup;
children = (
+ 349581060E7232A5003773EC /* PressDownKeys.cpp */,
+ 349581070E7232A5003773EC /* PressDownKeys.hpp */,
345B06B70DB21ABF000023FD /* bridge.hpp */,
348ED8350CE4680F00E179EC /* remap.hpp */,
348ED8480CE47D9D00E179EC /* RemapUtil.hpp */,
@@ -121,6 +127,7 @@
34FB835F0CE5DBFF00BD6A24 /* base.hpp in Headers */,
345B06AE0DB21A88000023FD /* Client.hpp in Headers */,
345B06B80DB21ABF000023FD /* bridge.hpp in Headers */,
+ 349581090E7232A5003773EC /* PressDownKeys.hpp in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -195,6 +202,7 @@
348ED8340CE467FD00E179EC /* remap.cpp in Sources */,
348ED8470CE47D9400E179EC /* RemapUtil.cpp in Sources */,
345B06AD0DB21A88000023FD /* Client.cpp in Sources */,
+ 349581080E7232A5003773EC /* PressDownKeys.cpp in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -4,9 +4,12 @@
#include "keycode.hpp"
#include "Config.hpp"
+#include "util/PressDownKeys.hpp"
+
namespace org_pqrs_KeyRemap4MacBook {
AllFlagStatus allFlagStatus;
ListFireExtraKey listFireExtraKey;
+ PressDownKeys pressDownKeys;
ListFireConsumerKey listFireConsumerKey;
ListFirePointingClick listFirePointingClick;
FirePointingScroll firePointingScroll;
@@ -434,8 +437,13 @@ namespace org_pqrs_KeyRemap4MacBook {
callback(target, eventType, flags, key, charCode,
charSet, origCharCode, origCharSet, keyboardType, repeat, ts, sender, refcon);
- if (key == KeyCode::JIS_EISUU || key == KeyCode::JIS_KANA) {
- jisKanaMode.setMode(eventType, key, flags);
+ if (eventType == KeyEvent::DOWN) {
+ if (key == KeyCode::JIS_EISUU || key == KeyCode::JIS_KANA) {
+ jisKanaMode.setMode(eventType, key, flags);
+ }
+ pressDownKeys.add(key, keyboardType);
+ } else {
+ pressDownKeys.remove(key, keyboardType);
}
}
}
@@ -4,6 +4,7 @@
#include <IOKit/hidsystem/IOHIKeyboard.h>
#include "remap.hpp"
#include "keycode.hpp"
+#include "util/PressDownKeys.hpp"
namespace org_pqrs_KeyRemap4MacBook {
namespace RemapUtil {
@@ -501,6 +502,8 @@ namespace org_pqrs_KeyRemap4MacBook {
Mode mode;
};
extern JISKanaMode jisKanaMode;
+
+ extern PressDownKeys pressDownKeys;
}
#endif
@@ -0,0 +1,55 @@
+#include "PressDownKeys.hpp"
+#include "RemapUtil.hpp"
+#include "keycode.hpp"
+
+namespace org_pqrs_KeyRemap4MacBook {
+ void
+ PressDownKeys::initialize(void)
+ {
+ for (int i = 0; i < MAXNUM; ++i) {
+ item[i].enable = false;
+ }
+ }
+
+ void
+ PressDownKeys::add(unsigned int _key, unsigned int _keyboardType)
+ {
+ for (int i = 0; i < MAXNUM; ++i) {
+ if (! item[i].enable) {
+ item[i].enable = true;
+ item[i].key = _key;
+ item[i].keyboardType = _keyboardType;
+ }
+ }
+ }
+
+ void
+ PressDownKeys::remove(unsigned int _key, unsigned int _keyboardType)
+ {
+ for (int i = 0; i < MAXNUM; ++i) {
+ if (! item[i].enable) continue;
+ if (item[i].key != _key) continue;
+ if (item[i].keyboardType != _keyboardType) continue;
+ item[i].enable = false;
+ }
+ }
+
+ void
+ PressDownKeys::clear(KeyboardEventCallback callback, OSObject *target, AbsoluteTime ts, OSObject *sender, void *refcon)
+ {
+ if (callback == NULL) return;
+
+ for (int i = 0; i < MAXNUM; ++i) {
+ if (! item[i].enable) continue;
+ unsigned int flags = 0;
+ unsigned int charCode = 0;
+ unsigned int charSet = 0;
+ unsigned int origCharCode = 0;
+ unsigned int origCharSet = 0;
+ RemapUtil::fireKey(callback,
+ target, KeyEvent::UP, flags, item[i].key,
+ charCode, charSet, origCharCode, origCharSet,
+ item[i].keyboardType, false, ts, sender, refcon);
+ }
+ }
+}
@@ -0,0 +1,29 @@
+#ifndef REMAPUTIL_PRESSDOWNKEYS_HPP
+#define REMAPUTIL_PRESSDOWNKEYS_HPP
+
+#include "base.hpp"
+
+namespace org_pqrs_KeyRemap4MacBook {
+ // ----------------------------------------------------------------------
+ // store RemapUtil::fireKey results
+ class PressDownKeys {
+ public:
+ void initialize(void);
+ void add(unsigned int _key, unsigned int _keyboardType);
+ void remove(unsigned int _key, unsigned int _keyboardType);
+ void clear(KeyboardEventCallback callback, OSObject *target, AbsoluteTime ts, OSObject *sender, void *refcon);
+
+ private:
+ enum {
+ MAXNUM = 16,
+ };
+ struct Item {
+ bool enable;
+ unsigned int key;
+ unsigned int keyboardType;
+ };
+ Item item[MAXNUM];
+ };
+}
+
+#endif

0 comments on commit ea5ba7b

Please sign in to comment.