Files
LookingGlass/client/include/interface/input.h
Geoffrey McRae f495e5b7ba [client] input: abstract guest input backends
Introduce LG_InputOps and route keyboard and mouse input through the
active video transport when it provides an input backend.

Keep SPICE as the fallback and force it while the SPICE display is
active. Add atomic shared/exclusive locking for safe backend changes.
2026-08-08 21:23:32 +10:00

61 lines
2.0 KiB
C

/**
* Looking Glass
* Copyright © 2017-2026 The Looking Glass Authors
* https://looking-glass.io
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc., 59
* Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _H_LG_CLIENT_INPUT_INTERFACE_
#define _H_LG_CLIENT_INPUT_INTERFACE_
#include <stdbool.h>
#include <stdint.h>
typedef enum LG_InputSupport
{
LG_INPUT_SUPPORT_MOUSE_ABSOLUTE,
}
LG_InputSupport;
typedef struct LG_InputOps
{
const char * name;
/* Operations must fail safely if a remote endpoint disappears. */
bool (*supports)(void * opaque, LG_InputSupport support);
/* Keyboard codes use the Linux input-event KEY_* values. */
bool (*keyDown)(void * opaque, int key);
bool (*keyUp)(void * opaque, int key);
bool (*keyboardLEDs)(void * opaque, bool numLock, bool capsLock,
bool scrollLock);
bool (*mouseMotion)(void * opaque, int32_t x, int32_t y);
/* Position is in guest pixels and must be within the supplied dimensions. */
bool (*mousePosition)(void * opaque, uint32_t x, uint32_t y,
uint32_t width, uint32_t height);
/* Button order: left, middle, right, wheel up/down, side, extra. */
bool (*mousePress)(void * opaque, unsigned int button);
bool (*mouseRelease)(void * opaque, unsigned int button);
/* Restore all devices owned by this implementation to a neutral state.
* This must safely tolerate the remote input endpoint becoming unavailable. */
void (*reset)(void * opaque);
}
LG_InputOps;
#endif