mirror of
https://github.com/gnif/LookingGlass.git
synced 2025-04-25 08:06:30 +00:00
[client] evdev: implement mouse support
Some checks are pending
build / client (Debug, map[cc:clang cxx:clang++], libdecor) (push) Waiting to run
build / client (Debug, map[cc:clang cxx:clang++], xdg-shell) (push) Waiting to run
build / client (Debug, map[cc:gcc cxx:g++], libdecor) (push) Waiting to run
build / client (Debug, map[cc:gcc cxx:g++], xdg-shell) (push) Waiting to run
build / client (Release, map[cc:clang cxx:clang++], libdecor) (push) Waiting to run
build / client (Release, map[cc:clang cxx:clang++], xdg-shell) (push) Waiting to run
build / client (Release, map[cc:gcc cxx:g++], libdecor) (push) Waiting to run
build / client (Release, map[cc:gcc cxx:g++], xdg-shell) (push) Waiting to run
build / module (push) Waiting to run
build / host-linux (push) Waiting to run
build / host-windows-cross (push) Waiting to run
build / host-windows-native (push) Waiting to run
build / obs (clang) (push) Waiting to run
build / obs (gcc) (push) Waiting to run
build / docs (push) Waiting to run
Some checks are pending
build / client (Debug, map[cc:clang cxx:clang++], libdecor) (push) Waiting to run
build / client (Debug, map[cc:clang cxx:clang++], xdg-shell) (push) Waiting to run
build / client (Debug, map[cc:gcc cxx:g++], libdecor) (push) Waiting to run
build / client (Debug, map[cc:gcc cxx:g++], xdg-shell) (push) Waiting to run
build / client (Release, map[cc:clang cxx:clang++], libdecor) (push) Waiting to run
build / client (Release, map[cc:clang cxx:clang++], xdg-shell) (push) Waiting to run
build / client (Release, map[cc:gcc cxx:g++], libdecor) (push) Waiting to run
build / client (Release, map[cc:gcc cxx:g++], xdg-shell) (push) Waiting to run
build / module (push) Waiting to run
build / host-linux (push) Waiting to run
build / host-windows-cross (push) Waiting to run
build / host-windows-native (push) Waiting to run
build / obs (clang) (push) Waiting to run
build / obs (gcc) (push) Waiting to run
build / docs (push) Waiting to run
This commit is contained in:
parent
4278a10fe1
commit
5382a94945
@ -28,6 +28,7 @@
|
|||||||
#include <sys/epoll.h>
|
#include <sys/epoll.h>
|
||||||
|
|
||||||
#include "app_internal.h"
|
#include "app_internal.h"
|
||||||
|
#include "core.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
|
||||||
#include "common/debug.h"
|
#include "common/debug.h"
|
||||||
@ -74,7 +75,7 @@ static struct Option options[] =
|
|||||||
{
|
{
|
||||||
.module = "input",
|
.module = "input",
|
||||||
.name = "evdev",
|
.name = "evdev",
|
||||||
.description = "csv list of evdev keyboard devices to use "
|
.description = "csv list of evdev input devices to use "
|
||||||
"for capture mode (ie: /dev/input/by-id/usb-some_device-event-kbd)",
|
"for capture mode (ie: /dev/input/by-id/usb-some_device-event-kbd)",
|
||||||
.type = OPTION_TYPE_STRING,
|
.type = OPTION_TYPE_STRING,
|
||||||
.value.x_string = NULL,
|
.value.x_string = NULL,
|
||||||
@ -82,8 +83,7 @@ static struct Option options[] =
|
|||||||
{
|
{
|
||||||
.module = "input",
|
.module = "input",
|
||||||
.name = "evdevExclusive",
|
.name = "evdevExclusive",
|
||||||
.description = "Only use evdev devices for keyboard input when in capture "
|
.description = "Only use evdev devices for input when in capture mode",
|
||||||
"mode",
|
|
||||||
.type = OPTION_TYPE_BOOL,
|
.type = OPTION_TYPE_BOOL,
|
||||||
.value.x_bool = true
|
.value.x_bool = true
|
||||||
},
|
},
|
||||||
@ -199,21 +199,33 @@ static int evdev_thread(void * opaque)
|
|||||||
if (n % sizeof(*msgs) != 0)
|
if (n % sizeof(*msgs) != 0)
|
||||||
DEBUG_WARN("Incomplete evdev read: %s", device->path);
|
DEBUG_WARN("Incomplete evdev read: %s", device->path);
|
||||||
|
|
||||||
|
bool grabbed = state.grabbed;
|
||||||
|
|
||||||
int count = n / sizeof(*msgs);
|
int count = n / sizeof(*msgs);
|
||||||
struct input_event *ev = msgs;
|
struct input_event *ev = msgs;
|
||||||
|
int mouseX = 0, mouseY = 0;
|
||||||
|
|
||||||
for(int i = 0; i < count; ++i, ++ev)
|
for(int i = 0; i < count; ++i, ++ev)
|
||||||
{
|
{
|
||||||
if (ev->type != EV_KEY)
|
switch(ev->type)
|
||||||
continue;
|
{
|
||||||
|
case EV_KEY:
|
||||||
|
{
|
||||||
|
bool isMouseBtn = ev->code >= BTN_MOUSE && ev->code <= BTN_BACK;
|
||||||
|
static const int mouseBtnMap[] = {1, 3, 2, 6, 7, 0, 0};
|
||||||
|
|
||||||
bool grabbed = state.grabbed;
|
|
||||||
if (ev->value == 1)
|
if (ev->value == 1)
|
||||||
{
|
{
|
||||||
++state.keys[ev->code];
|
++state.keys[ev->code];
|
||||||
|
|
||||||
if (grabbed && state.keys[ev->code] == 1)
|
if (grabbed && state.keys[ev->code] == 1)
|
||||||
|
{
|
||||||
|
if (isMouseBtn)
|
||||||
|
app_handleButtonPress(mouseBtnMap[ev->code - BTN_MOUSE]);
|
||||||
|
else
|
||||||
app_handleKeyPressInternal(ev->code);
|
app_handleKeyPressInternal(ev->code);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else if (ev->value == 0 && --state.keys[ev->code] <= 0)
|
else if (ev->value == 0 && --state.keys[ev->code] <= 0)
|
||||||
{
|
{
|
||||||
state.keys[ev->code] = 0;
|
state.keys[ev->code] = 0;
|
||||||
@ -230,9 +242,49 @@ static int evdev_thread(void * opaque)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (grabbed)
|
if (grabbed)
|
||||||
|
{
|
||||||
|
if (isMouseBtn)
|
||||||
|
app_handleButtonRelease(mouseBtnMap[ev->code - BTN_MOUSE]);
|
||||||
|
else
|
||||||
app_handleKeyReleaseInternal(ev->code);
|
app_handleKeyReleaseInternal(ev->code);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case EV_REL:
|
||||||
|
if (!grabbed)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
switch(ev->code)
|
||||||
|
{
|
||||||
|
case REL_X:
|
||||||
|
mouseX += ev->value;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case REL_Y:
|
||||||
|
mouseY += ev->value;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case REL_WHEEL:
|
||||||
|
{
|
||||||
|
int btn;
|
||||||
|
if (ev->value > 0)
|
||||||
|
btn = 4;
|
||||||
|
else
|
||||||
|
btn = 5;
|
||||||
|
|
||||||
|
app_handleButtonPress (btn);
|
||||||
|
app_handleButtonRelease(btn);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mouseX != 0 || mouseY != 0)
|
||||||
|
core_handleMouseGrabbed(mouseX, mouseY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DEBUG_INFO("evdev_thread Stopped");
|
DEBUG_INFO("evdev_thread Stopped");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user