/*---------------------------------------------------------------------- Main ----------------------------------------------------------------------*/ int main(int argc, char* argv[]) { /* allow I/O from user mode */ syscall_get_io(); Mouse::disable(); Mouse::disableKeyboard(); /* Mouse init */ int mouse = Mouse::init(); if (mouse) { _printf("Mouse init error=%d\n", mouse); return -1; } /* Mouse server initialize */ MouseServer server; if (!server.Initialize()) { syscall_print("Mouse Server: initialize error\n"); return -1; } Mouse::enable(); Mouse::enableKeyboard(); /* we receive MSG_INTERRUPTED from IRQ12 Handler */ syscall_set_irq_receiver(12, 0); if (monapi_name_add("/servers/mouse") != M_OK) { monapi_fatal("monapi_name_add failed"); } /* service start */ server.MessageLoop(); return 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); }
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); }
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 ); }