Add encrypted LAN mouse and keyboard sharing with four-edge handoff

This commit is contained in:
agrynco committed 2026-11-06 16:28:43 +02:00
1 parent 9b565dd55e
commit e0bfdd9a90
15 files changed
+1093 -104

No files matched your search

+53
View File
@@ -0,0 +1,53 @@
#pragma once
#include "lan_channel.h"
#include <array>
namespace ks::lan
{
enum class ControlMode { Local, Requesting, Sending, Receiving };
struct InputEnvironment
{
std::function<RECT()> bounds;
std::function<POINT()> cursor;
std::function<bool(const INPUT &)> inject;
std::function<bool()> desktop;
std::function<bool()> held;
std::function<POINT()> anchor;
std::function<void(ControlMode)> modeChanged;
};
InputEnvironment windowsInputEnvironment();
ULONG_PTR remoteInputMarker();
ULONG_PTR cursorWarpMarker();
bool atEdge(POINT,RECT,int edge);
int edgePosition(POINT,RECT,int edge);
POINT edgePoint(RECT,int edge,int position,int inset=8);
class InputRouter
{
InputEnvironment env;
std::function<bool(InputFrame)> send;
ControlMode mode_=ControlMode::Local;
int edge{};bool preferLocal{},connected{};
uint32_t nextToken{},token{};
uint64_t cooldown{},requested{},revision_{};
POINT anchor{},returnPoint{};
std::array<bool,256> physical{},outKeys{},remoteKeys{};
std::array<INPUT,256> releases{};
std::array<bool,5> outButtons{},remoteButtons{};
void mode(ControlMode);
bool emit(INPUT);
bool move(POINT,bool warp=false);
bool post(InputFrame);
bool held() const;
void release();
void local(uint64_t now,int position=-1);
public:
InputRouter(InputEnvironment,std::function<bool(InputFrame)>,int edge,bool preferLocal);
~InputRouter();
ControlMode mode()const{return mode_;}
uint64_t revision()const{return revision_;}
void tick(bool ready,uint64_t now);
void receive(const InputFrame &,uint64_t now);
bool keyboard(const KBDLLHOOKSTRUCT &,bool down,uint64_t now);
bool mouse(UINT,const MSLLHOOKSTRUCT &,uint64_t now,bool allowEnter=true);
void cancel(uint64_t now);
};
}