Show input.cpp syntax highlighted
/***************************************************************************
input.cpp - Message and input processing
-------------------
begin : Tue Apr 1 2003
copyright : (C) 2003 by Reality Rift Studios
email : mattias@realityrift.com
***************************************************************************
The contents of this file are subject to the Mozilla Public License Version
1.1 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the
License.
The Original Code is the NeoEngine, NeoDevOpenGL, input.cpp
The Initial Developer of the Original Code is Mattias Jansson.
Portions created by Mattias Jansson are Copyright (C) 2003
Reality Rift Studios. All Rights Reserved.
***************************************************************************/
#include "device.h"
#include "framebuffertarget.h"
#include <neoengine/logstream.h>
#ifdef POSIX
# include <X11/Xutil.h>
# include <X11/keysym.h>
#endif
#ifdef __APPLE__
# include <Carbon/Carbon.h>
#endif
using namespace std;
using namespace NeoEngine;
namespace NeoOGL
{
#ifdef POSIX
int checkEvent( Display *pDisplay, XEvent *pEvent, char *pData )
{
return 1;
}
#endif
#ifdef __APPLE__
enum
{
kMenuApple = 128,
kMenuFile = 129,
kAppleAbout = 1,
kFileShowHideST = 1,
kFileQuit = 2
};
#endif /* __APPLE__ */
bool Device::Collect( InputEvent *pkEvent )
{
#ifdef WIN32
// if( pkWindow->m_hWnd ) //&& ( m_kWindow.m_uiFlags & RenderWindow::DEVICECREATED ) )
if( m_kWindow.m_hWnd && ( m_kWindow.m_uiFlags & RenderWindow::DEVICECREATED ) )
{
MSG msg;
int bGotMsg = 0;
while( ( bGotMsg = PeekMessage( &msg, (HWND)m_kWindow.m_hWnd, 0U, 0U, PM_REMOVE ) ) )
{
TranslateMessage( &msg );
DispatchMessage( &msg );
}
}
#elif defined(__APPLE__)
EventRecord kEvt;
static int s_iMouseButton = -1;
if( WaitNextEvent( everyEvent, &kEvt, 1, NULL ) )
{
if (HasInputEventGroup(InputDevice::MOUSEINPUT)) {
// for some reason event.where isnt set?
GetGlobalMouse( &kEvt.where );
if( ( kEvt.where.h != m_ptLastWhere.h ) || ( kEvt.where.v != m_ptLastWhere.v ) )
{
Point pt;
pt = m_ptLastWhere = kEvt.where;
// convert mouse coordinates into local if not under fullscreen
if( !m_kWindow.m_kCaps.IsSet( RenderCaps::FULLSCREEN ) )
{
GrafPtr savePort;
GetPort( &savePort );
SetPort( GetWindowPort( (OpaqueWindowPtr*)m_kWindow.m_pWindow ) );
GlobalToLocal( &pt );
SetPort( savePort );
}
int iMouseButtonBitmask = 0;
if( s_iMouseButton >= 0 )
iMouseButtonBitmask |= ( 1 << s_iMouseButton );
m_vpkEvents.push_back( new InputEvent( IE_MOUSEMOVE, pt.h, pt.v, 0, iMouseButtonBitmask ) );
}
}
if (HasInputEventGroup(InputDevice::KEYBOARDINPUT)) {
// check for special non-event keys
if( kEvt.modifiers != m_emLastModifiers )
{
}
// check for normal event keys, but we have to scan the
// actual keyboard state because on MacOS X a keydown event
// is immediately followed by a keyup event.
KeyMap keys;
GetKeys( keys );
if ( ( keys[0] != m_kmLastKeys[0] ) ||
( keys[1] != m_kmLastKeys[1] ) ||
( keys[2] != m_kmLastKeys[2] ) ||
( keys[3] != m_kmLastKeys[3] ) )
{
int old_bit, new_bit;
for( int i = 0; i < 128; ++i )
{
old_bit = (((UInt8*)m_kmLastKeys)[i/8]>>(i%8)) & 0x01;
new_bit = (((UInt8*)keys )[i/8]>>(i%8)) & 0x01;
if( old_bit != new_bit )
{
// push new key event
int iEvent = ( new_bit == 1 ) ? IE_KEYUP : IE_KEYDOWN;
//FIXME: ASCII code
m_vpkEvents.push_back( new InputEvent( iEvent, m_aiKeyMap[i] ) );
}
}
m_kmLastKeys[0] = keys[0];
m_kmLastKeys[1] = keys[1];
m_kmLastKeys[2] = keys[2];
m_kmLastKeys[3] = keys[3];
}
}
switch( kEvt.what )
{
case mouseDown:
{
if (HasInputEventGroup(InputDevice::MOUSEINPUT)) {
WindowRef win;
short area;
area = FindWindow( kEvt.where, &win );
if( win && ( win != FrontWindow() ) )
SelectWindow(win);
switch( area )
{
case inMenuBar:
break;
case inDrag:
DragWindow( win, kEvt.where, 0 );
break;
case inGoAway:
if( TrackGoAway( win, kEvt.where ) )
m_vpkEvents.push_back( new InputEvent( IE_SYSEVENT, IE_SYSEVENT_KILL ) );
break;
case inContent:
{
Point pt;
pt = kEvt.where;
if( !m_kWindow.m_kCaps.IsSet( RenderCaps::FULLSCREEN ) )
{
GrafPtr saveport;
GetPort( &saveport );
SetPort( GetWindowPort( (OpaqueWindowPtr*)m_kWindow.m_pWindow ) );
GlobalToLocal( &pt );
SetPort( saveport );
}
// treat command-click as right mouse button
if( kEvt.modifiers & optionKey )
s_iMouseButton = MB_MIDDLE;
else if( kEvt.modifiers & cmdKey )
s_iMouseButton = MB_RIGHT;
else
s_iMouseButton = MB_LEFT;
m_vpkEvents.push_back( new InputEvent( IE_MOUSEDOWN, s_iMouseButton, pt.h, pt.v ) );
break;
}
default:
break;
}
}
break;
}
case mouseUp:
{
if (HasInputEventGroup(InputDevice::MOUSEINPUT)) {
if( s_iMouseButton < 0 )
break;
Point pt;
pt = kEvt.where;
if( !m_kWindow.m_kCaps.IsSet( RenderCaps::FULLSCREEN ) )
{
GrafPtr saveport;
GetPort( &saveport );
SetPort( GetWindowPort( (OpaqueWindowPtr*)m_kWindow.m_pWindow ) );
GlobalToLocal( &pt );
SetPort( saveport );
}
// release the mouse button we simulated in the last press.
// the drawback of this methos is we cannot press more than
// one button. however, this doesn't matter, since there is
// only a single logical mouse button, even if you have a
// multi-button mouse, this doesn't matter at all.
m_vpkEvents.push_back( new InputEvent( IE_MOUSEUP, s_iMouseButton, pt.h, pt.v ) );
s_iMouseButton = -1;
}
break;
}
case keyDown:
if (HasInputEventGroup(InputDevice::KEYBOARDINPUT)) {
//FIXME: ASCII code
m_vpkEvents.push_back( new InputEvent( IE_KEYDOWN, m_aiKeyMap[ ( kEvt.message & keyCodeMask ) >> 8 ] ) );
}
break;
case keyUp:
if (HasInputEventGroup(InputDevice::KEYBOARDINPUT)) {
//FIXME: ASCII code
m_vpkEvents.push_back( new InputEvent( IE_KEYUP, m_aiKeyMap[ ( kEvt.message & keyCodeMask ) >> 8 ] ) );
}
break;
case activateEvt:
if (HasInputEventGroup(InputDevice::SYSTEMINPUT)) {
if( m_pkFrameBufferTarget->m_aglContext )
aglUpdateContext( m_pkFrameBufferTarget->m_aglContext );
}
break;
case updateEvt:
if (HasInputEventGroup(InputDevice::SYSTEMINPUT)) {
if( m_pkFrameBufferTarget->m_aglContext )
aglUpdateContext( m_pkFrameBufferTarget->m_aglContext );
}
break;
default:
break;
}
}
#elif defined(POSIX)
Display *pDisplay = (Display*)m_kWindow.m_pDisplay;
XEvent Event;
static char s_szKeyStrBuf[10];
static int iMouseButtonBitmask = 0;
do
{
if( !XCheckIfEvent( pDisplay, &Event, checkEvent, 0 ) )
break;
switch( Event.type )
{
case MotionNotify:
if( HasInputEventGroup( InputDevice::MOUSEINPUT ) )
m_vpkEvents.push_back( new InputEvent( IE_MOUSEMOVE, ((XPointerMovedEvent*)&Event)->x, ((XPointerMovedEvent*)&Event)->y, 0, iMouseButtonBitmask ) );
break;
case ButtonPress:
{
int iButton = 0;
switch( ((XButtonEvent*)&Event)->button )
{
case MB_X_LEFT:
iMouseButtonBitmask |= ( 1 << ( iButton = NeoEngine::MB_LEFT ) );
break;
case MB_X_MIDDLE:
iMouseButtonBitmask |= ( 1 << ( iButton = NeoEngine::MB_MIDDLE ) );
break;
case MB_X_RIGHT:
iMouseButtonBitmask |= ( 1 << ( iButton = NeoEngine::MB_RIGHT ) );
break;
default:
iMouseButtonBitmask |= ( 1 << ( iButton = ( ((XButtonEvent*)&Event)->button - 1 ) ) );
break;
}
if( HasInputEventGroup( InputDevice::MOUSEINPUT ) )
m_vpkEvents.push_back( new InputEvent( IE_MOUSEDOWN, iButton, ((XPointerMovedEvent*)&Event)->x, ((XPointerMovedEvent*)&Event)->y ) );
break;
}
case ButtonRelease:
{
int iButton = 0;
switch( ((XButtonEvent*)&Event)->button )
{
case MB_X_LEFT:
iMouseButtonBitmask |= ~( 1 << ( iButton = NeoEngine::MB_LEFT ) );
break;
case MB_X_MIDDLE:
iMouseButtonBitmask |= ~( 1 << ( iButton = NeoEngine::MB_MIDDLE ) );
break;
case MB_X_RIGHT:
iMouseButtonBitmask |= ~( 1 << ( iButton = NeoEngine::MB_RIGHT ) );
break;
default:
iMouseButtonBitmask |= ~( 1 << ( iButton = ( ((XButtonEvent*)&Event)->button - 1 ) ) );
break;
}
if( HasInputEventGroup( InputDevice::MOUSEINPUT ) )
m_vpkEvents.push_back( new InputEvent( IE_MOUSEUP, iButton, ((XPointerMovedEvent*)&Event)->x, ((XPointerMovedEvent*)&Event)->y ) );
break;
}
case KeyRelease:
case KeyPress:
{
if( HasInputEventGroup(InputDevice::KEYBOARDINPUT ) )
{
int iLastEventNum = m_vpkEvents.size() - 1;
int iEvent = ( Event.type == KeyRelease ) ? IE_KEYUP : IE_KEYDOWN;
unsigned long iKeysym = NoSymbol;
XLookupString( (XKeyEvent*)&Event, s_szKeyStrBuf, 10, (KeySym*)&iKeysym, 0 );
switch( iKeysym )
{
case XK_KP_Enter:
case XK_Return:
m_vpkEvents.push_back( new InputEvent( iEvent, KC_RETURN ) );
break;
case XK_BackSpace:
m_vpkEvents.push_back( new InputEvent( iEvent, KC_BACKSPACE ) );
break;
case XK_Delete:
m_vpkEvents.push_back( new InputEvent( iEvent, KC_DELETE ) );
break;
case XK_space:
m_vpkEvents.push_back( new InputEvent( iEvent, KC_SPACE, ' ' ) );
break;
case XK_F1:
m_vpkEvents.push_back( new InputEvent( iEvent, KC_F1 ) );
break;
case XK_F2:
m_vpkEvents.push_back( new InputEvent( iEvent, KC_F2 ) );
break;
case XK_F3:
m_vpkEvents.push_back( new InputEvent( iEvent, KC_F3 ) );
break;
case XK_F4:
m_vpkEvents.push_back( new InputEvent( iEvent, KC_F4 ) );
break;
case XK_F5:
m_vpkEvents.push_back( new InputEvent( iEvent, KC_F5 ) );
break;
case XK_F6:
m_vpkEvents.push_back( new InputEvent( iEvent, KC_F6 ) );
break;
case XK_F7:
m_vpkEvents.push_back( new InputEvent( iEvent, KC_F7 ) );
break;
case XK_F8:
m_vpkEvents.push_back( new InputEvent( iEvent, KC_F8 ) );
break;
case XK_F9:
m_vpkEvents.push_back( new InputEvent( iEvent, KC_F9 ) );
break;
case XK_F10:
m_vpkEvents.push_back( new InputEvent( iEvent, KC_F10 ) );
break;
case XK_F11:
m_vpkEvents.push_back( new InputEvent( iEvent, KC_F11 ) );
break;
case XK_F12:
m_vpkEvents.push_back( new InputEvent( iEvent, KC_F12 ) );
break;
case XK_Escape:
m_vpkEvents.push_back( new InputEvent( iEvent, KC_ESCAPE ) );
break;
case XK_Left:
m_vpkEvents.push_back( new InputEvent( iEvent, KC_LEFT ) );
break;
case XK_Right:
m_vpkEvents.push_back( new InputEvent( iEvent, KC_RIGHT ) );
break;
case XK_Up:
m_vpkEvents.push_back( new InputEvent( iEvent, KC_UP ) );
break;
case XK_Down:
m_vpkEvents.push_back( new InputEvent( iEvent, KC_DOWN ) );
break;
case XK_KP_0:
case XK_KP_1:
case XK_KP_2:
case XK_KP_3:
case XK_KP_4:
case XK_KP_5:
case XK_KP_6:
case XK_KP_7:
case XK_KP_8:
case XK_KP_9:
m_vpkEvents.push_back( new InputEvent( iEvent, KC_0 + int( iKeysym - XK_KP_0 ), '0' + int( iKeysym - XK_KP_0 ) ) );
break;
case XK_0:
case XK_1:
case XK_2:
case XK_3:
case XK_4:
case XK_5:
case XK_6:
case XK_7:
case XK_8:
case XK_9:
m_vpkEvents.push_back( new InputEvent( iEvent, KC_0 + int( iKeysym - XK_0 ), '0' + int( iKeysym - XK_0 ) ) );
break;
case XK_a:
case XK_b:
case XK_c:
case XK_d:
case XK_e:
case XK_f:
case XK_g:
case XK_h:
case XK_i:
case XK_j:
case XK_k:
case XK_l:
case XK_m:
case XK_n:
case XK_o:
case XK_p:
case XK_q:
case XK_r:
case XK_s:
case XK_t:
case XK_u:
case XK_v:
case XK_w:
case XK_x:
case XK_y:
case XK_z:
m_vpkEvents.push_back( new InputEvent( iEvent, KC_A + int( iKeysym - XK_a ), 'a' + int( iKeysym - XK_a ) ) );
break;
case XK_A:
case XK_B:
case XK_C:
case XK_D:
case XK_E:
case XK_F:
case XK_G:
case XK_H:
case XK_I:
case XK_J:
case XK_K:
case XK_L:
case XK_M:
case XK_N:
case XK_O:
case XK_P:
case XK_Q:
case XK_R:
case XK_S:
case XK_T:
case XK_U:
case XK_V:
case XK_W:
case XK_X:
case XK_Y:
case XK_Z:
m_vpkEvents.push_back( new InputEvent( iEvent, KC_A + int( iKeysym - XK_A ), 'A' + int( iKeysym - XK_A ) ) );
break;
case XK_exclam:
m_vpkEvents.push_back( new InputEvent( iEvent, KC_EXCLAMATION, '!' ) );
break;
case XK_quotedbl:
m_vpkEvents.push_back( new InputEvent( iEvent, KC_QUOTEDOUBLE, '"' ) );
break;
case XK_dollar:
m_vpkEvents.push_back( new InputEvent( iEvent, KC_DOLLAR, '$' ) );
break;
case XK_percent:
m_vpkEvents.push_back( new InputEvent( iEvent, KC_PERCENT, '%' ) );
break;
case XK_ampersand:
m_vpkEvents.push_back( new InputEvent( iEvent, KC_AMPERSAND, '&' ) );
break;
case XK_apostrophe:
m_vpkEvents.push_back( new InputEvent( iEvent, KC_QUOTE, '\'' ) );
break;
case XK_parenleft:
m_vpkEvents.push_back( new InputEvent( iEvent, KC_LEFTPARENTHESIS, '(' ) );
break;
case XK_parenright:
m_vpkEvents.push_back( new InputEvent( iEvent, KC_RIGHTPARENTHESIS, ')' ) );
break;
case XK_multiply:
case XK_asterisk:
m_vpkEvents.push_back( new InputEvent( iEvent, KC_ASTERISK, '*' ) );
break;
case XK_plus:
m_vpkEvents.push_back( new InputEvent( iEvent, KC_PLUS, '+' ) );
break;
case XK_comma:
m_vpkEvents.push_back( new InputEvent( iEvent, KC_COMMA, ',' ) );
break;
case XK_minus:
m_vpkEvents.push_back( new InputEvent( iEvent, KC_MINUS, '-' ) );
break;
case XK_period:
m_vpkEvents.push_back( new InputEvent( iEvent, KC_DOT, '.' ) );
break;
case XK_slash:
m_vpkEvents.push_back( new InputEvent( iEvent, KC_SLASH, '/' ) );
break;
case XK_colon:
m_vpkEvents.push_back( new InputEvent( iEvent, KC_COLON, ':' ) );
break;
case XK_semicolon:
m_vpkEvents.push_back( new InputEvent( iEvent, KC_SEMICOLON, ';' ) );
break;
case XK_less:
m_vpkEvents.push_back( new InputEvent( iEvent, KC_LESS, '<' ) );
break;
case XK_equal:
m_vpkEvents.push_back( new InputEvent( iEvent, KC_EQUAL, '=' ) );
break;
case XK_greater:
m_vpkEvents.push_back( new InputEvent( iEvent, KC_GREATER, '>' ) );
break;
case XK_question:
m_vpkEvents.push_back( new InputEvent( iEvent, KC_QUESTION, '?' ) );
break;
case XK_bracketleft:
m_vpkEvents.push_back( new InputEvent( iEvent, KC_LEFTBRACKET, '[' ) );
break;
case XK_bracketright:
m_vpkEvents.push_back( new InputEvent( iEvent, KC_RIGHTBRACKET, ']' ) );
break;
case XK_backslash:
m_vpkEvents.push_back( new InputEvent( iEvent, KC_BACKSLASH, '\\' ) );
break;
case XK_underscore:
m_vpkEvents.push_back( new InputEvent( iEvent, KC_UNDERSCORE, '_' ) );
break;
case XK_grave:
m_vpkEvents.push_back( new InputEvent( iEvent, KC_GRAVE, '`' ) );
break;
case XK_braceleft:
m_vpkEvents.push_back( new InputEvent( iEvent, KC_LEFTCURL, '{' ) );
break;
case XK_braceright:
m_vpkEvents.push_back( new InputEvent( iEvent, KC_RIGHTCURL, '}' ) );
break;
case XK_asciitilde:
m_vpkEvents.push_back( new InputEvent( iEvent, KC_TILDE, '~' ) );
break;
case XK_at:
m_vpkEvents.push_back( new InputEvent( iEvent, KC_AT, '@' ) );
break;
// MULTI-CHARACTER
// case XK_sterling:
// m_vpkEvents.push_back( new InputEvent( iEvent, KC_POUND, '£' ) );
// break;
//
// case XK_euro:
// m_vpkEvents.push_back( new InputEvent( iEvent, KC_EURO, '$' ) );
// break;
case XK_Shift_L:
m_vpkEvents.push_back( new InputEvent( iEvent, KC_LSHIFT ) );
break;
case XK_Shift_R:
m_vpkEvents.push_back( new InputEvent( iEvent, KC_RSHIFT ) );
break;
case XK_Control_L:
m_vpkEvents.push_back( new InputEvent( iEvent, KC_LCTRL ) );
break;
case XK_Control_R:
m_vpkEvents.push_back( new InputEvent( iEvent, KC_RCTRL ) );
break;
case XK_Caps_Lock:
m_vpkEvents.push_back( new InputEvent( iEvent, KC_CAPSLOCK ) );
break;
case XK_Alt_L:
m_vpkEvents.push_back( new InputEvent( iEvent, KC_LALT ) );
break;
case XK_Alt_R:
m_vpkEvents.push_back( new InputEvent( iEvent, KC_RALT ) );
break;
default:
break;
}
//Check if last event was a KeyRelease and our event is KeyPress, and same key && time, then remove old KeyRelease event
int iCurEventNum = m_vpkEvents.size() - 1;
if( ( iLastEventNum >= 0 ) && ( iLastEventNum != iCurEventNum ) &&
( m_vpkEvents[ iLastEventNum ]->m_iType == IE_KEYUP ) &&
( m_vpkEvents[ iLastEventNum ]->m_aArgs[0].m_iData == m_vpkEvents[ iCurEventNum ]->m_aArgs[0].m_iData ) )
{
delete m_vpkEvents[ iLastEventNum ];
m_vpkEvents.erase( m_vpkEvents.begin() + iLastEventNum );
}
}
break;
}
case ClientMessage:
{
if( HasInputEventGroup(InputDevice::SYSTEMINPUT ) )
{
if( Event.xclient.data.l[0] == (int)m_WMDeleteWindow )
m_vpkEvents.push_back( new InputEvent( IE_SYSEVENT, IE_SYSEVENT_KILL ) );
}
break;
}
default:
break;
}
} while( !XPending( pDisplay ) );
#else
# error "Platform not implemented"
#endif
//Check if events in queue
{
if( m_vpkEvents.size() )
{
*pkEvent = *m_vpkEvents[0];
delete m_vpkEvents[0];
m_vpkEvents.erase( m_vpkEvents.begin() );
return true;
}
}
return false;
}
#ifdef __APPLE__
static OSStatus NeoWindowMouseEventHandler (EventHandlerCallRef myHandler, EventRef event)
{
WindowRef window = NULL;
OSStatus result = eventNotHandledErr;
UInt32 kind = GetEventKind (event);
EventMouseButton button = 0;
HIPoint location = {0.0f, 0.0f};
UInt32 modifiers = 0;
long wheelDelta = 0;
Rect rectPort;
GetEventParameter(event, kEventParamWindowRef, typeWindowRef, NULL, sizeof(WindowRef), NULL, &window);
GetWindowPortBounds (window, &rectPort);
result = CallNextEventHandler(myHandler, event);
if( result == eventNotHandledErr )
{
switch( kind )
{
case kEventMouseDown:
GetEventParameter( event, kEventParamMouseButton, typeMouseButton,
NULL, sizeof(EventMouseButton), NULL, &button );
GetEventParameter( event, kEventParamWindowMouseLocation,
typeHIPoint, NULL, sizeof(HIPoint), NULL, &location );
GetEventParameter( event, kEventParamKeyModifiers, typeUInt32,
NULL, sizeof(UInt32), NULL, &modifiers );
switch( button )
{
case kEventMouseButtonPrimary:
break;
case kEventMouseButtonSecondary:
break;
case kEventMouseButtonTertiary:
break;
}
break;
case kEventMouseUp:
GetEventParameter( event, kEventParamMouseButton, typeMouseButton,
NULL, sizeof( EventMouseButton ), NULL, &button );
GetEventParameter( event, kEventParamWindowMouseLocation,
typeHIPoint, NULL, sizeof( HIPoint ), NULL, &location );
GetEventParameter( event, kEventParamKeyModifiers, typeUInt32,
NULL, sizeof( UInt32 ), NULL, &modifiers );
switch( button )
{
case kEventMouseButtonPrimary:
break;
case kEventMouseButtonSecondary:
break;
case kEventMouseButtonTertiary:
break;
}
break;
case kEventMouseDragged:
GetEventParameter( event, kEventParamWindowMouseLocation,
typeHIPoint, NULL, sizeof(HIPoint), NULL, &location);
break;
case kEventMouseWheelMoved:
GetEventParameter( event, kEventParamMouseWheelDelta, typeLongInteger,
NULL, sizeof(long), NULL, &wheelDelta);
if (wheelDelta)
{
}
break;
}
result = noErr;
}
return result;
}
static void NeoKeyInputHandler (EventRef event, Boolean keyDown)
{
UInt32 keyCode;
GetEventParameter (event, kEventParamKeyCode, typeUInt32, NULL, sizeof(UInt32), NULL, &keyCode);
// Finish keyboard input handling here..
}
/*
static pascal OSStatus NeoWindowEventHandler (EventHandlerCallRef myHandler, EventRef event, void* userdata)
{
Device *pMain;
WindowRef window;
Rect rectPort = {0,0,0,0};
OSStatus result = eventNotHandledErr;
UInt32 eclass = GetEventClass (event);
UInt32 kind = GetEventKind (event);
if( !pMain )
{
pMain = (Device *) userdata;
}
switch (eclass)
{
case kEventClassKeyboard:
switch (kind)
{
case kEventRawKeyDown:
NeoKeyInputHandler( event, true );
break;
case kEventRawKeyUp:
NeoKeyInputHandler( event, false );
break;
}
break;
case kEventClassWindow:
switch (kind)
{
case kEventWindowClose:
HideWindow (window);
break;
case kEventWindowShown:
if (window == FrontWindow ())
SetUserFocusWindow (window);
InvalWindowRect (window, &rectPort);
break;
case kEventWindowBoundsChanged:
// handleWindowUpdate(window);
break;
}
break;
}
return result;
}
*/
pascal OSStatus NeoEventHandler( EventHandlerCallRef myHandler, EventRef event, void *userdata )
{
static Device *pMain = 0;
//OSStatus result = eventNotHandledErr;
WindowRef window = FrontWindow ();
UInt32 eclass = GetEventClass (event);
UInt32 kind = GetEventKind (event);
HICommand command;
//EventHandlerRef ref;
//EventTypeSpec list[] = { { kEventClassWindow, kEventWindowShown },
//{ kEventClassWindow, kEventWindowActivated },
//{ kEventClassWindow, kEventWindowClose },
//{ kEventClassWindow, kEventWindowDrawContent },
//{ kEventClassWindow, kEventWindowBoundsChanged },
//{ kEventClassWindow, kEventWindowZoomed },
//{ kEventClassKeyboard, kEventRawKeyDown },
//{ kEventClassKeyboard, kEventRawKeyUp } };
if( !pMain )
{
pMain = (Device *) userdata;
}
switch (eclass)
{
case kEventClassMouse:
NeoWindowMouseEventHandler( myHandler, event );
break;
case kEventClassMenu:
switch (kind)
{
case kEventMenuOpening:
if (window)
EnableMenuItem (GetMenuHandle (kMenuFile), kFileQuit);
else
DisableMenuItem (GetMenuHandle (kMenuFile), kFileQuit);
break;
}
break;
case kEventClassCommand:
switch (kind)
{
case kEventProcessCommand:
GetEventParameter (event, kEventParamDirectObject, kEventParamHICommand,
NULL, sizeof(command), NULL, &command);
switch (command.commandID)
{
case 'clsw':
case 'quit':
neolog << LogLevel( INFO ) << "Terminating" << endl;
pMain->m_vpkEvents.push_back( new InputEvent( IE_SYSEVENT, IE_SYSEVENT_KILL ) );
break;
}
}
break;
}
}
#endif // __APPLE
#ifdef WIN32
#ifdef MB_RIGHT
# undef MB_RIGHT
#endif
LONG WINAPI WindowProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
static Device *pMain = 0;
static bool bProcessMsg = true;
static int iMouseButtonBitmask = 0;
//Core::Get()->Log( LogDevice::LOGLEVEL_DEBUG, "Got windows message [%d], processing [%s]", uMsg, ( bProcessMsg ) ? "true" : "false" );
if( bProcessMsg )
{
if( !pMain )
pMain = (Device*)GetWindowLong( hWnd, GWL_USERDATA );
switch( uMsg )
{
case WM_MOUSEMOVE:
{
if( pMain->HasInputEventGroup( InputDevice::MOUSEINPUT ) )
{
int x = GET_X_LPARAM( lParam );
int y = GET_Y_LPARAM( lParam );
pMain->m_vpkEvents.push_back( new InputEvent( IE_MOUSEMOVE, x, y, 0, iMouseButtonBitmask ) );
}
break;
}
case WM_LBUTTONDOWN:
iMouseButtonBitmask |= ( 1 << NeoEngine::MB_LEFT );
if( pMain->HasInputEventGroup( InputDevice::MOUSEINPUT ) )
pMain->m_vpkEvents.push_back( new InputEvent( IE_MOUSEDOWN, NeoEngine::MB_LEFT, LOWORD( lParam ), HIWORD( lParam ) ) );
break;
case WM_LBUTTONUP:
iMouseButtonBitmask &= ~( 1 << NeoEngine::MB_LEFT );
if( pMain->HasInputEventGroup( InputDevice::MOUSEINPUT ) )
pMain->m_vpkEvents.push_back( new InputEvent( IE_MOUSEUP, NeoEngine::MB_LEFT, LOWORD( lParam ), HIWORD( lParam ) ) );
break;
case WM_RBUTTONDOWN:
iMouseButtonBitmask |= ( 1 << NeoEngine::MB_RIGHT );
if( pMain->HasInputEventGroup( InputDevice::MOUSEINPUT ) )
pMain->m_vpkEvents.push_back( new InputEvent( IE_MOUSEDOWN, NeoEngine::MB_RIGHT, LOWORD( lParam ), HIWORD( lParam ) ) );
break;
case WM_RBUTTONUP:
iMouseButtonBitmask &= ~( 1 << NeoEngine::MB_RIGHT );
if( pMain->HasInputEventGroup( InputDevice::MOUSEINPUT ) )
pMain->m_vpkEvents.push_back( new InputEvent( IE_MOUSEUP, NeoEngine::MB_RIGHT, LOWORD( lParam ), HIWORD( lParam ) ) );
break;
case WM_MBUTTONDOWN:
iMouseButtonBitmask |= ( 1 << NeoEngine::MB_MIDDLE );
if( pMain->HasInputEventGroup( InputDevice::MOUSEINPUT ) )
pMain->m_vpkEvents.push_back( new InputEvent( IE_MOUSEDOWN, NeoEngine::MB_MIDDLE, LOWORD( lParam ), HIWORD( lParam ) ) );
break;
case WM_MBUTTONUP:
iMouseButtonBitmask &= ~( 1 << NeoEngine::MB_MIDDLE );
if( pMain->HasInputEventGroup( InputDevice::MOUSEINPUT ) )
pMain->m_vpkEvents.push_back( new InputEvent( IE_MOUSEUP, NeoEngine::MB_MIDDLE, LOWORD( lParam ), HIWORD( lParam ) ) );
break;
case WM_KEYDOWN:
{
if( pMain->HasInputEventGroup( InputDevice::KEYBOARDINPUT ) )
{
if( ( (int)wParam >= VK_F1 ) && ( (int)wParam <= (int)VK_F12 ) )
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYDOWN, KC_F1 + (int)wParam - VK_F1 ) );
else if( (int)wParam == VK_ESCAPE )
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYDOWN, KC_ESCAPE ) );
else if( (int)wParam == VK_SPACE )
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYDOWN, KC_SPACE, ' ' ) );
else if( (int)wParam == VK_RETURN )
{
/* If the key is extended (24th bit), it is the keypad ENTER */
if (lParam & 1<<24)
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYDOWN, KC_KP_ENTER ) );
else
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYDOWN, KC_RETURN ) );
}
else if( (int)wParam == VK_UP )
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYDOWN, KC_UP ) );
else if( (int)wParam == VK_DOWN )
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYDOWN, KC_DOWN ) );
else if( (int)wParam == VK_LEFT )
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYDOWN, KC_LEFT ) );
else if( (int)wParam == VK_RIGHT )
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYDOWN, KC_RIGHT ) );
else if( (int)wParam == VK_BACK )
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYDOWN, KC_BACKSPACE ) );
else if( ( (int)wParam >= VK_NUMPAD0 ) && ( (int)wParam <= (int)VK_NUMPAD9 ) )
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYDOWN, KC_KP_0 + (int)wParam - VK_NUMPAD0 ) );
else if( (int)wParam == VK_ADD )
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYDOWN, KC_KP_PLUS ) );
else if( (int)wParam == VK_SUBTRACT )
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYDOWN, KC_KP_MINUS ) );
else if( (int)wParam == VK_DECIMAL )
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYDOWN, KC_KP_DECIMAL ) );
else if( (int)wParam == VK_DIVIDE )
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYDOWN, KC_KP_DIVIDE ) );
else if( (int)wParam == VK_MULTIPLY )
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYDOWN, KC_KP_ASTERISK ) );
else if( (int)wParam == VK_NUMLOCK )
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYDOWN, KC_KP_NUMLOCK ) );
else if( (int)wParam == VK_TAB )
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYDOWN, KC_TAB, '\t' ) );
else if( (int)wParam == VK_CAPITAL )
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYDOWN, KC_CAPSLOCK ) );
else if( (int)wParam == VK_SHIFT )
{
/* For most keyboards, 36 in the raw OEM code is the right SHIFT */
if ( ( lParam & 0x00ff0000 ) == 0x00360000)
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYDOWN, KC_RSHIFT ) );
else
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYDOWN, KC_LSHIFT ) );
}
else if( (int)wParam == VK_CONTROL )
{
/* If the key is extended (24th bit), it is the right CTRL */
if (lParam & 1<<24)
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYDOWN, KC_RCTRL ) );
else
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYDOWN, KC_LCTRL ) );
}
else if( (int)wParam == VK_MENU )
/* It would be too tricky (and long) to determine whether
it was the left or right one, so we just take it as left here.
Use neodevdinput8 if you really need to distinguish them. */
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYDOWN, KC_LALT ) );
else if( (int)wParam == VK_LWIN )
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYDOWN, KC_LWIN ) );
else if( (int)wParam == VK_RWIN )
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYDOWN, KC_RWIN ) );
else if( (int)wParam == VK_INSERT )
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYDOWN, KC_INSERT ) );
else if( (int)wParam == VK_DELETE )
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYDOWN, KC_DELETE ) );
else if( (int)wParam == VK_HOME )
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYDOWN, KC_HOME ) );
else if( (int)wParam == VK_END )
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYDOWN, KC_END ) );
else if( (int)wParam == VK_PRIOR )
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYDOWN, KC_PAGEUP ) );
else if( (int)wParam == VK_NEXT )
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYDOWN, KC_PAGEDOWN ) );
else if( (int)wParam == VK_SCROLL )
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYDOWN, KC_SCROLLLOCK ) );
else if( (int)wParam == VK_PAUSE )
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYDOWN, KC_PAUSE ) );
}
break;
}
case WM_KEYUP:
{
if( pMain->HasInputEventGroup( InputDevice::KEYBOARDINPUT ) )
{
if( ( (int)wParam >= (int)'A' ) && ( (int)wParam <= (int)'Z' ) )
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYUP, KC_A + (int)wParam - (int)'A' ) );
else if( ( (int)wParam >= (int)'0' ) && ( (int)wParam <= (int)'9' ) )
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYUP, KC_0 + (int)wParam - (int)'0' ) );
else if( ( (int)wParam >= VK_F1 ) && ( (int)wParam <= (int)VK_F12 ) )
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYUP, KC_F1 + (int)wParam - VK_F1 ) );
else if( (int)wParam == VK_ESCAPE )
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYUP, KC_ESCAPE ) );
else if( (int)wParam == VK_SPACE )
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYUP, KC_SPACE ) );
else if( (int)wParam == VK_RETURN )
{
/* If the key is extended (24th bit), it is the keypad ENTER */
if (lParam & 1<<24)
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYUP, KC_KP_ENTER ) );
else
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYUP, KC_RETURN ) );
}
else if( (int)wParam == VK_UP )
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYUP, KC_UP ) );
else if( (int)wParam == VK_DOWN )
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYUP, KC_DOWN ) );
else if( (int)wParam == VK_LEFT )
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYUP, KC_LEFT ) );
else if( (int)wParam == VK_RIGHT )
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYUP, KC_RIGHT ) );
else if( (int)wParam == VK_DECIMAL )
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYUP, KC_DOT ) );
else if( (int)wParam == VK_BACK )
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYUP, KC_BACKSPACE ) );
else if( ( (int)wParam >= VK_NUMPAD0 ) && ( (int)wParam <= (int)VK_NUMPAD9 ) )
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYUP, KC_KP_0 + (int)wParam - VK_NUMPAD0 ) );
else if( (int)wParam == VK_ADD )
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYUP, KC_KP_PLUS ) );
else if( (int)wParam == VK_SUBTRACT )
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYUP, KC_KP_MINUS ) );
else if( (int)wParam == VK_DECIMAL )
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYUP, KC_KP_DECIMAL ) );
else if( (int)wParam == VK_DIVIDE )
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYUP, KC_KP_DIVIDE ) );
else if( (int)wParam == VK_MULTIPLY )
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYUP, KC_KP_ASTERISK ) );
else if( (int)wParam == VK_NUMLOCK )
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYUP, KC_KP_NUMLOCK ) );
else if( (int)wParam == VK_SEPARATOR )
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYUP, KC_KP_ENTER ) );
else if( (int)wParam == VK_TAB )
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYUP, KC_TAB ) );
else if( (int)wParam == VK_CAPITAL )
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYUP, KC_CAPSLOCK ) );
else if( (int)wParam == VK_SHIFT )
{
/* For most keyboards, 36 in the raw OEM code is the right SHIFT */
if ( ( lParam & 0x00ff0000 ) == 0x00360000)
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYUP, KC_RSHIFT ) );
else
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYUP, KC_LSHIFT ) );
}
else if( (int)wParam == VK_CONTROL )
{
/* If the key is extended (24th bit), it is the right CTRL */
if (lParam & 1<<24)
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYUP, KC_RCTRL ) );
else
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYUP, KC_LCTRL ) );
}
else if( (int)wParam == VK_MENU )
/* It would be too tricky (and long) to determine whether
it was the left or right one, so we just take it as left here.
Use neodevdinput8 if you really need to distinguish them. */
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYUP, KC_LALT ) );
else if( (int)wParam == VK_LWIN )
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYUP, KC_LWIN ) );
else if( (int)wParam == VK_RWIN )
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYUP, KC_RWIN ) );
else if( (int)wParam == VK_INSERT )
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYUP, KC_INSERT ) );
else if( (int)wParam == VK_DELETE )
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYUP, KC_DELETE ) );
else if( (int)wParam == VK_HOME )
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYUP, KC_HOME ) );
else if( (int)wParam == VK_END )
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYUP, KC_END ) );
else if( (int)wParam == VK_PRIOR )
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYUP, KC_PAGEUP ) );
else if( (int)wParam == VK_NEXT )
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYUP, KC_PAGEDOWN ) );
else if( (int)wParam == VK_SCROLL )
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYUP, KC_SCROLLLOCK ) );
else if( (int)wParam == VK_PAUSE )
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYUP, KC_PAUSE ) );
}
break;
}
case WM_CHAR:
{
if( pMain->HasInputEventGroup( InputDevice::KEYBOARDINPUT ) )
{
if( ( (int)wParam >= (int)'A' ) && ( (int)wParam <= (int)'Z' ) )
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYDOWN, KC_A + int( wParam - 'A' ), 'A' + int( wParam - 'A' ) ) );
else if( ( (int)wParam >= (int)'a' ) && ( (int)wParam <= (int)'z' ) )
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYDOWN, KC_A + int( wParam - 'a' ), 'a' + int( wParam - 'a' ) ) );
else if( ( (int)wParam >= (int)'0' ) && ( (int)wParam <= (int)'9' ) )
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYDOWN, KC_0 + int( wParam - '0' ), '0' + int( wParam - '0' ) ) );
else if( wParam == '!' )
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYDOWN, KC_EXCLAMATION, '!' ) );
else if( wParam == '"' )
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYDOWN, KC_QUOTEDOUBLE, '"' ) );
else if( wParam == '#' )
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYDOWN, KC_HASH, '#' ) );
else if( wParam == '%' )
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYDOWN, KC_PERCENT, '%' ) );
else if( wParam == '&' )
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYDOWN, KC_AMPERSAND, '&' ) );
else if( wParam == '/' )
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYDOWN, KC_SLASH, '/' ) );
else if( wParam == '(' )
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYDOWN, KC_LEFTPARENTHESIS, '(' ) );
else if( wParam == ')' )
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYDOWN, KC_RIGHTPARENTHESIS, ')' ) );
else if( wParam == '[' )
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYDOWN, KC_LEFTBRACKET, '[' ) );
else if( wParam == ']' )
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYDOWN, KC_RIGHTBRACKET, ']' ) );
else if( wParam == '{' )
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYDOWN, KC_LEFTCURL, '{' ) );
else if( wParam == '}' )
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYDOWN, KC_RIGHTCURL, '}' ) );
else if( wParam == '+' )
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYDOWN, KC_PLUS, '+' ) );
else if( wParam == '-' )
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYDOWN, KC_MINUS, '-' ) );
else if( wParam == '_' )
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYDOWN, KC_UNDERSCORE, '_' ) );
else if( wParam == '.' )
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYDOWN, KC_DOT, '.' ) );
else if( wParam == ',' )
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYDOWN, KC_COMMA, ',' ) );
else if( wParam == ':' )
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYDOWN, KC_COLON, ':' ) );
else if( wParam == ';' )
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYDOWN, KC_SEMICOLON, ';' ) );
else if( wParam == '<' )
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYDOWN, KC_LESS, '<' ) );
else if( wParam == '>' )
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYDOWN, KC_GREATER, '>' ) );
else if( wParam == '|' )
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYDOWN, KC_BAR, '|' ) );
else if( wParam == '\\' )
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYDOWN, KC_BACKSLASH, '\\' ) );
else if( wParam == '=' )
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYDOWN, KC_EQUAL, '=' ) );
else if( wParam == '\'' )
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYDOWN, KC_QUOTE, '\'' ) );
else if( wParam == '?' )
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYDOWN, KC_QUESTION, '?' ) );
else if( wParam == '$' )
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYDOWN, KC_DOLLAR, '$' ) );
//Multi-byte character
//else if( wParam == 'ç )
// pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYDOWN, KC_POUND, 'ç ) );
else if( wParam == '@' )
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYDOWN, KC_AT, '@' ) );
else if( wParam == '*' )
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYDOWN, KC_ASTERISK, '*' ) );
else if( wParam == '~' )
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYDOWN, KC_TILDE, '~' ) );
else if( wParam == '`' )
pMain->m_vpkEvents.push_back( new InputEvent( IE_KEYDOWN, KC_GRAVE, '?' ) );
}
break;
}
case WM_SIZE:
{
if( pMain && pMain->HasInputEventGroup( InputDevice::SYSTEMINPUT ) )
{
if( ( wParam == SIZE_RESTORED ) || ( wParam == SIZE_MAXIMIZED ) )
{
// TEST GIANCA
int w = LOWORD(lParam);
int h = HIWORD(lParam);
RenderWindow kRW;
kRW.m_kResolution.m_uiWidth = w;
kRW.m_kResolution.m_uiHeight = h;
pMain->Resize( kRW );
//
//m_iDeviceWidth = LOWORD(lParam);
//m_iDeviceHeight = HIWORD(lParam);
//Resize();
}
}
break;
}
case WM_DESTROY:
{
if( pMain && !pMain->m_bIgnoreKill && pMain->HasInputEventGroup( InputDevice::SYSTEMINPUT ) )
{
neolog << LogLevel( INFO ) << "Got WM_DESTROY, terminating" << endl;
pMain->m_vpkEvents.push_back( new InputEvent( IE_SYSEVENT, IE_SYSEVENT_KILL ) );
bProcessMsg = false;
}
pMain->m_bIgnoreKill = false;
break;
}
default:
break;
}
}
//dario
SetCursor(LoadCursor (NULL, MAKEINTRESOURCE( Device::getMouseShape() )));
return DefWindowProc( hWnd, uMsg, wParam, lParam );
}
#endif
}; // namespace NeoOGL
See more files for this project here