From 9267fff1ed446e4136efe1994d911bc29b728506 Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Thu, 10 Dec 2015 17:58:51 +0200 Subject: [PATCH] 3220b1 --- include/options.h | 2 +- od-win32/fsdb_mywin32.cpp | 2 +- od-win32/resources/winuae.rc | 8 +- od-win32/rp.cpp | 10 +- od-win32/win32.cpp | 194 ++++++++++++++++++++++++++++++++--- od-win32/win32.h | 10 +- od-win32/win32gfx.cpp | 8 ++ od-win32/win32gui.cpp | 44 ++++++-- od-win32/win32gui.h | 2 +- od-win32/win32gui_extra.cpp | 14 ++- 10 files changed, 248 insertions(+), 46 deletions(-) diff --git a/include/options.h b/include/options.h index 40dca5de..ce30cd31 100644 --- a/include/options.h +++ b/include/options.h @@ -14,7 +14,7 @@ #define UAEMAJOR 3 #define UAEMINOR 2 -#define UAESUBREV 1 +#define UAESUBREV 2 typedef enum { KBD_LANG_US, KBD_LANG_DK, KBD_LANG_DE, KBD_LANG_SE, KBD_LANG_FR, KBD_LANG_IT, KBD_LANG_ES } KbdLang; diff --git a/od-win32/fsdb_mywin32.cpp b/od-win32/fsdb_mywin32.cpp index 8fa8104d..0766261a 100644 --- a/od-win32/fsdb_mywin32.cpp +++ b/od-win32/fsdb_mywin32.cpp @@ -546,7 +546,7 @@ FILE *my_opentext (const TCHAR *name) f = _tfopen (name, _T("rb")); if (!f) return NULL; - v = fread (tmp, 1, 4, f); + v = fread (tmp, 1, sizeof tmp, f); fclose (f); if (v == 4) { if (tmp[0] == 0xef && tmp[1] == 0xbb && tmp[2] == 0xbf) diff --git a/od-win32/resources/winuae.rc b/od-win32/resources/winuae.rc index ea41bb94..bebc2eb1 100644 --- a/od-win32/resources/winuae.rc +++ b/od-win32/resources/winuae.rc @@ -1297,8 +1297,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 3,2,1,0 - PRODUCTVERSION 3,2,1,0 + FILEVERSION 3,2,2,0 + PRODUCTVERSION 3,2,2,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -1314,12 +1314,12 @@ BEGIN BLOCK "040904b0" BEGIN VALUE "FileDescription", "WinUAE" - VALUE "FileVersion", "3.2.1.0" + VALUE "FileVersion", "3.2.2.0" VALUE "InternalName", "WinUAE" VALUE "LegalCopyright", "© 1996-2015 under the GNU Public License (GPL)" VALUE "OriginalFilename", "WinUAE.exe" VALUE "ProductName", "WinUAE" - VALUE "ProductVersion", "3.2.1.0" + VALUE "ProductVersion", "3.2.2.0" END END BLOCK "VarFileInfo" diff --git a/od-win32/rp.cpp b/od-win32/rp.cpp index 00e0ff34..c7cf05c3 100644 --- a/od-win32/rp.cpp +++ b/od-win32/rp.cpp @@ -776,10 +776,14 @@ static void set_screenmode (struct RPScreenMode *sm, struct uae_prefs *p) p->gfx_resolution = hres; p->gfx_vresolution = vres; - if (sm->lClipWidth <= 0) + if (sm->lClipWidth <= 0) { p->gfx_size_win.width = shift (AMIGA_WIDTH_MAX, -hdbl); - else - p->gfx_size_win.width = sm->lClipWidth >> (RES_MAX - hdbl); + } else { + if (hdbl > RES_MAX) + p->gfx_size_win.width = sm->lClipWidth << (hdbl - RES_MAX); + else + p->gfx_size_win.width = sm->lClipWidth >> (RES_MAX - hdbl); + } if (sm->lClipHeight <= 0) { p->gfx_size_win.height = shift (AMIGA_HEIGHT_MAX, -vdbl); diff --git a/od-win32/win32.cpp b/od-win32/win32.cpp index bf1fb703..73a5c307 100644 --- a/od-win32/win32.cpp +++ b/od-win32/win32.cpp @@ -1038,10 +1038,162 @@ static void add_media_insert_queue(HWND hwnd, const TCHAR *drvname, int retrycnt static int touch_touched; static DWORD touch_time; +#define MAX_TOUCHES 10 +struct touch_store +{ + int id; + int port; + int button; + int axis; +}; +static struct touch_store touches[MAX_TOUCHES]; + +static void touch_event(int id, int pressrel, int x, int y, RECT *rcontrol) +{ + struct touch_store *ts = NULL; + int buttonheight = rcontrol->bottom - (rcontrol->bottom - rcontrol->top) / 5; + + int new_slot = -1; + for (int i = 0; i < MAX_TOUCHES; i++) { + struct touch_store *tts = &touches[i]; + if (tts->id < 0 && new_slot < 0) + new_slot = i; + if (tts->id == id) { + ts = tts; + break; + } + } + if (!ts) { + if (pressrel == 0) + return; + if (new_slot < 0) + return; + ts = &touches[new_slot]; + ts->axis = -1; + ts->button = -1; + ts->id = id; + + } + + if (ts->id == id && pressrel < 0) { + if (ts->port == 0) { + if (ts->button == 0) + inputdevice_uaelib(_T("JOY1_FIRE_BUTTON"), 0, 0, false); + if (ts->button == 1) + inputdevice_uaelib(_T("JOY1_2ND_BUTTON"), 0, 0, false); + } else if (ts->port == 1) { + if (ts->button == 0) + inputdevice_uaelib(_T("JOY2_FIRE_BUTTON"), 0, 0, false); + if (ts->button == 1) + inputdevice_uaelib(_T("JOY2_2ND_BUTTON"), 0, 0, false); + } + ts->button = -1; + if (ts->axis > 0) { + RECT *r = &rcontrol[ts->port]; + if (ts->port == 0) { + inputdevice_uaelib(_T("MOUSE1_HORIZ"), 0, r->right - r->left, false); + inputdevice_uaelib(_T("MOUSE1_VERT"), 0, r->top - r->bottom, false); + } else { + inputdevice_uaelib(_T("JOY2_HORIZ"), 0, 0, false); + inputdevice_uaelib(_T("JOY2_VERT"), 0, 0, false); + } + } + ts->axis = -1; + } + + for (int i = 0; i < 2; i++) { + RECT *r = &rcontrol[i]; + if (x >= r->left && x < r->right && y >= r->top && y < r->bottom) { + if (pressrel > 0) { + ts->port = i; + if (y >= buttonheight) { + ts->button = x > r->left + (r->right - r->left) / 2 ? 1 : 0; + } else { + ts->axis = 1; + } + } + } + } + + if (ts->id == id && ts->axis > 0) { + RECT *r = &rcontrol[ts->port]; + int xdiff = (r->left + (r->right - r->left) / 2) - x; + int ydiff = (r->top + (r->bottom - r->top - buttonheight) / 2) - y; + + if (ts->port == 0) { + int div = (r->top - r->bottom) / 10; + xdiff /= div; + ydiff /= div; + inputdevice_uaelib(_T("MOUSE1_HORIZ"), xdiff, r->right - r->left, false); + inputdevice_uaelib(_T("MOUSE1_VERT"), ydiff, r->top - r->bottom, false); + } else { + int div = (r->top - r->bottom) / 3; + if (xdiff <= -div) + inputdevice_uaelib(_T("JOY2_HORIZ"), -1, 1, false); + else if (xdiff >= div) + inputdevice_uaelib(_T("JOY2_HORIZ"), 1, 1, false); + else + inputdevice_uaelib(_T("JOY2_HORIZ"), 0, 1, false); + if (ydiff <= -div) + inputdevice_uaelib(_T("JOY2_VERT"), -1, 1, false); + else if (ydiff >= div) + inputdevice_uaelib(_T("JOY2_VERT"), 1, 1, false); + else + inputdevice_uaelib(_T("JOY2_VERT"), 0, 1, false); + } + } + + if (ts->id == id && pressrel > 0) { + if (ts->port == 0) { + if (ts->button == 0) + inputdevice_uaelib(_T("JOY1_FIRE_BUTTON"), 0, 0, false); + if (ts->button == 1) + inputdevice_uaelib(_T("JOY1_2ND_BUTTON"), 0, 0, false); + } else if (ts->port == 1) { + if (ts->button == 0) + inputdevice_uaelib(_T("JOY2_FIRE_BUTTON"), 0, 0, false); + if (ts->button == 1) + inputdevice_uaelib(_T("JOY2_2ND_BUTTON"), 0, 0, false); + } + } +} + static void processtouch(HWND hwnd, WPARAM wParam, LPARAM lParam) { if (!pGetTouchInputInfo || !pCloseTouchInputHandle) return; + + RECT rgui, rcontrol[2]; + int bottom; + if (isfullscreen()) { + rgui.left = amigawin_rect.left; + rgui.top = amigawin_rect.top; + rgui.right = amigawin_rect.right; + rgui.bottom = amigawin_rect.top + 30; + bottom = amigawin_rect.bottom; + } else { + rgui.left = mainwin_rect.left; + rgui.top = mainwin_rect.top; + rgui.right = mainwin_rect.right; + rgui.bottom = amigawin_rect.top + GetSystemMetrics(SM_CYMENU) + 2; + bottom = mainwin_rect.bottom; + } + int maxx = rgui.right - rgui.left; + int maxy = rgui.bottom - rgui.top; + int max = maxx > maxy ? maxx : maxy; + + // left control region + rcontrol[0].left = rgui.left; + rcontrol[0].right = rcontrol[0].left + max / 2; + rcontrol[0].bottom = bottom; + rcontrol[0].top = bottom - max / 2; + + // right control region + rcontrol[1].right = rgui.right; + rcontrol[1].left = rcontrol[1].right - max / 2; + rcontrol[1].bottom = bottom; + rcontrol[1].top = bottom - max / 2; + UINT cInputs = LOWORD(wParam); PTOUCHINPUT pInputs = new TOUCHINPUT[cInputs]; if (NULL != pInputs) { @@ -1053,20 +1205,17 @@ static void processtouch(HWND hwnd, WPARAM wParam, LPARAM lParam) #if TOUCH_DEBUG write_log(_T("ID=%08x FLAGS=%08x MASK=%08x X=%d Y=%d \n"), ti->dwID, ti->dwFlags, ti->dwMask, x, y); #endif + if (currprefs.input_tablet == TABLET_OFF) { + if (ti->dwFlags & TOUCHEVENTF_DOWN) + touch_event(ti->dwID, 1, x, y, rcontrol); + if (ti->dwFlags & TOUCHEVENTF_UP) + touch_event(ti->dwID, -1, x, y, rcontrol); + if (ti->dwFlags & TOUCHEVENTF_MOVE) + touch_event(ti->dwID, 0, x, y, rcontrol); + } + if (ti->dwFlags & TOUCHEVENTF_PRIMARY) { - RECT r; - if (isfullscreen()) { - r.left = amigawin_rect.left; - r.top = amigawin_rect.top; - r.right = amigawin_rect.right; - r.bottom = amigawin_rect.top + 30; - } else { - r.left = mainwin_rect.left; - r.top = mainwin_rect.top; - r.right = mainwin_rect.right; - r.bottom = amigawin_rect.top + GetSystemMetrics(SM_CYMENU) + 2; - } - if (x < r.left || x >= r.right || y < r.top || y >= r.bottom) { + if (x < rgui.left || x >= rgui.right || y < rgui.top || y >= rgui.bottom) { touch_touched = 0; } else { if (ti->dwFlags & (TOUCHEVENTF_DOWN | TOUCHEVENTF_MOVE)) { @@ -1124,6 +1273,18 @@ static LRESULT CALLBACK AmigaWindowProc (HWND hWnd, UINT message, WPARAM wParam, handle_rawinput (lParam); DefWindowProc (hWnd, message, wParam, lParam); return 0; + case WM_INPUT_DEVICE_CHANGE: + if (is_hid_rawinput()) { + if (handle_rawinput_change(lParam, wParam)) { + // wait 2 seconds before re-enumerating + if (device_change_timer) + KillTimer(hWnd, 4); + device_change_timer = 1; + SetTimer(hWnd, 4, 2000, NULL); + } + return 0; + } + return DefWindowProc(hWnd, message, wParam, lParam); } switch (message) @@ -1546,7 +1707,7 @@ static LRESULT CALLBACK AmigaWindowProc (HWND hWnd, UINT message, WPARAM wParam, } } } - if (devicechange) { + if (devicechange && !is_hid_rawinput()) { if (device_change_timer) KillTimer(hWnd, 4); device_change_timer = 1; @@ -1809,6 +1970,7 @@ static LRESULT CALLBACK MainWindowProc (HWND hWnd, UINT message, WPARAM wParam, case WM_HELP: case WM_DEVICECHANGE: case WM_INPUT: + case WM_INPUT_DEVICE_CHANGE: case WM_USER + 1: case WM_USER + 2: case WM_COMMAND: @@ -2646,8 +2808,8 @@ void logging_init (void) } } - write_log (_T("\n%s (%d.%d %s%s[%d])"), VersionStr, - osVersion.dwMajorVersion, osVersion.dwMinorVersion, osVersion.szCSDVersion, + write_log (_T("\n%s (%d.%d.%d %s%s[%d])"), VersionStr, + osVersion.dwMajorVersion, osVersion.dwMinorVersion, osVersion.dwBuildNumber, osVersion.szCSDVersion, _tcslen (osVersion.szCSDVersion) > 0 ? _T(" ") : _T(""), os_admin); write_log (_T(" %d-bit %X.%X.%X %d %s"), wow64 ? 64 : 32, diff --git a/od-win32/win32.h b/od-win32/win32.h index ed08b132..184a298c 100644 --- a/od-win32/win32.h +++ b/od-win32/win32.h @@ -15,17 +15,17 @@ #define GETBDM(x) (((x) - ((x / 10000) * 10000)) / 100) #define GETBDD(x) ((x) % 100) -#define WINUAEPUBLICBETA 0 +#define WINUAEPUBLICBETA 1 #define LANG_DLL 1 #define LANG_DLL_FULL_VERSION_MATCH 0 #if WINUAEPUBLICBETA -#define WINUAEBETA _T("") +#define WINUAEBETA _T("1") #else #define WINUAEBETA _T("") #endif -#define WINUAEDATE MAKEBD(2015, 11, 19) +#define WINUAEDATE MAKEBD(2015, 12, 10) //#define WINUAEEXTRA _T("AmiKit Preview") //#define WINUAEEXTRA _T("Amiga Forever Edition") @@ -116,7 +116,9 @@ extern void sleep_millis_amiga (int ms); extern void wait_keyrelease (void); extern void keyboard_settrans (void); -extern void handle_rawinput (LPARAM lParam); +extern void handle_rawinput(LPARAM lParam); +extern bool handle_rawinput_change(LPARAM lParam, WPARAM wParam); +extern bool is_hid_rawinput(void); #define DEFAULT_PRIORITY 2 struct threadpriorities { diff --git a/od-win32/win32gfx.cpp b/od-win32/win32gfx.cpp index 20c4c7d4..bb3bfd0a 100644 --- a/od-win32/win32gfx.cpp +++ b/od-win32/win32gfx.cpp @@ -1883,6 +1883,7 @@ int check_prefs_changed_gfx (void) c |= currprefs.gfx_apmode[1].gfx_refreshrate != changed_prefs.gfx_apmode[1].gfx_refreshrate ? 2 | 16 : 0; #endif c |= currprefs.gfx_autoresolution != changed_prefs.gfx_autoresolution ? (2|8|16) : 0; + c |= currprefs.gfx_autoresolution_vga != changed_prefs.gfx_autoresolution_vga ? (2|8|16) : 0; c |= currprefs.gfx_api != changed_prefs.gfx_api ? (1|8|32) : 0; c |= currprefs.lightboost_strobo != changed_prefs.lightboost_strobo ? (2|16) : 0; @@ -1936,6 +1937,7 @@ int check_prefs_changed_gfx (void) c |= currprefs.gfx_autoresolution_minv != changed_prefs.gfx_autoresolution_minv ? (128) : 0; c |= currprefs.gfx_iscanlines != changed_prefs.gfx_iscanlines ? (2 | 8) : 0; c |= currprefs.gfx_pscanlines != changed_prefs.gfx_pscanlines ? (2 | 8) : 0; + c |= currprefs.monitoremu != changed_prefs.monitoremu ? (2 | 8) : 0; c |= currprefs.genlock_image != changed_prefs.genlock_image ? (2 | 8) : 0; c |= currprefs.genlock != changed_prefs.genlock ? (2 | 8) : 0; @@ -1972,6 +1974,7 @@ int check_prefs_changed_gfx (void) cfgfile_configuration_change (1); currprefs.gfx_autoresolution = changed_prefs.gfx_autoresolution; + currprefs.gfx_autoresolution_vga = changed_prefs.gfx_autoresolution_vga; currprefs.color_mode = changed_prefs.color_mode; currprefs.gfx_api = changed_prefs.gfx_api; currprefs.lightboost_strobo = changed_prefs.lightboost_strobo; @@ -1981,6 +1984,11 @@ int check_prefs_changed_gfx (void) display_change_requested = 1; } + if (c & 128) { + // hres/vres change + rp_screenmode_changed(); + } + if (display_change_requested) { if (display_change_requested == 3) { c = 1024; diff --git a/od-win32/win32gui.cpp b/od-win32/win32gui.cpp index a830bda5..03848d52 100644 --- a/od-win32/win32gui.cpp +++ b/od-win32/win32gui.cpp @@ -2098,6 +2098,7 @@ static int gui_width, gui_height; static int gui_fullscreen; static bool gui_resize_enabled; static bool gui_resize_allowed; + // Internal panel max size: 396, 318 static int mm = 0; @@ -5431,7 +5432,7 @@ static void ziplog(const char *name, const TCHAR *path, zipFile zf) } zipCloseFileInZip(zf); } - xfree(s); + fclose(s); } } static void zipconfig(const char *name, zipFile zf) @@ -5454,13 +5455,25 @@ static void zipconfig(const char *name, zipFile zf) static void savelog (HWND hDlg, int all) { TCHAR tmp[MAX_DPATH], tmp2[MAX_DPATH]; + TCHAR name[MAX_DPATH]; tmp[0] = 0; + + _stprintf(name, _T("winuae%s_%s_%d.%d.%d.%s"), +#ifdef _WIN64 + _T("64"), +#else + _T(""), +#endif + all ? _T("debug") : _T("config"), + UAEMAJOR, UAEMINOR, UAESUBREV, + all ? _T("zip") : _T("txt")); + if (all) { OPENFILENAME openFileName = { 0 }; flush_log (); - _tcscat (tmp, _T("winuae_debug.zip")); - _tcscpy (tmp2, tmp); + _tcscpy(tmp, name); + _tcscpy(tmp2, tmp); openFileName.lStructSize = sizeof (OPENFILENAME); openFileName.hwndOwner = hDlg; @@ -5486,7 +5499,7 @@ static void savelog (HWND hDlg, int all) } else { if (GetTempPath (MAX_DPATH, tmp) <= 0) return; - _tcscat (tmp, _T("winuae_config.txt")); + _tcscat(tmp, name); FILE *f = _tfopen (tmp, _T("wt, ccs=UTF-8")); saveconfig (f); fclose (f); @@ -10012,12 +10025,17 @@ static void setstatefilename (HWND hDlg) setchecked (hDlg, IDC_STATECLEAR, workprefs.statefile[0] != 0); } +static int previous_dpix, previous_dpiy; + static void setdefaultguisize (void) { double dpix = 1.0, dpiy = 1.0; - if (isfullscreen() <= 0) - scaleresource_getdpimult(&dpix, &dpiy); + previous_dpix = 0; + previous_dpiy = 0; + if (isfullscreen() <= 0) { + scaleresource_getdpimult(&dpix, &dpiy, &previous_dpix, &previous_dpiy); + } gui_width = (int)(GUI_INTERNAL_WIDTH * dpix); gui_height = (int)(GUI_INTERNAL_HEIGHT * dpiy); @@ -10200,7 +10218,7 @@ static INT_PTR MiscDlgProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) v = 140 - v * 10; } if (isfullscreen() <= 0) - scaleresource_getdpimult(&dpix, &dpiy); + scaleresource_getdpimult(&dpix, &dpiy, &previous_dpix, &previous_dpiy); gui_width = (int)(GUI_INTERNAL_WIDTH * dpix * v / 100); gui_height = (int)(GUI_INTERNAL_HEIGHT * dpiy * v / 100); if (gui_width < MIN_GUI_INTERNAL_WIDTH || gui_height < MIN_GUI_INTERNAL_HEIGHT) { @@ -18279,10 +18297,14 @@ static INT_PTR CALLBACK DialogProc (HWND hDlg, UINT msg, WPARAM wParam, LPARAM l if (!gui_size_changed && hGUIWnd != NULL) { int dx = LOWORD(wParam); int dy = HIWORD(wParam); - RECT *r = (RECT*)lParam; - gui_width = r->right - r->left; - gui_height = r->bottom - r->top; - gui_size_changed = 1; + if (dx != previous_dpix || dy != previous_dpiy) { + RECT *r = (RECT*)lParam; + previous_dpix = dx; + previous_dpiy = dy; + gui_width = r->right - r->left; + gui_height = r->bottom - r->top; + gui_size_changed = 1; + } } } break; diff --git a/od-win32/win32gui.h b/od-win32/win32gui.h index 3a8aae38..1fa1da4e 100644 --- a/od-win32/win32gui.h +++ b/od-win32/win32gui.h @@ -43,6 +43,6 @@ extern void scaleresource_init (const TCHAR*, int); extern int scaleresource_choosefont (HWND hDlg, int fonttype); extern void scaleresource_setdefaults (void); extern void scaleresource_setfont (HWND hDlg); -extern void scaleresource_getdpimult (double*, double*); +extern void scaleresource_getdpimult (double*, double*, int*, int*); #endif diff --git a/od-win32/win32gui_extra.cpp b/od-win32/win32gui_extra.cpp index 7d272810..769e69c0 100644 --- a/od-win32/win32gui_extra.cpp +++ b/od-win32/win32gui_extra.cpp @@ -534,22 +534,26 @@ typedef enum MONITOR_DPI_TYPE { } MONITOR_DPI_TYPE; typedef HRESULT(CALLBACK* GETDPIFORMONITOR)(HMONITOR, MONITOR_DPI_TYPE, UINT*, UINT*); -void scaleresource_getdpimult (double *dpixp, double *dpiyp) +void scaleresource_getdpimult (double *dpixmp, double *dpiymp, int *dpixp, int *dpiyp) { GETDPIFORMONITOR pGetDpiForMonitor; POINT pt = { 32000, 32000 }; HMONITOR mon = MonitorFromPoint(pt, MONITOR_DEFAULTTOPRIMARY); - *dpixp = 1.0; - *dpiyp = 1.0; + *dpixmp = 1.0; + *dpiymp = 1.0; + *dpixp = 0; + *dpiyp = 0; pGetDpiForMonitor = (GETDPIFORMONITOR)GetProcAddress(GetModuleHandle(_T("Shcore.dll")), "GetDpiForMonitor"); if (pGetDpiForMonitor) { UINT dpix, dpiy; if (SUCCEEDED(pGetDpiForMonitor(mon, MDT_EFFECTIVE_DPI, &dpix, &dpiy))) { if (dpix > 96) - *dpixp = (double)dpix / 96.0; + *dpixmp = (double)dpix / 96.0; if (dpiy > 96) - *dpiyp = (double)dpiy / 96.0; + *dpiymp = (double)dpiy / 96.0; + *dpixp = dpix; + *dpiyp = dpiy; } } } -- 2.47.3