diff options
author | Ton Roosendaal <ton@blender.org> | 2003-07-09 20:01:27 +0400 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2003-07-09 20:01:27 +0400 |
commit | 0a5145c118055bd704c073f6f183a8e798673dac (patch) | |
tree | 4bba6166db7d90616bf77a75e9b20d66b156bd22 /intern | |
parent | 4f571661bdbc12a7ab06c48988d0c9d2dd1dfeea (diff) |
* Added a roman -> latin charset convertor.
MacOSX returns a Roman charset with kEventParamKeyMacCharCodes
as defined here: http://developer.apple.com/documentation/mac/Text/Text-516.html
I am not sure how international this works...
For cross-platform convention, we'll use the Latin ascii set instead.
As defined at: http://www.ramsch.org/martin/uni/fmi-hp/iso8859-1.html
* changed window-pop behaviour, it now also activates the window for input
(OSX only)
Diffstat (limited to 'intern')
-rw-r--r-- | intern/ghost/intern/GHOST_SystemCarbon.cpp | 139 | ||||
-rw-r--r-- | intern/ghost/intern/GHOST_WindowCarbon.cpp | 3 |
2 files changed, 137 insertions, 5 deletions
diff --git a/intern/ghost/intern/GHOST_SystemCarbon.cpp b/intern/ghost/intern/GHOST_SystemCarbon.cpp index b0d5de19a1a..2f89818ac99 100644 --- a/intern/ghost/intern/GHOST_SystemCarbon.cpp +++ b/intern/ghost/intern/GHOST_SystemCarbon.cpp @@ -102,10 +102,9 @@ static GHOST_TKey convertKey(int rawCode) * without regard to the modifiers (so we don't get 'a' * and 'A' for example. */ - UInt32 dummy= 0; + static UInt32 dummy= 0; Handle transData = (Handle) GetScriptManagerVariable(smKCHRCache); - char vk = KeyTranslate(transData, rawCode, &dummy); - + char vk = KeyTranslate(transData, rawCode, &dummy); /* Map numpad based on rawcodes first, otherwise they * look like non-numpad events. */ @@ -185,6 +184,135 @@ static GHOST_TKey convertKey(int rawCode) return GHOST_kKeyUnknown; } +/* MacOSX returns a Roman charset with kEventParamKeyMacCharCodes + * as defined here: http://developer.apple.com/documentation/mac/Text/Text-516.html + * I am not sure how international this works... + * For cross-platform convention, we'll use the Latin ascii set instead. + * As defined at: http://www.ramsch.org/martin/uni/fmi-hp/iso8859-1.html + * + */ +static unsigned char convertRomanToLatin(unsigned char ascii) +{ + + if(ascii<128) return ascii; + + switch(ascii) { + case 128: return 142; + case 129: return 143; + case 130: return 128; + case 131: return 201; + case 132: return 209; + case 133: return 214; + case 134: return 220; + case 135: return 225; + case 136: return 224; + case 137: return 226; + case 138: return 228; + case 139: return 227; + case 140: return 229; + case 141: return 231; + case 142: return 233; + case 143: return 232; + case 144: return 234; + case 145: return 235; + case 146: return 237; + case 147: return 236; + case 148: return 238; + case 149: return 239; + case 150: return 241; + case 151: return 243; + case 152: return 242; + case 153: return 244; + case 154: return 246; + case 155: return 245; + case 156: return 250; + case 157: return 249; + case 158: return 251; + case 159: return 252; + case 160: return 0; + case 161: return 176; + case 162: return 162; + case 163: return 163; + case 164: return 167; + case 165: return 183; + case 166: return 182; + case 167: return 223; + case 168: return 174; + case 169: return 169; + case 170: return 174; + case 171: return 180; + case 172: return 168; + case 173: return 0; + case 174: return 198; + case 175: return 216; + case 176: return 0; + case 177: return 177; + case 178: return 0; + case 179: return 0; + case 180: return 165; + case 181: return 181; + case 182: return 0; + case 183: return 0; + case 184: return 215; + case 185: return 0; + case 186: return 0; + case 187: return 170; + case 188: return 186; + case 189: return 0; + case 190: return 230; + case 191: return 248; + case 192: return 191; + case 193: return 161; + case 194: return 172; + case 195: return 0; + case 196: return 0; + case 197: return 0; + case 198: return 0; + case 199: return 171; + case 200: return 187; + case 201: return 201; + case 202: return 0; + case 203: return 192; + case 204: return 195; + case 205: return 213; + case 206: return 0; + case 207: return 0; + case 208: return 0; + case 209: return 0; + case 210: return 0; + + case 214: return 247; + + case 229: return 194; + case 230: return 202; + case 231: return 193; + case 232: return 203; + case 233: return 200; + case 234: return 205; + case 235: return 206; + case 236: return 207; + case 237: return 204; + case 238: return 211; + case 239: return 212; + case 240: return 0; + case 241: return 210; + case 242: return 218; + case 243: return 219; + case 244: return 217; + case 245: return 0; + case 246: return 0; + case 247: return 0; + case 248: return 0; + case 249: return 0; + case 250: return 0; + + + default: return 0; + } + +} + + /***/ GHOST_SystemCarbon::GHOST_SystemCarbon() : @@ -590,7 +718,7 @@ OSStatus GHOST_SystemCarbon::handleKeyEvent(EventRef event) UInt32 modifiers; UInt32 rawCode; GHOST_TKey key; - char ascii; + unsigned char ascii; /* Can happen, very rarely - seems to only be when command-H makes * the window go away and we still get an HKey up. @@ -607,7 +735,10 @@ OSStatus GHOST_SystemCarbon::handleKeyEvent(EventRef event) case kEventRawKeyUp: ::GetEventParameter(event, kEventParamKeyCode, typeUInt32, NULL, sizeof(UInt32), NULL, &rawCode); ::GetEventParameter(event, kEventParamKeyMacCharCodes, typeChar, NULL, sizeof(char), NULL, &ascii); + key = convertKey(rawCode); + ascii= convertRomanToLatin(ascii); + if (key!=GHOST_kKeyUnknown) { GHOST_TEventType type; if (kind == kEventRawKeyDown) { diff --git a/intern/ghost/intern/GHOST_WindowCarbon.cpp b/intern/ghost/intern/GHOST_WindowCarbon.cpp index 4f5a76985d2..35e1efc793e 100644 --- a/intern/ghost/intern/GHOST_WindowCarbon.cpp +++ b/intern/ghost/intern/GHOST_WindowCarbon.cpp @@ -329,7 +329,8 @@ GHOST_TSuccess GHOST_WindowCarbon::setOrder(GHOST_TWindowOrder order) { GHOST_ASSERT(getValid(), "GHOST_WindowCarbon::setOrder(): window invalid") if (order == GHOST_kWindowOrderTop) { - ::BringToFront(m_windowRef); + //::BringToFront(m_windowRef); is wrong, front window should be active for input too + ::SelectWindow(m_windowRef); } else { ::SendBehind(m_windowRef, nil); |