示例#1
0
文件: main.cpp 项目: s50/mona
int main(int argc, char* argv[])
{
  logprintf("%s %s:%d\n", __func__, __FILE__, __LINE__);
    syscall_get_io();
  logprintf("%s %s:%d\n", __func__, __FILE__, __LINE__);
    intptr_t ret = monapi_enable_stacktrace("/SERVERS/KEYBDMNG.map");
  logprintf("%s %s:%d\n", __func__, __FILE__, __LINE__);
    if (ret != M_OK) {
        monapi_warn("syscall_stack_trace_enable error %d\n", ret);
        exit(-1);
    }
  logprintf("%s %s:%d\n", __func__, __FILE__, __LINE__);
    /* initilize KeyBoardManager */
    KeyBoardManager manager;
    manager.init();

  logprintf("%s %s:%d\n", __func__, __FILE__, __LINE__);
    if (monapi_notify_server_start("MONITOR.BIN") != M_OK) {
        exit(-1);
    }
  logprintf("%s %s:%d\n", __func__, __FILE__, __LINE__);
    syscall_set_irq_receiver(1, 0);
  logprintf("%s %s:%d\n", __func__, __FILE__, __LINE__);
    if (monapi_name_add("/servers/keyboard") != M_OK) {
        monapi_fatal("monapi_name_add failed");
    }
    KeyboardServer server;
    server.messageLoop(manager);
    return 0;
}
示例#2
0
LRESULT WINAPI MsgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	/*Graphics *pGraphicsWTF = reinterpret_cast<Graphics *>(static_cast<LONG_PTR>(
		::GetWindowLongPtrW(
			hWnd,
			GWLP_USERDATA
			)));
			*/

	switch (msg)
	{
	case WM_DESTROY:
		PostQuitMessage(0);
		break;
		/*
	case WM_SETCURSOR:
	{
		WORD ht = LOWORD(lParam);
		static bool hiddencursor = false;
		if (HTCLIENT == ht && !hiddencursor)
		{
			hiddencursor = true;
			ShowCursor(false);
		}
		else if (HTCLIENT != ht && hiddencursor)
		{
			hiddencursor = false;
			ShowCursor(true);
		}
	}
	break;
	*/
	
		
		// ************ KEYBOARD MESSAGES ************ //
	case WM_KEYDOWN:
		switch (wParam)
		{
		case VK_UP:
			kServ.OnUpPressed();
			break;
		case VK_DOWN:
			kServ.OnDownPressed();
			break;
		case VK_LEFT:
			kServ.OnLeftPressed();
			break;
		case VK_RIGHT:
			kServ.OnRightPressed();
			break;
		case VK_SPACE:
			kServ.OnSpacePressed();
			break;
		case VK_RETURN:
			kServ.OnEnterPressed();
			break;
		case VK_LCONTROL:
			kServ.OnLControlPressed();
			break;
		}
		break;

	case WM_KEYUP:
		switch (wParam)
		{
		case VK_UP:
			kServ.OnUpReleased();
			break;
		case VK_DOWN:
			kServ.OnDownReleased();
			break;
		case VK_LEFT:
			kServ.OnLeftReleased();
			break;
		case VK_RIGHT:
			kServ.OnRightReleased();
			break;
		case VK_SPACE:
			kServ.OnSpaceReleased();
			break;
		case VK_RETURN:
			kServ.OnEnterReleased();
			break;
		case VK_LCONTROL:
			kServ.OnLControlReleased();
			break;
		}	
		break;
		// ************ END KEYBOARD MESSAGES ************ //

		// ************ MOUSE MESSAGES ************ //
	case WM_MOUSEMOVE:
	{
		int x = (short)LOWORD(lParam); 
		int y = (short)HIWORD(lParam); 
		if (x > 0 && x < 1600 && y > 0 && y < 900)
		{
			mServ.OnMouseMove(x, y);
			if (!mServ.IsInWindow())
			{
				SetCapture(hWnd);
				mServ.OnMouseEnter();
			}
		}
		else
		{
			if (wParam & (MK_LBUTTON | MK_RBUTTON))
			{
				x = max(0, x);
				x = min(1599, x);
				y = max(0, y);
				y = min(899, y);
				mServ.OnMouseMove(x, y);
			}
			else
			{
				ReleaseCapture();
				mServ.OnMouseLeave();
				mServ.OnLeftReleased();
				mServ.OnRightReleased();
			}
		}
	}
	break;
	case WM_LBUTTONDOWN:
		mServ.OnLeftPressed();
		//nowyKoniec = true; /////////////////////////////////////////////////
		break;
	case WM_RBUTTONDOWN:
		mServ.OnRightPressed();
		break;
	case WM_LBUTTONUP:
		mServ.OnLeftReleased();
		break;
	case WM_RBUTTONUP:
		mServ.OnRightReleased();
		break;
		// ************ END MOUSE MESSAGES ************ //
	}

	return DefWindowProc(hWnd, msg, wParam, lParam);
}
示例#3
0
LRESULT WINAPI MsgProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	switch (msg)
	{
	case WM_DESTROY:
		PostQuitMessage(0);
		return 0;

		// ************ KEYBOARD MESSAGES ************ //
	case WM_KEYDOWN:
		switch (wParam)
		{
		case VK_UP:
			kServ.OnUpPressed();
			break;
		case VK_DOWN:
			kServ.OnDownPressed();
			break;
		case VK_LEFT:
			kServ.OnLeftPressed();
			break;
		case VK_RIGHT:
			kServ.OnRightPressed();
			break;
		case VK_SPACE:
			kServ.OnSpacePressed();
			break;
		case VK_RETURN:
			kServ.OnEnterPressed();
			break;
		}
		break;
	case WM_KEYUP:
		switch (wParam)
		{
		case VK_UP:
			kServ.OnUpReleased();
			break;
		case VK_DOWN:
			kServ.OnDownReleased();
			break;
		case VK_LEFT:
			kServ.OnLeftReleased();
			break;
		case VK_RIGHT:
			kServ.OnRightReleased();
			break;
		case VK_SPACE:
			kServ.OnSpaceReleased();
			break;
		case VK_RETURN:
			kServ.OnEnterReleased();
			break;
		}
		break;
		// ************ END KEYBOARD MESSAGES ************ //

		// ************ MOUSE MESSAGES ************ //
	case WM_MOUSEMOVE:
	{
		int x = (short)LOWORD(lParam);
		int y = (short)HIWORD(lParam);
		if (x > 0 && x < SCREENWIDTH && y > 0 && y < SCREENHEIGHT)
		{
			mServ.OnMouseMove(x, y);
			if (!mServ.IsInWindow())
			{
				SetCapture(hWnd);
				mServ.OnMouseEnter();
			}
		}
		else
		{
			if (wParam & (MK_LBUTTON | MK_RBUTTON))
			{
				x = max(0, x);
				x = min((SCREENWIDTH - 1), x);
				y = max(0, y);
				y = min((SCREENHEIGHT - 1), y);
				mServ.OnMouseMove(x, y);
			}
			else
			{
				ReleaseCapture();
				mServ.OnMouseLeave();
				mServ.OnLeftReleased();
				mServ.OnRightReleased();
			}
		}
	}
	break;
	case WM_LBUTTONDOWN:
		mServ.OnLeftPressed();
		break;
	case WM_RBUTTONDOWN:
		mServ.OnRightPressed();
		break;
	case WM_LBUTTONUP:
		mServ.OnLeftReleased();
		break;
	case WM_RBUTTONUP:
		mServ.OnRightReleased();
		break;
		// ************ END MOUSE MESSAGES ************ //
	}

	return DefWindowProc(hWnd, msg, wParam, lParam);
}
示例#4
0
LRESULT WINAPI MsgProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
    switch( msg )
    {
        case WM_DESTROY:
            PostQuitMessage( 0 );
            break;

		// ************ KEYBOARD MESSAGES ************ //
		case WM_KEYDOWN:
			if( !( lParam & 0x40000000 ) ) // no thank you on the autorepeat
			{
				kServ.OnKeyPressed( wParam );
			}
			break;
		case WM_KEYUP:
   			kServ.OnKeyReleased( wParam );
			break;
		case WM_CHAR:
			kServ.OnChar( wParam );
			break;
		// ************ END KEYBOARD MESSAGES ************ //

		// ************ MOUSE MESSAGES ************ //
		case WM_MOUSEMOVE:
		{
			int x = (short)LOWORD( lParam );
			int y = (short)HIWORD( lParam );
			if( x > 0 && x < D3DGraphics::SCREENWIDTH && y > 0 && y < D3DGraphics::SCREENHEIGHT )
			{
				mServ.OnMouseMove( x,y );
				if( !mServ.IsInWindow() )
				{
					SetCapture( hWnd );
					mServ.OnMouseEnter();
				}
			}
			else
			{
				if( wParam & (MK_LBUTTON | MK_RBUTTON) )
				{
					x = max( 0,x );
					x = min( D3DGraphics::SCREENWIDTH - 1,x );
					y = max( 0,y );
					y = min( D3DGraphics::SCREENHEIGHT - 1,y );
					mServ.OnMouseMove( x,y );
				}
				else
				{
					ReleaseCapture();
					mServ.OnMouseLeave();
					mServ.OnLeftReleased( x,y );
					mServ.OnRightReleased( x,y );
				}
			}
			break;
		}
		case WM_LBUTTONDOWN:
		{
			int x = (short)LOWORD( lParam );
			int y = (short)HIWORD( lParam );
			mServ.OnLeftPressed( x,y );
			break;
		}
		case WM_RBUTTONDOWN:
		{
			int x = (short)LOWORD( lParam );
			int y = (short)HIWORD( lParam );
			mServ.OnRightPressed( x,y );
			break;
		}
		case WM_LBUTTONUP:
		{
			int x = (short)LOWORD( lParam );
			int y = (short)HIWORD( lParam );
			mServ.OnLeftReleased( x,y );
			break;
		}
		case WM_RBUTTONUP:
		{
			int x = (short)LOWORD( lParam );
			int y = (short)HIWORD( lParam );
			mServ.OnRightReleased( x,y );
			break;
		}
		case WM_MOUSEWHEEL:
		{
			int x = (short)LOWORD( lParam );
			int y = (short)HIWORD( lParam );
			if( GET_WHEEL_DELTA_WPARAM( wParam ) > 0 )
			{
				mServ.OnWheelUp( x,y );
			}
			else if( GET_WHEEL_DELTA_WPARAM( wParam ) < 0 )
			{
				mServ.OnWheelDown( x,y );
			}
			break;
		}
		// ************ END MOUSE MESSAGES ************ //
    }

    return DefWindowProc( hWnd, msg, wParam, lParam );
}
示例#5
0
文件: Windows.cpp 项目: prusso/Code
LRESULT WINAPI MsgProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
    switch( msg )
    {
        case WM_DESTROY:
            PostQuitMessage( 0 );
            return 0;
		case WM_KEYDOWN:
			switch( wParam )
			{
			case VK_UP:
				kServ.OnUpPressed();
				break;
			case VK_DOWN:
				kServ.OnDownPressed();
				break;
			case VK_LEFT:
				kServ.OnLeftPressed();
				break;
			case VK_RIGHT:
				kServ.OnRightPressed();
				break;
			case VK_SPACE:
                kServ.OnSpacePressed();
				break;
			case VK_RETURN:
				kServ.OnEnterPressed();
				break;
			}
			break;
		case WM_KEYUP:
   			switch( wParam )
			{
			case VK_UP:
				kServ.OnUpReleased();
				break;
			case VK_DOWN:
				kServ.OnDownReleased();
				break;
			case VK_LEFT:
				kServ.OnLeftReleased();
				break;
			case VK_RIGHT:
				kServ.OnRightReleased();
				break;
			case VK_SPACE:
				kServ.OnSpaceReleased();
				break;
			case VK_RETURN:
				kServ.OnEnterReleased();
				break;
			}
    }

    return DefWindowProc( hWnd, msg, wParam, lParam );
}