src/native/globalshortcut/net_java_sip_communicator_impl_globalshortcut_NativeKeyboardHook.cpp
/**
 * \brief Called in WndProc to check the event received.
 * \param wParam wparam
 * \param lParam lparam
 * \return 0 if hotkey is processed, -1 otherwise
 */
\brief Called in WndProc to check the event received.
\param wParam wparam
\param lParam lparam
\return 0 if hotkey is processed, -1 otherwise
\ brief Called in WndProc to check the event received . \ param wParam wparam \ param lParam lparam \ return 0 if hotkey is processed - 1 otherwise
HRESULT callback(UINT msg, WPARAM wParam, LPARAM lParam)
{
  if(msg == WM_HOTKEY)
  {
    keyboard_hook* keyboard = &g_keyboard_hook;
    if(keyboard->hwnd)
    {
        for(std::list<keystrok>::iterator it = keyboard->keystrokes.begin() ; it != keyboard->keystrokes.end() ; ++it)
        {
            keystrok& ks = (*it);
            if(ks.active == 0)
            {
                ks.active = 1;
                if(!RegisterHotKey(keyboard->hwnd, ks.id, ks.modifiers | MOD_NOREPEAT, ks.vkcode))
                {
                  fprintf(stderr, "[LOOP] Problem with RegisterHotKey: %d\n", GetLastError());fflush(stderr);
                  ks.active = -1;
                }
            }
            else if(ks.active == -1)
            {
                if(!UnregisterHotKey(keyboard->hwnd, ks.id))
                {
                }
                it = keyboard->keystrokes.erase(it)--;
            }
        }
    }
    for(std::list<keystrok>::iterator it = g_keyboard_hook.keystrokes.begin() ; it != g_keyboard_hook.keystrokes.end() ; ++it)
    {
      keystrok ks = (*it);
      if(ks.id == wParam)
      {
        int javaModifiers = 0;
        int javaKeycode = 0;
        javaKeycode = convertWindowsKeycodeToJava(HIWORD(lParam)); 
        javaModifiers = convertWindowsModifiersToJavaUserDefined(ks.modifiers);
        notify(javaKeycode, javaModifiers, false);
        if(ks.is_on_key_release)
        {
          setHotkeyRealese(ks.modifiers, ks.vkcode, javaModifiers, javaKeycode);
        }
        return 0;
      }
    }
  }
  return  -1;
}
HRESULT callback ( UINT msg , WPARAM wParam , LPARAM lParam ) { if ( msg == WM_HOTKEY ) { keyboard_hook * keyboard = & g_keyboard_hook ; if ( keyboard -> hwnd ) { for ( std :: list < keystrok > :: iterator it = keyboard -> keystrokes . begin ( ) ; it != keyboard -> keystrokes . end ( ) ; ++ it ) { keystrok & ks = ( * it ) ; if ( ks . active == 0 ) { ks . active = 1 ; if ( ! RegisterHotKey ( keyboard -> hwnd , ks . id , ks . modifiers | MOD_NOREPEAT , ks . vkcode ) ) { fprintf ( stderr , " \n " , GetLastError ( ) ) ; fflush ( stderr ) ; ks . active = -1 ; } } else if ( ks . active == -1 ) { if ( ! UnregisterHotKey ( keyboard -> hwnd , ks . id ) ) { } it = keyboard -> keystrokes . erase ( it ) -- ; } } } for ( std :: list < keystrok > :: iterator it = g_keyboard_hook . keystrokes . begin ( ) ; it != g_keyboard_hook . keystrokes . end ( ) ; ++ it ) { keystrok ks = ( * it ) ; if ( ks . id == wParam ) { int javaModifiers = 0 ; int javaKeycode = 0 ; javaKeycode = convertWindowsKeycodeToJava ( HIWORD ( lParam ) ) ; javaModifiers = convertWindowsModifiersToJavaUserDefined ( ks . modifiers ) ; notify ( javaKeycode , javaModifiers , false ) ; if ( ks . is_on_key_release ) { setHotkeyRealese ( ks . modifiers , ks . vkcode , javaModifiers , javaKeycode ) ; } return 0 ; } } } return -1 ; }
\brief Called in WndProc to check the event received.
\ brief Called in WndProc to check the event received .
/* hotkey to add */ /* hotkey to remove */ //fprintf(stderr, "[LOOP] Error when UnregisterHotKey: %d\n", GetLastError());fflush(stderr); /* check via hotkey id */ //ks.vkcode);