From f33fb7ef58c184f37cff09d2d32252cc6d63a54c Mon Sep 17 00:00:00 2001 From: Krylov Yaroslav Date: Thu, 20 Jun 2019 11:12:41 +0300 Subject: [PATCH] added ABS_X and ABS_Y events handling in evdev --- src/evdev.c | 16 ++++++++++++++-- src/evdev.h | 3 ++- src/vivante_init.c | 9 +++++++-- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/evdev.c b/src/evdev.c index 1af0d1792..63ed2c4cf 100644 --- a/src/evdev.c +++ b/src/evdev.c @@ -367,15 +367,25 @@ static void handleKeyEvent(_GLFWeventDevice* ed, int code, int value) static void handleRelEvent(_GLFWeventDevice* ed, int code, int value) { if (code == REL_X){ - _glfwEvdevInputCursorPos(value, .0); + _glfwEvdevInputCursorMove(value, .0); }else if (code == REL_Y) - _glfwEvdevInputCursorPos(.0, value); + _glfwEvdevInputCursorMove(.0, value); else if (code == REL_HWHEEL) _glfwEvdevInputScroll(value, .0); else if (code == REL_WHEEL) _glfwEvdevInputScroll(.0, value); } +// Apply an EV_ABS event to the specified event device +// +static void handleAbsEvent(_GLFWeventDevice* ed, int code, int value) +{ + if (code == ABS_X){ + _glfwEvdevInputCursorPos(value, .0); + }else if (code == ABS_Y) + _glfwEvdevInputCursorPos(.0, value); +} + // Apply an EV_LED event to the specified event device // static void handleLedEvent(_GLFWeventDevice* ed, int code, int value) @@ -627,6 +637,8 @@ int _glfwPollEvdevDevice( _GLFWeventDevice* ed) handleKeyEvent(ed, e.code, e.value); else if (e.type == EV_REL) handleRelEvent(ed, e.code, e.value); + else if (e.type == EV_ABS) + handleAbsEvent(ed, e.code, e.value); else if (e.type == EV_LED) handleLedEvent(ed, e.code, e.value); } diff --git a/src/evdev.h b/src/evdev.h index 60795e2cd..3b72af28d 100644 --- a/src/evdev.h +++ b/src/evdev.h @@ -76,4 +76,5 @@ void _glfwEvdevInputKey(int key, int scancode, int action, int mods); void _glfwEvdevInputChar(unsigned int codepoint, int mods, GLFWbool plain); void _glfwEvdevInputScroll(double xoffset, double yoffset); void _glfwEvdevInputMouseClick(int button, int action, int mods); -void _glfwEvdevInputCursorPos(double xoffset, double yoffset); +void _glfwEvdevInputCursorMove(double xoffset, double yoffset); +void _glfwEvdevInputCursorPos(double xpos, double ypos); diff --git a/src/vivante_init.c b/src/vivante_init.c index c5ebca3c3..972c42ab8 100644 --- a/src/vivante_init.c +++ b/src/vivante_init.c @@ -169,7 +169,12 @@ void _glfwEvdevInputMouseClick(int button, int action, int mods) printf("_glfwEvdevInputMouseClick button = %i, action = %i, mods = %i\n", button, action, mods); } -void _glfwEvdevInputCursorPos(double xoffset, double yoffset) +void _glfwEvdevInputCursorPos(double xpos, double ypos) { - printf("_glfwEvdevInputCursorPos xoffset = %f, yoffset = %f\n", xoffset, yoffset); + printf("_glfwEvdevInputCursorPos xpos = %f, ypos = %f\n", xpos, ypos); +} + +void _glfwEvdevInputCursorMove(double xoffset, double yoffset) +{ + printf("_glfwEvdevInputCursorMove xoffset = %f, yoffset = %f\n", xoffset, yoffset); }