mirror of
https://github.com/Genymobile/scrcpy.git
synced 2025-04-21 03:55:05 +00:00
add plugin system
This commit is contained in:
parent
ab12b6c981
commit
3760c8c222
4 changed files with 58 additions and 2 deletions
|
@ -2,6 +2,7 @@ src = [
|
|||
'src/main.c',
|
||||
'src/adb.c',
|
||||
'src/cli.c',
|
||||
'src/plugin.c',
|
||||
'src/compat.c',
|
||||
'src/control_msg.c',
|
||||
'src/controller.c',
|
||||
|
|
49
app/src/plugin.c
Normal file
49
app/src/plugin.c
Normal file
|
@ -0,0 +1,49 @@
|
|||
#include "plugin.h"
|
||||
#include "scrcpy.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <SDL2/SDL.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
// not needed here, but winsock2.h must never be included AFTER windows.h
|
||||
# include <winsock2.h>
|
||||
# include <windows.h>
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
#define WM_PLUGIN_BASE WM_USER
|
||||
void on_window_message(void *userdata, void *hWnd, unsigned int message, Uint64 wParam, int64_t lParam){
|
||||
(void)(userdata);
|
||||
(void)(hWnd);
|
||||
if (message >= WM_PLUGIN_BASE ){
|
||||
message -= WM_PLUGIN_BASE;
|
||||
switch (message)
|
||||
{
|
||||
case SDL_FINGERDOWN:
|
||||
case SDL_FINGERUP:
|
||||
case SDL_FINGERMOTION:
|
||||
{
|
||||
SDL_Event sdlevent;
|
||||
sdlevent.type = message;
|
||||
sdlevent.tfinger.fingerId = 0;
|
||||
sdlevent.tfinger.pressure = 0.8;
|
||||
sdlevent.tfinger.x = (double)(wParam) / (1000*1000);
|
||||
sdlevent.tfinger.y = (double)(lParam) / (1000*1000);
|
||||
SDL_PushEvent(&sdlevent);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
void plugin_init(){
|
||||
#ifdef _WIN32
|
||||
SDL_SetWindowsMessageHook(on_window_message,NULL);
|
||||
#endif
|
||||
}
|
5
app/src/plugin.h
Normal file
5
app/src/plugin.h
Normal file
|
@ -0,0 +1,5 @@
|
|||
#ifndef __PLUGIN_H__
|
||||
#define __PLUGIN_H__
|
||||
|
||||
void plugin_init();
|
||||
#endif
|
|
@ -1,5 +1,5 @@
|
|||
#include "scrcpy.h"
|
||||
|
||||
#include "plugin.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
@ -115,6 +115,7 @@ sdl_init_and_configure(bool display, const char *render_driver,
|
|||
SDL_EnableScreenSaver();
|
||||
}
|
||||
|
||||
plugin_init();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -290,7 +291,7 @@ scrcpy(const struct scrcpy_options *options) {
|
|||
options->disable_screensaver)) {
|
||||
goto end;
|
||||
}
|
||||
|
||||
|
||||
char device_name[DEVICE_NAME_FIELD_LENGTH];
|
||||
struct size frame_size;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue