uint8_t __keyPressed() { uint8_t temp; static uint8_t state=START_STATE; //keyHit(); temp=_getKey(); //Serial.println(temp); switch(state) { case START_STATE:{ //Serial.println("START_STATE"); if(temp==STARKEY) { state=SHIFTPRESSED; //==> SHIFTPRESSED temp=NOKEY; //Serial.println(""); } }break; case SHIFTPRESSED:{ //Serial.println(temp+10); temp+=10; // next key layer state=START_STATE; //==> START_STATE }break; } return temp; }
void GLWidget::keyReleaseEvent( QKeyEvent* qevent ) { if( !_eventHandler ) return; WindowEvent* windowEvent = new WindowEvent; windowEvent->eq::Event::type = Event::KEY_RELEASE; windowEvent->keyRelease.key = _getKey( *qevent ); QApplication::postEvent( _eventHandler, windowEvent ); }
void GLWidget::keyPressEvent( QKeyEvent* qevent ) { if( !_eventHandler ) return; WindowEvent* windowEvent = new WindowEvent; windowEvent->eq::Event::type = Event::KEY_PRESS; windowEvent->keyPress.key = _getKey( *qevent ); QApplication::postEvent( _eventHandler, windowEvent ); }
void EventHandler::_processEvent( WindowEvent& event ) { LB_TS_THREAD( _thread ); XEvent& xEvent = event.xEvent; XID drawable = xEvent.xany.window; if( _window->getXDrawable() != drawable ) return; switch( xEvent.type ) { case Expose: if( xEvent.xexpose.count ) // Only report last expose event return; event.type = Event::WINDOW_EXPOSE; break; case ConfigureNotify: event.type = Event::WINDOW_RESIZE; _getWindowSize( xEvent.xany.display, drawable, event.resize ); break; case UnmapNotify: event.type = Event::WINDOW_HIDE; _getWindowSize( xEvent.xany.display, drawable, event.resize ); break; case MapNotify: event.type = Event::WINDOW_SHOW; _getWindowSize( xEvent.xany.display, drawable, event.resize ); break; case ClientMessage: { #ifdef EQUALIZER_USE_MAGELLAN_GLX spnav_event spev; /* spacenav event */ if( spnav_x11_event( &xEvent, &spev )) { switch( spev.type ) { case SPNAV_EVENT_MOTION: event.type = Event::MAGELLAN_AXIS; event.magellan.xAxis = spev.motion.x; event.magellan.yAxis = spev.motion.y; event.magellan.zAxis = -spev.motion.z; event.magellan.xRotation = -spev.motion.rx; event.magellan.yRotation = -spev.motion.ry; event.magellan.zRotation = spev.motion.rz; break; case SPNAV_EVENT_BUTTON: event.type = Event::MAGELLAN_BUTTON; event.magellan.buttons = spev.button.press; event.magellan.button = spev.button.bnum; break; default: LBUNIMPLEMENTED; return; } /* remove any other queued motion events */ //? spnav_remove_events( SPNAV_EVENT_MOTION ); break; } #endif Atom deleteAtom = XInternAtom( xEvent.xany.display, "WM_DELETE_WINDOW", False ); if( static_cast<Atom>( xEvent.xclient.data.l[0] ) != deleteAtom ) return; // not a delete message, ignore. } // else: delete message, fall through case DestroyNotify: event.type = Event::WINDOW_CLOSE; break; case MotionNotify: event.type = Event::WINDOW_POINTER_MOTION; event.pointerMotion.x = xEvent.xmotion.x; event.pointerMotion.y = xEvent.xmotion.y; event.pointerMotion.buttons = _getButtonState( xEvent ); event.pointerMotion.button = PTR_BUTTON_NONE; _computePointerDelta( event ); break; case ButtonPress: event.type = Event::WINDOW_POINTER_BUTTON_PRESS; event.pointerButtonPress.x = xEvent.xbutton.x; event.pointerButtonPress.y = xEvent.xbutton.y; event.pointerButtonPress.buttons = _getButtonState( xEvent ); event.pointerButtonPress.button = _getButtonAction( xEvent ); // Translate wheel events switch( event.pointerButtonPress.button ) { case PTR_BUTTON4: event.pointerWheel.yAxis = 1; break; case PTR_BUTTON5: event.pointerWheel.yAxis = -1; break; case PTR_BUTTON6: event.pointerWheel.xAxis = 1; break; case PTR_BUTTON7: event.pointerWheel.xAxis = -1; break; } switch( event.pointerButtonPress.button ) { case PTR_BUTTON4: case PTR_BUTTON5: case PTR_BUTTON6: case PTR_BUTTON7: event.type = Event::WINDOW_POINTER_WHEEL; event.pointerWheel.button = PTR_BUTTON_NONE; } _computePointerDelta( event ); break; case ButtonRelease: event.type = Event::WINDOW_POINTER_BUTTON_RELEASE; event.pointerButtonRelease.x = xEvent.xbutton.x; event.pointerButtonRelease.y = xEvent.xbutton.y; event.pointerButtonRelease.buttons = _getButtonState( xEvent ); event.pointerButtonRelease.button = _getButtonAction( xEvent); _computePointerDelta( event ); break; case KeyPress: event.type = Event::KEY_PRESS; event.keyPress.key = _getKey( xEvent ); break; case KeyRelease: event.type = Event::KEY_RELEASE; event.keyPress.key = _getKey( xEvent ); break; case ReparentNotify: case VisibilityNotify: event.type = Event::UNKNOWN; LBVERB << "Ignored X event, type " << xEvent.type << std::endl; break; default: event.type = Event::UNKNOWN; LBWARN << "Unhandled X event, type " << xEvent.type << std::endl; break; } _window->processEvent( event ); }
void GLXEventHandler::_processEvent( GLXWindowEvent& event ) { EQ_TS_THREAD( _thread ); XEvent& xEvent = event.xEvent; XID drawable = xEvent.xany.window; if( _window->getXDrawable() != drawable ) return; Window* window = _window->getWindow(); switch( xEvent.type ) { case Expose: if( xEvent.xexpose.count ) // Only report last expose event return; event.type = Event::WINDOW_EXPOSE; break; case ConfigureNotify: event.type = Event::WINDOW_RESIZE; _getWindowSize( xEvent.xany.display, drawable, event.resize ); break; case UnmapNotify: event.type = Event::WINDOW_HIDE; _getWindowSize( xEvent.xany.display, drawable, event.resize ); break; case MapNotify: event.type = Event::WINDOW_SHOW; _getWindowSize( xEvent.xany.display, drawable, event.resize ); break; case ClientMessage: { Atom deleteAtom = XInternAtom( xEvent.xany.display, "WM_DELETE_WINDOW", False ); if( static_cast<Atom>( xEvent.xclient.data.l[0] ) != deleteAtom ) return; // not a delete message, ignore. } // else: delete message, fall through case DestroyNotify: event.type = Event::WINDOW_CLOSE; break; case MotionNotify: event.type = Event::WINDOW_POINTER_MOTION; event.pointerMotion.x = xEvent.xmotion.x; event.pointerMotion.y = xEvent.xmotion.y; event.pointerMotion.buttons = _getButtonState( xEvent ); event.pointerMotion.button = PTR_BUTTON_NONE; _computePointerDelta( window, event ); _getRenderContext( window, event ); break; case ButtonPress: event.type = Event::WINDOW_POINTER_BUTTON_PRESS; event.pointerButtonPress.x = xEvent.xbutton.x; event.pointerButtonPress.y = xEvent.xbutton.y; event.pointerButtonPress.buttons = _getButtonState( xEvent ); event.pointerButtonPress.button = _getButtonAction( xEvent ); // Translate wheel events switch( event.pointerButtonPress.button ) { case PTR_BUTTON4: event.pointerWheel.xAxis = 1; break; case PTR_BUTTON5: event.pointerWheel.xAxis = -1; break; case PTR_BUTTON6: event.pointerWheel.yAxis = 1; break; case PTR_BUTTON7: event.pointerWheel.yAxis = -1; break; } switch( event.pointerButtonPress.button ) { case PTR_BUTTON4: case PTR_BUTTON5: case PTR_BUTTON6: case PTR_BUTTON7: event.type = Event::WINDOW_POINTER_WHEEL; event.pointerWheel.button = PTR_BUTTON_NONE; } _computePointerDelta( window, event ); _getRenderContext( window, event ); break; case ButtonRelease: event.type = Event::WINDOW_POINTER_BUTTON_RELEASE; event.pointerButtonRelease.x = xEvent.xbutton.x; event.pointerButtonRelease.y = xEvent.xbutton.y; event.pointerButtonRelease.buttons = _getButtonState( xEvent ); event.pointerButtonRelease.button = _getButtonAction( xEvent); _computePointerDelta( window, event ); _getRenderContext( window, event ); break; case KeyPress: event.type = Event::KEY_PRESS; event.keyPress.key = _getKey( xEvent ); break; case KeyRelease: event.type = Event::KEY_RELEASE; event.keyPress.key = _getKey( xEvent ); break; case ReparentNotify: case VisibilityNotify: event.type = Event::UNKNOWN; EQINFO << "Ignored X event, type " << xEvent.type << std::endl; break; default: event.type = Event::UNKNOWN; EQWARN << "Unhandled X event, type " << xEvent.type << std::endl; break; } event.originator = window->getID(); event.serial = window->getSerial(); _window->processEvent( event ); }
bool EventHandler::_processEvent( const XEvent& event ) { LB_TS_THREAD( _thread ); XID drawable = event.xany.window; if( _window->getXDrawable() != drawable ) return false; switch( event.type ) { case Expose: if( event.xexpose.count ) // Only report last expose event return true; return _window->processEvent( EVENT_WINDOW_EXPOSE, event ); case ConfigureNotify: { SizeEvent sizeEvent; _getWindowSize( event.xany.display, drawable, sizeEvent ); return _window->processEvent( EVENT_WINDOW_RESIZE, event, sizeEvent ); } case UnmapNotify: { SizeEvent sizeEvent; _getWindowSize( event.xany.display, drawable, sizeEvent ); return _window->processEvent( EVENT_WINDOW_HIDE, event, sizeEvent ); } case MapNotify: { SizeEvent sizeEvent; _getWindowSize( event.xany.display, drawable, sizeEvent ); return _window->processEvent( EVENT_WINDOW_SHOW, event, sizeEvent ); } case ClientMessage: { #ifdef EQUALIZER_USE_MAGELLAN_GLX spnav_event spev; if( spnav_x11_event( &event, &spev )) // spacenav event { switch( spev.type ) { case SPNAV_EVENT_MOTION: { AxisEvent axisEvent; axisEvent.xAxis = spev.motion.x; axisEvent.yAxis = spev.motion.y; axisEvent.zAxis = -spev.motion.z; axisEvent.xRotation = -spev.motion.rx; axisEvent.yRotation = -spev.motion.ry; axisEvent.zRotation = spev.motion.rz; return _window->processEvent( event, axisEvent ); } case SPNAV_EVENT_BUTTON: { ButtonEvent buttonEvent; buttonEvent.buttons = spev.button.press; buttonEvent.button = spev.button.bnum; return _window->processEvent( event, buttonEvent ); } default: LBUNIMPLEMENTED; return false; } break; } #endif Atom deleteAtom = XInternAtom( event.xany.display, "WM_DELETE_WINDOW", False ); if( static_cast<Atom>( event.xclient.data.l[0] ) != deleteAtom ) return false; // not a delete message, ignore. } // else: delete message, fall through case DestroyNotify: return _window->processEvent( EVENT_WINDOW_CLOSE, event ); case MotionNotify: { PointerEvent pointerEvent; pointerEvent.x = event.xmotion.x; pointerEvent.y = event.xmotion.y; pointerEvent.buttons = _getButtonState( event ); pointerEvent.button = PTR_BUTTON_NONE; pointerEvent.modifiers = _getKeyModifiers( event.xbutton.state ); _computePointerDelta( EVENT_WINDOW_POINTER_MOTION, pointerEvent ); return _window->processEvent( EVENT_WINDOW_POINTER_MOTION, event, pointerEvent ); } case ButtonPress: { PointerEvent pointerEvent; pointerEvent.x = event.xbutton.x; pointerEvent.y = event.xbutton.y; pointerEvent.buttons = _getButtonState( event ); pointerEvent.button = _getButtonAction( event ); pointerEvent.modifiers = _getKeyModifiers( event.xbutton.state ); switch( pointerEvent.button ) // Translate wheel events { case PTR_BUTTON4: pointerEvent.yAxis = 1; break; case PTR_BUTTON5: pointerEvent.yAxis = -1; break; case PTR_BUTTON6: pointerEvent.xAxis = 1; break; case PTR_BUTTON7: pointerEvent.xAxis = -1; break; } switch( pointerEvent.button ) { case PTR_BUTTON4: case PTR_BUTTON5: case PTR_BUTTON6: case PTR_BUTTON7: pointerEvent.button = PTR_BUTTON_NONE; _computePointerDelta( EVENT_WINDOW_POINTER_WHEEL, pointerEvent ); return _window->processEvent( EVENT_WINDOW_POINTER_WHEEL, event, pointerEvent ); } _computePointerDelta( EVENT_WINDOW_POINTER_BUTTON_PRESS, pointerEvent ); return _window->processEvent( EVENT_WINDOW_POINTER_BUTTON_PRESS, event, pointerEvent ); } case ButtonRelease: { PointerEvent pointerEvent; pointerEvent.x = event.xbutton.x; pointerEvent.y = event.xbutton.y; pointerEvent.buttons = _getButtonState( event ); pointerEvent.button = _getButtonAction( event); pointerEvent.modifiers = _getKeyModifiers( event.xbutton.state ); _computePointerDelta( EVENT_WINDOW_POINTER_BUTTON_RELEASE, pointerEvent ); return _window->processEvent( EVENT_WINDOW_POINTER_BUTTON_RELEASE, event, pointerEvent ); } case KeyPress: { KeyEvent keyEvent; keyEvent.key = _getKey( event ); keyEvent.modifiers = _getKeyModifiers( event.xkey.state ); return _window->processEvent( EVENT_KEY_PRESS, event, keyEvent ); } case KeyRelease: { KeyEvent keyEvent; keyEvent.key = _getKey( event ); keyEvent.modifiers = _getKeyModifiers( event.xkey.state ); return _window->processEvent( EVENT_KEY_RELEASE, event, keyEvent ); } default: LBWARN << "Unhandled X event, type " << event.type << std::endl; // no break; case ReparentNotify: case VisibilityNotify: return _window->processEvent( EVENT_UNKNOWN, event ); } }
void EventHandler::_processEvents( const Proxy* proxy ) { LB_TS_THREAD( _thread ); if( !_proxy || (proxy && _proxy != proxy )) return; Channel& channel = _proxy->getChannel(); const PixelViewport& pvp = channel.getPixelViewport(); Window* window = channel.getWindow(); while( _proxy->hasNewEvent( )) { ::deflect::Event deflectEvent = _proxy->getEvent(); if( deflectEvent.type == ::deflect::Event::EVT_CLOSE ) { _proxy->stopRunning(); ConfigEvent configEvent; configEvent.data.type = Event::EXIT; window->getConfig()->sendEvent( configEvent ); break; } Event event; event.originator = channel.getID(); event.serial = channel.getSerial(); event.type = Event::UNKNOWN; const float x = deflectEvent.mouseX * pvp.w; const float y = deflectEvent.mouseY * pvp.h; if( _proxy-> getNavigationMode() == Proxy::MODE_PAN ) std::swap( deflectEvent.mouseLeft, deflectEvent.mouseRight ); switch( deflectEvent.type ) { case ::deflect::Event::EVT_KEY_PRESS: case ::deflect::Event::EVT_KEY_RELEASE: event.type = deflectEvent.type == ::deflect::Event::EVT_KEY_PRESS ? Event::KEY_PRESS : Event::KEY_RELEASE; event.keyPress.key = _getKey( deflectEvent.key ); break; case ::deflect::Event::EVT_PRESS: case ::deflect::Event::EVT_RELEASE: event.type = deflectEvent.type == ::deflect::Event::EVT_PRESS ? Event::CHANNEL_POINTER_BUTTON_PRESS : Event::CHANNEL_POINTER_BUTTON_RELEASE; event.pointerButtonPress.x = x; event.pointerButtonPress.y = y; if( deflectEvent.mouseLeft ) event.pointerButtonPress.buttons |= PTR_BUTTON1; if( deflectEvent.mouseMiddle ) event.pointerButtonPress.buttons |= PTR_BUTTON2; if( deflectEvent.mouseRight ) event.pointerButtonPress.buttons |= PTR_BUTTON3; event.pointerButtonPress.button = event.pointerButtonPress.buttons; _computePointerDelta( event ); break; case ::deflect::Event::EVT_DOUBLECLICK: break; case ::deflect::Event::EVT_MOVE: event.type = Event::CHANNEL_POINTER_MOTION; event.pointerMotion.x = x; event.pointerMotion.y = y; if( deflectEvent.mouseLeft ) event.pointerButtonPress.buttons |= PTR_BUTTON1; if( deflectEvent.mouseMiddle ) event.pointerButtonPress.buttons |= PTR_BUTTON2; if( deflectEvent.mouseRight ) event.pointerButtonPress.buttons |= PTR_BUTTON3; event.pointerMotion.button = event.pointerMotion.buttons; event.pointerMotion.dx = deflectEvent.dx * pvp.w; event.pointerMotion.dy = deflectEvent.dy * pvp.h; break; case ::deflect::Event::EVT_WHEEL: event.type = Event::CHANNEL_POINTER_WHEEL; event.pointerWheel.x = x; event.pointerWheel.y = pvp.h - y; event.pointerWheel.buttons = PTR_BUTTON_NONE; event.pointerWheel.xAxis = deflectEvent.dx / 40.f; event.pointerWheel.yAxis = deflectEvent.dy / 40.f; event.pointerMotion.dx = -deflectEvent.dx; event.pointerMotion.dy = -deflectEvent.dy; break; case ::deflect::Event::EVT_TAP_AND_HOLD: { const Proxy::NavigationMode mode = _proxy->getNavigationMode() == Proxy::MODE_PAN ? Proxy::MODE_ROTATE : Proxy::MODE_PAN; _proxy->setNavigationMode( mode ); Event windowEvent; windowEvent.originator = window->getID(); windowEvent.serial = window->getSerial(); windowEvent.type = Event::WINDOW_EXPOSE; window->processEvent( windowEvent ); } break; case ::deflect::Event::EVT_NONE: default: break; } if( event.type != Event::UNKNOWN ) { // TODO: compute and use window x,y coordinates if( !window->getRenderContext( x, y, event.context )) LBVERB << "No rendering context for pointer event at " << x << ", " << y << std::endl; channel.processEvent( event ); } } }
Event<eq::KeyEvent>::Event(const QEvent* from) : type(_getType(from)) { const QKeyEvent* qevent = static_cast<const QKeyEvent*>(from); event.key = _getKey(*qevent); }
#include "lzma/LzmaDec.h" } #include <vector> #include <algorithm> const char* _getKey() { const char* p = "f0a193d50ade553e9835595f5cd75ddd"; static char sztemp[64] = {0}; strcpy( sztemp, p ); sztemp[1] += 5; return sztemp; } //std::string CCCrypto::m_sKey = CCCrypto::fromHex("f5a193d50ade553e9835595f5cd75ddd"); std::string CCCrypto::m_sKey = CCCrypto::fromHex(_getKey()); //NS_CC_EXTRA_BEGIN int CCCrypto::encodeBase64Len(const char* input, int inputLength) { return Base64encode_len(inputLength); } int CCCrypto::encodeBase64(const char* input, int inputLength, char* output, int outputBufferLength) { CCAssert(Base64encode_len(inputLength) <= outputBufferLength, "CCCrypto::encodeBase64() - outputBufferLength too small"); return Base64encode(output, input, inputLength); }
LRESULT CALLBACK EventHandler::_wndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { case WM_SHOWWINDOW: { SizeEvent sizeEvent; _getWindowSize(hWnd, sizeEvent); EventType type = wParam == TRUE ? EVENT_WINDOW_SHOW : EVENT_WINDOW_HIDE; if (_window->processEvent(type, sizeEvent)) return TRUE; break; } case WM_CREATE: case WM_SIZE: case WM_MOVE: case WM_WINDOWPOSCHANGED: { SizeEvent sizeEvent; _getWindowSize(hWnd, sizeEvent); const bool hasArea = (sizeEvent.w > 0 && sizeEvent.h > 0); const PixelViewport& pvp = _window->getPixelViewport(); // No show/hide events on Win32?: Emulate. EventType type; if (!hasArea && pvp.hasArea()) type = EVENT_WINDOW_HIDE; else if (hasArea && !pvp.hasArea()) type = EVENT_WINDOW_SHOW; else type = EVENT_WINDOW_RESIZE; if (_window->processEvent(type, sizeEvent)) return TRUE; break; } case WM_CLOSE: case WM_DESTROY: { if (_window->processEvent(EVENT_WINDOW_CLOSE)) return TRUE; break; } case WM_PAINT: { if (GetUpdateRect(hWnd, 0, false) == 0) // No 'expose' return DefWindowProc(hWnd, uMsg, wParam, lParam); if (_window->processEvent(EVENT_WINDOW_EXPOSE)) return TRUE; break; } case WM_MOUSEMOVE: { _syncButtonState(wParam); PointerEvent pointerEvent; pointerEvent.x = GET_X_LPARAM(lParam); pointerEvent.y = GET_Y_LPARAM(lParam); pointerEvent.buttons = _buttonState; _computePointerDelta(EVENT_WINDOW_POINTER_MOTION, pointerEvent); if (_window->processEvent(EVENT_WINDOW_POINTER_MOTION, pointerEvent)) return TRUE; break; } case WM_LBUTTONDOWN: if (_mouseButtonPress(PTR_BUTTON1, lParam)) return TRUE; break; case WM_RBUTTONDOWN: if (_mouseButtonPress(PTR_BUTTON2, lParam)) return TRUE; break; case WM_MBUTTONDOWN: if (_mouseButtonPress(PTR_BUTTON3, lParam)) return TRUE; break; case WM_XBUTTONDOWN: { const PointerButton button = GET_XBUTTON_WPARAM(wParam) & XBUTTON1 ? PTR_BUTTON4 : PTR_BUTTON5; _syncButtonState(GET_XBUTTON_WPARAM(wParam)); if (_mouseButtonPress(button, lParam)) return TRUE; break; } case WM_LBUTTONUP: if (_mouseButtonRelease(PTR_BUTTON1, lParam)) return TRUE; break; case WM_RBUTTONUP: if (_mouseButtonRelease(PTR_BUTTON2, lParam)) return TRUE; break; case WM_MBUTTONUP: if (_mouseButtonRelease(PTR_BUTTON3, lParam)) return TRUE; break; case WM_XBUTTONUP: { const PointerButton button = GET_XBUTTON_WPARAM(wParam) & XBUTTON1 ? PTR_BUTTON4 : PTR_BUTTON5; _syncButtonState(GET_XBUTTON_WPARAM(wParam)); if (_mouseButtonRelease(button, lParam)) return TRUE; break; } case WM_MOUSEWHEEL: { PointerEvent pointerEvent; pointerEvent.x = GET_X_LPARAM(lParam); pointerEvent.y = GET_Y_LPARAM(lParam); pointerEvent.buttons = _buttonState; pointerEvent.modifiers = _getKeyModifiers(); pointerEvent.yAxis = _getWheelDelta(wParam); pointerEvent.button = PTR_BUTTON_NONE; _computePointerDelta(EVENT_WINDOW_POINTER_WHEEL, pointerEvent); if (_window->processEvent(EVENT_WINDOW_POINTER_WHEEL, pointerEvent)) return TRUE; break; } #ifdef WM_MOUSEHWHEEL // only available on vista or later case WM_MOUSEHWHEEL: { PointerEvent pointerEvent; pointerEvent.x = GET_X_LPARAM(lParam); pointerEvent.y = GET_Y_LPARAM(lParam); pointerEvent.buttons = _buttonState; pointerEvent.modifiers = _getKeyModifiers(); pointerEvent.xAxis = _getWheelDelta(wParam); pointerEvent.button = PTR_BUTTON_NONE; _computePointerDelta(EVENT_WINDOW_POINTER_WHEEL, pointerEvent); if (_window->processEvent(EVENT_WINDOW_POINTER_WHEEL, pointerEvent)) return TRUE; break; } #endif case WM_SYSKEYDOWN: case WM_KEYDOWN: { KeyEvent keyEvent; keyEvent.key = _getKey(lParam, wParam); keyEvent.modifiers = _getKeyModifiers(); if (_window->processEvent(EVENT_KEY_PRESS, keyEvent)) return TRUE; break; } case WM_SYSKEYUP: case WM_KEYUP: { KeyEvent keyEvent; keyEvent.key = _getKey(lParam, wParam); keyEvent.modifiers = _getKeyModifiers(); if (_window->processEvent(EVENT_KEY_RELEASE, keyEvent)) return TRUE; break; } case WM_SYSCOMMAND: switch (wParam) { case SC_MONITORPOWER: case SC_SCREENSAVE: if (lParam >= 0) // request off { if (_window->processEvent(EVENT_WINDOW_SCREENSAVER)) return TRUE; break; } // else no break; fall through default: _window->processEvent(EVENT_UNKNOWN); LBVERB << "Unhandled system command 0x" << std::hex << wParam << std::dec << std::endl; break; } break; #ifdef EQUALIZER_USE_MAGELLAN case WM_INPUT: _magellanEventHandler(lParam); break; #endif default: _window->processEvent(EVENT_UNKNOWN); LBVERB << "Unhandled message 0x" << std::hex << uMsg << std::dec << std::endl; break; } return CallWindowProc(_prevWndProc, hWnd, uMsg, wParam, lParam); }
LRESULT CALLBACK EventHandler::_wndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam ) { WindowEvent event; event.uMsg = uMsg; event.wParam = wParam; event.lParam = lParam; event.time = _window->getConfig()->getTime(); eq::Window* const window = _window->getWindow(); LONG result = 0; switch( uMsg ) { case WM_SHOWWINDOW: if( wParam == TRUE ) event.type = Event::WINDOW_SHOW; else event.type = Event::WINDOW_HIDE; _getWindowSize( hWnd, event.resize ); break; case WM_CREATE: case WM_SIZE: case WM_MOVE: case WM_WINDOWPOSCHANGED: { _getWindowSize( hWnd, event.resize ); const bool hasArea = (event.resize.w >0 && event.resize.h > 0); const PixelViewport& pvp = window->getPixelViewport(); // No show/hide events on Win32?: Emulate. if( !hasArea && pvp.hasArea( )) event.type = Event::WINDOW_HIDE; else if( hasArea && !pvp.hasArea( )) event.type = Event::WINDOW_SHOW; else event.type = Event::WINDOW_RESIZE; break; } case WM_CLOSE: case WM_DESTROY: event.type = Event::WINDOW_CLOSE; break; case WM_PAINT: { if( GetUpdateRect( hWnd, 0, false ) == 0 ) // No 'expose' return DefWindowProc( hWnd, uMsg, wParam, lParam ); event.type = Event::WINDOW_EXPOSE; break; } case WM_MOUSEMOVE: { _syncButtonState( wParam ); event.type = Event::WINDOW_POINTER_MOTION; event.pointerMotion.x = GET_X_LPARAM( lParam ); event.pointerMotion.y = GET_Y_LPARAM( lParam ); event.pointerMotion.buttons = _buttonState; _computePointerDelta( window, event ); _getRenderContext( window, event ); break; } case WM_LBUTTONDOWN: _buttonState |= PTR_BUTTON1; event.type = Event::WINDOW_POINTER_BUTTON_PRESS; event.pointerButtonPress.x = GET_X_LPARAM( lParam ); event.pointerButtonPress.y = GET_Y_LPARAM( lParam ); event.pointerButtonPress.buttons = _buttonState; event.pointerButtonPress.button = PTR_BUTTON1; _computePointerDelta( window, event ); _getRenderContext( window, event ); break; case WM_MBUTTONDOWN: _buttonState |= PTR_BUTTON2; event.type = Event::WINDOW_POINTER_BUTTON_PRESS; event.pointerButtonPress.x = GET_X_LPARAM( lParam ); event.pointerButtonPress.y = GET_Y_LPARAM( lParam ); event.pointerButtonPress.buttons = _buttonState; event.pointerButtonPress.button = PTR_BUTTON2; _computePointerDelta( window, event ); _getRenderContext( window, event ); break; case WM_RBUTTONDOWN: _buttonState |= PTR_BUTTON3; event.type = Event::WINDOW_POINTER_BUTTON_PRESS; event.pointerButtonPress.x = GET_X_LPARAM( lParam ); event.pointerButtonPress.y = GET_Y_LPARAM( lParam ); event.pointerButtonPress.buttons = _buttonState; event.pointerButtonPress.button = PTR_BUTTON3; _computePointerDelta( window, event ); _getRenderContext( window, event ); break; case WM_XBUTTONDOWN: event.type = Event::WINDOW_POINTER_BUTTON_PRESS; event.pointerButtonPress.x = GET_X_LPARAM( lParam ); event.pointerButtonPress.y = GET_Y_LPARAM( lParam ); if( GET_XBUTTON_WPARAM( wParam ) & XBUTTON1 ) event.pointerButtonRelease.button = PTR_BUTTON4; else event.pointerButtonRelease.button = PTR_BUTTON5; _buttonState |= event.pointerButtonPress.button; _syncButtonState( GET_KEYSTATE_WPARAM( wParam )); event.pointerButtonPress.buttons = _buttonState; _computePointerDelta( window, event ); _getRenderContext( window, event ); result = TRUE; break; case WM_LBUTTONUP: _buttonState &= ~PTR_BUTTON1; event.type = Event::WINDOW_POINTER_BUTTON_RELEASE; event.pointerButtonRelease.x = GET_X_LPARAM( lParam ); event.pointerButtonRelease.y = GET_Y_LPARAM( lParam ); event.pointerButtonRelease.buttons = _buttonState; event.pointerButtonRelease.button = PTR_BUTTON1; _computePointerDelta( window, event ); _getRenderContext( window, event ); break; case WM_MBUTTONUP: _buttonState &= ~PTR_BUTTON2; event.type = Event::WINDOW_POINTER_BUTTON_RELEASE; event.pointerButtonRelease.x = GET_X_LPARAM( lParam ); event.pointerButtonRelease.y = GET_Y_LPARAM( lParam ); event.pointerButtonRelease.buttons = _buttonState; event.pointerButtonRelease.button = PTR_BUTTON2; _computePointerDelta( window, event ); _getRenderContext( window, event ); break; case WM_RBUTTONUP: _buttonState &= ~PTR_BUTTON3; event.type = Event::WINDOW_POINTER_BUTTON_RELEASE; event.pointerButtonRelease.x = GET_X_LPARAM( lParam ); event.pointerButtonRelease.y = GET_Y_LPARAM( lParam ); event.pointerButtonRelease.buttons = _buttonState; event.pointerButtonRelease.button = PTR_BUTTON3; _computePointerDelta( window, event ); _getRenderContext( window, event ); break; case WM_XBUTTONUP: event.type = Event::WINDOW_POINTER_BUTTON_RELEASE; event.pointerButtonRelease.x = GET_X_LPARAM( lParam ); event.pointerButtonRelease.y = GET_Y_LPARAM( lParam ); if( GET_XBUTTON_WPARAM( wParam ) & XBUTTON1 ) event.pointerButtonRelease.button = PTR_BUTTON4; else event.pointerButtonRelease.button = PTR_BUTTON5; _buttonState &= ~event.pointerButtonRelease.button; _syncButtonState( GET_KEYSTATE_WPARAM( wParam )); event.pointerButtonRelease.buttons =_buttonState; _computePointerDelta( window, event ); _getRenderContext( window, event ); result = TRUE; break; case WM_MOUSEWHEEL: event.type = Event::WINDOW_POINTER_WHEEL; event.pointerWheel.x = GET_X_LPARAM( lParam ); event.pointerWheel.y = GET_Y_LPARAM( lParam ); event.pointerWheel.buttons = _buttonState; event.pointerWheel.xAxis = _getWheelDelta( wParam ); break; #ifdef WM_MOUSEHWHEEL // only available on vista or later case WM_MOUSEHWHEEL: event.type = Event::WINDOW_POINTER_WHEEL; event.pointerWheel.x = GET_X_LPARAM( lParam ); event.pointerWheel.y = GET_Y_LPARAM( lParam ); event.pointerWheel.buttons = _buttonState; event.pointerWheel.yAxis = _getWheelDelta( wParam ); break; #endif case WM_SYSKEYDOWN: case WM_KEYDOWN: event.type = Event::KEY_PRESS; event.keyPress.key = _getKey( lParam, wParam ); break; case WM_SYSKEYUP: case WM_KEYUP: event.type = Event::KEY_RELEASE; event.keyRelease.key = _getKey( lParam, wParam ); break; case WM_SYSCOMMAND: switch( wParam ) { case SC_MONITORPOWER: case SC_SCREENSAVE: if( lParam >= 0 ) // request off { event.type = Event::WINDOW_SCREENSAVER; break; } // else no break; fall through default: event.type = Event::UNKNOWN; LBVERB << "Unhandled system command 0x" << std::hex << wParam << std::dec << std::endl; break; } break; #ifdef EQUALIZER_USE_MAGELLAN case WM_INPUT: _magellanEventHandler( lParam ); break; #endif default: event.type = Event::UNKNOWN; LBVERB << "Unhandled message 0x" << std::hex << uMsg << std::dec << std::endl; break; } LBASSERT( window->getID() != 0 ); event.originator = window->getID(); event.serial = window->getSerial(); if( _window->processEvent( event )) return result; return CallWindowProc( _prevWndProc, hWnd, uMsg, wParam, lParam ); }