Skip to content

Commit

Permalink
Debug messages for Android
Browse files Browse the repository at this point in the history
  • Loading branch information
deathkiller committed Nov 26, 2024
1 parent d7fe64f commit 019c6cb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
9 changes: 8 additions & 1 deletion Sources/nCine/Backends/Android/AndroidInputManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ namespace nCine
}

keyboardEvent_.scancode = AKeyEvent_getScanCode(event);
keyboardEvent_.sym = AndroidKeys::keySymValueToEnum(AKeyEvent_getKeyCode(event));
keyboardEvent_.sym = AndroidKeys::keySymValueToEnum(keyCode);
keyboardEvent_.mod = AndroidKeys::keyModMaskToEnumMask(AKeyEvent_getMetaState(event));

const unsigned int keySym = static_cast<unsigned int>(keyboardEvent_.sym);
Expand All @@ -428,15 +428,18 @@ namespace nCine
if (keyboardEvent_.sym != KeySym::UNKNOWN) {
keyboardState_.keys_[keySym] = 1;
}
LOGW("ANDROIDKEY DOWN: %i | %i | %i", keyCode, keyboardEvent_.sym, keyboardEvent_.mod);
inputEventHandler_->OnKeyPressed(keyboardEvent_);
break;
case AKEY_EVENT_ACTION_UP:
if (keyboardEvent_.sym != KeySym::UNKNOWN) {
keyboardState_.keys_[keySym] = 0;
}
LOGW("ANDROIDKEY DOWN: %i | %i | %i", keyCode, keyboardEvent_.sym, keyboardEvent_.mod);
inputEventHandler_->OnKeyReleased(keyboardEvent_);
break;
case AKEY_EVENT_ACTION_MULTIPLE:
LOGW("ANDROIDKEY MULTIPLE: %i | %i | %i", keyCode, keyboardEvent_.sym, keyboardEvent_.mod);
inputEventHandler_->OnKeyPressed(keyboardEvent_);
break;
}
Expand All @@ -450,6 +453,10 @@ namespace nCine
if (textInputEvent_.length > 0) {
inputEventHandler_->OnTextInput(textInputEvent_);
}
LOGW("ANDROIDKEY TEXT 1: %i | %i | %s", keyCode, unicodeKey, String(textInputEvent_.text, textInputEvent_.length).data());
} else {
const int unicodeKey = keyEvent.getUnicodeChar(AKeyEvent_getMetaState(event));
LOGW("ANDROIDKEY TEXT 2: %i | %i", keyCode, unicodeKey);
}
}

Expand Down
5 changes: 2 additions & 3 deletions Sources/nCine/Backends/Android/AndroidInputManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ namespace nCine
/// The class for parsing and dispatching Android input events
class AndroidInputManager : public IInputManager
{
friend class AndroidApplication;

public:
explicit AndroidInputManager(struct android_app* state);
~AndroidInputManager() override;
Expand Down Expand Up @@ -222,9 +224,6 @@ namespace nCine
static int findJoyId(int deviceId);
static bool isDeviceConnected(int deviceId);
static void deviceInfo(int deviceId, int joyId);

/// To update joystick connections in `AndroidApplication::androidMain()`
friend class AndroidApplication;
};

}

0 comments on commit 019c6cb

Please sign in to comment.