void Pane::OnHmdTap() { if (m_visible == false) return; const glm::vec2& pc = m_pointerCoords; OnMouseClick(1, static_cast<int>(pc.x), static_cast<int>(pc.y)); OnMouseClick(0, static_cast<int>(pc.x), static_cast<int>(pc.y)); }
BOOL CMapToolView::PreTranslateMessage(MSG* pMsg) { // TODO: 여기에 특수화된 코드를 추가 및/또는 기본 클래스를 호출합니다. switch (pMsg->message) { case WM_KEYDOWN: if( LOWORD(pMsg->lParam) == 1 ) OnKeyPress(LOWORD(pMsg->wParam)); break; case WM_KEYUP: OnKeyRelease(LOWORD(pMsg->wParam)); break; case WM_LBUTTONDOWN: OnMouseClick(LOWORD(pMsg->lParam), HIWORD(pMsg->lParam), 0, LOWORD(pMsg->wParam)); break; case WM_RBUTTONDOWN: OnMouseClick(LOWORD(pMsg->lParam), HIWORD(pMsg->lParam), 1, LOWORD(pMsg->wParam)); break; case WM_MBUTTONDOWN: OnMouseClick(LOWORD(pMsg->lParam), HIWORD(pMsg->lParam), 2, LOWORD(pMsg->wParam)); break; case WM_LBUTTONUP: OnMouseRelease(LOWORD(pMsg->lParam), HIWORD(pMsg->lParam), 0, LOWORD(pMsg->wParam)); break; case WM_RBUTTONUP: OnMouseRelease(LOWORD(pMsg->lParam), HIWORD(pMsg->lParam), 1, LOWORD(pMsg->wParam)); break; case WM_MBUTTONUP: OnMouseRelease(LOWORD(pMsg->lParam), HIWORD(pMsg->lParam), 2, LOWORD(pMsg->wParam)); break; case WM_LBUTTONDBLCLK: OnMouseDoubleClick(LOWORD(pMsg->lParam), HIWORD(pMsg->lParam), 0, LOWORD(pMsg->wParam)); break; case WM_RBUTTONDBLCLK: OnMouseDoubleClick(LOWORD(pMsg->lParam), HIWORD(pMsg->lParam), 1, LOWORD(pMsg->wParam)); break; case WM_MBUTTONDBLCLK: OnMouseDoubleClick(LOWORD(pMsg->lParam), HIWORD(pMsg->lParam), 2, LOWORD(pMsg->wParam)); break; case WM_MOUSEMOVE: OnMouseMove(LOWORD(pMsg->lParam), HIWORD(pMsg->lParam)); break; case WM_MOUSEWHEEL: OnMouseWheel((short)HIWORD(pMsg->wParam), LOWORD(pMsg->wParam)); break; } return CView::PreTranslateMessage(pMsg); }
void dOnMouseClick( const int iMouseType, const float fMouseX, const float fMouseY ) { if (!g_iGameState) { //点击开始,游戏状态为1,isNew = true if (dIsPointInSprite( "startNew", fMouseX, fMouseY )) { isNew = true; g_iGameState = 1; //播放音效 PlaySound(NULL, NULL, SND_PURGE); PlaySound("game/data/audio/whoosh_mono.wav", NULL, SND_ASYNC); } //点击继续,游戏状态为1 else if (dIsPointInSprite( "startOld", fMouseX, fMouseY )) { if (isNew) return; g_iGameState = 1; //播放音效 PlaySound(NULL, NULL, SND_PURGE); PlaySound("game/data/audio/whoosh_mono.wav", NULL, SND_ASYNC); } return; } // 可以在此添加游戏需要的响应函数 OnMouseClick(iMouseType, fMouseX, fMouseY); }
void ds::Gui::IController::Invoke( ds::Gui::Event Event ) { if( !m_Component ) return; switch( Event ) { case EventMouseHover: OnMouseHover( m_Component ); break; case EventMouseHoverEnter: OnMouseHoverEnter( m_Component ); break; case EventMouseHoverQuit: OnMouseHoverQuit( m_Component ); break; case EventMouseClickUp: OnMouseClickUp( m_Component ); break; case EventMouseClick: OnMouseClick( m_Component ); break; case EventMouseClickDown: OnMouseClickDown( m_Component ); break; case EventBackgroundTask: m_IsWorking = true; if( !m_Pause && !OnBackgroundTask( m_Component ) ) m_IsWorking = false; break; } }
bool TextWidget::OnMouseDoubleClick() { switch(m_id) { case BUTTON_MENUEDITQUEST_LOAD: OnMouseClick(); if(pWindowMenu) { for(size_t i = 0; i < pWindowMenu->m_pages.size(); i++) { MenuPage * page = pWindowMenu->m_pages[i]; if(page->eMenuState == EDIT_QUEST_LOAD) { for(size_t j = 0; j < page->m_children.m_widgets.size(); j++) { Widget * widget = page->m_children.m_widgets[j]->GetZoneWithID(BUTTON_MENUEDITQUEST_LOAD_CONFIRM); if(widget) { widget->OnMouseClick(); } } } } } return true; default: return false; } return false; }
LRESULT D3D11App::ProcessMessage(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { PAINTSTRUCT ps; HDC hdc; switch (message) { case WM_PAINT: hdc = BeginPaint(hwnd, &ps); EndPaint(hwnd, &ps); break; case WM_MOUSEMOVE: OnMouseMove(hwnd, GETX(lParam), GETY(lParam), (wParam & MK_LBUTTON) != 0, (wParam & MK_MBUTTON) != 0, (wParam & MK_RBUTTON) != 0); break; case WM_KEYDOWN: if (wParam == VK_ESCAPE) { if (m_mouseCapture) { // Release mouse capture on escape if there is one ... CaptureMouse(false); } else { // ... otherwise exit the application PostMessage(hwnd, WM_CLOSE, 0, 0); } } else { OnKeyPress(hwnd, (unsigned int) wParam, true); } break; case WM_KEYUP: OnKeyPress(hwnd, (unsigned int) wParam, false); break; case WM_SYSKEYDOWN: // Toggle fullscreen on Alt-Enter if ((lParam & (1 << 29)) && wParam == VK_RETURN) { m_context->ToggleFullscreen(); } break; case WM_LBUTTONDOWN: OnMouseClick(hwnd, GETX(lParam), GETY(lParam), MOUSE_LEFT, true); break; case WM_LBUTTONUP: OnMouseClick(hwnd, GETX(lParam), GETY(lParam), MOUSE_LEFT, false); break; case WM_RBUTTONDOWN: OnMouseClick(hwnd, GETX(lParam), GETY(lParam), MOUSE_RIGHT, true); break; case WM_RBUTTONUP: OnMouseClick(hwnd, GETX(lParam), GETY(lParam), MOUSE_RIGHT, false); break; case WM_MBUTTONDOWN: OnMouseClick(hwnd, GETX(lParam), GETY(lParam), MOUSE_MIDDLE, true); break; case WM_MBUTTONUP: OnMouseClick(hwnd, GETX(lParam), GETY(lParam), MOUSE_MIDDLE, false); break; case WM_WINDOWPOSCHANGED: WINDOWPOS *p; p = (WINDOWPOS *) lParam; // Ignore events with SWP_NOSENDCHANGING flag if (p->flags & SWP_NOSENDCHANGING) break; if ((p->flags & SWP_NOMOVE) == 0) { OnPosition(hwnd, p->x, p->y); } if ((p->flags & SWP_NOSIZE) == 0) { RECT rect; GetClientRect(hwnd, &rect); OnSize(hwnd, rect.right - rect.left, rect.bottom - rect.top); } break; case WM_CREATE: ShowWindow(hwnd, SW_SHOW); break; case WM_CLOSE: DestroyWindow(hwnd); break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hwnd, message, wParam, lParam); } return 0; }
void rb::GameScene::Start() { SetBackgroundColour(Colour::darkGrey); asteroidSpawnerPrefab = std::make_unique<GameObject>(); asteroidSpawnerPrefab->AddScript<AsteroidSpawner>(); Instantiate(*asteroidSpawnerPrefab); cannonPrefab = std::make_unique<GameObject>(); cannonPrefab->AddScript<Cannon>(); cannonPrefab->SetTransform(Vec2(Screen::WidthToFloat()*0.5f, 50.0f)); Instantiate(*cannonPrefab); mouseClickEvent = Input::RegisterMouseClickCallback([&](int button, int action, const Vec2& mousePos) {OnMouseClick(button, action, mousePos); }); backgroundPrefab = std::make_unique<GameObject>(TextureManager::GetTexture("Background")); backgroundPrefab->tag = "Background"; backgroundPrefab->SetTransform(Screen::Center(), 0.0f, Screen::GetResolution()); Instantiate(*backgroundPrefab); city1Prefab = std::make_unique<GameObject>(TextureManager::GetTexture("City1")); //city1Prefab->GetTransform()->s Instantiate(*city1Prefab, Vec2(300.0f, 75.0f), 0.0f); }
/*virtual*/ void CMainWnd::WindowMessage(int nMsg, int nParam /*=0*/) { // BIOS::LCD::Printf( 0, 0, RGB565(ff0000), RGB565(ffffff), "%d", BIOS::ADC::GetState() ); if ( nMsg == WmTick ) { if ( m_bSleeping ) return; m_Mouse.Hide(); if ( m_Mouse.Clicked() ) OnMouseClick(); // timers update CWnd::WindowMessage( nMsg, nParam ); bool bEnableSdk = Settings.Runtime.m_bUartSdk ? true : false; #ifdef ENABLE_MONITOR // When the user is in UART monitor screen, do not intercept UART traffic if ( MainWnd.m_wndToolBar.GetCurrentLayout() == &MainWnd.m_wndUserCWndUserMonitor ) bEnableSdk = false; #endif #ifdef ENABLE_MODULE_GPIOTEST if ( MainWnd.m_wndToolBar.GetCurrentLayout() == &MainWnd.m_wndUserCWndGpioTest ) bEnableSdk = false; #endif if ( bEnableSdk ) SdkUartProc(); if ( (Settings.Trig.Sync != CSettings::Trigger::_None) && BIOS::ADC::Enabled() && BIOS::ADC::Ready() ) { // ADC::Ready means that the write pointer is at the end of buffer, we can restart sampler BIOS::ADC::Copy( BIOS::ADC::GetCount() ); BIOS::ADC::Restart(); Resample(); // trig stuff m_lLastAcquired = BIOS::SYS::GetTick(); if ( BIOS::ADC::Enabled() && Settings.Trig.Sync == CSettings::Trigger::_Single ) { BIOS::ADC::Enable( false ); Settings.Trig.State = CSettings::Trigger::_Stop; if ( m_wndMenuInput.m_itmTrig.IsVisible() ) m_wndMenuInput.m_itmTrig.Invalidate(); } // broadcast message for windows that process waveform data WindowMessage( CWnd::WmBroadcast, ToWord('d', 'g') ); } m_Mouse.Show(); return; } if ( nMsg == WmKey ) { if ( m_bSleeping ) { SetTimer( 200 ); m_bSleeping = false; BIOS::SYS::Standby( FALSE ); CCoreOscilloscope::ConfigureAdc(); CCoreGenerator::Update(); m_wndMessage.Hide(); Invalidate(); for ( int i = 0; i < Settings.Runtime.m_nBacklight; i++) { BIOS::SYS::SetBacklight( i ); BIOS::SYS::DelayMs(10); } m_nLastKey = BIOS::SYS::GetTick(); CCoreSettings::Update(); // display backlight return; } m_nLastKey = BIOS::SYS::GetTick(); if ( nParam & ( BIOS::KEY::KeyFunction | BIOS::KEY::KeyFunction2 | BIOS::KEY::KeyS2 | BIOS::KEY::KeyS1 ) ) { m_Mouse.Hide(); if ( nParam == BIOS::KEY::KeyFunction ) CMainWnd::CallShortcut(Settings.Runtime.m_nShortcutCircle); if ( nParam == BIOS::KEY::KeyFunction2 ) CMainWnd::CallShortcut(Settings.Runtime.m_nShortcutTriangle); if ( nParam == BIOS::KEY::KeyS2 ) CMainWnd::CallShortcut(Settings.Runtime.m_nShortcutS2); if ( nParam == BIOS::KEY::KeyS1 ) CMainWnd::CallShortcut(Settings.Runtime.m_nShortcutS1); m_Mouse.Show(); return; } } m_Mouse.Hide(); CWnd::WindowMessage( nMsg, nParam ); m_Mouse.Show(); }
//========================================================================== // // 引擎捕捉鼠标点击消息后,将调用到本函数 // 参数 iMouseType:鼠标按键值,见 enum MouseTypes 定义 // 参数 fMouseX, fMouseY:为鼠标当前坐标 // void dOnMouseClick( const int iMouseType, const float fMouseX, const float fMouseY ) { // 可以在此添加游戏需要的响应函数 OnMouseClick(iMouseType, fMouseX, fMouseY); }
LRESULT CALLBACK Widget::WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { MsgProcResult result; switch(msg) { case WM_PAINT: { PAINTSTRUCT ps; HDC hDC; if(wParam == 0) hDC = BeginPaint(hWnd, &ps); else hDC = (HDC)wParam; Gdiplus::Graphics g(hDC); OnPaint(&g, ps.rcPaint); if(wParam == 0) EndPaint(hWnd, &ps); } break; case WM_LBUTTONDOWN: case WM_RBUTTONDOWN: case WM_MBUTTONDOWN: { mIsMouseDown = true; SetCapture(hWnd); mMouseLastPos = POINT{GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)}; MouseEvent ev(this, mMouseLastPos, 1, wParam, msg == WM_LBUTTONDOWN ? MouseButton::Left : msg == WM_RBUTTONDOWN ? MouseButton::Right : msg == WM_MBUTTONDOWN ? MouseButton::Middle : MouseButton::None); SignalMouseDown.emit(ev); OnMouseDown(ev); } break; case WM_LBUTTONUP: case WM_RBUTTONUP: case WM_MBUTTONUP: { mIsMouseDown = false; ReleaseCapture(); mMouseLastPos = POINT{GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)}; MouseEvent ev(this, mMouseLastPos, 1, wParam, msg == WM_LBUTTONUP ? MouseButton::Left : msg == WM_RBUTTONUP ? MouseButton::Right : msg == WM_MBUTTONUP ? MouseButton::Middle : MouseButton::None); SignalMouseUp.emit(ev); OnMouseUp(ev); if(!mHasDragged) { SignalMouseClick.emit(ev); OnMouseClick(ev); } else mHasDragged = false; } break; case WM_LBUTTONDBLCLK: case WM_MBUTTONDBLCLK: case WM_RBUTTONDBLCLK: { MouseEvent ev(this, POINT{GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)}, 2, wParam, msg == WM_LBUTTONDBLCLK ? MouseButton::Left : msg == WM_MBUTTONDBLCLK ? MouseButton::Right : msg == WM_RBUTTONDBLCLK ? MouseButton::Middle : MouseButton::None); SignalMouseDoubleClick.emit(ev); OnMouseDoubleClick(ev); } break; case WM_MOUSEMOVE: { POINT mouseNewPos = POINT{GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)}; MouseEvent ev(this, mouseNewPos, 0, wParam, MouseButton::None, mMouseLastPos); mMouseLastPos = mouseNewPos; if(mIsMouseDown) { mHasDragged = true; SignalMouseDrag.emit(ev); OnMouseDrag(ev); } else { SignalMouseMove.emit(ev); OnMouseMove(ev); } } break; case WM_MOUSEWHEEL: { POINT pt = POINT{GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)}; ScreenToClient(mhWnd, &pt); MouseEvent ev(this, pt, 0, GET_KEYSTATE_WPARAM(wParam), MouseButton::None, mMouseLastPos, GET_WHEEL_DELTA_WPARAM(wParam)/WHEEL_DELTA); SignalMouseWheel.emit(ev); OnMouseWheel(ev); } break; case WM_SIZE: { int width = LOWORD(lParam); int height = HIWORD(lParam); SignalResize.emit(width, height); if(mLayout) mLayout->Apply(this); OnResize(width, height); } break; case WM_COMMAND: { HWND hCtrl = reinterpret_cast<HWND>(lParam); if(hCtrl != nullptr) { Widget* child = Widget::FromHandle(hCtrl); if(child != nullptr) child->OnCommand(HIWORD(wParam)); } } break; case WM_NOTIFY: { LPNMHDR lpnmhdr = reinterpret_cast<LPNMHDR>(lParam); Widget* child = Widget::FromHandle(lpnmhdr->hwndFrom); if(child != nullptr) result = child->OnNotify(lpnmhdr); } break; } if(result.ReturnDefault()) return CallDefaultProc(hWnd, msg, wParam, lParam); else return result.Value(); }
void Pane::OnHmdTap() { OnMouseClick(1, m_pointerCoords.x, m_pointerCoords.y); OnMouseClick(0, m_pointerCoords.x, m_pointerCoords.y); }
void Application::Run() { // // keyboard // if (keyboard_needs_poll()) poll_keyboard(); for (int k = 0; k < 256; k++) { if (key[k]) { OnKeyPress(k); if (!prevKeyState[k]) OnKeyPressed(k); } else if (!key[k]) { if (prevKeyState[k]) OnKeyReleased(k); } } memcpy(prevKeyState,(char*)key,256); // // mouse // if (mouse_needs_poll()) poll_mouse(); for (int button = 0; button < (numMouseButtons); button++) { if ((mouse_b & (1 << button)) != 0) { mouseButtons[button] = true; } else { mouseButtons[button] = false; } if (mouseButtons[button] && (!prevMouseButtons[button])) { OnMousePressed(button, mouse_x, mouse_y); mousePressedLocs[button].x = mouse_x; mousePressedLocs[button].y = mouse_y; } else if ((!mouseButtons[button]) && prevMouseButtons[button]) { OnMouseReleased(button, mouse_x, mouse_y); if ((mousePressedLocs[button].x == mouse_x) && (mousePressedLocs[button].y == mouse_y)) { OnMouseClick(button,mouse_x,mouse_y); } } } memcpy(prevMouseButtons,mouseButtons,sizeof(bool)*(numMouseButtons+1)); if ((mouse_x != prevMouseX) || (mouse_y != prevMouseY)) { OnMouseMove(mouse_x,mouse_y); prevMouseX = mouse_x; prevMouseY = mouse_y; } // mouse wheel if (mouse_z > prevMouseZ) { OnMouseWheelUp( mouse_x, mouse_y ); prevMouseZ = mouse_z; } else if (mouse_z < prevMouseZ) { OnMouseWheelDown( mouse_x, mouse_y ); prevMouseZ = mouse_z; } // // run the game // show_mouse(NULL); RunGame(); show_mouse(canvas); // // render canvas to the screen // blit(canvas,screen,0,0,0,0,screen->w,screen->h); // // sound polling (to ensure sounds currently playing will keep playing) // SoundOGG::PollSounds(); // // handle timing // HandleTiming(); }
void Slider::Update(float) { SetAllKnobs(ConvertValueToPosition()); ProgressGet(); if (myIsDraggingKnob == true) { MouseManager::GetInstance()->SetInteractiveMode(eInteractive::eRegular); myKnob = myKnobPressed; if (MouseManager::GetInstance()->GetPosition().x > mySlider->GetPosition().x + mySlider->GetSize().x - 0.058f) { myValue = 1.0f; SetAllKnobs(ConvertValueToPosition()); } else if (MouseManager::GetInstance()->GetPosition().x < mySlider->GetPosition().x) { myValue = 0.0f; SetAllKnobs(ConvertValueToPosition()); } else { myKnob->SetPosition({ MouseManager::GetInstance()->GetPosition().x, myKnob->GetPosition().y }); myValue = ConvertPositionToValue(MouseManager::GetInstance()->GetPosition().x); SetAllKnobs(ConvertValueToPosition()); } } else if (myIsHoveringKnob == true && myIsDraggingKnob == false) { myKnob = myKnobHovered; MouseManager::GetInstance()->SetInteractiveMode(eInteractive::eActive); } else { myKnob = myKnobRegular; } if (OnMouseClick() == true) { myIsDraggingKnob = true; // do drag stuff } else { // stop dragging myIsDraggingKnob = false; } if (OnMouseHover() == true) { myIsHoveringKnob = true; } else { if (myIsHoveringKnob == true) { MouseManager::GetInstance()->SetInteractiveMode(eInteractive::eRegular); } myIsHoveringKnob = false; } SliderSpecificUpdate(); ProgressSet(); }
LRESULT CALLBACK CCustomPlayer::_MainWindowWndProc(HWND hWnd,UINT message,WPARAM wParam,LPARAM lParam) { switch(message) { case WM_DROPFILES: // Load any dropped file { char FileName[_MAX_PATH]; HDROP hdrop=(HDROP)wParam; DragQueryFile(hdrop,0,FileName,_MAX_PATH); Reset(); _Load(FileName); _FinishLoad(); break; } case WM_MOUSEMOVE: { // we allow window dragging enabled in the player.ini file ! if (GetPAppStyle()->g_MouseDrag==1) { DoMMove(lParam,wParam); } } case WM_ACTIVATEAPP: { OnActivateApp(wParam); } break; // Minimum size of the player window case WM_GETMINMAXINFO: // this message is not very useful because // the main window of the player is not resizable ... // but perhaps it will change so we manage this message. { CCustomPlayer& player = CCustomPlayer::Instance(); if((LPMINMAXINFO)lParam) { ((LPMINMAXINFO)lParam)->ptMinTrackSize.x=MininumWindowedWidth(); ((LPMINMAXINFO)lParam)->ptMinTrackSize.y=MininumWindowedHeight(); } } break; // Sends a Message "OnClick" or "OnDblClick" if any object is under mouse cursor case WM_LBUTTONDBLCLK: case WM_LBUTTONDOWN: { OnMouseClick(message); // [2/18/2008 mc007] // we allow window dragging enabled in the player.ini file ! if (GetPAppStyle()->g_MouseDrag) { StartMove(lParam); } } break; // Size and focus management case WM_SIZE: // if the window is maximized or minimized // we get/lost focus. { if (wParam==SIZE_MINIMIZED) { OnFocusChange(FALSE); } else if (wParam==SIZE_MAXIMIZED) { OnFocusChange(TRUE); } } break; // Manage system key (ALT + KEY) case WM_SYSKEYDOWN: { // return OnSysKeyDownMainWindow(theApp.m_Config,(int)wParam); } break; // Repaint main frame case WM_PAINT: { OnPaint(); } break; // The main windows has been closed by the user case WM_CLOSE: PostQuitMessage(0); break; // Focus management case WM_KILLFOCUS: case WM_SETFOCUS: { OnFocusChange(message==WM_SETFOCUS); } break; default: return DefWindowProc(hWnd, message, wParam, lParam); } return DefWindowProc(hWnd, message, wParam, lParam); }