void Module::OnEvent(const SDL_Event& event) { switch (event.type) { case SDL_WINDOWEVENT: { switch (event.window.event) { case SDL_WINDOWEVENT_ENTER: OnMouseFocus(); break; case SDL_WINDOWEVENT_LEAVE: OnMouseBlur(); break; case SDL_WINDOWEVENT_FOCUS_GAINED: OnInputFocus(); break; case SDL_WINDOWEVENT_FOCUS_LOST: OnInputBlur(); break; case SDL_WINDOWEVENT_RESTORED: OnRestore(); break; case SDL_WINDOWEVENT_MINIMIZED: OnMinimize(); break; case SDL_WINDOWEVENT_MAXIMIZED: OnMaximize(); break; case SDL_WINDOWEVENT_EXPOSED: OnExpose(); break; case SDL_WINDOWEVENT_SIZE_CHANGED: OnResize(event.window.data1, event.window.data2); break; default: break; } break; } case SDL_KEYDOWN: if (event.key.repeat) OnKeyRepeat(event.key.keysym); else OnKeyDown(event.key.keysym); break; case SDL_KEYUP: OnKeyUp(event.key.keysym); break; case SDL_MOUSEMOTION: OnMouseMove(event.motion); break; case SDL_MOUSEWHEEL: OnMouseWheel(event.wheel); break; case SDL_MOUSEBUTTONDOWN: OnMouseButtonDown(event.button); break; case SDL_MOUSEBUTTONUP: OnMouseButtonUp(event.button); break; case SDL_JOYAXISMOTION: OnJoyAxis(event.jaxis); break; case SDL_JOYBALLMOTION: OnJoyBall(event.jball); break; case SDL_JOYHATMOTION: OnJoyHat(event.jhat); break; case SDL_JOYBUTTONDOWN: OnJoyButtonDown(event.jbutton); break; case SDL_JOYBUTTONUP: OnJoyButtonUp(event.jbutton); break; case SDL_QUIT: OnExit(); break; case SDL_SYSWMEVENT: break; default: OnUser(event.user);break; } }
void CEvent::OnEvent(SDL_Event* Event) { switch(Event->type) { case SDL_ACTIVEEVENT: { switch(Event->active.state) { case SDL_APPMOUSEFOCUS: { if ( Event->active.gain ) OnMouseFocus(); else OnMouseBlur(); break; } case SDL_APPINPUTFOCUS: { if ( Event->active.gain ) OnInputFocus(); else OnInputBlur(); break; } case SDL_APPACTIVE: { if ( Event->active.gain ) OnRestore(); else OnMinimize(); break; } } break; } case SDL_KEYDOWN: { OnKeyDown(Event->key.keysym.sym,Event->key.keysym.mod,Event->key.keysym.unicode); break; } case SDL_KEYUP: { OnKeyUp(Event->key.keysym.sym,Event->key.keysym.mod,Event->key.keysym.unicode); break; } case SDL_MOUSEMOTION: { OnMouseMove(Event->motion.x,Event->motion.y,Event->motion.xrel,Event->motion.yrel,(Event->motion.state&SDL_BUTTON(SDL_BUTTON_LEFT))!=0,(Event->motion.state&SDL_BUTTON(SDL_BUTTON_RIGHT))!=0,(Event->motion.state&SDL_BUTTON(SDL_BUTTON_MIDDLE))!=0); break; } case SDL_MOUSEBUTTONDOWN: { switch(Event->button.button) { case SDL_BUTTON_LEFT: { OnLButtonDown(Event->button.x,Event->button.y); break; } case SDL_BUTTON_RIGHT: { OnRButtonDown(Event->button.x,Event->button.y); break; } case SDL_BUTTON_MIDDLE: { OnMButtonDown(Event->button.x,Event->button.y); break; } } break; } case SDL_MOUSEBUTTONUP: { switch(Event->button.button) { case SDL_BUTTON_LEFT: { OnLButtonUp(Event->button.x,Event->button.y); break; } case SDL_BUTTON_RIGHT: { OnRButtonUp(Event->button.x,Event->button.y); break; } case SDL_BUTTON_MIDDLE: { OnMButtonUp(Event->button.x,Event->button.y); break; } } break; } case SDL_JOYAXISMOTION: { OnJoyAxis(Event->jaxis.which,Event->jaxis.axis,Event->jaxis.value); break; } case SDL_JOYBALLMOTION: { OnJoyBall(Event->jball.which,Event->jball.ball,Event->jball.xrel,Event->jball.yrel); break; } case SDL_JOYHATMOTION: { OnJoyHat(Event->jhat.which,Event->jhat.hat,Event->jhat.value); break; } case SDL_JOYBUTTONDOWN: { OnJoyButtonDown(Event->jbutton.which,Event->jbutton.button); break; } case SDL_JOYBUTTONUP: { OnJoyButtonUp(Event->jbutton.which,Event->jbutton.button); break; } case SDL_QUIT: { OnExit(); break; } case SDL_SYSWMEVENT: { //Ignore break; } case SDL_VIDEORESIZE: { OnResize(Event->resize.w,Event->resize.h); break; } case SDL_VIDEOEXPOSE: { OnExpose(); break; } default: { OnUser(Event->user.type,Event->user.code,Event->user.data1,Event->user.data2); break; } } }
void Gevents::OnEvent(SDL_Event* Event) { switch(Event->type) { case SDL_KEYDOWN: { OnKeyDown(Event->key.keysym.sym,Event->key.keysym.mod,Event->key.keysym.scancode); break; } case SDL_KEYUP: { OnKeyUp(Event->key.keysym.sym,Event->key.keysym.mod,Event->key.keysym.scancode); break; } case SDL_MOUSEMOTION: { OnMouseMove(Event->motion.x,Event->motion.y,Event->motion.xrel,Event->motion.yrel,(Event->motion.state&SDL_BUTTON(SDL_BUTTON_LEFT))!=0,(Event->motion.state&SDL_BUTTON(SDL_BUTTON_RIGHT))!=0,(Event->motion.state&SDL_BUTTON(SDL_BUTTON_MIDDLE))!=0); break; } case SDL_MOUSEBUTTONDOWN: { switch(Event->button.button) { case SDL_BUTTON_LEFT: { OnLButtonDown(Event->button.x,Event->button.y); OnLButtonDown(Event->button.x, Event->button.y, Event->key.keysym.mod); break; } case SDL_BUTTON_RIGHT: { OnRButtonDown(Event->button.x,Event->button.y); break; } case SDL_BUTTON_MIDDLE: { OnMButtonDown(Event->button.x,Event->button.y); break; } } break; } case SDL_MOUSEBUTTONUP: { switch(Event->button.button) { case SDL_BUTTON_LEFT: { OnLButtonUp(Event->button.x,Event->button.y); break; } case SDL_BUTTON_RIGHT: { OnRButtonUp(Event->button.x,Event->button.y); break; } case SDL_BUTTON_MIDDLE: { OnMButtonUp(Event->button.x,Event->button.y); break; } } break; } case SDL_JOYAXISMOTION: { OnJoyAxis(Event->jaxis.which,Event->jaxis.axis,Event->jaxis.value); break; } case SDL_JOYBALLMOTION: { OnJoyBall(Event->jball.which,Event->jball.ball,Event->jball.xrel,Event->jball.yrel); break; } case SDL_JOYHATMOTION: { OnJoyHat(Event->jhat.which,Event->jhat.hat,Event->jhat.value); break; } case SDL_JOYBUTTONDOWN: { OnJoyButtonDown(Event->jbutton.which,Event->jbutton.button); break; } case SDL_JOYBUTTONUP: { OnJoyButtonUp(Event->jbutton.which,Event->jbutton.button); break; } case SDL_QUIT: { OnExit(); break; } case SDL_SYSWMEVENT: { //Ignore break; } default: { OnUser(Event->user.type,Event->user.code,Event->user.data1,Event->user.data2); break; } } }
void Event::OnEvent(SDL_Event* Event) { switch(Event->type) { case SDL_TEXTINPUT: { OnTextEdit(Event->text.text); break; } case SDL_KEYDOWN: { OnKeyDown(Event->key.keysym.sym, (SDL_Keymod)Event->key.keysym.mod); break; } case SDL_KEYUP: { OnKeyUp(Event->key.keysym.sym, (SDL_Keymod)Event->key.keysym.mod); break; } case SDL_MOUSEMOTION: { OnMouseMove(Event->motion.x,Event->motion.y,Event->motion.xrel,Event->motion.yrel,(Event->motion.state&SDL_BUTTON(SDL_BUTTON_LEFT))!=0,(Event->motion.state&SDL_BUTTON(SDL_BUTTON_RIGHT))!=0,(Event->motion.state&SDL_BUTTON(SDL_BUTTON_MIDDLE))!=0); break; } case SDL_MOUSEBUTTONDOWN: { switch(Event->button.button) { case SDL_BUTTON_LEFT: { OnLButtonDown(Event->button.x,Event->button.y); break; } case SDL_BUTTON_RIGHT: { OnRButtonDown(Event->button.x,Event->button.y); break; } case SDL_BUTTON_MIDDLE: { OnMButtonDown(Event->button.x,Event->button.y); break; } } break; } case SDL_MOUSEBUTTONUP: { switch(Event->button.button) { case SDL_BUTTON_LEFT: { OnLButtonUp(Event->button.x,Event->button.y); break; } case SDL_BUTTON_RIGHT: { OnRButtonUp(Event->button.x,Event->button.y); break; } case SDL_BUTTON_MIDDLE: { OnMButtonUp(Event->button.x,Event->button.y); break; } } break; } case SDL_MOUSEWHEEL: { if(Event->wheel.y > 0) { OnMouseWheel(true, false); } else { OnMouseWheel(false, true); } break; } case SDL_JOYAXISMOTION: { OnJoyAxis(Event->jaxis.which,Event->jaxis.axis,Event->jaxis.value); break; } case SDL_JOYBALLMOTION: { OnJoyBall(Event->jball.which,Event->jball.ball,Event->jball.xrel,Event->jball.yrel); break; } case SDL_JOYHATMOTION: { OnJoyHat(Event->jhat.which,Event->jhat.hat,Event->jhat.value); break; } case SDL_JOYBUTTONDOWN: { OnJoyButtonDown(Event->jbutton.which,Event->jbutton.button); break; } case SDL_JOYBUTTONUP: { OnJoyButtonUp(Event->jbutton.which,Event->jbutton.button); break; } case SDL_QUIT: { OnExit(); break; } case SDL_SYSWMEVENT: { //Ignore break; } default: { OnUser(Event->user.type,Event->user.code,Event->user.data1,Event->user.data2); break; } } }
void CEvent::OnEvent(SDL_Event* Event) { switch(Event->type) { /* case SDL_ACTIVEEVENT: { switch(Event->active.state) { case SDL_APPMOUSEFOCUS: { if ( Event->active.gain) OnMouseFocus(); else OnMouseBlur(); break; } case SDL_APPINPUTFOCUS: { if ( Event->active.gain) OnInputFocus(); else OnInputBlur(); break; } case SDL_APPACTIVE: { if ( Event->active.gain) OnRestore(); else OnMinimize(); break; } } break; } */ case SDL_KEYDOWN: { OnKeyDown(Event->key.keysym.scancode); break; } case SDL_KEYUP: { OnKeyUp(Event->key.keysym.scancode); break; } case SDL_MOUSEMOTION: { OnMouseMove(Event->motion.x,Event->motion.y,Event->motion.xrel,Event->motion.yrel,(Event->motion.state&SDL_BUTTON(SDL_BUTTON_LEFT))!=0,(Event->motion.state&SDL_BUTTON(SDL_BUTTON_RIGHT))!=0,(Event->motion.state&SDL_BUTTON(SDL_BUTTON_MIDDLE))!=0); break; } case SDL_MOUSEBUTTONUP: { switch(Event->button.button) { case SDL_BUTTON_LEFT: { OnLButtonUp(Event->button.x,Event->button.y); break; } case SDL_BUTTON_RIGHT: { OnRButtonUp(Event->button.x,Event->button.y); break; } case SDL_BUTTON_MIDDLE: { OnMButtonUp(Event->button.x,Event->button.y); break; } } break; } case SDL_QUIT: { OnExit(); break; } case SDL_SYSWMEVENT: { //Ignore break; } //case SDL_VIDEORESIZE: { // OnResize(Event->resize.w,Event->resize.h); // break; //} //case SDL_VIDEOEXPOSE: { // OnExpose(); // break; //} default: { OnUser(Event->user.type,Event->user.code,Event->user.data1,Event->user.data2); break; } } }
LRESULT Window::OnMessage(HWND _hWnd, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_CREATE: OnCreate(); return 0; case WM_DESTROY: OnDestroy(); return 0; case WM_SIZE: OnResize({LOWORD(lParam), HIWORD(lParam)}); return 0; case WM_MOUSEMOVE: if (OnMouseMove(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), wParam)) return 0; break; case WM_LBUTTONDOWN: if (OnMouseDown(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))) { /* true returned: message was handled */ ResetUserIdle(); return 0; } break; case WM_LBUTTONUP: if (OnMouseUp(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))) { /* true returned: message was handled */ ResetUserIdle(); return 0; } break; case WM_LBUTTONDBLCLK: if (!double_clicks) /* instead of disabling CS_DBLCLKS (which would affect all instances of a window class), we just translate WM_LBUTTONDBLCLK to WM_LBUTTONDOWN here; this even works for built-in window class such as BUTTON */ return OnMessage(_hWnd, WM_LBUTTONDOWN, wParam, lParam); if (OnMouseDouble(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam))) { /* true returned: message was handled */ ResetUserIdle(); return 0; } break; #ifdef WM_MOUSEWHEEL case WM_MOUSEWHEEL: if (OnMouseWheel(GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), GET_WHEEL_DELTA_WPARAM(wParam))) { /* true returned: message was handled */ ResetUserIdle(); return 0; } break; #endif case WM_KEYDOWN: if (OnKeyDown(wParam)) { /* true returned: message was handled */ ResetUserIdle(); return 0; } break; case WM_KEYUP: if (OnKeyUp(wParam)) { /* true returned: message was handled */ ResetUserIdle(); return 0; } break; case WM_CHAR: if (OnCharacter((TCHAR)wParam)) /* true returned: message was handled */ return 0; break; case WM_COMMAND: if (OnCommand(LOWORD(wParam), HIWORD(wParam))) { /* true returned: message was handled */ ResetUserIdle(); return 0; } break; case WM_CANCELMODE: OnCancelMode(); /* pass on to DefWindowProc(), there may be more to do */ break; case WM_SETFOCUS: OnSetFocus(); /* pass on to DefWindowProc() so the underlying window class knows it's focused */ break; case WM_KILLFOCUS: OnKillFocus(); /* pass on to DefWindowProc() so the underlying window class knows it's not focused anymore */ break; case WM_TIMER: if (OnTimer(*(WindowTimer *)wParam)) return 0; break; case WM_PAINT: if (custom_painting) { PaintCanvas canvas(*this); OnPaint(canvas, canvas.get_dirty()); return 0; } break; case WM_GETDLGCODE: if (OnKeyCheck(wParam)) return DLGC_WANTMESSAGE; break; } if (message >= WM_USER && message <= 0x7FFF && OnUser(message - WM_USER)) return 0; return OnUnhandledMessage(_hWnd, message, wParam, lParam); }
void CEvent::OnEvent(SDL_Event* Event) { switch (Event->type) { case SDL_WINDOWEVENT: { switch (Event->window.event) { case SDL_WINDOWEVENT_ENTER: { OnMouseFocus(); break; } case SDL_WINDOWEVENT_LEAVE: { OnMouseBlur(); break; } case SDL_WINDOWEVENT_FOCUS_GAINED: { OnInputFocus(); break; } //keyboard focus. What is keyboard focus? case SDL_WINDOWEVENT_FOCUS_LOST: { OnInputBlur(); break; } case SDL_WINDOWEVENT_RESTORED: { OnRestore(); break; } case SDL_WINDOWEVENT_MINIMIZED: { OnMinimize(); break; } case SDL_WINDOWEVENT_RESIZED: { OnResize(Event->window.data1, Event->window.data2); break; } case SDL_WINDOWEVENT_EXPOSED: { OnExpose(); break; } case SDL_WINDOWEVENT_CLOSE: { OnExit(); break; } } break; } case SDL_KEYDOWN: { OnKeyDown(Event->key.keysym.sym, Event->key.keysym.mod); break; } case SDL_KEYUP: { OnKeyUp(Event->key.keysym.sym, Event->key.keysym.mod); break; } case SDL_MOUSEMOTION: { OnMouseMove(Event->motion.x, Event->motion.y, Event->motion.xrel, Event->motion.yrel, (Event->motion.state&SDL_BUTTON(SDL_BUTTON_LEFT)) != 0, (Event->motion.state&SDL_BUTTON(SDL_BUTTON_RIGHT)) != 0, (Event->motion.state&SDL_BUTTON(SDL_BUTTON_MIDDLE)) != 0); break; } case SDL_MOUSEBUTTONDOWN: { switch (Event->button.button) { case SDL_BUTTON_LEFT: { OnLButtonDown(Event->button.x, Event->button.y); break; } case SDL_BUTTON_RIGHT: { OnRButtonDown(Event->button.x, Event->button.y); break; } case SDL_BUTTON_MIDDLE: { OnMButtonDown(Event->button.x, Event->button.y); break; } } break; } case SDL_MOUSEBUTTONUP: { switch (Event->button.button) { case SDL_BUTTON_LEFT: { OnLButtonUp(Event->button.x, Event->button.y); break; } case SDL_BUTTON_RIGHT: { OnRButtonUp(Event->button.x, Event->button.y); break; } case SDL_BUTTON_MIDDLE: { OnMButtonUp(Event->button.x, Event->button.y); break; } } break; } case SDL_JOYAXISMOTION: { OnJoyAxis(Event->jaxis.which, Event->jaxis.axis, Event->jaxis.value); break; } case SDL_JOYBALLMOTION: { OnJoyBall(Event->jball.which, Event->jball.ball, Event->jball.xrel, Event->jball.yrel); break; } case SDL_JOYHATMOTION: { OnJoyHat(Event->jhat.which, Event->jhat.hat, Event->jhat.value); break; } case SDL_JOYBUTTONDOWN: { OnJoyButtonDown(Event->jbutton.which, Event->jbutton.button); break; } case SDL_JOYBUTTONUP: { OnJoyButtonUp(Event->jbutton.which, Event->jbutton.button); break; } case SDL_QUIT: { OnExit(); break; } case SDL_SYSWMEVENT: { //Ignore break; } default: { OnUser(Event->user.type, Event->user.code, Event->user.data1, Event->user.data2); break; } } }
//============================================================================== void CEvent::OnEvent(SDL_Event* Event) { switch(Event->type) { case SDL_ACTIVEEVENT: { switch(Event->active.state) {//check to see what event has occured case SDL_APPMOUSEFOCUS: { if ( Event->active.gain ) OnMouseFocus(); else OnMouseBlur(); break; } case SDL_APPINPUTFOCUS: { if ( Event->active.gain ) OnInputFocus(); else OnInputBlur(); break; } case SDL_APPACTIVE: { if ( Event->active.gain ) OnRestore(); else OnMinimize(); break; } } break; } case SDL_KEYDOWN: {//on key down pass in what was pressed OnKeyDown(Event->key.keysym.sym,Event->key.keysym.mod,Event->key.keysym.unicode); break; } case SDL_KEYUP: {//on key up pass in what was depressed OnKeyUp(Event->key.keysym.sym,Event->key.keysym.mod,Event->key.keysym.unicode); break; } case SDL_MOUSEMOTION: {// OnMouseMove(Event->motion.x,Event->motion.y,Event->motion.xrel,Event->motion.yrel,(Event->motion.state&SDL_BUTTON(SDL_BUTTON_LEFT))!=0,(Event->motion.state&SDL_BUTTON(SDL_BUTTON_RIGHT))!=0,(Event->motion.state&SDL_BUTTON(SDL_BUTTON_MIDDLE))!=0); break; } case SDL_MOUSEBUTTONDOWN: {//if the button on the mouse is pressed pass in its x and y switch(Event->button.button) { case SDL_BUTTON_LEFT: { OnLButtonDown(Event->button.x,Event->button.y); break; } case SDL_BUTTON_RIGHT: { OnRButtonDown(Event->button.x,Event->button.y); break; } case SDL_BUTTON_MIDDLE: { OnMButtonDown(Event->button.x,Event->button.y); break; } } break; } case SDL_MOUSEBUTTONUP: { switch(Event->button.button) { case SDL_BUTTON_LEFT: { OnLButtonUp(Event->button.x,Event->button.y); break; } case SDL_BUTTON_RIGHT: { OnRButtonUp(Event->button.x,Event->button.y); break; } case SDL_BUTTON_MIDDLE: { OnMButtonUp(Event->button.x,Event->button.y); break; } } break; } case SDL_JOYAXISMOTION: {//stuff we dont use OnJoyAxis(Event->jaxis.which,Event->jaxis.axis,Event->jaxis.value); break; } case SDL_JOYBALLMOTION: { OnJoyBall(Event->jball.which,Event->jball.ball,Event->jball.xrel,Event->jball.yrel); break; } case SDL_JOYHATMOTION: { OnJoyHat(Event->jhat.which,Event->jhat.hat,Event->jhat.value); break; } case SDL_JOYBUTTONDOWN: { OnJoyButtonDown(Event->jbutton.which,Event->jbutton.button); break; } case SDL_JOYBUTTONUP: { OnJoyButtonUp(Event->jbutton.which,Event->jbutton.button); break; } case SDL_QUIT: {//if SDL is quit then run the exit function OnExit(); break; } //more stufff we dont use case SDL_SYSWMEVENT: { //Ignore break; } case SDL_VIDEORESIZE: { OnResize(Event->resize.w,Event->resize.h); break; } case SDL_VIDEOEXPOSE: { OnExpose(); break; } default: { OnUser(Event->user.type,Event->user.code,Event->user.data1,Event->user.data2); break; } } }