Ticket #31974: patch-src_mac_MacKeyboard.cpp.diff
File patch-src_mac_MacKeyboard.cpp.diff, 3.7 KB (added by marin.saric@…, 13 years ago) |
---|
-
src/mac/MacKeyboard.cpp
1 1 /* 2 2 The zlib/libpng License 3 3 4 Copyright (c) 200 6 Chris Snyder4 Copyright (c) 2005-2007 Phillip Castaneda (pjcast -- www.wreckedgames.com) 5 5 6 6 This software is provided 'as-is', without any express or implied warranty. In no event will 7 7 the authors be held liable for any damages arising from the use of this software. 8 8 9 Permission is granted to anyone to use this software for any purpose, including commercial 9 Permission is granted to anyone to use this software for any purpose, including commercial 10 10 applications, and to alter it and redistribute it freely, subject to the following 11 11 restrictions: 12 12 13 1. The origin of this software must not be misrepresented; you must not claim that 14 you wrote the original software. If you use this software in a product, 15 an acknowledgment in the product documentation would be appreciated but is 13 1. The origin of this software must not be misrepresented; you must not claim that 14 you wrote the original software. If you use this software in a product, 15 an acknowledgment in the product documentation would be appreciated but is 16 16 not required. 17 17 18 2. Altered source versions must be plainly marked as such, and must not be 18 2. Altered source versions must be plainly marked as such, and must not be 19 19 misrepresented as being the original software. 20 20 21 21 3. This notice may not be removed or altered from any source distribution. 22 */22 */ 23 23 24 #ifndef __LP64__ 25 24 26 #include "mac/MacKeyboard.h" 25 27 #include "mac/MacInputManager.h" 26 28 #include "mac/MacHelpers.h" … … 141 143 // if not buffered just return, we update the unbuffered automatically 142 144 if ( !mBuffered || !mListener ) 143 145 return; 144 145 //If the mListener returns false, that means that we are probably deleted... 146 //send no more events and just leave as the this pointer is invalid now... 147 bool ret = true; 148 146 149 147 // run through our event stack 150 148 eventStack::iterator cur_it; 151 149 … … 165 163 //-------------------------------------------------------------------// 166 164 std::string& MacKeyboard::getAsString( KeyCode key ) 167 165 { 168 getString = ""; 169 166 CGKeyCode deviceKeycode; 167 168 // Convert OIS KeyCode back into device keycode 169 for(VirtualtoOIS_KeyMap::iterator it = keyConversion.begin(); it != keyConversion.end(); ++it) 170 { 171 if(it->second == key) 172 deviceKeycode = it->first; 173 } 174 175 UniChar unicodeString[1]; 176 UniCharCount actualStringLength = 0; 177 178 CGEventSourceRef sref = CGEventSourceCreate(kCGEventSourceStateHIDSystemState); 179 CGEventRef ref = CGEventCreateKeyboardEvent(sref, deviceKeycode, true); 180 CGEventKeyboardGetUnicodeString(ref, sizeof(unicodeString) / sizeof(*unicodeString), &actualStringLength, unicodeString); 181 // NSLog([NSString stringWithFormat:@"%C\n", unicodeString[0]]); 182 getString = unicodeString[0]; 183 170 184 return getString; 171 185 } 172 186 … … 206 220 //status = GetEventParameter( theEvent, 'kuni', typeUnicodeText, NULL, 0, &stringsize, NULL); 207 221 //status = GetEventParameter( theEvent, 'kuni', typeUnicodeText, NULL, sizeof(UniChar)*10, NULL, &text ); 208 222 status = GetEventParameter( theEvent, 'kuni', typeUnicodeText, NULL, sizeof(UniChar) * 10, &stringsize, &text ); 209 std::cout << "String length: " << stringsize << std::endl;223 // std::cout << "String length: " << stringsize << std::endl; 210 224 211 225 //wstring unitext; 212 226 //for (int i=0;i<10;i++) unitext += (wchar_t)text[i]; … … 462 476 keyConversion.insert(VirtualtoOIS_KeyMap::value_type(0x75, KC_DELETE)); // del under help key? 463 477 } 464 478 465 466 467 479 #endif