MacBookの右下のEnterをControlに
MacBookの右下にControlキーがなく、代わりにenter がついてるキー配列がいかんともしがたいのでキーカスタマイズソフトを探してみた。
DoubleCommand というソフトがあるんだけどそれを入れるとマウスが効かなくなったり、文字が入力できなくなったりしたので削除。
で、次に見つけたKeyRemap4MacBookというのを入れてみた。
右下のEnterをControlにしたいんだけどそのカスタマイズはできないらしい。
ソースと、修正方法が書いてあったのでそれを見て修正&ビルドしてみる。
KeyRemap4MacBook-1.2.0/src/kext にある、
KeyRemap4MacBook.hppとKeyRemap4MacBook.cppを修正。
KeyRemap4MacBook-1.2.0/src/kext/KeyRemap4MacBook.cpp
--- KeyRemap4MacBook.cpp.orig 2007-07-27 23:28:35.000000000 +0900
+++ KeyRemap4MacBook.cpp 2007-07-27 23:33:29.000000000 +0900
@@ -19,6 +19,7 @@
int org_pqrs_driver_KeyRemap4MacBook::config_remap_shift2escape = 0;
int org_pqrs_driver_KeyRemap4MacBook::config_remap_space2shift = 0;
int org_pqrs_driver_KeyRemap4MacBook::config_remap_enter2command = 0;
+int org_pqrs_driver_KeyRemap4MacBook::config_remap_enter2control = 0;
int org_pqrs_driver_KeyRemap4MacBook::config_remap_jis_eisuu2control = 0;
int org_pqrs_driver_KeyRemap4MacBook::config_remap_jis_kana2return = 0;
@@ -91,6 +92,12 @@
0,
"Use 'Enter Key' as 'Command Key'");
+SYSCTL_INT(_keyremap4macbook_remap, OID_AUTO, enter2control, CTLTYPE_INT|CTLFLAG_RW,
+ &(org_pqrs_driver_KeyRemap4MacBook::config_remap_enter2control),
+ 0,
+ "Use 'Enter Key' as 'Control Key'");
+
+
SYSCTL_INT(_keyremap4macbook_remap, OID_AUTO, jis_eisuu2control, CTLTYPE_INT|CTLFLAG_RW,
&(org_pqrs_driver_KeyRemap4MacBook::config_remap_jis_eisuu2control),
0,
@@ -137,6 +144,7 @@
sysctl_register_oid(&sysctl__keyremap4macbook_remap_shift2escape);
sysctl_register_oid(&sysctl__keyremap4macbook_remap_space2shift);
sysctl_register_oid(&sysctl__keyremap4macbook_remap_enter2command);
+ sysctl_register_oid(&sysctl__keyremap4macbook_remap_enter2control);
sysctl_register_oid(&sysctl__keyremap4macbook_remap_jis_eisuu2control);
sysctl_register_oid(&sysctl__keyremap4macbook_remap_jis_kana2return);
sysctl_register_oid(&sysctl__keyremap4macbook_option_homeposition_functionkey_add_cmd);
@@ -391,6 +399,7 @@
remap_shift2escape(params);
remap_space2shift(params);
remap_enter2command(params);
+ remap_enter2control(params);
remap_jis_eisuu2control(params);
remap_jis_kana2return(params);
@@ -553,6 +562,17 @@
}
void
+org_pqrs_driver_KeyRemap4MacBook::remap_enter2control(const RemapParams ¶ms)
+{
+ if (! config_remap_enter2control) return;
+
+ if (*(params.key) == KeyCode::ENTER_KEY) {
+ // Enter => Control
+ KeyToModifier(params.eventType, params.key, KeyCode::CONTROL_FLAG, KeyCode::CONTROL_KEY, KeyCode::KEY_MODIFY);
+ }
+}
+
+void
org_pqrs_driver_KeyRemap4MacBook::remap_jis_eisuu2control(const RemapParams ¶ms)
{
if (! config_remap_jis_eisuu2control) return;
KeyRemap4MacBook-1.2.0/src/kext/KeyRemap4MacBook.hpp
--- KeyRemap4MacBook.hpp.orig 2007-07-28 00:09:18.000000000 +0900 +++ KeyRemap4MacBook.hpp 2007-07-27 23:34:48.000000000 +0900 @@ -25,6 +25,7 @@ static int config_remap_shift2escape; static int config_remap_space2shift; static int config_remap_enter2command; + static int config_remap_enter2control; static int config_option_homeposition_functionkey_add_cmd; static int config_option_space2shift_shift2space; @@ -85,6 +86,7 @@ static void remap_shift2escape(const RemapParams ¶ms); static void remap_space2shift(const RemapParams ¶ms); static void remap_enter2command(const RemapParams ¶ms); + static void remap_enter2control(const RemapParams ¶ms); static void remap_jis_eisuu2control(const RemapParams ¶ms); static void remap_jis_kana2return(const RemapParams ¶ms);何がなんだかわからないけど適当にコピペで enter2controlを実装。 ビルドしてみる。
$ cd KeyRemap4MacBook-1.2.0 $ make make[1]: setversion.sh: Command not found make[1]: *** [all] Error 127 make: *** [build] Error 2pkginfo/Makefile の setversion.sh を
./setversion.sh
に書き換えたらmakeが通るようになった。KeyRemap4MacBook-1.2.0.dmg というファイルができるので、それをクリックしてインストール。
再起動したあとで、以下のようにターミナルから実行し、有効化する。
$ sudo sysctl -w keyremap4macbook.remap.enter2control=1
やっと右のcontrolキーが使えるようになったよ!
あと、左下のcaps lock もcontrolにしたいけど、きょうはここまで。

ありゃ、確かに Makefile を修正しないといけないですね。ありがとうございます。
あとパッチを本体のほうに組み込ませていただきます。
こちらもありがとうございました。
> Takayama Fumihiko 様
おー、ありがとうございます!
macbookには右下のctrlがなくて不便でこまっていたのですが、KeyRemap4MacBookでかなり快適になりました。
(emacs使ってる時に右下のctrl多用してたので)