18 if (!WindowImpl::nativeWindow) {
19 std::unique_lock<std::mutex> lk(WindowImpl::androidMutex);
20 WindowImpl::cv.wait(lk);
35 const float deadZone = (8689.0f / 32768.0f);
36 float value = AMotionEvent_getAxisValue(event, axis, 0);
37 if (value > deadZone) {
38 return (value - deadZone) / (1.0f - deadZone);
39 }
else if (value < -deadZone) {
40 return (value + deadZone) / (1.0f - deadZone);
47 event.touchScreen.drag =
false;
48 event.touchScreen.pinch =
false;
51 if (AInputEvent_getType(androidEvent) == AINPUT_EVENT_TYPE_MOTION) {
59 event.touchScreen.doubleTap = !
event.touchScreen.doubleTap;
67 event.touchScreen.drag =
true;
74 pinchState & ndk_helper::GESTURE_STATE_END) {
75 event.touchScreen.pinch =
true;
90 AInputEvent* androidEvent =
nullptr;
92 if (AInputQueue_getEvent(
inputQueue, &androidEvent) >= 0) {
93 if (AInputQueue_preDispatchEvent(
inputQueue, androidEvent)) {
99 events.push(std::move(event));
100 AInputQueue_finishEvent(
inputQueue, androidEvent, 1);
int32_t HandleInput(lug::Window::Event &event, AInputEvent *androidEvent)
lug::Math::Vec2f coordinates[2]
The Touch coordinate.
ndk_helper::DoubletapDetector doubletap_detector_
virtual GESTURE_STATE Detect(const AInputEvent *event)
bool init(const Window::InitInfo &initInfo)
static ANativeWindow * nativeWindow
float MapCenteredAxis(AInputEvent *event, int32_t axis)
void setMousePos(const Math::Vec2i &mousePosition)
virtual GESTURE_STATE Detect(const AInputEvent *motion_event)
void setMouseCursorVisible(bool visible)
bool GetPointers(lug::Math::Vec2f &v1, lug::Math::Vec2f &v2)
virtual GESTURE_STATE Detect(const AInputEvent *event)
ndk_helper::DragDetector drag_detector_
static std::queue< lug::Window::Event > events
static AInputQueue * inputQueue
ANativeWindow * getWindow()
static ANativeActivity * activity
bool pollEvent(lug::Window::Event &event)
TouchScreenEvent touchScreen
void setKeyRepeat(bool state)
ndk_helper::PinchDetector pinch_detector_
bool GetPointer(lug::Math::Vec2f &v)
static std::condition_variable cv
static std::mutex androidMutex