-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MEGA65: adding option to disable mouse emulation
The problem: Xemu user may leave mouse grab mode to do something with their mouse. To avoid bothering the mouse-aware MEGA65 program running, I returned zero for relative mouse position change in this case. However that can cause problems with certain programs which are not mouse based and expecting $FF if mouse is not there.
- Loading branch information
Showing
4 changed files
with
23 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/* A work-in-progess MEGA65 (Commodore-65 clone origins) emulator | ||
Part of the Xemu project, please visit: https://github.com/lgblgblgb/xemu | ||
Copyright (C)2016-2023 LGB (Gábor Lénárt) <[email protected]> | ||
Copyright (C)2016-2024 LGB (Gábor Lénárt) <[email protected]> | ||
This program is free software; you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
|
@@ -519,9 +519,15 @@ int emu_callback_key ( int pos, SDL_Scancode key, int pressed, int handled ) | |
if (pos == RESTORE_KEY_POS) | ||
restore_is_held = 0; | ||
if (pos == -2 && key == 0) { // special case pos = -2, key = 0, handled = mouse button (which?) and release event! | ||
if ((handled == SDL_BUTTON_LEFT) && set_mouse_grab(SDL_TRUE, 0)) { | ||
OSD(-1, -1, " Mouse grab activated. Press \n both SHIFTs together to cancel."); | ||
DEBUGPRINT("UI: mouse grab activated" NL); | ||
if ((handled == SDL_BUTTON_LEFT)) { | ||
if (configdb.nomouseemu) { | ||
OSD(-1, -1, "Mouse emulation is disabled.\nCannot enter mouse grab mode."); | ||
} else { | ||
if (set_mouse_grab(SDL_TRUE, 0)) { | ||
OSD(-1, -1, "Mouse grab activated. Press\nboth SHIFTs together to cancel."); | ||
DEBUGPRINT("UI: mouse grab activated" NL); | ||
} | ||
} | ||
} | ||
if (handled == SDL_BUTTON_RIGHT) { | ||
ui_enter(); | ||
|
@@ -534,26 +540,32 @@ int emu_callback_key ( int pos, SDL_Scancode key, int pressed, int handled ) | |
|
||
Uint8 get_mouse_x_via_sid ( void ) | ||
{ | ||
static Uint8 result = 0; | ||
if (is_mouse_grab()) { | ||
static Uint8 result = 0; | ||
static int mouse_x = 0; | ||
mouse_x = (mouse_x + (hid_read_mouse_rel_x(-23, 23) / 3)) & 0x3F; | ||
DEBUG("MOUSE: X is %d, result byte is %d" NL, mouse_x, result); | ||
result = mouse_x << 1; | ||
return result; | ||
} | ||
const Uint8 result = configdb.nomouseemu ? 0xFF : 0x00; | ||
DEBUG("MOUSE: X query without mouse-grab is $%02X" NL, result); | ||
return result; | ||
} | ||
|
||
|
||
Uint8 get_mouse_y_via_sid ( void ) | ||
{ | ||
static Uint8 result = 0; | ||
if (is_mouse_grab()) { | ||
static Uint8 result = 0; | ||
static int mouse_y = 0; | ||
mouse_y = (mouse_y - (hid_read_mouse_rel_y(-23, 23) / 3)) & 0x3F; | ||
DEBUG("MOUSE: Y is %d, result byte is %d" NL, mouse_y, result); | ||
result = mouse_y << 1; | ||
return result; | ||
} | ||
const Uint8 result = configdb.nomouseemu ? 0xFF : 0x00; | ||
DEBUG("MOUSE: Y query without mouse-grab is $%02X" NL, result); | ||
return result; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters