Scale mouse events
The video screen size on the client may differ from the real device screen size (e.g. the video stream may be scaled down). As a consequence, mouse events must be scaled to match the real device coordinates. For this purpose, make the client send the video screen size along with the absolute pointer location, and the server scale the location to match the real device size before injecting mouse events.
This commit is contained in:
@@ -5,16 +5,31 @@
|
||||
#include <SDL2/SDL_events.h>
|
||||
#include "controlevent.h"
|
||||
|
||||
// on Android, a scroll event requires the current mouse position
|
||||
struct complete_mouse_wheel_event {
|
||||
SDL_MouseWheelEvent *mouse_wheel_event;
|
||||
Sint32 x;
|
||||
Sint32 y;
|
||||
struct complete_mouse_motion_event {
|
||||
SDL_MouseMotionEvent *mouse_motion_event;
|
||||
struct size screen_size;
|
||||
};
|
||||
|
||||
SDL_bool input_key_from_sdl_to_android(const SDL_KeyboardEvent *from, struct control_event *to);
|
||||
SDL_bool mouse_button_from_sdl_to_android(const SDL_MouseButtonEvent *from, struct control_event *to);
|
||||
SDL_bool mouse_motion_from_sdl_to_android(const SDL_MouseMotionEvent *from, struct control_event *to);
|
||||
SDL_bool mouse_wheel_from_sdl_to_android(const struct complete_mouse_wheel_event *from, struct control_event *to);
|
||||
struct complete_mouse_wheel_event {
|
||||
SDL_MouseWheelEvent *mouse_wheel_event;
|
||||
struct point position;
|
||||
};
|
||||
|
||||
SDL_bool input_key_from_sdl_to_android(const SDL_KeyboardEvent *from,
|
||||
struct control_event *to);
|
||||
SDL_bool mouse_button_from_sdl_to_android(const SDL_MouseButtonEvent *from,
|
||||
struct size screen_size,
|
||||
struct control_event *to);
|
||||
|
||||
// the video size may be different from the real device size, so we need the size
|
||||
// to which the absolute position apply, to scale it accordingly
|
||||
SDL_bool mouse_motion_from_sdl_to_android(const SDL_MouseMotionEvent *from,
|
||||
struct size screen_size,
|
||||
struct control_event *to);
|
||||
|
||||
// on Android, a scroll event requires the current mouse position
|
||||
SDL_bool mouse_wheel_from_sdl_to_android(const SDL_MouseWheelEvent *from,
|
||||
struct point point,
|
||||
struct control_event *to);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user