X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/8d1147f94291adcfa4d028d7122b3d39e5b553e1..053950ae73612200beb95afd1ded05c2f25b24bf:/src/mac/carbon/app.cpp diff --git a/src/mac/carbon/app.cpp b/src/mac/carbon/app.cpp index d79c0356e8..494ac9592f 100644 --- a/src/mac/carbon/app.cpp +++ b/src/mac/carbon/app.cpp @@ -59,6 +59,8 @@ # if defined(WXMAKINGDLL_CORE) # include # endif +// include hid keyboard +# include "wx/mac/carbon/private/hid.h" #else # include # include @@ -119,6 +121,10 @@ long wxApp::s_macPreferencesMenuItemId = wxID_PREFERENCES ; long wxApp::s_macExitMenuItemId = wxID_EXIT ; wxString wxApp::s_macHelpMenuTitleName = wxT("&Help") ; +#ifdef __DARWIN__ + wxHIDKeyboard* wxApp::s_macHIDKeyboard = NULL; +#endif + // Normally we're not a plugin bool wxApp::sm_isEmbedded = false; //---------------------------------------------------------------------- @@ -719,6 +725,12 @@ void wxApp::CleanUp() # endif #endif +#ifdef __DARWIN__ + // clean up HID Keyboard + if (s_macHIDKeyboard) + delete s_macHIDKeyboard; +#endif + UMACleanupToolbox() ; if (s_macCursorRgn) { ::DisposeRgn((RgnHandle)s_macCursorRgn); @@ -1169,11 +1181,16 @@ int wxMacKeyCodeToModifier(wxKeyCode key) bool wxGetKeyState(wxKeyCode key) //virtual key code if < 10.2.x, else see below { -//#ifdef __DARWIN__ -// wxHIDKeyboard keyboard; -// return keyboard.IsActive(key); -//#else -// TODO: Have it use HID Manager on OSX... +#ifdef __DARWIN__ + // Startup HID keyboard for getting key codes on DARWIN + if (!wxApp::s_macHIDKeyboard) + { + wxApp::s_macHIDKeyboard = new wxHIDKeyboard(); + wxApp::s_macHIDKeyboard->Create(); + } + + return wxApp::s_macHIDKeyboard->IsActive(key); +#else //if OS X > 10.2 (i.e. 10.2.x) //a known apple bug prevents the system from determining led //states with GetKeys... can only determine caps lock led @@ -1182,7 +1199,7 @@ bool wxGetKeyState(wxKeyCode key) //virtual key code if < 10.2.x, else see below // KeyMapByteArray keymap; // GetKeys((BigEndianLong*)keymap); // return !!(BitTst(keymap, (sizeof(KeyMapByteArray)*8) - iKey)); -//#endif +#endif }