WIP: Implemented clipboard sharing functionality

Not fully done yet, WIP
This commit is contained in:
Dimitris Panokostas 2020-07-04 14:53:00 +02:00
parent 91ec59c434
commit 673e14ac60
10 changed files with 1408 additions and 109 deletions

View file

@ -260,6 +260,7 @@
<ClCompile Include="..\..\src\osdep\bsdsocket_host.cpp" />
<ClCompile Include="..\..\src\osdep\cda_play.cpp" />
<ClCompile Include="..\..\src\osdep\charset.cpp" />
<ClCompile Include="..\..\src\osdep\clipboard.cpp" />
<ClCompile Include="..\..\src\osdep\fsdb_host.cpp" />
<ClCompile Include="..\..\src\osdep\gui\CreateFilesysHardfile.cpp" />
<ClCompile Include="..\..\src\osdep\gui\EditFilesysHardfile.cpp" />
@ -384,6 +385,7 @@
<ClInclude Include="..\..\src\include\cdtv.h" />
<ClInclude Include="..\..\src\include\cdtvcr.h" />
<ClInclude Include="..\..\src\include\cia.h" />
<ClInclude Include="..\..\src\include\clipboard.h" />
<ClInclude Include="..\..\src\include\commpipe.h" />
<ClInclude Include="..\..\src\include\consolehook.h" />
<ClInclude Include="..\..\src\include\cpummu.h" />

View file

@ -631,6 +631,9 @@
<ClCompile Include="..\..\src\consolehook.cpp">
<Filter>Source files</Filter>
</ClCompile>
<ClCompile Include="..\..\src\osdep\clipboard.cpp">
<Filter>Source files\osdep</Filter>
</ClCompile>
<ClCompile Include="..\..\src\uaeexe.cpp">
<Filter>Source files</Filter>
</ClCompile>
@ -1041,6 +1044,9 @@
<ClInclude Include="..\..\src\include\consolehook.h">
<Filter>Source files\include</Filter>
</ClInclude>
<ClInclude Include="..\..\src\include\clipboard.h">
<Filter>Source files\include</Filter>
</ClInclude>
<ClInclude Include="..\..\src\include\uaeexe.h">
<Filter>Source files\include</Filter>
</ClInclude>

View file

@ -24,6 +24,7 @@
#include "custom.h"
#include "xwin.h"
#include "bsdsocket.h"
#include "clipboard.h"
#include "uaeresource.h"
#include "native2amiga.h"
#include "gensound.h"
@ -214,7 +215,7 @@ void devices_vsync_pre(void)
inputdevice_vsync();
filesys_vsync();
//sampler_vsync ();
//clipboard_vsync ();
clipboard_vsync ();
statusline_vsync();
execute_device_items(device_vsyncs_pre, device_vsync_pre_cnt);
@ -394,3 +395,8 @@ void devices_unpause(void)
//pausevideograb(0);
//ethernet_pause(0);
}
void devices_unsafeperiod(void)
{
clipboard_unsafeperiod();
}

View file

@ -46,6 +46,7 @@
#include "bsdsocket.h"
#include "uaeresource.h"
#include "inputdevice.h"
#include "clipboard.h"
#include "consolehook.h"
#include "blkdev.h"
#include "isofs_api.h"
@ -8320,26 +8321,19 @@ static uae_u32 REGPARAM2 mousehack_done (TrapContext *ctx)
uaecptr dispinfo = trap_get_areg(ctx, 3);
uaecptr vp = trap_get_areg(ctx, 4);
return input_mousehack_status(ctx, mode, diminfo, dispinfo, vp, trap_get_dreg(ctx, 2));
}
else if (mode == 10) {
//amiga_clipboard_die(ctx);
}
else if (mode == 11) {
//amiga_clipboard_got_data(ctx, trap_get_areg(ctx, 2), trap_get_dreg(ctx, 2), trap_get_dreg(ctx, 0) + 8);
}
else if (mode == 12) {
//return amiga_clipboard_want_data(ctx);
}
else if (mode == 13) {
//return amiga_clipboard_proc_start(ctx);
}
else if (mode == 14) {
//amiga_clipboard_task_start(ctx, trap_get_dreg(ctx, 0));
}
else if (mode == 15) {
//amiga_clipboard_init(ctx);
}
else if (mode == 16) {
} else if (mode == 10) {
amiga_clipboard_die(ctx);
} else if (mode == 11) {
amiga_clipboard_got_data(ctx, trap_get_areg(ctx, 2), trap_get_dreg(ctx, 2), trap_get_dreg(ctx, 0) + 8);
} else if (mode == 12) {
return amiga_clipboard_want_data(ctx);
} else if (mode == 13) {
return amiga_clipboard_proc_start(ctx);
} else if (mode == 14) {
amiga_clipboard_task_start(ctx, trap_get_dreg(ctx, 0));
} else if (mode == 15) {
amiga_clipboard_init(ctx);
} else if (mode == 16) {
uaecptr a2 = trap_get_areg(ctx, 2);
input_mousehack_mouseoffset(a2);
} else if (mode == 17) {

21
src/include/clipboard.h Normal file
View file

@ -0,0 +1,21 @@
#ifndef UAE_CLIPBOARD_H
#define UAE_CLIPBOARD_H
#include "uae/types.h"
extern void clipboard_init();
extern void clipboard_changed(int);
extern void clipboard_reset();
extern void clipboard_active(int, int);
extern int amiga_clipboard_want_data(TrapContext *ctx);
extern void amiga_clipboard_got_data(TrapContext *ctx, uaecptr data, uae_u32 size, uae_u32 actual);
extern void amiga_clipboard_die(TrapContext *ctx);
extern void amiga_clipboard_init(TrapContext *ctx);
extern uaecptr amiga_clipboard_proc_start(TrapContext *ctx);
extern void amiga_clipboard_task_start(TrapContext *ctx, uaecptr);
extern void clipboard_disable(bool);
extern void clipboard_vsync(void);
extern void clipboard_unsafeperiod(void);
#endif /* UAE_CLIPBOARD_H */

View file

@ -1,6 +1,12 @@
#ifndef LIBAMIGA_LIBAMIGA_H_
#define LIBAMIGA_LIBAMIGA_H_
// Clipboard functions
char* uae_clipboard_get_text(void);
void uae_clipboard_free_text(char* text);
void uae_clipboard_put_text(const char* text);
typedef const char * (*amiga_plugin_lookup_function)(const char *name);
void amiga_set_plugin_lookup_function(amiga_plugin_lookup_function function);

View file

@ -4117,8 +4117,35 @@ static bool inputdevice_handle_inputcode2(int code, int state, const TCHAR *s)
//case AKS_STATERESTOREQUICK9:
// savestate_quick((code - AKS_STATERESTOREQUICK) / 2, 0);
// break;
case AKS_TOGGLEDEFAULTSCREEN:
toggle_fullscreen(-1);
break;
case AKS_TOGGLEWINDOWEDFULLSCREEN:
toggle_fullscreen();
toggle_fullscreen(0);
break;
case AKS_TOGGLEFULLWINDOWFULLSCREEN:
toggle_fullscreen(1);
break;
case AKS_TOGGLEWINDOWFULLWINDOW:
toggle_fullscreen(2);
break;
case AKS_TOGGLEMOUSEGRAB:
toggle_mousegrab();
break;
case AKS_SWAPJOYPORTS:
if (state == 1)
inputdevice_swap_compa_ports(&changed_prefs, 0);
else if (state == 2)
inputdevice_swap_compa_ports(&changed_prefs, 2);
break;
case AKS_PASTE:
target_paste_to_keyboard();
break;
case AKS_SWITCHINTERPOL:
changed_prefs.sound_interpol++;
if (changed_prefs.sound_interpol > 4)
changed_prefs.sound_interpol = 0;
set_config_changed();
break;
case AKS_STATESAVEDIALOG:
if (s) {

View file

@ -45,6 +45,9 @@
#include "devices.h"
#include <map>
#include "clipboard.h"
#include "uae/uae.h"
extern FILE* debugfile;
int pause_emulation;
@ -1302,6 +1305,7 @@ void target_addtorecent(const TCHAR* name, int t)
void target_reset(void)
{
clipboard_reset();
}
bool target_can_autoswitchdevice(void)
@ -1392,6 +1396,7 @@ int main(int argc, char* argv[])
alloc_AmigaMem();
RescanROMs();
clipboard_init();
// set capslock state based upon current "real" state
ioctl(0, KDGKBLED, &kbd_flags);
@ -1431,7 +1436,7 @@ int main(int argc, char* argv[])
return 0;
}
void toggle_mouse_grab()
void toggle_mousegrab()
{
// Release mouse
if (mouse_grabbed)
@ -1453,7 +1458,7 @@ void set_mouse_grab(const bool grab)
if (grab && mouse_grabbed || !grab && !mouse_grabbed)
return;
if (!grab && mouse_grabbed || grab && !mouse_grabbed)
toggle_mouse_grab();
toggle_mousegrab();
}
void setminimized()
@ -1476,7 +1481,7 @@ static void amiberry_inactive(int minimized)
focus = 0;
recapture = 0;
setmouseactive(0);
//clipboard_active(0);
clipboard_active(1, 0);
if (!quit_program) {
if (minimized) {
@ -1512,7 +1517,7 @@ static void amiberry_active(int minimized)
inputdevice_acquire(TRUE);
if (isfullscreen() > 0)
setmouseactive(1);
//clipboard_active(1);
clipboard_active(1, 1);
}
static void setmouseactive2(int active, bool allowpause)
@ -1768,7 +1773,7 @@ void process_event(SDL_Event event)
if (event.button.button == SDL_BUTTON_MIDDLE)
{
if (currprefs.input_mouse_untrap)
toggle_mouse_grab();
toggle_mousegrab();
else
setmousebuttonstate(0, 2, 0);
}
@ -1845,15 +1850,15 @@ void process_event(SDL_Event event)
int handle_msgpump()
{
auto gotEvent = 0;
auto got_event = 0;
SDL_Event event;
while (SDL_PollEvent(&event))
{
gotEvent = 1;
got_event = 1;
process_event(event);
}
return gotEvent;
return got_event;
}
bool handle_events()
@ -1894,35 +1899,3 @@ bool handle_events()
return pause_emulation != 0;
}
static uaecptr clipboard_data;
void amiga_clipboard_die()
{
}
void amiga_clipboard_init()
{
}
void amiga_clipboard_task_start(uaecptr data)
{
clipboard_data = data;
}
uae_u32 amiga_clipboard_proc_start()
{
return clipboard_data;
}
void amiga_clipboard_got_data(uaecptr data, uae_u32 size, uae_u32 actual)
{
}
int amiga_clipboard_want_data()
{
return 0;
}
void clipboard_vsync()
{
}

View file

@ -15,6 +15,9 @@
#include "amiberry_gfx.h"
#include <png.h>
#include "clipboard.h"
#include "devices.h"
#include "inputdevice.h"
#if 0
@ -54,6 +57,7 @@ bool can_have_linedouble;
static unsigned long last_synctime;
static int host_hz = 50;
static bool clipboard_initialized;
/* Possible screen modes (x and y resolutions) */
#define MAX_SCREEN_MODES 14
@ -64,6 +68,7 @@ struct PicassoResolution* DisplayModes;
struct MultiDisplay Displays[MAX_DISPLAYS];
int screen_is_picasso = 0;
static int wasfullwindow_a, wasfullwindow_p;
static SDL_Surface* current_screenshot = nullptr;
static char screenshot_filename_default[MAX_DPATH] =
@ -428,20 +433,92 @@ int graphics_setup(void)
return 1;
}
void toggle_fullscreen()
void set_screen_mode(struct uae_prefs* p)
{
if (sdl_window && strcmp(sdl_video_driver, "x11") == 0)
{
const auto window_flags = SDL_GetWindowFlags(sdl_window);
const bool is_fullwindow = window_flags & SDL_WINDOW_FULLSCREEN_DESKTOP;
const bool is_fullscreen = window_flags & SDL_WINDOW_FULLSCREEN;
if (p->gfx_apmode[0].gfx_fullscreen == GFX_FULLSCREEN)
{
// Switch to Fullscreen mode, if we don't have it already
if (!is_fullscreen)
SDL_SetWindowFullscreen(sdl_window, SDL_WINDOW_FULLSCREEN);
}
else if (p->gfx_apmode[0].gfx_fullscreen == GFX_FULLWINDOW)
{
if (!is_fullwindow)
SDL_SetWindowFullscreen(sdl_window, SDL_WINDOW_FULLSCREEN_DESKTOP);
}
else
{
// Switch to Window mode, if we don't have it already
if (is_fullscreen || is_fullwindow)
SDL_SetWindowFullscreen(sdl_window, 0);
}
if (!is_fullscreen && !is_fullwindow)
if ((SDL_GetWindowFlags(sdl_window) & SDL_WINDOW_MAXIMIZED) == 0)
{
if (screen_is_picasso)
SDL_SetWindowSize(sdl_window, display_width, display_height);
else
SDL_SetWindowSize(sdl_window, display_width * 2 >> p->gfx_resolution, display_height * 2 >> p->gfx_vresolution);
}
}
}
void toggle_fullscreen(int mode)
{
#ifdef USE_DISPMANX
// Dispmanx is fullscreen always
#else
const Uint32 fullscreen_flag = SDL_WINDOW_FULLSCREEN_DESKTOP;
if (sdl_window)
{
const bool is_fullscreen = SDL_GetWindowFlags(sdl_window) & fullscreen_flag;
SDL_SetWindowFullscreen(sdl_window, is_fullscreen ? 0 : fullscreen_flag);
SDL_ShowCursor(is_fullscreen);
const auto idx = screen_is_picasso ? 1 : 0;
currprefs.gfx_apmode[idx].gfx_fullscreen = is_fullscreen ? GFX_FULLSCREEN : GFX_WINDOW;
struct amigadisplay* ad = &adisplays;
int* p = ad->picasso_on ? &changed_prefs.gfx_apmode[1].gfx_fullscreen : &changed_prefs.gfx_apmode[0].gfx_fullscreen;
int wfw = ad->picasso_on ? wasfullwindow_p : wasfullwindow_a;
int v = *p;
if (mode < 0) {
// fullscreen <> window (if in fullwindow: fullwindow <> fullscreen)
if (v == GFX_FULLWINDOW)
v = GFX_FULLSCREEN;
else if (v == GFX_WINDOW)
v = GFX_FULLSCREEN;
else if (v == GFX_FULLSCREEN)
if (wfw > 0)
v = GFX_FULLWINDOW;
else
v = GFX_WINDOW;
}
else if (mode == 0) {
// fullscreen <> window
if (v == GFX_FULLSCREEN)
v = GFX_WINDOW;
else
v = GFX_FULLSCREEN;
}
else if (mode == 1) {
// fullscreen <> fullwindow
if (v == GFX_FULLSCREEN)
v = GFX_FULLWINDOW;
else
v = GFX_FULLSCREEN;
}
else if (mode == 2) {
// window <> fullwindow
if (v == GFX_FULLWINDOW)
v = GFX_WINDOW;
else
v = GFX_FULLWINDOW;
}
else if (mode == 10) {
v = GFX_WINDOW;
}
*p = v;
devices_unsafeperiod();
set_screen_mode(&currprefs);
#endif
}
@ -582,43 +659,6 @@ bool isModeAspectRatioExact(SDL_DisplayMode* mode, const int width, const int he
return mode->w % width == 0 && mode->h % height == 0;
}
void set_screen_mode(struct uae_prefs* p)
{
if (sdl_window && strcmp(sdl_video_driver, "x11") == 0)
{
const auto window_flags = SDL_GetWindowFlags(sdl_window);
const bool is_fullwindow = window_flags & SDL_WINDOW_FULLSCREEN_DESKTOP;
const bool is_fullscreen = window_flags & SDL_WINDOW_FULLSCREEN;
if (p->gfx_apmode[0].gfx_fullscreen == GFX_FULLSCREEN)
{
// Switch to Fullscreen mode, if we don't have it already
if (!is_fullscreen)
SDL_SetWindowFullscreen(sdl_window, SDL_WINDOW_FULLSCREEN);
}
else if (p->gfx_apmode[0].gfx_fullscreen == GFX_FULLWINDOW)
{
if (!is_fullwindow)
SDL_SetWindowFullscreen(sdl_window, SDL_WINDOW_FULLSCREEN_DESKTOP);
}
else
{
// Switch to Window mode, if we don't have it already
if (is_fullscreen || is_fullwindow)
SDL_SetWindowFullscreen(sdl_window, 0);
}
if (!is_fullscreen && !is_fullwindow)
if ((SDL_GetWindowFlags(sdl_window) & SDL_WINDOW_MAXIMIZED) == 0)
{
if (screen_is_picasso)
SDL_SetWindowSize(sdl_window, display_width, display_height);
else
SDL_SetWindowSize(sdl_window, display_width * 2 >> p->gfx_resolution, display_height * 2 >> p->gfx_vresolution);
}
}
}
static void open_screen(struct uae_prefs* p)
{
auto* avidinfo = &adisplays.gfxvidinfo;
@ -652,6 +692,11 @@ static void open_screen(struct uae_prefs* p)
display_height = (p->gfx_monitor.gfx_size.height ? p->gfx_monitor.gfx_size.height : 270) << p->gfx_vresolution;
}
if (wasfullwindow_a == 0)
wasfullwindow_a = currprefs.gfx_apmode[0].gfx_fullscreen == GFX_FULLWINDOW ? 1 : -1;
if (wasfullwindow_p == 0)
wasfullwindow_p = currprefs.gfx_apmode[1].gfx_fullscreen == GFX_FULLWINDOW ? 1 : -1;
#ifdef USE_DISPMANX
next_synctime = 0;
current_resource_amigafb = 0;

1219
src/osdep/clipboard.cpp Normal file

File diff suppressed because it is too large Load diff