]> git.saurik.com Git - wxWidgets.git/blobdiff - src/osx/core/hid.cpp
Add wxActivateEvent::GetActivationReason().
[wxWidgets.git] / src / osx / core / hid.cpp
index f09912422c41f343c9a4db144534efc30d7722d9..92c874aa26577de99bc670aac4abf682a9568f7e 100644 (file)
@@ -4,7 +4,6 @@
 // Author:      Ryan Norton
 // Modified by:
 // Created:     11/11/2003
-// RCS-ID:      $Id$
 // Copyright:   (c) Ryan Norton
 // Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
@@ -36,7 +35,7 @@
     #include "wx/module.h"
 #endif
 
-#include "wx/osx/core/cfstring.h"
+#include "wx/osx/private.h"
 
 // ============================================================================
 // implementation
@@ -379,7 +378,7 @@ bool wxHIDDevice::IsActive(int nIndex)
 // ----------------------------------------------------------------------------
 bool wxHIDDevice::HasElement(int nIndex)
 {
-    return (void*) m_pCookies[nIndex] != NULL;
+    return m_pCookies[nIndex] != 0;
 }
 
 // ----------------------------------------------------------------------------
@@ -673,73 +672,8 @@ bool wxGetKeyState (wxKeyCode key)
     wxASSERT_MSG(key != WXK_LBUTTON && key != WXK_RBUTTON && key !=
         WXK_MBUTTON, wxT("can't use wxGetKeyState() for mouse buttons"));
 
-    if (wxHIDModule::sm_keyboards.GetCount() == 0)
-    {
-        int nKeyboards = wxHIDKeyboard::GetCount();
-
-        for(int i = 1; i <= nKeyboards; ++i)
-        {
-            wxHIDKeyboard* keyboard = new wxHIDKeyboard();
-            if(keyboard->Create(i))
-            {
-                wxHIDModule::sm_keyboards.Add(keyboard);
-            }
-            else
-            {
-                delete keyboard;
-                break;
-            }
-        }
-
-        wxASSERT_MSG(wxHIDModule::sm_keyboards.GetCount() != 0,
-                     wxT("No keyboards found!"));
-    }
-
-    for(size_t i = 0; i < wxHIDModule::sm_keyboards.GetCount(); ++i)
-    {
-        wxHIDKeyboard* keyboard = (wxHIDKeyboard*)
-                                wxHIDModule::sm_keyboards[i];
-
-    switch(key)
-    {
-    case WXK_SHIFT:
-            if( keyboard->IsActive(WXK_SHIFT) ||
-                   keyboard->IsActive(WXK_RSHIFT) )
-            {
-                return true;
-            }
-        break;
-    case WXK_ALT:
-            if( keyboard->IsActive(WXK_ALT) ||
-                   keyboard->IsActive(WXK_RALT) )
-            {
-                return true;
-            }
-        break;
-    case WXK_CONTROL:
-            if( keyboard->IsActive(WXK_CONTROL) ||
-                   keyboard->IsActive(WXK_RCONTROL) )
-            {
-                return true;
-            }
-        break;
-    case WXK_RAW_CONTROL:
-            if( keyboard->IsActive(WXK_RAW_CONTROL) ||
-                   keyboard->IsActive(WXK_RAW_RCONTROL) )
-            {
-                return true;
-            }
-        break;
-    default:
-            if( keyboard->IsActive(key) )
-            {
-                return true;
-            }
-        break;
-    }
-    }
-
-    return false; //not down/error
+    CGKeyCode cgcode = wxCharCodeWXToOSX((wxKeyCode)key);
+    return CGEventSourceKeyState(kCGEventSourceStateCombinedSessionState, cgcode);
 }
 
 #endif //__DARWIN__