mirror of
https://github.com/digarok/gsplus.git
synced 2024-11-24 06:34:02 +00:00
cleaner shutdown / mouse code for SDL
This commit is contained in:
parent
712c0792bf
commit
48bad8a432
@ -1678,6 +1678,7 @@ void adb_physical_key_update(int a2code, int is_up) {
|
||||
g_hide_pointer = g_warp_pointer;
|
||||
x_hide_pointer(g_hide_pointer);
|
||||
}
|
||||
glogf("g_warp_pointer is now %d", g_warp_pointer);
|
||||
break;
|
||||
case 0x09: /* F9 - swap paddles */
|
||||
if(SHIFT_DOWN) {
|
||||
|
@ -134,8 +134,6 @@
|
||||
|
||||
#define BORDER_WIDTH 32
|
||||
|
||||
//#define EFF_BORDER_WIDTH (BORDER_WIDTH + (640-560))
|
||||
|
||||
// OG Eff_border_widht == border side in A2 mode
|
||||
#define EFF_BORDER_WIDTH (BORDER_WIDTH + (640-560)/2)
|
||||
|
||||
@ -149,15 +147,12 @@
|
||||
#define A2_WINDOW_WIDTH 640
|
||||
#define A2_WINDOW_HEIGHT 400
|
||||
|
||||
#define X_A2_WINDOW_WIDTH (A2_WINDOW_WIDTH + BASE_MARGIN_LEFT + \
|
||||
BASE_MARGIN_RIGHT)
|
||||
#define X_A2_WINDOW_HEIGHT (A2_WINDOW_HEIGHT + BASE_MARGIN_TOP + \
|
||||
BASE_MARGIN_BOTTOM)
|
||||
#define X_A2_WINDOW_WIDTH (A2_WINDOW_WIDTH + BASE_MARGIN_LEFT + BASE_MARGIN_RIGHT)
|
||||
#define X_A2_WINDOW_HEIGHT (A2_WINDOW_HEIGHT + BASE_MARGIN_TOP + BASE_MARGIN_BOTTOM)
|
||||
#define BASE_WINDOW_WIDTH (X_A2_WINDOW_WIDTH)
|
||||
#define BASE_WINDOW_HEIGHT (X_A2_WINDOW_HEIGHT)
|
||||
|
||||
#define MAX_STATUS_LINES 7
|
||||
#define STATUS_LINE_LENGTH 88
|
||||
|
||||
#define BASE_WINDOW_WIDTH (X_A2_WINDOW_WIDTH)
|
||||
|
||||
|
||||
#define A2_BORDER_COLOR_NUM 0xfe
|
||||
|
@ -85,7 +85,7 @@ static size_t g_clipboard_pos = 0;
|
||||
void dev_video_init_sdl();
|
||||
void handle_sdl_key_event(SDL_Event event);
|
||||
void check_input_events_sdl();
|
||||
int handle_sdl_mouse_motion_event(SDL_Event event);
|
||||
void handle_sdl_mouse_event(SDL_Event event);
|
||||
|
||||
int g_num_a2_keycodes = 0;
|
||||
int a2_key_to_sdlkeycode[][3] = {
|
||||
@ -393,7 +393,11 @@ void dev_video_init_sdl() {
|
||||
// UPDATE A RECT OF THE APPLE II SCREEN TEXTURE
|
||||
SDL_UpdateTexture(overlay_texture, &dstrect, overlay_pixels, pitch*sizeof(Uint32) );
|
||||
|
||||
// Turn off host mouse cursor
|
||||
SDL_ShowCursor(SDL_DISABLE);
|
||||
SDL_SetWindowGrab(window, true);
|
||||
SDL_SetRelativeMouseMode(true);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -453,7 +457,6 @@ void check_input_events() {
|
||||
|
||||
|
||||
void check_input_events_sdl() {
|
||||
int motion = 0;
|
||||
SDL_Event event;
|
||||
|
||||
while (SDL_PollEvent(&event)) {
|
||||
@ -469,13 +472,10 @@ void check_input_events_sdl() {
|
||||
case SDL_MOUSEMOTION:
|
||||
case SDL_MOUSEBUTTONUP:
|
||||
case SDL_MOUSEBUTTONDOWN:
|
||||
motion |= handle_sdl_mouse_motion_event(event);
|
||||
handle_sdl_mouse_event(event);
|
||||
break;
|
||||
case SDL_QUIT:
|
||||
SDL_DestroyWindow(window);
|
||||
iwm_shut();
|
||||
// Clean up
|
||||
SDL_Quit();
|
||||
xdriver_end();
|
||||
my_exit(1);
|
||||
break;
|
||||
case SDL_DROPFILE:
|
||||
@ -615,15 +615,21 @@ void handle_sdl_key_event(SDL_Event event) {
|
||||
}
|
||||
|
||||
|
||||
int handle_sdl_mouse_motion_event(SDL_Event event) {
|
||||
void handle_sdl_mouse_event(SDL_Event event) {
|
||||
int x, y;
|
||||
// @todo: FIX MOUSE BUTTON MAPPING, AT LEAST CLEAN UP AND DOCUMENT BEHAVIOR
|
||||
x = event.motion.x - BASE_MARGIN_LEFT;
|
||||
y = event.motion.y - BASE_MARGIN_TOP;
|
||||
if (event.type == SDL_MOUSEBUTTONUP) {
|
||||
return update_mouse(x, y, 0, event.motion.state &7 );
|
||||
} else {
|
||||
return update_mouse(x, y, event.motion.state, event.motion.state &7 );
|
||||
|
||||
x = event.motion.x * A2_WINDOW_WIDTH / BASE_WINDOW_WIDTH;
|
||||
y = event.motion.y * A2_WINDOW_HEIGHT / BASE_WINDOW_HEIGHT;
|
||||
switch (event.type) {
|
||||
case SDL_MOUSEMOTION:
|
||||
update_mouse(x, y, 0, 0);
|
||||
break;
|
||||
case SDL_MOUSEBUTTONUP:
|
||||
update_mouse(x, y, 0, event.motion.state &7 );
|
||||
break;
|
||||
case SDL_MOUSEBUTTONDOWN:
|
||||
update_mouse(x, y, event.motion.state &7, event.motion.state &7 );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -771,6 +777,9 @@ int x_show_alert(int is_fatal, const char *str) {
|
||||
}
|
||||
|
||||
void xdriver_end() {
|
||||
SDL_DestroyWindow(window);
|
||||
iwm_shut();
|
||||
// Clean up
|
||||
SDL_Quit();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user