mirror of
https://github.com/gnif/LookingGlass.git
synced 2026-08-22 07:01:30 +00:00
[client] evdev: fix input capture and device handling
Classify configured devices by keyboard and pointer capability so automatic keyboard capture leaves relative pointer devices with the display server. Run descriptor, grab, physical-state, and LED operations on one worker. Marshal normalized events through each display server's event loop and serialize ownership changes with per-lane barriers. Fall back whole lanes to native input when an evdev cohort cannot be owned, and retry missing or removed devices without disabling the rest. Handle report framing, SYN_DROPPED, high-resolution wheels, queue overflow, held-state cleanup, and guest-driven keyboard LEDs. Restore host LEDs and kernel grabs during teardown. Re-evaluate capture when the active input transport changes.
This commit is contained in:
@@ -36,22 +36,31 @@ bool evdev_start(void);
|
|||||||
void evdev_stop(void);
|
void evdev_stop(void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* restore the display server hooks and free the device state; only
|
* free the device state; only call once display server callbacks have stopped
|
||||||
* call once display server callbacks have stopped
|
|
||||||
*/
|
*/
|
||||||
void evdev_free(void);
|
void evdev_free(void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* grab the keyboard for exclusive access
|
* update the keyboard and pointer capture requirements
|
||||||
*/
|
*/
|
||||||
void evdev_grabKeyboard(void);
|
void evdev_setGrab(bool keyboard, bool pointer);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ungrab the keyboard
|
* return the event fd used to dispatch captured input
|
||||||
*/
|
*/
|
||||||
void evdev_ungrabKeyboard(void);
|
int evdev_getEventFD(void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* returns true if input should only be processed by evdev
|
* dispatch captured input on the display server's event thread
|
||||||
|
*/
|
||||||
|
void evdev_dispatch(void * opaque);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* return true if keyboard input should only be processed by evdev
|
||||||
*/
|
*/
|
||||||
bool evdev_isExclusive(void);
|
bool evdev_isExclusive(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* return true if pointer input should only be processed by evdev
|
||||||
|
*/
|
||||||
|
bool evdev_isPointerExclusive(void);
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
typedef void (*LGInputKeyboardLEDsFn)(void * opaque,
|
typedef void (*LGInputKeyboardLEDsFn)(void * opaque,
|
||||||
bool valid, uint8_t leds);
|
bool valid, uint8_t leds);
|
||||||
|
typedef void (*LGInputAvailabilityFn)(void * opaque, bool available);
|
||||||
|
|
||||||
void lgInput_init(void);
|
void lgInput_init(void);
|
||||||
void lgInput_free(void);
|
void lgInput_free(void);
|
||||||
@@ -43,11 +44,20 @@ bool lgInput_supports(LG_InputSupport support);
|
|||||||
* call back into the input layer. */
|
* call back into the input layer. */
|
||||||
void lgInput_setKeyboardLEDsListener(
|
void lgInput_setKeyboardLEDsListener(
|
||||||
LGInputKeyboardLEDsFn callback, void * opaque);
|
LGInputKeyboardLEDsFn callback, void * opaque);
|
||||||
|
/* The listener is called synchronously with the current input availability
|
||||||
|
* and later from transport threads whenever it changes. The callback must
|
||||||
|
* not call back into the input layer. */
|
||||||
|
void lgInput_setAvailabilityListener(
|
||||||
|
LGInputAvailabilityFn callback, void * opaque);
|
||||||
|
|
||||||
bool lgInput_keyDown(int key);
|
bool lgInput_keyDown(int key);
|
||||||
bool lgInput_keyUp(int key);
|
bool lgInput_keyUp(int key);
|
||||||
bool lgInput_keyboardLEDs(bool numLock, bool capsLock, bool scrollLock);
|
bool lgInput_keyboardLEDs(bool numLock, bool capsLock, bool scrollLock);
|
||||||
void lgInput_releaseKeys(void);
|
void lgInput_releaseKeys(void);
|
||||||
|
void lgInput_releaseButtons(void);
|
||||||
|
/* Release all tracked keyboard and mouse button state under one active-input
|
||||||
|
* transaction. */
|
||||||
|
void lgInput_releaseAll(void);
|
||||||
|
|
||||||
bool lgInput_mouseMotion(int32_t x, int32_t y);
|
bool lgInput_mouseMotion(int32_t x, int32_t y);
|
||||||
bool lgInput_mousePosition(uint32_t x, uint32_t y, uint32_t width,
|
bool lgInput_mousePosition(uint32_t x, uint32_t y, uint32_t width,
|
||||||
|
|||||||
@@ -174,6 +174,9 @@ bool app_isOverlayMode(void)
|
|||||||
|
|
||||||
void app_updateCursorPos(double x, double y)
|
void app_updateCursorPos(double x, double y)
|
||||||
{
|
{
|
||||||
|
if (evdev_isPointerExclusive())
|
||||||
|
return;
|
||||||
|
|
||||||
const bool overlay = app_isOverlayMode();
|
const bool overlay = app_isOverlayMode();
|
||||||
if (overlay)
|
if (overlay)
|
||||||
{
|
{
|
||||||
@@ -375,7 +378,7 @@ static int mapInputToImGuiButton(uint32_t button)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void app_handleButtonPress(int button)
|
void app_handleButtonPressInternal(int button)
|
||||||
{
|
{
|
||||||
g_cursor.buttons |= (1U << button);
|
g_cursor.buttons |= (1U << button);
|
||||||
app_updateMouseButtons();
|
app_updateMouseButtons();
|
||||||
@@ -399,7 +402,13 @@ void app_handleButtonPress(int button)
|
|||||||
DEBUG_ERROR("app_handleButtonPress: failed to send message");
|
DEBUG_ERROR("app_handleButtonPress: failed to send message");
|
||||||
}
|
}
|
||||||
|
|
||||||
void app_handleButtonRelease(int button)
|
void app_handleButtonPress(int button)
|
||||||
|
{
|
||||||
|
if (!evdev_isPointerExclusive())
|
||||||
|
app_handleButtonPressInternal(button);
|
||||||
|
}
|
||||||
|
|
||||||
|
void app_handleButtonReleaseInternal(int button)
|
||||||
{
|
{
|
||||||
g_cursor.buttons &= ~(1U << button);
|
g_cursor.buttons &= ~(1U << button);
|
||||||
app_updateMouseButtons();
|
app_updateMouseButtons();
|
||||||
@@ -422,8 +431,17 @@ void app_handleButtonRelease(int button)
|
|||||||
DEBUG_ERROR("app_handleButtonRelease: failed to send message");
|
DEBUG_ERROR("app_handleButtonRelease: failed to send message");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void app_handleButtonRelease(int button)
|
||||||
|
{
|
||||||
|
if (!evdev_isPointerExclusive())
|
||||||
|
app_handleButtonReleaseInternal(button);
|
||||||
|
}
|
||||||
|
|
||||||
void app_handleWheelMotion(double motion)
|
void app_handleWheelMotion(double motion)
|
||||||
{
|
{
|
||||||
|
if (evdev_isPointerExclusive())
|
||||||
|
return;
|
||||||
|
|
||||||
if (app_isOverlayMode())
|
if (app_isOverlayMode())
|
||||||
g_state.io->MouseWheel -= motion;
|
g_state.io->MouseWheel -= motion;
|
||||||
}
|
}
|
||||||
@@ -570,11 +588,15 @@ void app_handleKeyRelease(int sc)
|
|||||||
|
|
||||||
void app_handleKeyboardTyped(const char * typed)
|
void app_handleKeyboardTyped(const char * typed)
|
||||||
{
|
{
|
||||||
|
if (evdev_isExclusive())
|
||||||
|
return;
|
||||||
|
|
||||||
app_registerImGuiText(typed);
|
app_registerImGuiText(typed);
|
||||||
ImGuiIO_AddInputCharactersUTF8(g_state.io, typed);
|
ImGuiIO_AddInputCharactersUTF8(g_state.io, typed);
|
||||||
}
|
}
|
||||||
|
|
||||||
void app_handleKeyboardModifiers(bool ctrl, bool shift, bool alt, bool super)
|
void app_handleKeyboardModifiersInternal(
|
||||||
|
bool ctrl, bool shift, bool alt, bool super)
|
||||||
{
|
{
|
||||||
g_state.modCtrl = ctrl;
|
g_state.modCtrl = ctrl;
|
||||||
g_state.modShift = shift;
|
g_state.modShift = shift;
|
||||||
@@ -582,8 +604,57 @@ void app_handleKeyboardModifiers(bool ctrl, bool shift, bool alt, bool super)
|
|||||||
g_state.modSuper = super;
|
g_state.modSuper = super;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void app_handleKeyboardModifiers(bool ctrl, bool shift, bool alt, bool super)
|
||||||
|
{
|
||||||
|
if (!evdev_isExclusive())
|
||||||
|
app_handleKeyboardModifiersInternal(ctrl, shift, alt, super);
|
||||||
|
}
|
||||||
|
|
||||||
|
void app_handleInputResetInternal(bool keyboard, bool pointer)
|
||||||
|
{
|
||||||
|
if (pointer)
|
||||||
|
{
|
||||||
|
g_cursor.buttons = 0;
|
||||||
|
app_updateMouseButtons();
|
||||||
|
g_state.io->MouseDown[ImGuiMouseButton_Left ] = false;
|
||||||
|
g_state.io->MouseDown[ImGuiMouseButton_Right ] = false;
|
||||||
|
g_state.io->MouseDown[ImGuiMouseButton_Middle] = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (keyboard)
|
||||||
|
{
|
||||||
|
for(int key = 0; key < KEY_MAX; ++key)
|
||||||
|
if (linux_to_imgui[key])
|
||||||
|
ImGuiIO_AddKeyEvent(g_state.io, linux_to_imgui[key], false);
|
||||||
|
|
||||||
|
g_state.modCtrl = false;
|
||||||
|
g_state.modShift = false;
|
||||||
|
g_state.modAlt = false;
|
||||||
|
g_state.modSuper = false;
|
||||||
|
g_state.escapeActive = false;
|
||||||
|
g_state.escapeTime = 0;
|
||||||
|
g_state.escapeAction = -1;
|
||||||
|
memset(g_state.escapeKeys, 0, sizeof(g_state.escapeKeys));
|
||||||
|
memset(g_state.escapeShiftKeys, 0,
|
||||||
|
sizeof(g_state.escapeShiftKeys));
|
||||||
|
atomic_store_explicit(
|
||||||
|
&g_state.keyModifiers, 0, memory_order_release);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (keyboard && pointer)
|
||||||
|
lgInput_releaseAll();
|
||||||
|
else if (keyboard)
|
||||||
|
lgInput_releaseKeys();
|
||||||
|
else if (pointer)
|
||||||
|
lgInput_releaseButtons();
|
||||||
|
app_invalidateWindow(false);
|
||||||
|
}
|
||||||
|
|
||||||
void app_handleKeyboardLEDs(bool numLock, bool capsLock, bool scrollLock)
|
void app_handleKeyboardLEDs(bool numLock, bool capsLock, bool scrollLock)
|
||||||
{
|
{
|
||||||
|
if (evdev_isExclusive())
|
||||||
|
return;
|
||||||
|
|
||||||
if (!core_inputEnabled())
|
if (!core_inputEnabled())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -594,6 +665,9 @@ void app_handleKeyboardLEDs(bool numLock, bool capsLock, bool scrollLock)
|
|||||||
void app_handleMouseRelative(double normx, double normy,
|
void app_handleMouseRelative(double normx, double normy,
|
||||||
double rawx, double rawy)
|
double rawx, double rawy)
|
||||||
{
|
{
|
||||||
|
if (evdev_isPointerExclusive())
|
||||||
|
return;
|
||||||
|
|
||||||
MTRACE("rel delta=%.3f,%.3f raw=%.3f,%.3f inWin=%d inView=%d "
|
MTRACE("rel delta=%.3f,%.3f raw=%.3f,%.3f inWin=%d inView=%d "
|
||||||
"grab=%d", normx, normy, rawx, rawy, g_cursor.inWindow,
|
"grab=%d", normx, normy, rawx, rawy, g_cursor.inWindow,
|
||||||
g_cursor.inView, g_cursor.grab);
|
g_cursor.inView, g_cursor.grab);
|
||||||
|
|||||||
@@ -25,5 +25,10 @@
|
|||||||
|
|
||||||
void app_handleKeyPressInternal(int scancode);
|
void app_handleKeyPressInternal(int scancode);
|
||||||
void app_handleKeyReleaseInternal(int scancode);
|
void app_handleKeyReleaseInternal(int scancode);
|
||||||
|
void app_handleButtonPressInternal(int button);
|
||||||
|
void app_handleButtonReleaseInternal(int button);
|
||||||
|
void app_handleKeyboardModifiersInternal(
|
||||||
|
bool ctrl, bool shift, bool alt, bool super);
|
||||||
|
void app_handleInputResetInternal(bool keyboard, bool pointer);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
#include "kb.h"
|
#include "kb.h"
|
||||||
#include "message.h"
|
#include "message.h"
|
||||||
#include "input.h"
|
#include "input.h"
|
||||||
|
#include "evdev.h"
|
||||||
|
|
||||||
#include "common/time.h"
|
#include "common/time.h"
|
||||||
#include "common/debug.h"
|
#include "common/debug.h"
|
||||||
@@ -140,6 +141,8 @@ bool core_inputEnabled(void)
|
|||||||
void core_updateKeyboardGrab(void)
|
void core_updateKeyboardGrab(void)
|
||||||
{
|
{
|
||||||
const bool inputEnabled = core_inputEnabled();
|
const bool inputEnabled = core_inputEnabled();
|
||||||
|
const bool localActive = g_state.focused && !app_isOverlayMode() &&
|
||||||
|
!g_state.ignoreInput;
|
||||||
/* Explicit capture is local window state and must survive an input provider
|
/* Explicit capture is local window state and must survive an input provider
|
||||||
* becoming unavailable or changing during startup. */
|
* becoming unavailable or changing during startup. */
|
||||||
const bool capture = g_cursor.grab && g_params.grabKeyboard &&
|
const bool capture = g_cursor.grab && g_params.grabKeyboard &&
|
||||||
@@ -150,6 +153,7 @@ void core_updateKeyboardGrab(void)
|
|||||||
const bool active = g_state.focused && !app_isOverlayMode() &&
|
const bool active = g_state.focused && !app_isOverlayMode() &&
|
||||||
(capture || (inputEnabled && (view || automatic)));
|
(capture || (inputEnabled && (view || automatic)));
|
||||||
|
|
||||||
|
evdev_setGrab(active, localActive && g_cursor.grab);
|
||||||
if (active)
|
if (active)
|
||||||
g_state.ds->grabKeyboard();
|
g_state.ds->grabKeyboard();
|
||||||
else
|
else
|
||||||
|
|||||||
2353
client/src/evdev.c
2353
client/src/evdev.c
File diff suppressed because it is too large
Load Diff
@@ -42,15 +42,19 @@ static struct
|
|||||||
LG_Lock bindingLock;
|
LG_Lock bindingLock;
|
||||||
LG_RWLock activeLock;
|
LG_RWLock activeLock;
|
||||||
LG_Lock keyboardLEDsDispatch;
|
LG_Lock keyboardLEDsDispatch;
|
||||||
|
LG_Lock availabilityDispatch;
|
||||||
uint32_t nextBindingEpoch;
|
uint32_t nextBindingEpoch;
|
||||||
|
|
||||||
LGInputKeyboardLEDsFn keyboardLEDsCallback;
|
LGInputKeyboardLEDsFn keyboardLEDsCallback;
|
||||||
void * keyboardLEDsOpaque;
|
void * keyboardLEDsOpaque;
|
||||||
|
LGInputAvailabilityFn availabilityCallback;
|
||||||
|
void * availabilityOpaque;
|
||||||
|
|
||||||
struct InputBinding fallback;
|
struct InputBinding fallback;
|
||||||
struct InputBinding transport;
|
struct InputBinding transport;
|
||||||
struct InputBinding active;
|
struct InputBinding active;
|
||||||
bool useTransport;
|
bool useTransport;
|
||||||
|
bool notifiedAvailable;
|
||||||
|
|
||||||
_Atomic(bool) keys[KEY_MAX];
|
_Atomic(bool) keys[KEY_MAX];
|
||||||
_Atomic(uint32_t) buttons;
|
_Atomic(uint32_t) buttons;
|
||||||
@@ -126,6 +130,30 @@ static void dispatchKeyboardLEDs(void)
|
|||||||
LG_UNLOCK(l_input.keyboardLEDsDispatch);
|
LG_UNLOCK(l_input.keyboardLEDsDispatch);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool updateAvailabilityNL(void)
|
||||||
|
{
|
||||||
|
const bool available = l_input.active.ops != NULL;
|
||||||
|
if (l_input.notifiedAvailable == available)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
l_input.notifiedAvailable = available;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void dispatchAvailability(void)
|
||||||
|
{
|
||||||
|
LG_LOCK(l_input.availabilityDispatch);
|
||||||
|
LG_LOCK_SHARED(l_input.activeLock);
|
||||||
|
LGInputAvailabilityFn callback = l_input.availabilityCallback;
|
||||||
|
void * opaque = l_input.availabilityOpaque;
|
||||||
|
const bool available = l_input.active.ops != NULL;
|
||||||
|
LG_UNLOCK_SHARED(l_input.activeLock);
|
||||||
|
|
||||||
|
if (callback)
|
||||||
|
callback(opaque, available);
|
||||||
|
LG_UNLOCK(l_input.availabilityDispatch);
|
||||||
|
}
|
||||||
|
|
||||||
static void releaseKeysNL(void)
|
static void releaseKeysNL(void)
|
||||||
{
|
{
|
||||||
for (int key = 0; key < KEY_MAX; ++key)
|
for (int key = 0; key < KEY_MAX; ++key)
|
||||||
@@ -234,9 +262,12 @@ static void fallbackStatusChanged(void * opaque,
|
|||||||
if (l_input.fallback.ops &&
|
if (l_input.fallback.ops &&
|
||||||
l_input.fallback.epoch == (uint32_t)(uintptr_t)opaque)
|
l_input.fallback.epoch == (uint32_t)(uintptr_t)opaque)
|
||||||
keyboardLEDsChanged = updateStatusNL(&l_input.fallback, status);
|
keyboardLEDsChanged = updateStatusNL(&l_input.fallback, status);
|
||||||
|
const bool availabilityChanged = updateAvailabilityNL();
|
||||||
LG_UNLOCK_EXCLUSIVE(l_input.activeLock);
|
LG_UNLOCK_EXCLUSIVE(l_input.activeLock);
|
||||||
if (keyboardLEDsChanged)
|
if (keyboardLEDsChanged)
|
||||||
dispatchKeyboardLEDs();
|
dispatchKeyboardLEDs();
|
||||||
|
if (availabilityChanged)
|
||||||
|
dispatchAvailability();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void transportStatusChanged(void * opaque,
|
static void transportStatusChanged(void * opaque,
|
||||||
@@ -250,9 +281,12 @@ static void transportStatusChanged(void * opaque,
|
|||||||
if (l_input.transport.ops &&
|
if (l_input.transport.ops &&
|
||||||
l_input.transport.epoch == (uint32_t)(uintptr_t)opaque)
|
l_input.transport.epoch == (uint32_t)(uintptr_t)opaque)
|
||||||
keyboardLEDsChanged = updateStatusNL(&l_input.transport, status);
|
keyboardLEDsChanged = updateStatusNL(&l_input.transport, status);
|
||||||
|
const bool availabilityChanged = updateAvailabilityNL();
|
||||||
LG_UNLOCK_EXCLUSIVE(l_input.activeLock);
|
LG_UNLOCK_EXCLUSIVE(l_input.activeLock);
|
||||||
if (keyboardLEDsChanged)
|
if (keyboardLEDsChanged)
|
||||||
dispatchKeyboardLEDs();
|
dispatchKeyboardLEDs();
|
||||||
|
if (availabilityChanged)
|
||||||
|
dispatchAvailability();
|
||||||
}
|
}
|
||||||
|
|
||||||
void lgInput_init(void)
|
void lgInput_init(void)
|
||||||
@@ -261,6 +295,7 @@ void lgInput_init(void)
|
|||||||
l_input.transport = (struct InputBinding) { 0 };
|
l_input.transport = (struct InputBinding) { 0 };
|
||||||
l_input.active = (struct InputBinding) { 0 };
|
l_input.active = (struct InputBinding) { 0 };
|
||||||
l_input.useTransport = true;
|
l_input.useTransport = true;
|
||||||
|
l_input.notifiedAvailable = false;
|
||||||
|
|
||||||
for (int key = 0; key < KEY_MAX; ++key)
|
for (int key = 0; key < KEY_MAX; ++key)
|
||||||
atomic_init(&l_input.keys[key], false);
|
atomic_init(&l_input.keys[key], false);
|
||||||
@@ -269,6 +304,7 @@ void lgInput_init(void)
|
|||||||
LG_LOCK_INIT(l_input.bindingLock);
|
LG_LOCK_INIT(l_input.bindingLock);
|
||||||
LG_RWLOCK_INIT(l_input.activeLock);
|
LG_RWLOCK_INIT(l_input.activeLock);
|
||||||
LG_LOCK_INIT(l_input.keyboardLEDsDispatch);
|
LG_LOCK_INIT(l_input.keyboardLEDsDispatch);
|
||||||
|
LG_LOCK_INIT(l_input.availabilityDispatch);
|
||||||
}
|
}
|
||||||
|
|
||||||
void lgInput_free(void)
|
void lgInput_free(void)
|
||||||
@@ -278,6 +314,7 @@ void lgInput_free(void)
|
|||||||
|
|
||||||
LG_LOCK(l_input.bindingLock);
|
LG_LOCK(l_input.bindingLock);
|
||||||
LG_LOCK(l_input.keyboardLEDsDispatch);
|
LG_LOCK(l_input.keyboardLEDsDispatch);
|
||||||
|
LG_LOCK(l_input.availabilityDispatch);
|
||||||
LG_LOCK_EXCLUSIVE(l_input.activeLock);
|
LG_LOCK_EXCLUSIVE(l_input.activeLock);
|
||||||
resetActiveNL();
|
resetActiveNL();
|
||||||
fallback = l_input.fallback;
|
fallback = l_input.fallback;
|
||||||
@@ -287,7 +324,10 @@ void lgInput_free(void)
|
|||||||
l_input.transport = (struct InputBinding) { 0 };
|
l_input.transport = (struct InputBinding) { 0 };
|
||||||
l_input.keyboardLEDsCallback = NULL;
|
l_input.keyboardLEDsCallback = NULL;
|
||||||
l_input.keyboardLEDsOpaque = NULL;
|
l_input.keyboardLEDsOpaque = NULL;
|
||||||
|
l_input.availabilityCallback = NULL;
|
||||||
|
l_input.availabilityOpaque = NULL;
|
||||||
LG_UNLOCK_EXCLUSIVE(l_input.activeLock);
|
LG_UNLOCK_EXCLUSIVE(l_input.activeLock);
|
||||||
|
LG_UNLOCK(l_input.availabilityDispatch);
|
||||||
LG_UNLOCK(l_input.keyboardLEDsDispatch);
|
LG_UNLOCK(l_input.keyboardLEDsDispatch);
|
||||||
|
|
||||||
if (fallback.ops && fallback.ops->setStatusListener)
|
if (fallback.ops && fallback.ops->setStatusListener)
|
||||||
@@ -297,6 +337,7 @@ void lgInput_free(void)
|
|||||||
|
|
||||||
LG_UNLOCK(l_input.bindingLock);
|
LG_UNLOCK(l_input.bindingLock);
|
||||||
LG_RWLOCK_FREE(l_input.activeLock);
|
LG_RWLOCK_FREE(l_input.activeLock);
|
||||||
|
LG_LOCK_FREE(l_input.availabilityDispatch);
|
||||||
LG_LOCK_FREE(l_input.keyboardLEDsDispatch);
|
LG_LOCK_FREE(l_input.keyboardLEDsDispatch);
|
||||||
LG_LOCK_FREE(l_input.bindingLock);
|
LG_LOCK_FREE(l_input.bindingLock);
|
||||||
}
|
}
|
||||||
@@ -325,10 +366,13 @@ static void setBinding(struct InputBinding * target,
|
|||||||
LG_LOCK_EXCLUSIVE(l_input.activeLock);
|
LG_LOCK_EXCLUSIVE(l_input.activeLock);
|
||||||
*target = next;
|
*target = next;
|
||||||
const bool keyboardLEDsChanged = updateActiveNL(false);
|
const bool keyboardLEDsChanged = updateActiveNL(false);
|
||||||
|
const bool availabilityChanged = updateAvailabilityNL();
|
||||||
LG_UNLOCK_EXCLUSIVE(l_input.activeLock);
|
LG_UNLOCK_EXCLUSIVE(l_input.activeLock);
|
||||||
|
|
||||||
if (keyboardLEDsChanged)
|
if (keyboardLEDsChanged)
|
||||||
dispatchKeyboardLEDs();
|
dispatchKeyboardLEDs();
|
||||||
|
if (availabilityChanged)
|
||||||
|
dispatchAvailability();
|
||||||
|
|
||||||
if (next.ops && next.ops->setStatusListener)
|
if (next.ops && next.ops->setStatusListener)
|
||||||
next.ops->setStatusListener(next.opaque, statusFn,
|
next.ops->setStatusListener(next.opaque, statusFn,
|
||||||
@@ -343,9 +387,12 @@ static void dropBinding(struct InputBinding * target)
|
|||||||
const bool wasActive = bindingEqual(&l_input.active, target);
|
const bool wasActive = bindingEqual(&l_input.active, target);
|
||||||
*target = (struct InputBinding) { 0 };
|
*target = (struct InputBinding) { 0 };
|
||||||
const bool keyboardLEDsChanged = updateActiveNL(wasActive);
|
const bool keyboardLEDsChanged = updateActiveNL(wasActive);
|
||||||
|
const bool availabilityChanged = updateAvailabilityNL();
|
||||||
LG_UNLOCK_EXCLUSIVE(l_input.activeLock);
|
LG_UNLOCK_EXCLUSIVE(l_input.activeLock);
|
||||||
if (keyboardLEDsChanged)
|
if (keyboardLEDsChanged)
|
||||||
dispatchKeyboardLEDs();
|
dispatchKeyboardLEDs();
|
||||||
|
if (availabilityChanged)
|
||||||
|
dispatchAvailability();
|
||||||
LG_UNLOCK(l_input.bindingLock);
|
LG_UNLOCK(l_input.bindingLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -374,9 +421,12 @@ void lgInput_useTransport(bool enable)
|
|||||||
LG_LOCK_EXCLUSIVE(l_input.activeLock);
|
LG_LOCK_EXCLUSIVE(l_input.activeLock);
|
||||||
l_input.useTransport = enable;
|
l_input.useTransport = enable;
|
||||||
const bool keyboardLEDsChanged = updateActiveNL(false);
|
const bool keyboardLEDsChanged = updateActiveNL(false);
|
||||||
|
const bool availabilityChanged = updateAvailabilityNL();
|
||||||
LG_UNLOCK_EXCLUSIVE(l_input.activeLock);
|
LG_UNLOCK_EXCLUSIVE(l_input.activeLock);
|
||||||
if (keyboardLEDsChanged)
|
if (keyboardLEDsChanged)
|
||||||
dispatchKeyboardLEDs();
|
dispatchKeyboardLEDs();
|
||||||
|
if (availabilityChanged)
|
||||||
|
dispatchAvailability();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool lgInput_available(void)
|
bool lgInput_available(void)
|
||||||
@@ -423,6 +473,21 @@ void lgInput_setKeyboardLEDsListener(
|
|||||||
LG_UNLOCK(l_input.keyboardLEDsDispatch);
|
LG_UNLOCK(l_input.keyboardLEDsDispatch);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void lgInput_setAvailabilityListener(
|
||||||
|
LGInputAvailabilityFn callback, void * opaque)
|
||||||
|
{
|
||||||
|
LG_LOCK(l_input.availabilityDispatch);
|
||||||
|
LG_LOCK_SHARED(l_input.activeLock);
|
||||||
|
l_input.availabilityCallback = callback;
|
||||||
|
l_input.availabilityOpaque = opaque;
|
||||||
|
const bool available = l_input.active.ops != NULL;
|
||||||
|
LG_UNLOCK_SHARED(l_input.activeLock);
|
||||||
|
|
||||||
|
if (callback)
|
||||||
|
callback(opaque, available);
|
||||||
|
LG_UNLOCK(l_input.availabilityDispatch);
|
||||||
|
}
|
||||||
|
|
||||||
bool lgInput_keyDown(int key)
|
bool lgInput_keyDown(int key)
|
||||||
{
|
{
|
||||||
if (key < 0 || key >= KEY_MAX)
|
if (key < 0 || key >= KEY_MAX)
|
||||||
@@ -483,6 +548,21 @@ void lgInput_releaseKeys(void)
|
|||||||
LG_UNLOCK_EXCLUSIVE(l_input.activeLock);
|
LG_UNLOCK_EXCLUSIVE(l_input.activeLock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void lgInput_releaseButtons(void)
|
||||||
|
{
|
||||||
|
LG_LOCK_EXCLUSIVE(l_input.activeLock);
|
||||||
|
releaseButtonsNL();
|
||||||
|
LG_UNLOCK_EXCLUSIVE(l_input.activeLock);
|
||||||
|
}
|
||||||
|
|
||||||
|
void lgInput_releaseAll(void)
|
||||||
|
{
|
||||||
|
LG_LOCK_EXCLUSIVE(l_input.activeLock);
|
||||||
|
releaseKeysNL();
|
||||||
|
releaseButtonsNL();
|
||||||
|
LG_UNLOCK_EXCLUSIVE(l_input.activeLock);
|
||||||
|
}
|
||||||
|
|
||||||
bool lgInput_mouseMotion(int32_t x, int32_t y)
|
bool lgInput_mouseMotion(int32_t x, int32_t y)
|
||||||
{
|
{
|
||||||
LG_LOCK_SHARED(l_input.activeLock);
|
LG_LOCK_SHARED(l_input.activeLock);
|
||||||
|
|||||||
@@ -3603,7 +3603,7 @@ static int lg_run(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (evdev_start())
|
if (evdev_start())
|
||||||
DEBUG_INFO("Using evdev for keyboard capture");
|
DEBUG_INFO("Using evdev for input capture");
|
||||||
|
|
||||||
// override the SIGINIT handler so that we can tell the difference between
|
// override the SIGINIT handler so that we can tell the difference between
|
||||||
// SIGINT and the user sending a close event, such as ALT+F4
|
// SIGINT and the user sending a close event, such as ALT+F4
|
||||||
@@ -3739,7 +3739,13 @@ static int lg_run(void)
|
|||||||
.largeCursorDot = g_params.largeCursorDot,
|
.largeCursorDot = g_params.largeCursorDot,
|
||||||
.allowNoInput = strcmp(g_params.transport, "test") == 0,
|
.allowNoInput = strcmp(g_params.transport, "test") == 0,
|
||||||
.opengl = needsOpenGL,
|
.opengl = needsOpenGL,
|
||||||
.jitRender = g_params.jitRender
|
.jitRender = g_params.jitRender,
|
||||||
|
.eventSource =
|
||||||
|
{
|
||||||
|
.fd = evdev_getEventFD(),
|
||||||
|
.callback = evdev_dispatch,
|
||||||
|
.opaque = NULL,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
g_state.dsInitialized = g_state.ds->init(params);
|
g_state.dsInitialized = g_state.ds->init(params);
|
||||||
|
|||||||
@@ -163,6 +163,10 @@ bool core_inputEnabled(void)
|
|||||||
return t.input;
|
return t.input;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void core_updateKeyboardGrab(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void core_setGrab(bool enable)
|
void core_setGrab(bool enable)
|
||||||
{
|
{
|
||||||
++t.grabN;
|
++t.grabN;
|
||||||
|
|||||||
@@ -224,6 +224,10 @@ void core_updatePositionInfo(void)
|
|||||||
++t.posN;
|
++t.posN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void core_updateKeyboardGrab(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void core_setCursorInView(bool enable)
|
void core_setCursorInView(bool enable)
|
||||||
{
|
{
|
||||||
++t.cursorN;
|
++t.cursorN;
|
||||||
|
|||||||
@@ -282,6 +282,12 @@ void app_mouseTrace(const char * file, unsigned int line,
|
|||||||
(void)format;
|
(void)format;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void evdev_setGrab(bool keyboard, bool pointer)
|
||||||
|
{
|
||||||
|
(void)keyboard;
|
||||||
|
(void)pointer;
|
||||||
|
}
|
||||||
|
|
||||||
static bool inputSupports(void * opaque, LG_InputSupport support)
|
static bool inputSupports(void * opaque, LG_InputSupport support)
|
||||||
{
|
{
|
||||||
return support == LG_INPUT_SUPPORT_MOUSE_ABSOLUTE &&
|
return support == LG_INPUT_SUPPORT_MOUSE_ABSOLUTE &&
|
||||||
|
|||||||
@@ -95,7 +95,10 @@ Evdev capture
|
|||||||
-------------
|
-------------
|
||||||
|
|
||||||
Advanced users may list Linux evdev devices in ``input:evdev``. They become
|
Advanced users may list Linux evdev devices in ``input:evdev``. They become
|
||||||
active whenever Looking Glass grabs the keyboard, including capture mode and
|
active when Looking Glass captures their keyboard or relative-pointer role.
|
||||||
automatic keyboard capture. The client user must be allowed to read those
|
Automatic capture takes keyboard-only devices without taking mouse input from
|
||||||
devices. Keep ``input:evdevExclusive=yes`` unless duplicate input from the
|
the window system, while full capture takes both roles. Guest keyboard lock
|
||||||
window system is specifically required.
|
LEDs are mirrored while a writable keyboard is captured. The client user must
|
||||||
|
be allowed to read the configured devices and write them for LED mirroring.
|
||||||
|
Keep ``input:evdevExclusive=yes`` unless input from other window-system
|
||||||
|
devices is also required.
|
||||||
|
|||||||
Reference in New Issue
Block a user