mirror of
https://github.com/digarok/gsplus.git
synced 2024-11-28 04:49:18 +00:00
commit
df0833994a
Binary file not shown.
Binary file not shown.
Before Width: | Height: | Size: 180 KiB After Width: | Height: | Size: 118 KiB |
85
src/adb.c
85
src/adb.c
@ -11,6 +11,7 @@
|
||||
#include "glog.h"
|
||||
|
||||
int g_fullscreen = 0;
|
||||
int g_grabmouse = 0;
|
||||
|
||||
extern int Verbose;
|
||||
extern word32 g_vbl_count;
|
||||
@ -99,9 +100,13 @@ STRUCT(Mouse_fifo) {
|
||||
int x;
|
||||
int y;
|
||||
int buttons;
|
||||
int delta_x;
|
||||
int delta_y;
|
||||
int dxrd;
|
||||
int dyrd;
|
||||
};
|
||||
|
||||
Mouse_fifo g_mouse_fifo[ADB_MOUSE_FIFO] = { { 0, 0, 0, 0 } };
|
||||
Mouse_fifo g_mouse_fifo[ADB_MOUSE_FIFO] = { { 0, 0, 0, 0, 0, 0 ,0 ,0} };
|
||||
|
||||
int g_mouse_warp_x = 0;
|
||||
int g_mouse_warp_y = 0;
|
||||
@ -1066,6 +1071,20 @@ int adb_get_keypad_xy(int get_y) {
|
||||
}
|
||||
}
|
||||
|
||||
// stub in a wrapper to experiment with full delta movement
|
||||
int g_delta_x = 0;
|
||||
int g_delta_y = 0;
|
||||
int update_mouse_w_delta(int x, int y, int button_states, int buttons_valid, int delta_x, int delta_y) {
|
||||
g_delta_x = delta_x;
|
||||
g_delta_y = delta_y;
|
||||
//glogf("dx: %d dy: %d but: %02x", delta_x, delta_y, button_states);
|
||||
int ret = 0;
|
||||
ret = update_mouse(x,y,button_states,buttons_valid);
|
||||
g_delta_x = 0;
|
||||
g_delta_y = 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
int update_mouse(int x, int y, int button_states, int buttons_valid) {
|
||||
double dcycs;
|
||||
int button1_changed;
|
||||
@ -1139,29 +1158,31 @@ int update_mouse(int x, int y, int button_states, int buttons_valid) {
|
||||
g_mouse_warp_x, g_mouse_warp_y, g_mouse_fifo[0].x,
|
||||
g_mouse_fifo[0].y, g_mouse_a2_x, g_mouse_a2_y);
|
||||
#endif
|
||||
|
||||
mouse_moved = (g_mouse_fifo[0].x != x) || (g_mouse_fifo[0].y != y);
|
||||
if (!g_grabmouse) {
|
||||
mouse_moved = ((g_mouse_fifo[0].x != x) || (g_mouse_fifo[0].y != y));
|
||||
}
|
||||
|
||||
g_mouse_a2_x += g_mouse_warp_x;
|
||||
g_mouse_a2_y += g_mouse_warp_y;
|
||||
g_mouse_fifo[0].x = x;
|
||||
g_mouse_fifo[0].y = y;
|
||||
g_mouse_fifo[0].dcycs = dcycs;
|
||||
g_mouse_fifo[0].delta_x = g_delta_x;
|
||||
g_mouse_fifo[0].delta_y = g_delta_y;
|
||||
g_mouse_warp_x = 0;
|
||||
g_mouse_warp_y = 0;
|
||||
|
||||
button1_changed = (buttons_valid & 1) &&
|
||||
((button_states & 1) != (g_mouse_fifo[0].buttons & 1));
|
||||
((button_states & 1) != (g_mouse_fifo[0].buttons & 1)); //<- make sure fifo doesn't already have pending change to this state
|
||||
|
||||
if((button_states & 4) && !(g_mouse_fifo[0].buttons & 4) &&
|
||||
(buttons_valid & 4)) {
|
||||
/* right button pressed */
|
||||
|
||||
if((button_states & 4) && !(g_mouse_fifo[0].buttons & 4) && // fifo check why?
|
||||
(buttons_valid & 4)) { // right button pressed
|
||||
adb_increment_speed();
|
||||
}
|
||||
if((button_states & 2) && !(g_mouse_fifo[0].buttons & 2) &&
|
||||
if((button_states & 2) && !(g_mouse_fifo[0].buttons & 2) && // fifo check why?
|
||||
(buttons_valid & 2)) {
|
||||
/* middle button pressed */
|
||||
adb_increment_speed();
|
||||
adb_increment_speed(); // middle button pressed
|
||||
//halt2_printf("Middle button pressed\n");
|
||||
}
|
||||
|
||||
@ -1175,10 +1196,15 @@ int update_mouse(int x, int y, int button_states, int buttons_valid) {
|
||||
g_mouse_fifo[i + 1] = g_mouse_fifo[i]; /* copy struct*/
|
||||
}
|
||||
g_mouse_fifo_pos = pos + 1;
|
||||
}
|
||||
|
||||
}
|
||||
g_mouse_fifo[0].buttons = (button_states & buttons_valid) |
|
||||
(g_mouse_fifo[0].buttons & ~buttons_valid);
|
||||
if (g_grabmouse) {
|
||||
if (pos > 0) {
|
||||
mouse_moved = (g_mouse_fifo[0].delta_x || g_mouse_fifo[0].delta_y );
|
||||
}
|
||||
}
|
||||
|
||||
if(mouse_moved || button1_changed) {
|
||||
if( (g_mouse_ctl_addr == g_mouse_dev_addr) &&
|
||||
@ -1192,6 +1218,7 @@ int update_mouse(int x, int y, int button_states, int buttons_valid) {
|
||||
}
|
||||
|
||||
int mouse_read_c024(double dcycs) {
|
||||
|
||||
word32 ret;
|
||||
word32 tool_start;
|
||||
int em_active;
|
||||
@ -1217,6 +1244,10 @@ int mouse_read_c024(double dcycs) {
|
||||
mouse_button = (g_mouse_fifo[pos].buttons & 1);
|
||||
delta_x = target_x - g_mouse_a2_x;
|
||||
delta_y = target_y - g_mouse_a2_y;
|
||||
if (g_grabmouse) {
|
||||
delta_x = g_mouse_fifo[pos].delta_x;
|
||||
delta_y = g_mouse_fifo[pos].delta_y;
|
||||
}
|
||||
|
||||
clamped = 0;
|
||||
if(delta_x > 0x3f) {
|
||||
@ -1244,9 +1275,13 @@ int mouse_read_c024(double dcycs) {
|
||||
|
||||
if(g_adb_mouse_coord) {
|
||||
/* y coord */
|
||||
delta_x = 0; /* clear unneeded x delta */
|
||||
delta_x = 0; // clear unneeded x delta
|
||||
g_mouse_fifo[pos].dyrd = 1; // flag y delta as read
|
||||
g_mouse_fifo[pos].delta_y = 0; // clear y delta
|
||||
} else {
|
||||
delta_y = 0; /* clear unneeded y delta */
|
||||
delta_y = 0; // clear unneeded y delta
|
||||
g_mouse_fifo[pos].dxrd = 1; // flag x delta as read
|
||||
g_mouse_fifo[pos].delta_x = 0; // clear x delta
|
||||
}
|
||||
|
||||
|
||||
@ -1320,10 +1355,17 @@ int mouse_read_c024(double dcycs) {
|
||||
g_mouse_a2_x = a2_x;
|
||||
g_mouse_a2_y = a2_y;
|
||||
if(g_mouse_fifo_pos) {
|
||||
if (!g_grabmouse) {
|
||||
if((target_x == a2_x) && (target_y == a2_y) &&
|
||||
(g_mouse_a2_button == mouse_button)) {
|
||||
g_mouse_fifo_pos--;
|
||||
}
|
||||
} else {
|
||||
if(g_mouse_fifo[pos].dxrd && g_mouse_fifo[pos].dyrd
|
||||
&& (g_mouse_a2_button == mouse_button)) {
|
||||
g_mouse_fifo_pos--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1336,12 +1378,21 @@ int mouse_read_c024(double dcycs) {
|
||||
g_slow_memory_ptr[0x10190], g_slow_memory_ptr[0x10192],
|
||||
g_slow_memory_ptr[0x10191], g_slow_memory_ptr[0x10193]);
|
||||
|
||||
if (g_grabmouse) {
|
||||
if((g_mouse_fifo_pos == 0) && g_mouse_fifo[0].dxrd && g_mouse_fifo[0].dyrd
|
||||
&& ((g_mouse_fifo[0].buttons & 1) == g_mouse_a2_button)) {
|
||||
g_adb_mouse_valid_data = 0;
|
||||
adb_clear_mouse_int();
|
||||
}
|
||||
|
||||
} else {
|
||||
if((g_mouse_fifo_pos == 0) && (g_mouse_fifo[0].x == a2_x) &&
|
||||
(g_mouse_fifo[0].y == a2_y) &&
|
||||
((g_mouse_fifo[0].buttons & 1) == g_mouse_a2_button)) {
|
||||
g_adb_mouse_valid_data = 0;
|
||||
adb_clear_mouse_int();
|
||||
}
|
||||
}
|
||||
|
||||
g_adb_mouse_coord = !g_adb_mouse_coord;
|
||||
return ret;
|
||||
@ -1656,7 +1707,12 @@ void adb_physical_key_update(int a2code, int is_up) {
|
||||
break;
|
||||
case 0x05: /* F5 - emulator clipboard paste */
|
||||
if (SHIFT_DOWN) {
|
||||
// reserved
|
||||
g_grabmouse = !g_grabmouse;
|
||||
#ifdef HAVE_SDL
|
||||
extern void x_grabmouse();
|
||||
glogf("g_grabmouse = %d", g_grabmouse);
|
||||
x_grabmouse();
|
||||
#endif
|
||||
} else {
|
||||
clipboard_paste();
|
||||
}
|
||||
@ -1707,7 +1763,6 @@ void adb_physical_key_update(int a2code, int is_up) {
|
||||
x_full_screen(g_fullscreen);
|
||||
break;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
/* Handle Keypad Joystick here partly...if keypad key pressed */
|
||||
|
@ -501,7 +501,7 @@ Cfg_listhdr g_cfg_partitionlist = { 0 };
|
||||
|
||||
int g_cfg_file_pathfield = 0;
|
||||
|
||||
const char *g_gsplus_rom_names[] = { "ROM", "ROM", "ROM01", "ROM03", "ROM.01", "ROM.03", 0 };
|
||||
const char *g_gsplus_rom_names[] = { "ROM", "ROM", "ROM1", "ROM3", "ROM01", "ROM03", "ROM.01", "ROM.03", 0 };
|
||||
/* First entry is special--it will be overwritten by g_cfg_rom_path */
|
||||
|
||||
const char *g_gsplus_c1rom_names[] = { "parallel.rom", 0 };
|
||||
|
@ -217,7 +217,7 @@ int parse_cli_options(int argc, char **argv) {
|
||||
} else if(!strcmp("-noshm", argv[i])) {
|
||||
glogf("%s Not using X shared memory", parse_log_prefix);
|
||||
g_use_shmem = 0;
|
||||
} else if(!strcmp("-joystick", argv[i])) {
|
||||
} else if(!strcmp("-joy", argv[i])) {
|
||||
if((i+1) >= argc) {
|
||||
glogf("%s Error, option '-joy' missing argument", parse_log_prefix);
|
||||
exit(1);
|
||||
@ -411,7 +411,7 @@ void help_exit() {
|
||||
printf(" -noignbadacc Don’t ignore bad memory accesses\n");
|
||||
printf(" -noignhalt Don’t ignore code red halts\n");
|
||||
printf(" -test Allow testing\n");
|
||||
printf(" -joystick Ignore joystick option\n");
|
||||
printf(" -joy Set joystick number\n");
|
||||
printf(" -bw Force B/W modes\n");
|
||||
printf(" -dhr140 Use simple double-hires color map\n");
|
||||
printf(" -fullscreen Attempt to start emulator in fullscreen\n");
|
||||
@ -433,7 +433,6 @@ void help_exit() {
|
||||
printf(" -sh value Scale window to sh pixels high\n");
|
||||
printf(" -novsync Don't force emulator to sync each frame\n");
|
||||
printf(" -fulldesk Use desktop 'fake' fullscreen mode\n");
|
||||
|
||||
//printf(" -v value Set verbose flags to value\n\n");
|
||||
printf(" Note: The final argument, if not a flag, will be tried as a mountable device.\n\n");
|
||||
exit(1);
|
||||
|
@ -106,6 +106,7 @@ int read_adb_ram(word32 addr);
|
||||
void write_adb_ram(word32 addr, int val);
|
||||
int adb_get_keypad_xy(int get_y);
|
||||
int update_mouse(int x, int y, int button_states, int buttons_valid);
|
||||
int update_mouse_w_delta(int x, int y, int button_states, int buttons_valid, int delta_x, int delta_y);
|
||||
int mouse_read_c024(double dcycs);
|
||||
void mouse_compress_fifo(double dcycs);
|
||||
void adb_key_event(int a2code, int is_up);
|
||||
|
@ -42,6 +42,7 @@ int kb_shift_control_state = 0;
|
||||
|
||||
void debuginfo_renderer(SDL_Renderer *r);
|
||||
void x_take_screenshot(); // screenshot stuff
|
||||
void x_grabmouse();
|
||||
int g_screenshot_requested = 0; // DB to know if we want to save a screenshot
|
||||
extern char g_config_gsplus_name[];
|
||||
extern char g_config_gsplus_screenshot_dir[];
|
||||
@ -49,6 +50,7 @@ int screenshot_index = 0; // allows us to save time by not scanning from 0 each
|
||||
char screenshot_filename[256];
|
||||
|
||||
extern int g_fullscreen; // only checked at start if set via CLI, otherwise it's set via function call x_full_screen()
|
||||
extern int g_grabmouse;
|
||||
extern int g_highdpi;
|
||||
extern int g_borderless;
|
||||
extern int g_resizeable;
|
||||
@ -399,8 +401,6 @@ void dev_video_init_sdl() {
|
||||
|
||||
// Turn off host mouse cursor
|
||||
SDL_ShowCursor(SDL_DISABLE);
|
||||
//SDL_SetRelativeMouseMode(true);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -600,6 +600,8 @@ void handle_sdl_key_event(SDL_Event event) {
|
||||
if (!IsFullScreen(window)) {
|
||||
glog("Enable fullscreen");
|
||||
SDL_SetWindowGrab(window, true);
|
||||
SDL_SetRelativeMouseMode(true);
|
||||
|
||||
Uint32 fullmode = g_fullscreen_desktop ? SDL_WINDOW_FULLSCREEN_DESKTOP : SDL_WINDOW_FULLSCREEN;
|
||||
SDL_SetWindowFullscreen(window, fullmode);
|
||||
} else {
|
||||
@ -607,6 +609,8 @@ void handle_sdl_key_event(SDL_Event event) {
|
||||
SDL_SetWindowFullscreen(window, 0);
|
||||
SDL_SetWindowGrab(window, false);
|
||||
SDL_SetWindowSize(window, g_startw, g_starth);
|
||||
SDL_SetRelativeMouseMode(false);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -624,17 +628,24 @@ void handle_sdl_key_event(SDL_Event event) {
|
||||
void handle_sdl_mouse_event(SDL_Event event) {
|
||||
int x, y;
|
||||
|
||||
int scaledmotion = 0;
|
||||
if (scaledmotion) {
|
||||
x = event.motion.x * A2_WINDOW_WIDTH / g_startw;
|
||||
y = event.motion.y * A2_WINDOW_HEIGHT / g_starth;
|
||||
} else {
|
||||
x = event.motion.x - BASE_MARGIN_LEFT;
|
||||
y = event.motion.y - BASE_MARGIN_TOP;
|
||||
}
|
||||
|
||||
switch (event.type) {
|
||||
case SDL_MOUSEMOTION:
|
||||
update_mouse(x, y, 0, 0);
|
||||
update_mouse_w_delta(x, y, 0, 0, event.motion.xrel, event.motion.yrel);
|
||||
break;
|
||||
case SDL_MOUSEBUTTONUP:
|
||||
update_mouse(x, y, 0, event.motion.state &7 );
|
||||
update_mouse_w_delta(x, y, 0, event.motion.state &7, 0, 0);
|
||||
break;
|
||||
case SDL_MOUSEBUTTONDOWN:
|
||||
update_mouse(x, y, event.motion.state &7, event.motion.state &7 );
|
||||
update_mouse_w_delta(x, y, event.motion.state &7, event.motion.state &7 , 0, 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -838,6 +849,10 @@ void sdl_present_buffer() {
|
||||
}
|
||||
}
|
||||
|
||||
void x_grabmouse() {
|
||||
SDL_SetWindowGrab(window, g_grabmouse);
|
||||
SDL_SetRelativeMouseMode(g_grabmouse);
|
||||
}
|
||||
|
||||
// BELOW ARE FUNCTIONS THAT ARE EITHER UNIMPLEMENTED, OR AR NOT RELEVANT TO
|
||||
// THIS DRIVER.
|
||||
|
@ -168,7 +168,7 @@ int g_imagewriter_paper = 0;
|
||||
int g_imagewriter_banner = 0;
|
||||
|
||||
int g_config_iwm_vbl_count = 0;
|
||||
const char g_gsplus_version_str[] = "0.14rc";
|
||||
const char g_gsplus_version_str[] = "0.14";
|
||||
int g_pause=0; // OG Added pause
|
||||
|
||||
#define START_DCYCS (0.0)
|
||||
|
Loading…
Reference in New Issue
Block a user