diff -r f0c59438beaf files/prefpane/sysctl.xml --- a/files/prefpane/sysctl.xml Thu Feb 21 11:23:13 2008 +0900 +++ b/files/prefpane/sysctl.xml Fri Feb 22 16:15:20 2008 +0900 @@ -83,6 +83,12 @@ Enter to Option_L keyremap4macbook.remap.enter2optionL + + + Non-modifier Enter to Command_L+Space + keyremap4macbook.option.enter2optionL_commandspace + + Enter to Command_L+Control_L diff -r f0c59438beaf src/kext/config.cpp --- a/src/kext/config.cpp Thu Feb 21 11:23:13 2008 +0900 +++ b/src/kext/config.cpp Fri Feb 22 16:15:20 2008 +0900 @@ -76,6 +76,9 @@ namespace org_pqrs_KeyRemap4MacBook { SYSCTL_INT(_keyremap4macbook_remap, OID_AUTO, enter2optionL, CTLTYPE_INT|CTLFLAG_RW, &(config.remap_enter2optionL), 0, ""); + SYSCTL_INT(_keyremap4macbook_option, OID_AUTO, enter2optionL_commandspace, CTLTYPE_INT|CTLFLAG_RW, + &(config.option_enter2optionL_commandspace), 0, ""); + SYSCTL_INT(_keyremap4macbook_remap, OID_AUTO, enter2commandLcontrolL, CTLTYPE_INT|CTLFLAG_RW, &(config.remap_enter2commandLcontrolL), 0, ""); @@ -370,7 +373,10 @@ namespace org_pqrs_KeyRemap4MacBook { sysctl_register_oid(&sysctl__keyremap4macbook_remap_enter2commandL); sysctl_register_oid(&sysctl__keyremap4macbook_remap_enter2controlL); sysctl_register_oid(&sysctl__keyremap4macbook_remap_enter2fn); + sysctl_register_oid(&sysctl__keyremap4macbook_remap_enter2optionL); + sysctl_register_oid(&sysctl__keyremap4macbook_option_enter2optionL_commandspace); + sysctl_register_oid(&sysctl__keyremap4macbook_remap_enter2commandLcontrolL); sysctl_register_oid(&sysctl__keyremap4macbook_remap_enter2commandLshiftL); sysctl_register_oid(&sysctl__keyremap4macbook_remap_enter2semicolon); @@ -515,7 +521,10 @@ namespace org_pqrs_KeyRemap4MacBook { sysctl_unregister_oid(&sysctl__keyremap4macbook_remap_enter2commandL); sysctl_unregister_oid(&sysctl__keyremap4macbook_remap_enter2controlL); sysctl_unregister_oid(&sysctl__keyremap4macbook_remap_enter2fn); + sysctl_unregister_oid(&sysctl__keyremap4macbook_remap_enter2optionL); + sysctl_unregister_oid(&sysctl__keyremap4macbook_option_enter2optionL_commandspace); + sysctl_unregister_oid(&sysctl__keyremap4macbook_remap_enter2commandLcontrolL); sysctl_unregister_oid(&sysctl__keyremap4macbook_remap_enter2commandLshiftL); sysctl_unregister_oid(&sysctl__keyremap4macbook_remap_enter2semicolon); diff -r f0c59438beaf src/kext/config.hpp --- a/src/kext/config.hpp Thu Feb 21 11:23:13 2008 +0900 +++ b/src/kext/config.hpp Fri Feb 22 16:15:20 2008 +0900 @@ -31,7 +31,10 @@ namespace org_pqrs_KeyRemap4MacBook { int remap_enter2commandL; int remap_enter2controlL; int remap_enter2fn; + int remap_enter2optionL; + int option_enter2optionL_commandspace; + int remap_enter2commandLcontrolL; int remap_enter2commandLshiftL; int remap_enter2semicolon; diff -r f0c59438beaf src/kext/keycode.hpp --- a/src/kext/keycode.hpp Thu Feb 21 11:23:13 2008 +0900 +++ b/src/kext/keycode.hpp Fri Feb 22 16:15:20 2008 +0900 @@ -156,6 +156,7 @@ namespace org_pqrs_KeyRemap4MacBook { namespace CharCode { enum { CONTROL_L = 0, + COMMAND_L = 0, FN = 0, TAB = 9, RETURN = 13, diff -r f0c59438beaf src/kext/remap.cpp --- a/src/kext/remap.cpp Thu Feb 21 11:23:13 2008 +0900 +++ b/src/kext/remap.cpp Fri Feb 22 16:15:20 2008 +0900 @@ -122,7 +122,35 @@ namespace org_pqrs_KeyRemap4MacBook { { if (! config.remap_enter2optionL) return; - RemapUtil::keyToModifier(params, RemapUtil::getEnterKeyCode(params), ModifierFlag::OPTION_L); + KeyCode::KeyCode enterKeyCode = RemapUtil::getEnterKeyCode(params); + + if (config.option_enter2optionL_commandspace) { + static bool useEnterAsOption = false; + + if (params.ex_origKey != enterKeyCode && *(params.eventType) == KeyEvent::DOWN) { + useEnterAsOption = true; + } + + if (params.ex_origKey == enterKeyCode) { + // Enter => OptionL (if type EnterKey only, works as EnterKey) + unsigned int origEventType = *(params.eventType); + RemapUtil::keyToModifier(params, enterKeyCode, ModifierFlag::OPTION_L); + + if (origEventType == KeyEvent::DOWN) { + useEnterAsOption = false; + + } else if (origEventType == KeyEvent::UP) { + if (useEnterAsOption == false) { + listFireExtraKey.add(FireExtraKey::TYPE_AFTER, KeyEvent::MODIFY, ModifierFlag::COMMAND_L, KeyCode::COMMAND_L, CharCode::COMMAND_L); + listFireExtraKey.add(FireExtraKey::TYPE_AFTER, KeyEvent::DOWN, ModifierFlag::COMMAND_L, KeyCode::SPACE, CharCode::SPACE); + listFireExtraKey.add(FireExtraKey::TYPE_AFTER, KeyEvent::UP, ModifierFlag::COMMAND_L, KeyCode::SPACE, CharCode::SPACE); + listFireExtraKey.add(FireExtraKey::TYPE_AFTER, KeyEvent::MODIFY, 0, KeyCode::COMMAND_L, CharCode::COMMAND_L); + } + } + } + } else { + RemapUtil::keyToModifier(params, enterKeyCode, ModifierFlag::OPTION_L); + } } void