added ABS_X and ABS_Y events handling in evdev

This commit is contained in:
Krylov Yaroslav 2019-06-20 11:12:41 +03:00
parent 3e17d8f46b
commit f33fb7ef58
3 changed files with 23 additions and 5 deletions

View File

@ -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);
}

View File

@ -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);

View File

@ -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);
}