diff options
author | Campbell Barton <ideasman42@gmail.com> | 2011-12-20 12:09:46 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2011-12-20 12:09:46 +0400 |
commit | 84b58df85a08813a5f216d702c3e48b564840bd8 (patch) | |
tree | c644e3535207ed805ba048d20c7f60d31ed55cdb /source/gameengine | |
parent | efb4eff35312afb372e2a46aa598d12a74ff4a52 (diff) | |
parent | 0be004bb2ff380c41365506ae3d8488ff2691a85 (diff) |
svn merge ^/trunk/blender -r42742:42757
Diffstat (limited to 'source/gameengine')
13 files changed, 235 insertions, 349 deletions
diff --git a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp index 360a082b03b..445f2b8f0ba 100644 --- a/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp +++ b/source/gameengine/BlenderRoutines/BL_KetsjiEmbedStart.cpp @@ -241,6 +241,7 @@ extern "C" void StartKetsjiShell(struct bContext *C, struct ARegion *ar, rcti *c ketsjiengine->SetUseFixedTime(usefixed); ketsjiengine->SetTimingDisplay(frameRate, profile, properties); ketsjiengine->SetRestrictAnimationFPS(restrictAnimFPS); + KX_KetsjiEngine::SetExitKey(ConvertKeyCode(startscene->gm.exitkey)); //set the global settings (carried over if restart/load new files) ketsjiengine->SetGlobalSettings(&gs); diff --git a/source/gameengine/BlenderRoutines/KX_BlenderInputDevice.h b/source/gameengine/BlenderRoutines/KX_BlenderInputDevice.h index 1c91f498d32..93bf133635d 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderInputDevice.h +++ b/source/gameengine/BlenderRoutines/KX_BlenderInputDevice.h @@ -41,6 +41,7 @@ #include "wm_event_types.h" #include "WM_types.h" #include "SCA_IInputDevice.h" +#include "BL_BlenderDataConversion.h" #ifdef WITH_CXX_GUARDEDALLOC #include "MEM_guardedalloc.h" @@ -51,172 +52,9 @@ */ class BL_BlenderInputDevice : public SCA_IInputDevice { - // this map is Blender specific: a conversion between blender and ketsji enums - std::map<int,KX_EnumInputs> m_reverseKeyTranslateTable; public: BL_BlenderInputDevice() { - - /* The reverse table. In order to not confuse ourselves, we */ - /* immediately convert all events that come in to KX codes. */ - m_reverseKeyTranslateTable[LEFTMOUSE ] = KX_LEFTMOUSE; - m_reverseKeyTranslateTable[MIDDLEMOUSE ] = KX_MIDDLEMOUSE; - m_reverseKeyTranslateTable[RIGHTMOUSE ] = KX_RIGHTMOUSE; - m_reverseKeyTranslateTable[WHEELUPMOUSE ] = KX_WHEELUPMOUSE; - m_reverseKeyTranslateTable[WHEELDOWNMOUSE ] = KX_WHEELDOWNMOUSE; - m_reverseKeyTranslateTable[MOUSEX ] = KX_MOUSEX; - m_reverseKeyTranslateTable[MOUSEY ] = KX_MOUSEY; - - // TIMERS - - m_reverseKeyTranslateTable[TIMER0 ] = KX_TIMER0; - m_reverseKeyTranslateTable[TIMER1 ] = KX_TIMER1; - m_reverseKeyTranslateTable[TIMER2 ] = KX_TIMER2; - - // SYSTEM -#if 0 - /* **** XXX **** */ - m_reverseKeyTranslateTable[KEYBD ] = KX_KEYBD; - m_reverseKeyTranslateTable[RAWKEYBD ] = KX_RAWKEYBD; - m_reverseKeyTranslateTable[REDRAW ] = KX_REDRAW; - m_reverseKeyTranslateTable[INPUTCHANGE ] = KX_INPUTCHANGE; - m_reverseKeyTranslateTable[QFULL ] = KX_QFULL; - m_reverseKeyTranslateTable[WINFREEZE ] = KX_WINFREEZE; - m_reverseKeyTranslateTable[WINTHAW ] = KX_WINTHAW; - m_reverseKeyTranslateTable[WINCLOSE ] = KX_WINCLOSE; - m_reverseKeyTranslateTable[WINQUIT ] = KX_WINQUIT; - m_reverseKeyTranslateTable[Q_FIRSTTIME ] = KX_Q_FIRSTTIME; - /* **** XXX **** */ -#endif - // standard keyboard - - m_reverseKeyTranslateTable[AKEY ] = KX_AKEY; - m_reverseKeyTranslateTable[BKEY ] = KX_BKEY; - m_reverseKeyTranslateTable[CKEY ] = KX_CKEY; - m_reverseKeyTranslateTable[DKEY ] = KX_DKEY; - m_reverseKeyTranslateTable[EKEY ] = KX_EKEY; - m_reverseKeyTranslateTable[FKEY ] = KX_FKEY; - m_reverseKeyTranslateTable[GKEY ] = KX_GKEY; - //XXX clean up -#ifdef WIN32 -#define HKEY 'h' -#endif - m_reverseKeyTranslateTable[HKEY ] = KX_HKEY; - //XXX clean up -#ifdef WIN32 -#undef HKEY -#endif - m_reverseKeyTranslateTable[IKEY ] = KX_IKEY; - m_reverseKeyTranslateTable[JKEY ] = KX_JKEY; - m_reverseKeyTranslateTable[KKEY ] = KX_KKEY; - m_reverseKeyTranslateTable[LKEY ] = KX_LKEY; - m_reverseKeyTranslateTable[MKEY ] = KX_MKEY; - m_reverseKeyTranslateTable[NKEY ] = KX_NKEY; - m_reverseKeyTranslateTable[OKEY ] = KX_OKEY; - m_reverseKeyTranslateTable[PKEY ] = KX_PKEY; - m_reverseKeyTranslateTable[QKEY ] = KX_QKEY; - m_reverseKeyTranslateTable[RKEY ] = KX_RKEY; - m_reverseKeyTranslateTable[SKEY ] = KX_SKEY; - m_reverseKeyTranslateTable[TKEY ] = KX_TKEY; - m_reverseKeyTranslateTable[UKEY ] = KX_UKEY; - m_reverseKeyTranslateTable[VKEY ] = KX_VKEY; - m_reverseKeyTranslateTable[WKEY ] = KX_WKEY; - m_reverseKeyTranslateTable[XKEY ] = KX_XKEY; - m_reverseKeyTranslateTable[YKEY ] = KX_YKEY; - m_reverseKeyTranslateTable[ZKEY ] = KX_ZKEY; - - m_reverseKeyTranslateTable[ZEROKEY ] = KX_ZEROKEY; - m_reverseKeyTranslateTable[ONEKEY ] = KX_ONEKEY; - m_reverseKeyTranslateTable[TWOKEY ] = KX_TWOKEY; - m_reverseKeyTranslateTable[THREEKEY ] = KX_THREEKEY; - m_reverseKeyTranslateTable[FOURKEY ] = KX_FOURKEY; - m_reverseKeyTranslateTable[FIVEKEY ] = KX_FIVEKEY; - m_reverseKeyTranslateTable[SIXKEY ] = KX_SIXKEY; - m_reverseKeyTranslateTable[SEVENKEY ] = KX_SEVENKEY; - m_reverseKeyTranslateTable[EIGHTKEY ] = KX_EIGHTKEY; - m_reverseKeyTranslateTable[NINEKEY ] = KX_NINEKEY; - - m_reverseKeyTranslateTable[CAPSLOCKKEY ] = KX_CAPSLOCKKEY; - - m_reverseKeyTranslateTable[LEFTCTRLKEY ] = KX_LEFTCTRLKEY; - m_reverseKeyTranslateTable[LEFTALTKEY ] = KX_LEFTALTKEY; - m_reverseKeyTranslateTable[RIGHTALTKEY ] = KX_RIGHTALTKEY; - m_reverseKeyTranslateTable[RIGHTCTRLKEY ] = KX_RIGHTCTRLKEY; - m_reverseKeyTranslateTable[RIGHTSHIFTKEY ] = KX_RIGHTSHIFTKEY; - m_reverseKeyTranslateTable[LEFTSHIFTKEY ] = KX_LEFTSHIFTKEY; - - m_reverseKeyTranslateTable[ESCKEY ] = KX_ESCKEY; - m_reverseKeyTranslateTable[TABKEY ] = KX_TABKEY; - m_reverseKeyTranslateTable[RETKEY ] = KX_RETKEY; - m_reverseKeyTranslateTable[SPACEKEY ] = KX_SPACEKEY; - m_reverseKeyTranslateTable[LINEFEEDKEY ] = KX_LINEFEEDKEY; - m_reverseKeyTranslateTable[BACKSPACEKEY ] = KX_BACKSPACEKEY; - m_reverseKeyTranslateTable[DELKEY ] = KX_DELKEY; - m_reverseKeyTranslateTable[SEMICOLONKEY ] = KX_SEMICOLONKEY; - m_reverseKeyTranslateTable[PERIODKEY ] = KX_PERIODKEY; - m_reverseKeyTranslateTable[COMMAKEY ] = KX_COMMAKEY; - m_reverseKeyTranslateTable[QUOTEKEY ] = KX_QUOTEKEY; - m_reverseKeyTranslateTable[ACCENTGRAVEKEY ] = KX_ACCENTGRAVEKEY; - m_reverseKeyTranslateTable[MINUSKEY ] = KX_MINUSKEY; - m_reverseKeyTranslateTable[SLASHKEY ] = KX_SLASHKEY; - m_reverseKeyTranslateTable[BACKSLASHKEY ] = KX_BACKSLASHKEY; - m_reverseKeyTranslateTable[EQUALKEY ] = KX_EQUALKEY; - m_reverseKeyTranslateTable[LEFTBRACKETKEY ] = KX_LEFTBRACKETKEY; - m_reverseKeyTranslateTable[RIGHTBRACKETKEY ] = KX_RIGHTBRACKETKEY; - - m_reverseKeyTranslateTable[LEFTARROWKEY ] = KX_LEFTARROWKEY; - m_reverseKeyTranslateTable[DOWNARROWKEY ] = KX_DOWNARROWKEY; - m_reverseKeyTranslateTable[RIGHTARROWKEY ] = KX_RIGHTARROWKEY; - m_reverseKeyTranslateTable[UPARROWKEY ] = KX_UPARROWKEY; - - m_reverseKeyTranslateTable[PAD2 ] = KX_PAD2; - m_reverseKeyTranslateTable[PAD4 ] = KX_PAD4; - m_reverseKeyTranslateTable[PAD6 ] = KX_PAD6; - m_reverseKeyTranslateTable[PAD8 ] = KX_PAD8; - - m_reverseKeyTranslateTable[PAD1 ] = KX_PAD1; - m_reverseKeyTranslateTable[PAD3 ] = KX_PAD3; - m_reverseKeyTranslateTable[PAD5 ] = KX_PAD5; - m_reverseKeyTranslateTable[PAD7 ] = KX_PAD7; - m_reverseKeyTranslateTable[PAD9 ] = KX_PAD9; - - m_reverseKeyTranslateTable[PADPERIOD ] = KX_PADPERIOD; - m_reverseKeyTranslateTable[PADSLASHKEY ] = KX_PADSLASHKEY; - m_reverseKeyTranslateTable[PADASTERKEY ] = KX_PADASTERKEY; - - - m_reverseKeyTranslateTable[PAD0 ] = KX_PAD0; - m_reverseKeyTranslateTable[PADMINUS ] = KX_PADMINUS; - m_reverseKeyTranslateTable[PADENTER ] = KX_PADENTER; - m_reverseKeyTranslateTable[PADPLUSKEY ] = KX_PADPLUSKEY; - - - m_reverseKeyTranslateTable[F1KEY ] = KX_F1KEY; - m_reverseKeyTranslateTable[F2KEY ] = KX_F2KEY; - m_reverseKeyTranslateTable[F3KEY ] = KX_F3KEY; - m_reverseKeyTranslateTable[F4KEY ] = KX_F4KEY; - m_reverseKeyTranslateTable[F5KEY ] = KX_F5KEY; - m_reverseKeyTranslateTable[F6KEY ] = KX_F6KEY; - m_reverseKeyTranslateTable[F7KEY ] = KX_F7KEY; - m_reverseKeyTranslateTable[F8KEY ] = KX_F8KEY; - m_reverseKeyTranslateTable[F9KEY ] = KX_F9KEY; - m_reverseKeyTranslateTable[F10KEY ] = KX_F10KEY; - m_reverseKeyTranslateTable[F11KEY ] = KX_F11KEY; - m_reverseKeyTranslateTable[F12KEY ] = KX_F12KEY; - m_reverseKeyTranslateTable[F13KEY ] = KX_F13KEY; - m_reverseKeyTranslateTable[F14KEY ] = KX_F14KEY; - m_reverseKeyTranslateTable[F15KEY ] = KX_F15KEY; - m_reverseKeyTranslateTable[F16KEY ] = KX_F16KEY; - m_reverseKeyTranslateTable[F17KEY ] = KX_F17KEY; - m_reverseKeyTranslateTable[F18KEY ] = KX_F18KEY; - m_reverseKeyTranslateTable[F19KEY ] = KX_F19KEY; - - m_reverseKeyTranslateTable[PAUSEKEY ] = KX_PAUSEKEY; - m_reverseKeyTranslateTable[INSERTKEY ] = KX_INSERTKEY; - m_reverseKeyTranslateTable[HOMEKEY ] = KX_HOMEKEY; - m_reverseKeyTranslateTable[PAGEUPKEY ] = KX_PAGEUPKEY; - m_reverseKeyTranslateTable[PAGEDOWNKEY ] = KX_PAGEDOWNKEY; - m_reverseKeyTranslateTable[ENDKEY ] = KX_ENDKEY; } virtual ~BL_BlenderInputDevice() @@ -225,7 +63,7 @@ public: } KX_EnumInputs ToNative(unsigned short incode) { - return m_reverseKeyTranslateTable[incode]; + return ConvertKeyCode(incode); } virtual bool IsPressed(SCA_IInputDevice::KX_EnumInputs inputcode)=0; diff --git a/source/gameengine/BlenderRoutines/KX_BlenderKeyboardDevice.cpp b/source/gameengine/BlenderRoutines/KX_BlenderKeyboardDevice.cpp index a6712c531fb..54c60096812 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderKeyboardDevice.cpp +++ b/source/gameengine/BlenderRoutines/KX_BlenderKeyboardDevice.cpp @@ -36,6 +36,7 @@ #endif #include "KX_BlenderKeyboardDevice.h" +#include "KX_KetsjiEngine.h" KX_BlenderKeyboardDevice::KX_BlenderKeyboardDevice() : m_hookesc(false) @@ -106,7 +107,7 @@ bool KX_BlenderKeyboardDevice::ConvertBlenderEvent(unsigned short incode,short v if (val == KM_PRESS) { - if (kxevent == KX_ESCKEY && val != 0 && !m_hookesc) + if (kxevent == KX_KetsjiEngine::GetExitKey() && val != 0 && !m_hookesc) result = true; if (kxevent == KX_PAUSEKEY && val && (IsPressed(KX_LEFTCTRLKEY) || IsPressed(KX_RIGHTCTRLKEY))) result = true; diff --git a/source/gameengine/BlenderRoutines/KX_BlenderKeyboardDevice.h b/source/gameengine/BlenderRoutines/KX_BlenderKeyboardDevice.h index 63a01db2fe0..3039e69efcd 100644 --- a/source/gameengine/BlenderRoutines/KX_BlenderKeyboardDevice.h +++ b/source/gameengine/BlenderRoutines/KX_BlenderKeyboardDevice.h @@ -50,6 +50,8 @@ public: virtual bool ConvertBlenderEvent(unsigned short incode,short val); virtual void NextFrame(); virtual void HookEscape(); +private: + short m_exit_key; #ifdef WITH_CXX_GUARDEDALLOC diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.cpp b/source/gameengine/Converter/BL_BlenderDataConversion.cpp index 95ae7591776..821cb746b65 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.cpp +++ b/source/gameengine/Converter/BL_BlenderDataConversion.cpp @@ -197,6 +197,180 @@ extern "C" { static bool default_light_mode = 0; +static std::map<int, SCA_IInputDevice::KX_EnumInputs> create_translate_table() +{ + std::map<int, SCA_IInputDevice::KX_EnumInputs> m; + + /* The reverse table. In order to not confuse ourselves, we */ + /* immediately convert all events that come in to KX codes. */ + m[LEFTMOUSE ] = SCA_IInputDevice::KX_LEFTMOUSE; + m[MIDDLEMOUSE ] = SCA_IInputDevice::KX_MIDDLEMOUSE; + m[RIGHTMOUSE ] = SCA_IInputDevice::KX_RIGHTMOUSE; + m[WHEELUPMOUSE ] = SCA_IInputDevice::KX_WHEELUPMOUSE; + m[WHEELDOWNMOUSE ] = SCA_IInputDevice::KX_WHEELDOWNMOUSE; + m[MOUSEX ] = SCA_IInputDevice::KX_MOUSEX; + m[MOUSEY ] = SCA_IInputDevice::KX_MOUSEY; + + // TIMERS + + m[TIMER0 ] = SCA_IInputDevice::KX_TIMER0; + m[TIMER1 ] = SCA_IInputDevice::KX_TIMER1; + m[TIMER2 ] = SCA_IInputDevice::KX_TIMER2; + + // SYSTEM + +#if 0 + /* **** XXX **** */ + m[KEYBD ] = SCA_IInputDevice::KX_KEYBD; + m[RAWKEYBD ] = SCA_IInputDevice::KX_RAWKEYBD; + m[REDRAW ] = SCA_IInputDevice::KX_REDRAW; + m[INPUTCHANGE ] = SCA_IInputDevice::KX_INPUTCHANGE; + m[QFULL ] = SCA_IInputDevice::KX_QFULL; + m[WINFREEZE ] = SCA_IInputDevice::KX_WINFREEZE; + m[WINTHAW ] = SCA_IInputDevice::KX_WINTHAW; + m[WINCLOSE ] = SCA_IInputDevice::KX_WINCLOSE; + m[WINQUIT ] = SCA_IInputDevice::KX_WINQUIT; + m[Q_FIRSTTIME ] = SCA_IInputDevice::KX_Q_FIRSTTIME; + /* **** XXX **** */ +#endif + + // standard keyboard + + m[AKEY ] = SCA_IInputDevice::KX_AKEY; + m[BKEY ] = SCA_IInputDevice::KX_BKEY; + m[CKEY ] = SCA_IInputDevice::KX_CKEY; + m[DKEY ] = SCA_IInputDevice::KX_DKEY; + m[EKEY ] = SCA_IInputDevice::KX_EKEY; + m[FKEY ] = SCA_IInputDevice::KX_FKEY; + m[GKEY ] = SCA_IInputDevice::KX_GKEY; + +//XXX clean up +#ifdef WIN32 +#define HKEY 'h' +#endif + m[HKEY ] = SCA_IInputDevice::KX_HKEY; +//XXX clean up +#ifdef WIN32 +#undef HKEY +#endif + + m[IKEY ] = SCA_IInputDevice::KX_IKEY; + m[JKEY ] = SCA_IInputDevice::KX_JKEY; + m[KKEY ] = SCA_IInputDevice::KX_KKEY; + m[LKEY ] = SCA_IInputDevice::KX_LKEY; + m[MKEY ] = SCA_IInputDevice::KX_MKEY; + m[NKEY ] = SCA_IInputDevice::KX_NKEY; + m[OKEY ] = SCA_IInputDevice::KX_OKEY; + m[PKEY ] = SCA_IInputDevice::KX_PKEY; + m[QKEY ] = SCA_IInputDevice::KX_QKEY; + m[RKEY ] = SCA_IInputDevice::KX_RKEY; + m[SKEY ] = SCA_IInputDevice::KX_SKEY; + m[TKEY ] = SCA_IInputDevice::KX_TKEY; + m[UKEY ] = SCA_IInputDevice::KX_UKEY; + m[VKEY ] = SCA_IInputDevice::KX_VKEY; + m[WKEY ] = SCA_IInputDevice::KX_WKEY; + m[XKEY ] = SCA_IInputDevice::KX_XKEY; + m[YKEY ] = SCA_IInputDevice::KX_YKEY; + m[ZKEY ] = SCA_IInputDevice::KX_ZKEY; + + m[ZEROKEY ] = SCA_IInputDevice::KX_ZEROKEY; + m[ONEKEY ] = SCA_IInputDevice::KX_ONEKEY; + m[TWOKEY ] = SCA_IInputDevice::KX_TWOKEY; + m[THREEKEY ] = SCA_IInputDevice::KX_THREEKEY; + m[FOURKEY ] = SCA_IInputDevice::KX_FOURKEY; + m[FIVEKEY ] = SCA_IInputDevice::KX_FIVEKEY; + m[SIXKEY ] = SCA_IInputDevice::KX_SIXKEY; + m[SEVENKEY ] = SCA_IInputDevice::KX_SEVENKEY; + m[EIGHTKEY ] = SCA_IInputDevice::KX_EIGHTKEY; + m[NINEKEY ] = SCA_IInputDevice::KX_NINEKEY; + + m[CAPSLOCKKEY ] = SCA_IInputDevice::KX_CAPSLOCKKEY; + + m[LEFTCTRLKEY ] = SCA_IInputDevice::KX_LEFTCTRLKEY; + m[LEFTALTKEY ] = SCA_IInputDevice::KX_LEFTALTKEY; + m[RIGHTALTKEY ] = SCA_IInputDevice::KX_RIGHTALTKEY; + m[RIGHTCTRLKEY ] = SCA_IInputDevice::KX_RIGHTCTRLKEY; + m[RIGHTSHIFTKEY ] = SCA_IInputDevice::KX_RIGHTSHIFTKEY; + m[LEFTSHIFTKEY ] = SCA_IInputDevice::KX_LEFTSHIFTKEY; + + m[ESCKEY ] = SCA_IInputDevice::KX_ESCKEY; + m[TABKEY ] = SCA_IInputDevice::KX_TABKEY; + m[RETKEY ] = SCA_IInputDevice::KX_RETKEY; + m[SPACEKEY ] = SCA_IInputDevice::KX_SPACEKEY; + m[LINEFEEDKEY ] = SCA_IInputDevice::KX_LINEFEEDKEY; + m[BACKSPACEKEY ] = SCA_IInputDevice::KX_BACKSPACEKEY; + m[DELKEY ] = SCA_IInputDevice::KX_DELKEY; + m[SEMICOLONKEY ] = SCA_IInputDevice::KX_SEMICOLONKEY; + m[PERIODKEY ] = SCA_IInputDevice::KX_PERIODKEY; + m[COMMAKEY ] = SCA_IInputDevice::KX_COMMAKEY; + m[QUOTEKEY ] = SCA_IInputDevice::KX_QUOTEKEY; + m[ACCENTGRAVEKEY ] = SCA_IInputDevice::KX_ACCENTGRAVEKEY; + m[MINUSKEY ] = SCA_IInputDevice::KX_MINUSKEY; + m[SLASHKEY ] = SCA_IInputDevice::KX_SLASHKEY; + m[BACKSLASHKEY ] = SCA_IInputDevice::KX_BACKSLASHKEY; + m[EQUALKEY ] = SCA_IInputDevice::KX_EQUALKEY; + m[LEFTBRACKETKEY ] = SCA_IInputDevice::KX_LEFTBRACKETKEY; + m[RIGHTBRACKETKEY ] = SCA_IInputDevice::KX_RIGHTBRACKETKEY; + + m[LEFTARROWKEY ] = SCA_IInputDevice::KX_LEFTARROWKEY; + m[DOWNARROWKEY ] = SCA_IInputDevice::KX_DOWNARROWKEY; + m[RIGHTARROWKEY ] = SCA_IInputDevice::KX_RIGHTARROWKEY; + m[UPARROWKEY ] = SCA_IInputDevice::KX_UPARROWKEY; + + m[PAD2 ] = SCA_IInputDevice::KX_PAD2; + m[PAD4 ] = SCA_IInputDevice::KX_PAD4; + m[PAD6 ] = SCA_IInputDevice::KX_PAD6; + m[PAD8 ] = SCA_IInputDevice::KX_PAD8; + + m[PAD1 ] = SCA_IInputDevice::KX_PAD1; + m[PAD3 ] = SCA_IInputDevice::KX_PAD3; + m[PAD5 ] = SCA_IInputDevice::KX_PAD5; + m[PAD7 ] = SCA_IInputDevice::KX_PAD7; + m[PAD9 ] = SCA_IInputDevice::KX_PAD9; + + m[PADPERIOD ] = SCA_IInputDevice::KX_PADPERIOD; + m[PADSLASHKEY ] = SCA_IInputDevice::KX_PADSLASHKEY; + m[PADASTERKEY ] = SCA_IInputDevice::KX_PADASTERKEY; + + m[PAD0 ] = SCA_IInputDevice::KX_PAD0; + m[PADMINUS ] = SCA_IInputDevice::KX_PADMINUS; + m[PADENTER ] = SCA_IInputDevice::KX_PADENTER; + m[PADPLUSKEY ] = SCA_IInputDevice::KX_PADPLUSKEY; + + + m[F1KEY ] = SCA_IInputDevice::KX_F1KEY; + m[F2KEY ] = SCA_IInputDevice::KX_F2KEY; + m[F3KEY ] = SCA_IInputDevice::KX_F3KEY; + m[F4KEY ] = SCA_IInputDevice::KX_F4KEY; + m[F5KEY ] = SCA_IInputDevice::KX_F5KEY; + m[F6KEY ] = SCA_IInputDevice::KX_F6KEY; + m[F7KEY ] = SCA_IInputDevice::KX_F7KEY; + m[F8KEY ] = SCA_IInputDevice::KX_F8KEY; + m[F9KEY ] = SCA_IInputDevice::KX_F9KEY; + m[F10KEY ] = SCA_IInputDevice::KX_F10KEY; + m[F11KEY ] = SCA_IInputDevice::KX_F11KEY; + m[F12KEY ] = SCA_IInputDevice::KX_F12KEY; + m[F13KEY ] = SCA_IInputDevice::KX_F13KEY; + m[F14KEY ] = SCA_IInputDevice::KX_F14KEY; + m[F15KEY ] = SCA_IInputDevice::KX_F15KEY; + m[F16KEY ] = SCA_IInputDevice::KX_F16KEY; + m[F17KEY ] = SCA_IInputDevice::KX_F17KEY; + m[F18KEY ] = SCA_IInputDevice::KX_F18KEY; + m[F19KEY ] = SCA_IInputDevice::KX_F19KEY; + + + m[PAUSEKEY ] = SCA_IInputDevice::KX_PAUSEKEY; + m[INSERTKEY ] = SCA_IInputDevice::KX_INSERTKEY; + m[HOMEKEY ] = SCA_IInputDevice::KX_HOMEKEY; + m[PAGEUPKEY ] = SCA_IInputDevice::KX_PAGEUPKEY; + m[PAGEDOWNKEY ] = SCA_IInputDevice::KX_PAGEDOWNKEY; + m[ENDKEY ] = SCA_IInputDevice::KX_ENDKEY; + + return m; +} + +static std::map<int, SCA_IInputDevice::KX_EnumInputs> gReverseKeyTranslateTable = create_translate_table(); + static unsigned int KX_rgbaint2uint_new(unsigned int icol) { union @@ -2854,3 +3028,8 @@ void BL_ConvertBlenderObjects(struct Main* maggie, RAS_BucketManager *bucketmanager = kxscene->GetBucketManager(); bucketmanager->OptimizeBuckets(distance); } + +SCA_IInputDevice::KX_EnumInputs ConvertKeyCode(int key_code) +{ + return gReverseKeyTranslateTable[key_code]; +}
\ No newline at end of file diff --git a/source/gameengine/Converter/BL_BlenderDataConversion.h b/source/gameengine/Converter/BL_BlenderDataConversion.h index 2ae7fee1798..6da3ac90aef 100644 --- a/source/gameengine/Converter/BL_BlenderDataConversion.h +++ b/source/gameengine/Converter/BL_BlenderDataConversion.h @@ -36,6 +36,7 @@ #include "STR_String.h" #include "KX_Python.h" #include "KX_PhysicsEngineEnums.h" +#include "SCA_IInputDevice.h" class RAS_MeshObject* BL_ConvertMesh(struct Mesh* mesh,struct Object* lightobj,class KX_Scene* scene, class KX_BlenderSceneConverter *converter); @@ -49,5 +50,7 @@ void BL_ConvertBlenderObjects(struct Main* maggie, bool alwaysUseExpandFraming ); +SCA_IInputDevice::KX_EnumInputs ConvertKeyCode(int key_code); + #endif // __BLENDER_CONVERT diff --git a/source/gameengine/Converter/KX_ConvertSensors.cpp b/source/gameengine/Converter/KX_ConvertSensors.cpp index b7aee8ec924..9391d12a3ce 100644 --- a/source/gameengine/Converter/KX_ConvertSensors.cpp +++ b/source/gameengine/Converter/KX_ConvertSensors.cpp @@ -86,10 +86,7 @@ probably misplaced */ #include "KX_KetsjiEngine.h" #include "KX_BlenderSceneConverter.h" - -// this map is Blender specific: a conversion between blender and ketsji enums -std::map<int,SCA_IInputDevice::KX_EnumInputs> gReverseKeyTranslateTable; - +#include "BL_BlenderDataConversion.h" void BL_ConvertSensors(struct Object* blenderobject, class KX_GameObject* gameobj, @@ -102,177 +99,6 @@ void BL_ConvertSensors(struct Object* blenderobject, KX_BlenderSceneConverter* converter ) { - static bool reverseTableConverted = false; - - if (!reverseTableConverted) - { - reverseTableConverted = true; - - /* The reverse table. In order to not confuse ourselves, we */ - /* immediately convert all events that come in to KX codes. */ - gReverseKeyTranslateTable[LEFTMOUSE ] = SCA_IInputDevice::KX_LEFTMOUSE; - gReverseKeyTranslateTable[MIDDLEMOUSE ] = SCA_IInputDevice::KX_MIDDLEMOUSE; - gReverseKeyTranslateTable[RIGHTMOUSE ] = SCA_IInputDevice::KX_RIGHTMOUSE; - gReverseKeyTranslateTable[WHEELUPMOUSE ] = SCA_IInputDevice::KX_WHEELUPMOUSE; - gReverseKeyTranslateTable[WHEELDOWNMOUSE ] = SCA_IInputDevice::KX_WHEELDOWNMOUSE; - gReverseKeyTranslateTable[MOUSEX ] = SCA_IInputDevice::KX_MOUSEX; - gReverseKeyTranslateTable[MOUSEY ] = SCA_IInputDevice::KX_MOUSEY; - - // TIMERS - - gReverseKeyTranslateTable[TIMER0 ] = SCA_IInputDevice::KX_TIMER0; - gReverseKeyTranslateTable[TIMER1 ] = SCA_IInputDevice::KX_TIMER1; - gReverseKeyTranslateTable[TIMER2 ] = SCA_IInputDevice::KX_TIMER2; - - // SYSTEM - -#if 0 - /* **** XXX **** */ - gReverseKeyTranslateTable[KEYBD ] = SCA_IInputDevice::KX_KEYBD; - gReverseKeyTranslateTable[RAWKEYBD ] = SCA_IInputDevice::KX_RAWKEYBD; - gReverseKeyTranslateTable[REDRAW ] = SCA_IInputDevice::KX_REDRAW; - gReverseKeyTranslateTable[INPUTCHANGE ] = SCA_IInputDevice::KX_INPUTCHANGE; - gReverseKeyTranslateTable[QFULL ] = SCA_IInputDevice::KX_QFULL; - gReverseKeyTranslateTable[WINFREEZE ] = SCA_IInputDevice::KX_WINFREEZE; - gReverseKeyTranslateTable[WINTHAW ] = SCA_IInputDevice::KX_WINTHAW; - gReverseKeyTranslateTable[WINCLOSE ] = SCA_IInputDevice::KX_WINCLOSE; - gReverseKeyTranslateTable[WINQUIT ] = SCA_IInputDevice::KX_WINQUIT; - gReverseKeyTranslateTable[Q_FIRSTTIME ] = SCA_IInputDevice::KX_Q_FIRSTTIME; - /* **** XXX **** */ -#endif - - // standard keyboard - - gReverseKeyTranslateTable[AKEY ] = SCA_IInputDevice::KX_AKEY; - gReverseKeyTranslateTable[BKEY ] = SCA_IInputDevice::KX_BKEY; - gReverseKeyTranslateTable[CKEY ] = SCA_IInputDevice::KX_CKEY; - gReverseKeyTranslateTable[DKEY ] = SCA_IInputDevice::KX_DKEY; - gReverseKeyTranslateTable[EKEY ] = SCA_IInputDevice::KX_EKEY; - gReverseKeyTranslateTable[FKEY ] = SCA_IInputDevice::KX_FKEY; - gReverseKeyTranslateTable[GKEY ] = SCA_IInputDevice::KX_GKEY; - -//XXX clean up -#ifdef WIN32 -#define HKEY 'h' -#endif - gReverseKeyTranslateTable[HKEY ] = SCA_IInputDevice::KX_HKEY; -//XXX clean up -#ifdef WIN32 -#undef HKEY -#endif - - gReverseKeyTranslateTable[IKEY ] = SCA_IInputDevice::KX_IKEY; - gReverseKeyTranslateTable[JKEY ] = SCA_IInputDevice::KX_JKEY; - gReverseKeyTranslateTable[KKEY ] = SCA_IInputDevice::KX_KKEY; - gReverseKeyTranslateTable[LKEY ] = SCA_IInputDevice::KX_LKEY; - gReverseKeyTranslateTable[MKEY ] = SCA_IInputDevice::KX_MKEY; - gReverseKeyTranslateTable[NKEY ] = SCA_IInputDevice::KX_NKEY; - gReverseKeyTranslateTable[OKEY ] = SCA_IInputDevice::KX_OKEY; - gReverseKeyTranslateTable[PKEY ] = SCA_IInputDevice::KX_PKEY; - gReverseKeyTranslateTable[QKEY ] = SCA_IInputDevice::KX_QKEY; - gReverseKeyTranslateTable[RKEY ] = SCA_IInputDevice::KX_RKEY; - gReverseKeyTranslateTable[SKEY ] = SCA_IInputDevice::KX_SKEY; - gReverseKeyTranslateTable[TKEY ] = SCA_IInputDevice::KX_TKEY; - gReverseKeyTranslateTable[UKEY ] = SCA_IInputDevice::KX_UKEY; - gReverseKeyTranslateTable[VKEY ] = SCA_IInputDevice::KX_VKEY; - gReverseKeyTranslateTable[WKEY ] = SCA_IInputDevice::KX_WKEY; - gReverseKeyTranslateTable[XKEY ] = SCA_IInputDevice::KX_XKEY; - gReverseKeyTranslateTable[YKEY ] = SCA_IInputDevice::KX_YKEY; - gReverseKeyTranslateTable[ZKEY ] = SCA_IInputDevice::KX_ZKEY; - - gReverseKeyTranslateTable[ZEROKEY ] = SCA_IInputDevice::KX_ZEROKEY; - gReverseKeyTranslateTable[ONEKEY ] = SCA_IInputDevice::KX_ONEKEY; - gReverseKeyTranslateTable[TWOKEY ] = SCA_IInputDevice::KX_TWOKEY; - gReverseKeyTranslateTable[THREEKEY ] = SCA_IInputDevice::KX_THREEKEY; - gReverseKeyTranslateTable[FOURKEY ] = SCA_IInputDevice::KX_FOURKEY; - gReverseKeyTranslateTable[FIVEKEY ] = SCA_IInputDevice::KX_FIVEKEY; - gReverseKeyTranslateTable[SIXKEY ] = SCA_IInputDevice::KX_SIXKEY; - gReverseKeyTranslateTable[SEVENKEY ] = SCA_IInputDevice::KX_SEVENKEY; - gReverseKeyTranslateTable[EIGHTKEY ] = SCA_IInputDevice::KX_EIGHTKEY; - gReverseKeyTranslateTable[NINEKEY ] = SCA_IInputDevice::KX_NINEKEY; - - gReverseKeyTranslateTable[CAPSLOCKKEY ] = SCA_IInputDevice::KX_CAPSLOCKKEY; - - gReverseKeyTranslateTable[LEFTCTRLKEY ] = SCA_IInputDevice::KX_LEFTCTRLKEY; - gReverseKeyTranslateTable[LEFTALTKEY ] = SCA_IInputDevice::KX_LEFTALTKEY; - gReverseKeyTranslateTable[RIGHTALTKEY ] = SCA_IInputDevice::KX_RIGHTALTKEY; - gReverseKeyTranslateTable[RIGHTCTRLKEY ] = SCA_IInputDevice::KX_RIGHTCTRLKEY; - gReverseKeyTranslateTable[RIGHTSHIFTKEY ] = SCA_IInputDevice::KX_RIGHTSHIFTKEY; - gReverseKeyTranslateTable[LEFTSHIFTKEY ] = SCA_IInputDevice::KX_LEFTSHIFTKEY; - - gReverseKeyTranslateTable[ESCKEY ] = SCA_IInputDevice::KX_ESCKEY; - gReverseKeyTranslateTable[TABKEY ] = SCA_IInputDevice::KX_TABKEY; - gReverseKeyTranslateTable[RETKEY ] = SCA_IInputDevice::KX_RETKEY; - gReverseKeyTranslateTable[SPACEKEY ] = SCA_IInputDevice::KX_SPACEKEY; - gReverseKeyTranslateTable[LINEFEEDKEY ] = SCA_IInputDevice::KX_LINEFEEDKEY; - gReverseKeyTranslateTable[BACKSPACEKEY ] = SCA_IInputDevice::KX_BACKSPACEKEY; - gReverseKeyTranslateTable[DELKEY ] = SCA_IInputDevice::KX_DELKEY; - gReverseKeyTranslateTable[SEMICOLONKEY ] = SCA_IInputDevice::KX_SEMICOLONKEY; - gReverseKeyTranslateTable[PERIODKEY ] = SCA_IInputDevice::KX_PERIODKEY; - gReverseKeyTranslateTable[COMMAKEY ] = SCA_IInputDevice::KX_COMMAKEY; - gReverseKeyTranslateTable[QUOTEKEY ] = SCA_IInputDevice::KX_QUOTEKEY; - gReverseKeyTranslateTable[ACCENTGRAVEKEY ] = SCA_IInputDevice::KX_ACCENTGRAVEKEY; - gReverseKeyTranslateTable[MINUSKEY ] = SCA_IInputDevice::KX_MINUSKEY; - gReverseKeyTranslateTable[SLASHKEY ] = SCA_IInputDevice::KX_SLASHKEY; - gReverseKeyTranslateTable[BACKSLASHKEY ] = SCA_IInputDevice::KX_BACKSLASHKEY; - gReverseKeyTranslateTable[EQUALKEY ] = SCA_IInputDevice::KX_EQUALKEY; - gReverseKeyTranslateTable[LEFTBRACKETKEY ] = SCA_IInputDevice::KX_LEFTBRACKETKEY; - gReverseKeyTranslateTable[RIGHTBRACKETKEY ] = SCA_IInputDevice::KX_RIGHTBRACKETKEY; - - gReverseKeyTranslateTable[LEFTARROWKEY ] = SCA_IInputDevice::KX_LEFTARROWKEY; - gReverseKeyTranslateTable[DOWNARROWKEY ] = SCA_IInputDevice::KX_DOWNARROWKEY; - gReverseKeyTranslateTable[RIGHTARROWKEY ] = SCA_IInputDevice::KX_RIGHTARROWKEY; - gReverseKeyTranslateTable[UPARROWKEY ] = SCA_IInputDevice::KX_UPARROWKEY; - - gReverseKeyTranslateTable[PAD2 ] = SCA_IInputDevice::KX_PAD2; - gReverseKeyTranslateTable[PAD4 ] = SCA_IInputDevice::KX_PAD4; - gReverseKeyTranslateTable[PAD6 ] = SCA_IInputDevice::KX_PAD6; - gReverseKeyTranslateTable[PAD8 ] = SCA_IInputDevice::KX_PAD8; - - gReverseKeyTranslateTable[PAD1 ] = SCA_IInputDevice::KX_PAD1; - gReverseKeyTranslateTable[PAD3 ] = SCA_IInputDevice::KX_PAD3; - gReverseKeyTranslateTable[PAD5 ] = SCA_IInputDevice::KX_PAD5; - gReverseKeyTranslateTable[PAD7 ] = SCA_IInputDevice::KX_PAD7; - gReverseKeyTranslateTable[PAD9 ] = SCA_IInputDevice::KX_PAD9; - - gReverseKeyTranslateTable[PADPERIOD ] = SCA_IInputDevice::KX_PADPERIOD; - gReverseKeyTranslateTable[PADSLASHKEY ] = SCA_IInputDevice::KX_PADSLASHKEY; - gReverseKeyTranslateTable[PADASTERKEY ] = SCA_IInputDevice::KX_PADASTERKEY; - - gReverseKeyTranslateTable[PAD0 ] = SCA_IInputDevice::KX_PAD0; - gReverseKeyTranslateTable[PADMINUS ] = SCA_IInputDevice::KX_PADMINUS; - gReverseKeyTranslateTable[PADENTER ] = SCA_IInputDevice::KX_PADENTER; - gReverseKeyTranslateTable[PADPLUSKEY ] = SCA_IInputDevice::KX_PADPLUSKEY; - - - gReverseKeyTranslateTable[F1KEY ] = SCA_IInputDevice::KX_F1KEY; - gReverseKeyTranslateTable[F2KEY ] = SCA_IInputDevice::KX_F2KEY; - gReverseKeyTranslateTable[F3KEY ] = SCA_IInputDevice::KX_F3KEY; - gReverseKeyTranslateTable[F4KEY ] = SCA_IInputDevice::KX_F4KEY; - gReverseKeyTranslateTable[F5KEY ] = SCA_IInputDevice::KX_F5KEY; - gReverseKeyTranslateTable[F6KEY ] = SCA_IInputDevice::KX_F6KEY; - gReverseKeyTranslateTable[F7KEY ] = SCA_IInputDevice::KX_F7KEY; - gReverseKeyTranslateTable[F8KEY ] = SCA_IInputDevice::KX_F8KEY; - gReverseKeyTranslateTable[F9KEY ] = SCA_IInputDevice::KX_F9KEY; - gReverseKeyTranslateTable[F10KEY ] = SCA_IInputDevice::KX_F10KEY; - gReverseKeyTranslateTable[F11KEY ] = SCA_IInputDevice::KX_F11KEY; - gReverseKeyTranslateTable[F12KEY ] = SCA_IInputDevice::KX_F12KEY; - gReverseKeyTranslateTable[F13KEY ] = SCA_IInputDevice::KX_F13KEY; - gReverseKeyTranslateTable[F14KEY ] = SCA_IInputDevice::KX_F14KEY; - gReverseKeyTranslateTable[F15KEY ] = SCA_IInputDevice::KX_F15KEY; - gReverseKeyTranslateTable[F16KEY ] = SCA_IInputDevice::KX_F16KEY; - gReverseKeyTranslateTable[F17KEY ] = SCA_IInputDevice::KX_F17KEY; - gReverseKeyTranslateTable[F18KEY ] = SCA_IInputDevice::KX_F18KEY; - gReverseKeyTranslateTable[F19KEY ] = SCA_IInputDevice::KX_F19KEY; - - - gReverseKeyTranslateTable[PAUSEKEY ] = SCA_IInputDevice::KX_PAUSEKEY; - gReverseKeyTranslateTable[INSERTKEY ] = SCA_IInputDevice::KX_INSERTKEY; - gReverseKeyTranslateTable[HOMEKEY ] = SCA_IInputDevice::KX_HOMEKEY; - gReverseKeyTranslateTable[PAGEUPKEY ] = SCA_IInputDevice::KX_PAGEUPKEY; - gReverseKeyTranslateTable[PAGEDOWNKEY ] = SCA_IInputDevice::KX_PAGEDOWNKEY; - gReverseKeyTranslateTable[ENDKEY ] = SCA_IInputDevice::KX_ENDKEY; - } int executePriority = 0; int uniqueint = 0; @@ -470,9 +296,9 @@ void BL_ConvertSensors(struct Object* blenderobject, if (eventmgr) { gamesensor = new SCA_KeyboardSensor(eventmgr, - gReverseKeyTranslateTable[blenderkeybdsensor->key], - gReverseKeyTranslateTable[blenderkeybdsensor->qual], - gReverseKeyTranslateTable[blenderkeybdsensor->qual2], + ConvertKeyCode(blenderkeybdsensor->key), + ConvertKeyCode(blenderkeybdsensor->qual), + ConvertKeyCode(blenderkeybdsensor->qual2), (blenderkeybdsensor->type == SENS_ALL_KEYS), blenderkeybdsensor->targetName, blenderkeybdsensor->toggleName, diff --git a/source/gameengine/GamePlayer/common/GPC_KeyboardDevice.h b/source/gameengine/GamePlayer/common/GPC_KeyboardDevice.h index 5b267c92908..3d88dc467b0 100644 --- a/source/gameengine/GamePlayer/common/GPC_KeyboardDevice.h +++ b/source/gameengine/GamePlayer/common/GPC_KeyboardDevice.h @@ -57,6 +57,7 @@ protected: * System dependent keyboard codes are stored as ints. */ std::map<int, KX_EnumInputs> m_reverseKeyTranslateTable; + short m_exitkey; public: bool m_hookesc; diff --git a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp index 7490e187824..f9403c9725a 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_Application.cpp +++ b/source/gameengine/GamePlayer/ghost/GPG_Application.cpp @@ -40,6 +40,7 @@ #include "GPU_extensions.h" #include "GPG_Application.h" +#include "BL_BlenderDataConversion.h" #include <iostream> #include <MT_assert.h> @@ -626,6 +627,8 @@ bool GPG_Application::initEngine(GHOST_IWindow* window, const int stereoMode) m_ketsjiengine->SetRasterizer(m_rasterizer); m_ketsjiengine->SetTimingDisplay(frameRate, false, false); + + KX_KetsjiEngine::SetExitKey(ConvertKeyCode(gm->exitkey)); #ifdef WITH_PYTHON CValue::SetDeprecationWarnings(nodepwarnings); #else @@ -908,12 +911,10 @@ bool GPG_Application::handleKey(GHOST_IEvent* event, bool isDown) { GHOST_TEventDataPtr eventData = ((GHOST_IEvent*)event)->getData(); GHOST_TEventKeyData* keyData = static_cast<GHOST_TEventKeyData*>(eventData); - //no need for this test - //if (fSystem->getFullScreen()) { - if (keyData->key == GHOST_kKeyEsc && !m_keyboard->m_hookesc && !m_isEmbedded) { - m_exitRequested = KX_EXIT_REQUEST_OUTSIDE; - } - //} + + if (m_keyboard->ToNative(keyData->key) == KX_KetsjiEngine::GetExitKey() && !m_keyboard->m_hookesc && !m_isEmbedded) { + m_exitRequested = KX_EXIT_REQUEST_OUTSIDE; + } m_keyboard->ConvertEvent(keyData->key, isDown); handled = true; } diff --git a/source/gameengine/GamePlayer/ghost/GPG_Application.h b/source/gameengine/GamePlayer/ghost/GPG_Application.h index a8a976f9dd2..37625dc8998 100644 --- a/source/gameengine/GamePlayer/ghost/GPG_Application.h +++ b/source/gameengine/GamePlayer/ghost/GPG_Application.h @@ -103,6 +103,7 @@ protected: * Shuts the game engine down. */ void exitEngine(void); + short m_exitkey; /* The game data */ STR_String m_startSceneName; diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp index a9be588e6b2..29727dc04da 100644 --- a/source/gameengine/Ketsji/KX_KetsjiEngine.cpp +++ b/source/gameengine/Ketsji/KX_KetsjiEngine.cpp @@ -110,6 +110,7 @@ double KX_KetsjiEngine::m_suspendedtime = 0.0; double KX_KetsjiEngine::m_suspendeddelta = 0.0; double KX_KetsjiEngine::m_average_framerate = 0.0; bool KX_KetsjiEngine::m_restrict_anim_fps = false; +short KX_KetsjiEngine::m_exitkey = 130; //ESC Key /** @@ -1857,6 +1858,16 @@ double KX_KetsjiEngine::GetAverageFrameRate() return m_average_framerate; } +void KX_KetsjiEngine::SetExitKey(short key) +{ + m_exitkey = key; +} + +short KX_KetsjiEngine::GetExitKey() +{ + return m_exitkey; +} + void KX_KetsjiEngine::SetTimingDisplay(bool frameRate, bool profile, bool properties) { m_show_framerate = frameRate; diff --git a/source/gameengine/Ketsji/KX_KetsjiEngine.h b/source/gameengine/Ketsji/KX_KetsjiEngine.h index 5a02da07e43..96b737b686d 100644 --- a/source/gameengine/Ketsji/KX_KetsjiEngine.h +++ b/source/gameengine/Ketsji/KX_KetsjiEngine.h @@ -124,6 +124,8 @@ private: static double m_suspendedtime; static double m_suspendeddelta; + static short m_exitkey; /* Key used to exit the BGE */ + int m_exitcode; STR_String m_exitstring; /** @@ -352,6 +354,10 @@ public: */ static double GetAverageFrameRate(); + static void SetExitKey(short key); + + static short GetExitKey(); + /** * Activates or deactivates timing information display. * @param frameRate Display for frame rate on or off. diff --git a/source/gameengine/Ketsji/KX_PythonInit.cpp b/source/gameengine/Ketsji/KX_PythonInit.cpp index 29871c2b3cd..9a2c0cb89b1 100644 --- a/source/gameengine/Ketsji/KX_PythonInit.cpp +++ b/source/gameengine/Ketsji/KX_PythonInit.cpp @@ -419,6 +419,20 @@ static PyObject* gPyGetLogicTicRate(PyObject*) return PyFloat_FromDouble(KX_KetsjiEngine::GetTicRate()); } +static PyObject* gPySetExitKey(PyObject*, PyObject* args) +{ + short exitkey; + if (!PyArg_ParseTuple(args, "h:setExitKey", &exitkey)) + return NULL; + KX_KetsjiEngine::SetExitKey(exitkey); + Py_RETURN_NONE; +} + +static PyObject* gPyGetExitKey(PyObject*) +{ + return PyLong_FromSsize_t(KX_KetsjiEngine::GetExitKey()); +} + static PyObject* gPySetMaxLogicFrame(PyObject*, PyObject* args) { int frame; @@ -812,6 +826,8 @@ static struct PyMethodDef game_methods[] = { {"setLogicTicRate", (PyCFunction) gPySetLogicTicRate, METH_VARARGS, (const char *)"Sets the logic tic rate"}, {"getPhysicsTicRate", (PyCFunction) gPyGetPhysicsTicRate, METH_NOARGS, (const char *)"Gets the physics tic rate"}, {"setPhysicsTicRate", (PyCFunction) gPySetPhysicsTicRate, METH_VARARGS, (const char *)"Sets the physics tic rate"}, + {"getExitKey", (PyCFunction) gPyGetExitKey, METH_NOARGS, (const char *)"Gets the key used to exit the game engine"}, + {"setExitKey", (PyCFunction) gPySetExitKey, METH_VARARGS, (const char *)"Sets the key used to exit the game engine"}, {"getAverageFrameRate", (PyCFunction) gPyGetAverageFrameRate, METH_NOARGS, (const char *)"Gets the estimated average frame rate"}, {"getBlendFileList", (PyCFunction)gPyGetBlendFileList, METH_VARARGS, (const char *)"Gets a list of blend files in the same directory as the current blend file"}, {"PrintGLInfo", (PyCFunction)pyPrintExt, METH_NOARGS, (const char *)"Prints GL Extension Info"}, |