mirror of https://github.com/axmolengine/axmol.git
Merge pull request #3054 from simpliplant/windows_keyboard_support
Hardware keyboard support (Windows support + Mac fix)
This commit is contained in:
commit
ddf54a4f49
|
@ -54,11 +54,11 @@ void KeyboardDispatcher::setKeyReleaseDelegate(KeyboardDelegate delegate)
|
|||
|
||||
bool KeyboardDispatcher::dispatchKeyboardEvent(int keyCode, bool pressed)
|
||||
{
|
||||
if (_keyPressDelegate != NULL && pressed)
|
||||
if (_keyPressDelegate != nullptr && pressed)
|
||||
{
|
||||
_keyPressDelegate(keyCode);
|
||||
}
|
||||
else if (_keyReleaseDelegate != NULL)
|
||||
else if (_keyReleaseDelegate != nullptr )
|
||||
{
|
||||
_keyReleaseDelegate(keyCode);
|
||||
}
|
||||
|
|
|
@ -505,9 +505,8 @@ static int eventQueueCount;
|
|||
{
|
||||
if( dispatchEvents_ ) {
|
||||
tListEntry *entry, *tmp;
|
||||
cocos2d::Director::sharedDirector()->getKeyboardDispatcher()->dispatchKeyboardEvent(event.keyCode, true);
|
||||
|
||||
cocos2d::KeyboardDispatcher *kbDisp = cocos2d::Director::sharedDirector()->getKeyboardDispatcher();
|
||||
kbDisp->dispatchKeyboardEvent(event.keyCode, true);
|
||||
DL_FOREACH_SAFE( keyboardDelegates_, entry, tmp ) {
|
||||
if ( entry->flags & kImplementsKeyDown ) {
|
||||
void *swallows = [entry->delegate performSelector:@selector(ccKeyDown:) withObject:event];
|
||||
|
@ -522,9 +521,8 @@ static int eventQueueCount;
|
|||
{
|
||||
if( dispatchEvents_ ) {
|
||||
tListEntry *entry, *tmp;
|
||||
|
||||
cocos2d::KeyboardDispatcher *kbDisp = cocos2d::Director::sharedDirector()->getKeyboardDispatcher();
|
||||
kbDisp->dispatchKeyboardEvent(event.keyCode, true);
|
||||
cocos2d::Director::sharedDirector()->getKeyboardDispatcher()->dispatchKeyboardEvent(event.keyCode, false);
|
||||
|
||||
DL_FOREACH_SAFE( keyboardDelegates_, entry, tmp ) {
|
||||
if ( entry->flags & kImplementsKeyUp ) {
|
||||
void *swallows = [entry->delegate performSelector:@selector(ccKeyUp:) withObject:event];
|
||||
|
|
|
@ -32,6 +32,9 @@ THE SOFTWARE.
|
|||
#include "keypad_dispatcher/CCKeypadDispatcher.h"
|
||||
#include "support/CCPointExtension.h"
|
||||
#include "CCApplication.h"
|
||||
#ifdef CC_KEYBOARD_SUPPORT
|
||||
#include "keyboard_dispatcher/CCKeyboardDispatcher.h"
|
||||
#endif
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
|
@ -449,6 +452,9 @@ LRESULT EGLView::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
|
|||
}
|
||||
break;
|
||||
case WM_KEYDOWN:
|
||||
#ifdef CC_KEYBOARD_SUPPORT
|
||||
Director::sharedDirector()->getKeyboardDispatcher()->dispatchKeyboardEvent(wParam, true);
|
||||
#endif
|
||||
if (wParam == VK_F1 || wParam == VK_F2)
|
||||
{
|
||||
Director* pDirector = Director::sharedDirector();
|
||||
|
@ -466,6 +472,9 @@ LRESULT EGLView::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
|
|||
}
|
||||
break;
|
||||
case WM_KEYUP:
|
||||
#ifdef CC_KEYBOARD_SUPPORT
|
||||
Director::sharedDirector()->getKeyboardDispatcher()->dispatchKeyboardEvent(wParam, false);
|
||||
#endif
|
||||
if ( _lpfnAccelerometerKeyHook!=NULL )
|
||||
{
|
||||
(*_lpfnAccelerometerKeyHook)( message,wParam,lParam );
|
||||
|
|
Loading…
Reference in New Issue