mirror of
https://github.com/kanjitalk755/macemu.git
synced 2024-09-27 08:54:30 +00:00
SS: the hardware cursor can be used even when the magnification is not an integer when in fullscreen
This commit is contained in:
parent
3d49e9790b
commit
021bb50149
@ -49,6 +49,7 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
#ifdef __MACOSX__
|
#ifdef __MACOSX__
|
||||||
#include "utils_macosx.h"
|
#include "utils_macosx.h"
|
||||||
@ -1006,14 +1007,13 @@ void update_sdl_video(SDL_Surface *s, Sint32 x, Sint32 y, Sint32 w, Sint32 h)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef SHEEPSHAVER
|
#ifdef SHEEPSHAVER
|
||||||
static void MagBits(Uint8 *dst, Uint8 *src, int mag) {
|
static void MagBits(Uint8 *dst, Uint8 *src, int size) {
|
||||||
for (int y = 0; y < 16; y++)
|
float s = 16.f / size;
|
||||||
for (int x = 0; x < 16; x++) {
|
for (int y = 0; y < size; y++)
|
||||||
int sa = 16 * y + x;
|
for (int x = 0; x < size; x++) {
|
||||||
if (!(src[sa >> 3] & 0x80 >> (sa & 7))) continue;
|
int sa = 16 * int(y * s) + int(x * s);
|
||||||
for (int dy = 0; dy < mag; dy++)
|
if (src[sa >> 3] & 0x80 >> (sa & 7)) {
|
||||||
for (int dx = 0; dx < mag; dx++) {
|
int da = (size + 7 & ~7) * y + x;
|
||||||
int da = 16 * mag * (mag * y + dy) + mag * x + dx;
|
|
||||||
dst[da >> 3] |= 0x80 >> (da & 7);
|
dst[da >> 3] |= 0x80 >> (da & 7);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1021,12 +1021,13 @@ static void MagBits(Uint8 *dst, Uint8 *src, int mag) {
|
|||||||
static SDL_Cursor *MagCursor(bool hot) {
|
static SDL_Cursor *MagCursor(bool hot) {
|
||||||
int w, h;
|
int w, h;
|
||||||
SDL_GetWindowSize(sdl_window, &w, &h);
|
SDL_GetWindowSize(sdl_window, &w, &h);
|
||||||
int mag = std::min(w / drv->VIDEO_MODE_X, h / drv->VIDEO_MODE_Y);
|
float mag = std::min((float)w / drv->VIDEO_MODE_X, (float)h / drv->VIDEO_MODE_Y);
|
||||||
Uint8 *data = (Uint8 *)SDL_calloc(1, 32 * mag * mag);
|
int size = ceilf(16 * mag), n = ((size + 7) >> 3) * size;
|
||||||
Uint8 *mask = (Uint8 *)SDL_calloc(1, 32 * mag * mag);
|
Uint8 *data = (Uint8 *)SDL_calloc(n, 2);
|
||||||
MagBits(data, &MacCursor[4], mag);
|
Uint8 *mask = (Uint8 *)SDL_calloc(n, 2);
|
||||||
MagBits(mask, &MacCursor[36], mag);
|
MagBits(data, &MacCursor[4], size);
|
||||||
SDL_Cursor *cursor = SDL_CreateCursor(data, mask, 16 * mag, 16 * mag, hot ? MacCursor[2] * mag : 0, hot ? MacCursor[3] * mag : 0);
|
MagBits(mask, &MacCursor[36], size);
|
||||||
|
SDL_Cursor *cursor = SDL_CreateCursor(data, mask, size, size, hot ? MacCursor[2] * mag : 0, hot ? MacCursor[3] * mag : 0);
|
||||||
SDL_free(data);
|
SDL_free(data);
|
||||||
SDL_free(mask);
|
SDL_free(mask);
|
||||||
return cursor;
|
return cursor;
|
||||||
@ -2027,7 +2028,7 @@ void SDL_monitor_desc::switch_to_current_mode(void)
|
|||||||
#ifdef SHEEPSHAVER
|
#ifdef SHEEPSHAVER
|
||||||
bool video_can_change_cursor(void)
|
bool video_can_change_cursor(void)
|
||||||
{
|
{
|
||||||
return PrefsFindBool("hardcursor") && (display_type == DISPLAY_WINDOW || PrefsFindBool("scale_integer"));
|
return PrefsFindBool("hardcursor");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -49,6 +49,7 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
#ifdef __MACOS__
|
#ifdef __MACOS__
|
||||||
#include "utils_macosx.h"
|
#include "utils_macosx.h"
|
||||||
@ -993,14 +994,13 @@ void update_sdl_video(SDL_Surface *s, Sint32 x, Sint32 y, Sint32 w, Sint32 h)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef SHEEPSHAVER
|
#ifdef SHEEPSHAVER
|
||||||
static void MagBits(Uint8 *dst, Uint8 *src, int mag) {
|
static void MagBits(Uint8 *dst, Uint8 *src, int size) {
|
||||||
for (int y = 0; y < 16; y++)
|
float s = 16.f / size;
|
||||||
for (int x = 0; x < 16; x++) {
|
for (int y = 0; y < size; y++)
|
||||||
int sa = 16 * y + x;
|
for (int x = 0; x < size; x++) {
|
||||||
if (!(src[sa >> 3] & 0x80 >> (sa & 7))) continue;
|
int sa = 16 * int(y * s) + int(x * s);
|
||||||
for (int dy = 0; dy < mag; dy++)
|
if (src[sa >> 3] & 0x80 >> (sa & 7)) {
|
||||||
for (int dx = 0; dx < mag; dx++) {
|
int da = (size + 7 & ~7) * y + x;
|
||||||
int da = 16 * mag * (mag * y + dy) + mag * x + dx;
|
|
||||||
dst[da >> 3] |= 0x80 >> (da & 7);
|
dst[da >> 3] |= 0x80 >> (da & 7);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1008,12 +1008,13 @@ static void MagBits(Uint8 *dst, Uint8 *src, int mag) {
|
|||||||
static SDL_Cursor *MagCursor(bool hot) {
|
static SDL_Cursor *MagCursor(bool hot) {
|
||||||
int w, h;
|
int w, h;
|
||||||
SDL_GetWindowSize(sdl_window, &w, &h);
|
SDL_GetWindowSize(sdl_window, &w, &h);
|
||||||
int mag = std::min(w / drv->VIDEO_MODE_X, h / drv->VIDEO_MODE_Y);
|
float mag = std::min((float)w / drv->VIDEO_MODE_X, (float)h / drv->VIDEO_MODE_Y);
|
||||||
Uint8 *data = (Uint8 *)SDL_calloc(1, 32 * mag * mag);
|
int size = ceilf(16 * mag), n = ((size + 7) >> 3) * size;
|
||||||
Uint8 *mask = (Uint8 *)SDL_calloc(1, 32 * mag * mag);
|
Uint8 *data = (Uint8 *)SDL_calloc(n, 2);
|
||||||
MagBits(data, &MacCursor[4], mag);
|
Uint8 *mask = (Uint8 *)SDL_calloc(n, 2);
|
||||||
MagBits(mask, &MacCursor[36], mag);
|
MagBits(data, &MacCursor[4], size);
|
||||||
SDL_Cursor *cursor = SDL_CreateCursor(data, mask, 16 * mag, 16 * mag, hot ? MacCursor[2] * mag : 0, hot ? MacCursor[3] * mag : 0);
|
MagBits(mask, &MacCursor[36], size);
|
||||||
|
SDL_Cursor *cursor = SDL_CreateCursor(data, mask, size, size, hot ? MacCursor[2] * mag : 0, hot ? MacCursor[3] * mag : 0);
|
||||||
SDL_free(data);
|
SDL_free(data);
|
||||||
SDL_free(mask);
|
SDL_free(mask);
|
||||||
return cursor;
|
return cursor;
|
||||||
@ -2001,7 +2002,7 @@ void SDL_monitor_desc::switch_to_current_mode(void)
|
|||||||
#ifdef SHEEPSHAVER
|
#ifdef SHEEPSHAVER
|
||||||
bool video_can_change_cursor(void)
|
bool video_can_change_cursor(void)
|
||||||
{
|
{
|
||||||
return PrefsFindBool("hardcursor") && (display_type == DISPLAY_WINDOW || PrefsFindBool("scale_integer"));
|
return PrefsFindBool("hardcursor");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -2306,7 +2307,7 @@ static void handle_events(void)
|
|||||||
int w, h;
|
int w, h;
|
||||||
SDL_GetWindowSize(sdl_window, &w, &h);
|
SDL_GetWindowSize(sdl_window, &w, &h);
|
||||||
const VIDEO_MODE &mode = drv->mode;
|
const VIDEO_MODE &mode = drv->mode;
|
||||||
float mag = std::min(w / VIDEO_MODE_X, h / VIDEO_MODE_Y);
|
float mag = std::min((float)w / VIDEO_MODE_X, (float)h / VIDEO_MODE_Y);
|
||||||
if (PrefsFindBool("scale_integer")) mag = SDL_floorf(mag);
|
if (PrefsFindBool("scale_integer")) mag = SDL_floorf(mag);
|
||||||
if (mag) {
|
if (mag) {
|
||||||
x = (x - (w - mag * VIDEO_MODE_X) / 2) / mag;
|
x = (x - (w - mag * VIDEO_MODE_X) / 2) / mag;
|
||||||
|
@ -649,25 +649,25 @@ static int tick_func(void *arg)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef USE_SDL_VIDEO
|
#ifdef USE_SDL_VIDEO
|
||||||
|
#if SDL_VERSION_ATLEAST(3, 0, 0)
|
||||||
|
#include <SDL_video.h>
|
||||||
|
#else
|
||||||
#include <SDL_syswm.h>
|
#include <SDL_syswm.h>
|
||||||
|
#endif
|
||||||
extern SDL_Window *sdl_window;
|
extern SDL_Window *sdl_window;
|
||||||
HWND GetMainWindowHandle(void)
|
HWND GetMainWindowHandle(void)
|
||||||
{
|
{
|
||||||
SDL_SysWMinfo wmInfo;
|
if (!sdl_window) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
#if SDL_VERSION_ATLEAST(3, 0, 0)
|
#if SDL_VERSION_ATLEAST(3, 0, 0)
|
||||||
if (!sdl_window || !SDL_GetWindowWMInfo(sdl_window, &wmInfo, SDL_SYSWM_CURRENT_VERSION)) {
|
SDL_PropertiesID props = SDL_GetWindowProperties(sdl_window);
|
||||||
return NULL;
|
return (HWND)SDL_GetProperty(props, "SDL.window.cocoa.window", NULL);
|
||||||
}
|
|
||||||
#else
|
#else
|
||||||
|
SDL_SysWMinfo wmInfo;
|
||||||
SDL_VERSION(&wmInfo.version);
|
SDL_VERSION(&wmInfo.version);
|
||||||
if (!sdl_window || !SDL_GetWindowWMInfo(sdl_window, &wmInfo)) {
|
return SDL_GetWindowWMInfo(sdl_window, &wmInfo) ? wmInfo.info.win.window : NULL;
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
if (wmInfo.subsystem != SDL_SYSWM_WINDOWS) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
return wmInfo.info.win.window;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -793,25 +793,25 @@ void SheepMem::Exit(void)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef USE_SDL_VIDEO
|
#ifdef USE_SDL_VIDEO
|
||||||
|
#if SDL_VERSION_ATLEAST(3, 0, 0)
|
||||||
|
#include <SDL_video.h>
|
||||||
|
#else
|
||||||
#include <SDL_syswm.h>
|
#include <SDL_syswm.h>
|
||||||
|
#endif
|
||||||
extern SDL_Window *sdl_window;
|
extern SDL_Window *sdl_window;
|
||||||
HWND GetMainWindowHandle(void)
|
HWND GetMainWindowHandle(void)
|
||||||
{
|
{
|
||||||
SDL_SysWMinfo wmInfo;
|
if (!sdl_window) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
#if SDL_VERSION_ATLEAST(3, 0, 0)
|
#if SDL_VERSION_ATLEAST(3, 0, 0)
|
||||||
if (!sdl_window || !SDL_GetWindowWMInfo(sdl_window, &wmInfo, SDL_SYSWM_CURRENT_VERSION)) {
|
SDL_PropertiesID props = SDL_GetWindowProperties(sdl_window);
|
||||||
return NULL;
|
return (HWND)SDL_GetProperty(props, "SDL.window.cocoa.window", NULL);
|
||||||
}
|
|
||||||
#else
|
#else
|
||||||
|
SDL_SysWMinfo wmInfo;
|
||||||
SDL_VERSION(&wmInfo.version);
|
SDL_VERSION(&wmInfo.version);
|
||||||
if (!sdl_window || !SDL_GetWindowWMInfo(sdl_window, &wmInfo)) {
|
return SDL_GetWindowWMInfo(sdl_window, &wmInfo) ? wmInfo.info.win.window : NULL;
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
if (wmInfo.subsystem != SDL_SYSWM_WINDOWS) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
return wmInfo.info.win.window;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user