2018-02-15 19:07:47 +08:00
|
|
|
#ifndef INPUTMANAGER_H
|
|
|
|
#define INPUTMANAGER_H
|
|
|
|
|
2021-01-09 02:24:51 +08:00
|
|
|
#include "common.h"
|
|
|
|
|
2019-03-03 06:52:22 +08:00
|
|
|
#include <stdbool.h>
|
|
|
|
|
2020-07-17 06:00:42 +08:00
|
|
|
#include <SDL2/SDL.h>
|
|
|
|
|
2018-02-15 19:07:47 +08:00
|
|
|
#include "controller.h"
|
2018-08-15 23:01:54 +08:00
|
|
|
#include "fps_counter.h"
|
2021-10-28 00:43:47 +08:00
|
|
|
#include "options.h"
|
2018-02-15 19:07:47 +08:00
|
|
|
#include "screen.h"
|
2021-10-03 23:11:20 +08:00
|
|
|
#include "trait/key_processor.h"
|
2021-10-03 23:44:14 +08:00
|
|
|
#include "trait/mouse_processor.h"
|
2018-02-15 19:07:47 +08:00
|
|
|
|
|
|
|
struct input_manager {
|
|
|
|
struct controller *controller;
|
|
|
|
struct screen *screen;
|
2020-06-11 16:40:52 +08:00
|
|
|
|
2021-10-03 23:11:20 +08:00
|
|
|
struct sc_key_processor *kp;
|
2021-10-03 23:44:14 +08:00
|
|
|
struct sc_mouse_processor *mp;
|
2020-06-11 16:40:52 +08:00
|
|
|
|
2020-08-02 21:45:31 +08:00
|
|
|
bool control;
|
2020-10-06 02:45:53 +08:00
|
|
|
bool forward_all_clicks;
|
2020-10-07 03:30:10 +08:00
|
|
|
bool legacy_paste;
|
2021-11-22 15:49:10 +08:00
|
|
|
bool clipboard_autosync;
|
2020-07-17 06:00:42 +08:00
|
|
|
|
|
|
|
struct {
|
|
|
|
unsigned data[SC_MAX_SHORTCUT_MODS];
|
|
|
|
unsigned count;
|
|
|
|
} sdl_shortcut_mods;
|
2020-08-09 22:04:02 +08:00
|
|
|
|
|
|
|
bool vfinger_down;
|
2021-04-17 20:15:31 +08:00
|
|
|
|
|
|
|
// Tracks the number of identical consecutive shortcut key down events.
|
|
|
|
// Not to be confused with event->repeat, which counts the number of
|
|
|
|
// system-generated repeated key presses.
|
|
|
|
unsigned key_repeat;
|
|
|
|
SDL_Keycode last_keycode;
|
|
|
|
uint16_t last_mod;
|
Wait SET_CLIPBOARD ack before Ctrl+v via HID
To allow seamless copy-paste, on Ctrl+v, a SET_CLIPBOARD request is
performed before injecting Ctrl+v.
But when HID keyboard is enabled, the Ctrl+v injection is not sent on
the same channel as the clipboard request, so they are not serialized,
and may occur in any order. If Ctrl+v happens to be injected before the
new clipboard content is set, then the old content is pasted instead,
which is incorrect.
To minimize the probability of occurrence of the wrong order, a delay of
2 milliseconds was added before injecting Ctrl+v. Then 5ms. But even
with 5ms, the wrong behavior sometimes happens.
To handle it properly, add an acknowledgement mechanism, so that Ctrl+v
is injected over AOA only after the SET_CLIPBOARD request has been
performed and acknowledged by the server.
Refs e4163321f00bb3830c6049bdb6c1515e7cc668a0
Refs 45b0f8123a52f5c73a5860d616f4ceba2766ca6a
PR #2814 <https://github.com/Genymobile/scrcpy/pull/2814>
2021-11-22 00:40:11 +08:00
|
|
|
|
|
|
|
uint64_t next_sequence; // used for request acknowledgements
|
2018-02-15 19:07:47 +08:00
|
|
|
};
|
|
|
|
|
2020-07-17 06:00:42 +08:00
|
|
|
void
|
2021-05-17 14:46:38 +08:00
|
|
|
input_manager_init(struct input_manager *im, struct controller *controller,
|
2021-10-03 23:11:20 +08:00
|
|
|
struct screen *screen, struct sc_key_processor *kp,
|
2021-10-03 23:44:14 +08:00
|
|
|
struct sc_mouse_processor *mp,
|
2021-10-03 23:11:20 +08:00
|
|
|
const struct scrcpy_options *options);
|
2020-07-17 06:00:42 +08:00
|
|
|
|
2021-02-16 01:53:23 +08:00
|
|
|
bool
|
|
|
|
input_manager_handle_event(struct input_manager *im, SDL_Event *event);
|
2018-02-15 19:07:47 +08:00
|
|
|
|
|
|
|
#endif
|