From 1820a432c8a9870c7c6c1aad9a5685ddabde639d Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Sat, 11 Mar 2017 21:08:11 +0200 Subject: [PATCH] Touchscreen/tablet lightpen support, cross hair disable config entry. --- include/options.h | 1 + inputdevice.cpp | 338 ++++++++++++++++++++++++++++---------------- od-win32/dinput.cpp | 93 +++++++----- od-win32/win32.cpp | 55 ++++--- 4 files changed, 309 insertions(+), 178 deletions(-) diff --git a/include/options.h b/include/options.h index fafed97e..b249620d 100644 --- a/include/options.h +++ b/include/options.h @@ -503,6 +503,7 @@ struct uae_prefs { bool lightboost_strobo; int lightboost_strobo_ratio; bool gfx_grayscale; + bool lightpen_crosshair; struct gfx_filterdata gf[2]; diff --git a/inputdevice.cpp b/inputdevice.cpp index 59bd1bb1..787e8739 100644 --- a/inputdevice.cpp +++ b/inputdevice.cpp @@ -2149,6 +2149,48 @@ void input_mousehack_mouseoffset (uaecptr pointerprefs) mouseoffset_y = (uae_s16)get_word (pointerprefs + 30); } +static bool get_mouse_position(int *xp, int *yp, int inx, int iny) +{ + int x, y; + float fdy, fdx, fmx, fmy; + bool ob = false; + + x = inx; + y = iny; + + getgfxoffset (&fdx, &fdy, &fmx, &fmy); + +#ifdef PICASSO96 + if (picasso_on) { + x -= picasso96_state.XOffset; + y -= picasso96_state.YOffset; + x = (int)(x * fmx); + y = (int)(y * fmy); + x -= (int)(fdx * fmx); + y -= (int)(fdy * fmy); + } else +#endif + { + if (gfxvidinfo.outbuffer == NULL) { + *xp = 0; + *yp = 0; + return false; + } + x = (int)(x * fmx); + y = (int)(y * fmy); + x -= (int)(fdx * fmx) - 1; + y -= (int)(fdy * fmy) - 2; + x = coord_native_to_amiga_x(x); + if (y >= 0) + y = coord_native_to_amiga_y(y) * 2; + if (x < 0 || y < 0 || x >= gfxvidinfo.outbuffer->outwidth || y >= gfxvidinfo.outbuffer->outheight) + ob = true; + } + *xp = x; + *yp = y; + return ob == false; +} + void mousehack_wakeup(void) { if (mousehack_alive_cnt == 0) @@ -2215,104 +2257,183 @@ void inputdevice_tablet_strobe (void) put_byte_host(mousehack_address + MH_CNT, get_byte_host(mousehack_address + MH_CNT) + 1); } -void inputdevice_tablet (int x, int y, int z, int pressure, uae_u32 buttonbits, int inproximity, int ax, int ay, int az) +void tablet_lightpen(int tx, int ty, int tmaxx, int tmaxy, int touch, int buttonmask, bool touchmode, int devid) { - uae_u8 *p; - uae_u8 tmp[MH_END]; + if (picasso_on) + goto end; - mousehack_enable (); - if (inputdevice_is_tablet () <= 0 || !mousehack_address) - return; - //write_log (_T("%d %d %d %d %08X %d %d %d %d\n"), x, y, z, pressure, buttonbits, inproximity, ax, ay, az); - p = mousehack_address; + if (gfxvidinfo.outbuffer == NULL) + goto end; - memcpy (tmp, p + MH_START, MH_END - MH_START); -#if 0 - if (currprefs.input_magic_mouse) { - int maxx, maxy, diffx, diffy; - int dw, dh, ax, ay, aw, ah; - float xmult, ymult; - float fx, fy; - - fx = (float)x; - fy = (float)y; - desktop_coords (&dw, &dh, &ax, &ay, &aw, &ah); - xmult = (float)tablet_maxx / dw; - ymult = (float)tablet_maxy / dh; - - diffx = 0; - diffy = 0; - if (picasso_on) { - maxx = gfxvidinfo.width; - maxy = gfxvidinfo.height; - } else { - get_custom_mouse_limits (&maxx, &maxy, &diffx, &diffy); - } - diffx += ax; - diffy += ah; + if (touch < 0) + goto end; - fx -= diffx * xmult; - if (fx < 0) - fx = 0; - if (fx >= aw * xmult) - fx = aw * xmult - 1; - fy -= diffy * ymult; - if (fy < 0) - fy = 0; - if (fy >= ah * ymult) - fy = ah * ymult - 1; + int dw, dh, ax, ay, aw, ah; + float fx, fy; + float xmult, ymult; - x = (int)(fx * (aw * xmult) / tablet_maxx + 0.5); - y = (int)(fy * (ah * ymult) / tablet_maxy + 0.5); + fx = (float)tx; + fy = (float)ty; + desktop_coords (&dw, &dh, &ax, &ay, &aw, &ah); + + if (tmaxx < 0 || tmaxy < 0) { + tmaxx = dw; + tmaxy = dh; } -#endif - p[MH_X] = x >> 8; - p[MH_X + 1] = x; - p[MH_Y] = y >> 8; - p[MH_Y + 1] = y; - p[MH_Z] = z >> 8; - p[MH_Z + 1] = z; - - p[MH_AX] = ax >> 8; - p[MH_AX + 1] = ax; - p[MH_AY] = ay >> 8; - p[MH_AY + 1] = ay; - p[MH_AZ] = az >> 8; - p[MH_AZ + 1] = az; - - p[MH_PRESSURE] = pressure >> 8; - p[MH_PRESSURE + 1] = pressure; - - p[MH_BUTTONBITS + 0] = buttonbits >> 24; - p[MH_BUTTONBITS + 1] = buttonbits >> 16; - p[MH_BUTTONBITS + 2] = buttonbits >> 8; - p[MH_BUTTONBITS + 3] = buttonbits >> 0; - - if (inproximity < 0) { - p[MH_INPROXIMITY] = p[MH_INPROXIMITY + 1] = 0xff; - } else { - p[MH_INPROXIMITY] = 0; - p[MH_INPROXIMITY + 1] = inproximity ? 1 : 0; + + if (!touchmode) { + dw = aw; + dh = ah; + ax = 0; + ay = 0; } - if (!memcmp (tmp, p + MH_START, MH_END - MH_START)) - return; + xmult = (float)tmaxx / dw; + ymult = (float)tmaxy / dh; - if (tablet_log & 1) { - static int obuttonbits, oinproximity; - if (inproximity != oinproximity || buttonbits != obuttonbits) { - obuttonbits = buttonbits; - oinproximity = inproximity; - write_log (_T("TABLET: B=%08x P=%d\n"), buttonbits, inproximity); - } + fx = fx / xmult; + fy = fy / ymult; + + fx -= ax; + fy -= ay; + + float fdx, fdy, fmx, fmy; + getgfxoffset (&fdx, &fdy, &fmx, &fmy); + + int x = (int)(fx * fmx); + int y = (int)(fy * fmy); + x -= (int)(fdx * fmx) - 1; + y -= (int)(fdy * fmy) - 2; + + if (x < 0 || y < 0 || x >= aw || y >= ah) + goto end; + + lightpen_x = x; + lightpen_y = y; + + if (touch >= 0) + lightpen_active = true; + + if (touch > 0 && devid >= 0) { + setmousebuttonstate (devid, 0, 1); } - if (tablet_log & 2) { - write_log (_T("TABLET: X=%d Y=%d Z=%d AX=%d AY=%d AZ=%d\n"), x, y, z, ax, ay, az); + + lightpen_enabled = true; + return; + +end: + if (lightpen_active) { + lightpen_active = false; + setmousebuttonstate (devid, 0, 0); } - p[MH_E] = 0xc0 | 2; - p[MH_CNT]++; +} + +void inputdevice_tablet (int x, int y, int z, int pressure, uae_u32 buttonbits, int inproximity, int ax, int ay, int az, int devid) +{ + if (is_touch_lightpen()) { + + tablet_lightpen(x, y, tablet_maxx, tablet_maxy, inproximity ? 1 : -1, buttonbits, false, devid); + + } else { + uae_u8 *p; + uae_u8 tmp[MH_END]; + + mousehack_enable (); + if (inputdevice_is_tablet () <= 0 || !mousehack_address) + return; + //write_log (_T("%d %d %d %d %08X %d %d %d %d\n"), x, y, z, pressure, buttonbits, inproximity, ax, ay, az); + p = mousehack_address; + + memcpy (tmp, p + MH_START, MH_END - MH_START); +#if 0 + if (currprefs.input_magic_mouse) { + int maxx, maxy, diffx, diffy; + int dw, dh, ax, ay, aw, ah; + float xmult, ymult; + float fx, fy; + + fx = (float)x; + fy = (float)y; + desktop_coords (&dw, &dh, &ax, &ay, &aw, &ah); + xmult = (float)tablet_maxx / dw; + ymult = (float)tablet_maxy / dh; + + diffx = 0; + diffy = 0; + if (picasso_on) { + maxx = gfxvidinfo.width; + maxy = gfxvidinfo.height; + } else { + get_custom_mouse_limits (&maxx, &maxy, &diffx, &diffy); + } + diffx += ax; + diffy += ah; + + fx -= diffx * xmult; + if (fx < 0) + fx = 0; + if (fx >= aw * xmult) + fx = aw * xmult - 1; + fy -= diffy * ymult; + if (fy < 0) + fy = 0; + if (fy >= ah * ymult) + fy = ah * ymult - 1; + + x = (int)(fx * (aw * xmult) / tablet_maxx + 0.5); + y = (int)(fy * (ah * ymult) / tablet_maxy + 0.5); + + } +#endif + p[MH_X] = x >> 8; + p[MH_X + 1] = x; + p[MH_Y] = y >> 8; + p[MH_Y + 1] = y; + p[MH_Z] = z >> 8; + p[MH_Z + 1] = z; + + p[MH_AX] = ax >> 8; + p[MH_AX + 1] = ax; + p[MH_AY] = ay >> 8; + p[MH_AY + 1] = ay; + p[MH_AZ] = az >> 8; + p[MH_AZ + 1] = az; + + p[MH_PRESSURE] = pressure >> 8; + p[MH_PRESSURE + 1] = pressure; + + p[MH_BUTTONBITS + 0] = buttonbits >> 24; + p[MH_BUTTONBITS + 1] = buttonbits >> 16; + p[MH_BUTTONBITS + 2] = buttonbits >> 8; + p[MH_BUTTONBITS + 3] = buttonbits >> 0; + + if (inproximity < 0) { + p[MH_INPROXIMITY] = p[MH_INPROXIMITY + 1] = 0xff; + } else { + p[MH_INPROXIMITY] = 0; + p[MH_INPROXIMITY + 1] = inproximity ? 1 : 0; + } + + if (!memcmp (tmp, p + MH_START, MH_END - MH_START)) + return; + + if (tablet_log & 1) { + static int obuttonbits, oinproximity; + if (inproximity != oinproximity || buttonbits != obuttonbits) { + obuttonbits = buttonbits; + oinproximity = inproximity; + write_log (_T("TABLET: B=%08x P=%d\n"), buttonbits, inproximity); + } + } + if (tablet_log & 2) { + write_log (_T("TABLET: X=%d Y=%d Z=%d AX=%d AY=%d AZ=%d\n"), x, y, z, ax, ay, az); + } + + p[MH_E] = 0xc0 | 2; + p[MH_CNT]++; + } } void inputdevice_tablet_info (int maxx, int maxy, int maxz, int maxax, int maxay, int maxaz, int xres, int yres) @@ -2596,51 +2717,13 @@ static void inputdevice_mh_abs_v36 (int x, int y) static void mousehack_helper (uae_u32 buttonmask) { int x, y; - float fdy, fdx, fmx, fmy; - //write_log (_T("mousehack_helper %08X\n"), buttonmask); if (!(currprefs.input_mouse_untrap & MOUSEUNTRAP_MAGIC) && currprefs.input_tablet < TABLET_MOUSEHACK) return; -#if 0 - if (kickstart_version >= 36) { - inputdevice_mh_abs_v36 (lastmx, lastmy); - return; - } -#endif - x = lastmx; - y = lastmy; - getgfxoffset (&fdx, &fdy, &fmx, &fmy); + get_mouse_position(&x, &y, lastmx, lastmy); -#ifdef PICASSO96 - if (picasso_on) { - x -= picasso96_state.XOffset; - y -= picasso96_state.YOffset; - x = (int)(x * fmx); - y = (int)(y * fmy); - x -= (int)(fdx * fmx); - y -= (int)(fdy * fmy); - } else -#endif - { - if (gfxvidinfo.outbuffer == NULL) - return; - x = (int)(x * fmx); - y = (int)(y * fmy); - x -= (int)(fdx * fmx) - 1; - y -= (int)(fdy * fmy) - 2; - if (x < 0) - x = 0; - if (x >= gfxvidinfo.outbuffer->outwidth) - x = gfxvidinfo.outbuffer->outwidth - 1; - if (y < 0) - y = 0; - if (y >= gfxvidinfo.outbuffer->outheight) - y = gfxvidinfo.outbuffer->outheight - 1; - x = coord_native_to_amiga_x (x); - y = coord_native_to_amiga_y (y) << 1; - } inputdevice_mh_abs (x, y, buttonmask); } @@ -8075,6 +8158,9 @@ static void clearpressmask(void) } } +void target_inputdevice_acquire(void); +void target_inputdevice_unacquire(void); + void inputdevice_acquire (int allmode) { int i; @@ -8111,6 +8197,8 @@ void inputdevice_acquire (int allmode) idev[IDTYPE_MOUSE].acquire (-1, 0); idev[IDTYPE_KEYBOARD].acquire (-1, 0); + target_inputdevice_acquire(); + // if (!input_acquired) // write_log (_T("input devices acquired (%s)\n"), allmode ? "all" : "selected only"); input_acquired = 1; @@ -8142,6 +8230,8 @@ void inputdevice_unacquire(bool emulationactive, int inputmask) if (!input_acquired) return; + target_inputdevice_unacquire(); + input_acquired = 0; if (!(inputmask & 4)) idev[IDTYPE_JOYSTICK].unacquire(-1); diff --git a/od-win32/dinput.cpp b/od-win32/dinput.cpp index 9075a811..678dd0df 100644 --- a/od-win32/dinput.cpp +++ b/od-win32/dinput.cpp @@ -161,7 +161,7 @@ static int dd_inited, mouse_inited, keyboard_inited, joystick_inited; static int stopoutput; static HANDLE kbhandle = INVALID_HANDLE_VALUE; static int originalleds, oldleds, newleds, disabledleds, ledstate; -static int normalmouse, supermouse, rawmouse, winmouse, winmousenumber, winmousemode, winmousewheelbuttonstart; +static int normalmouse, supermouse, rawmouse, winmouse, winmousenumber, lightpen, lightpennumber, winmousewheelbuttonstart; static int normalkb, superkb, rawkb; static bool rawinput_enabled_mouse, rawinput_enabled_keyboard; static bool rawinput_decided; @@ -182,11 +182,11 @@ int dinput_wheelbuttonstart (void) { return winmousewheelbuttonstart; } -int dinput_winmousemode (void) +int dinput_lightpen (void) { - if (winmouse) - return winmousemode; - return 0; + if (lightpen) + return lightpennumber; + return -1; } #if 0 @@ -676,7 +676,7 @@ static void tablet_send (void) if (tablet_x < 0) return; inputdevice_tablet (tablet_x, tablet_y, tablet_z, tablet_pressure, tablet_buttons, tablet_proximity, - tablet_ax, tablet_ay, tablet_az); + tablet_ax, tablet_ay, tablet_az, dinput_lightpen()); tabletlib_tablet (tablet_x, tablet_y, tablet_z, tablet_pressure, maxpres, tablet_buttons, tablet_proximity, tablet_ax, tablet_ay, tablet_az); } @@ -749,7 +749,7 @@ void *open_tablet (HWND hwnd) if (!tablet) return 0; - if (inputdevice_is_tablet () <= 0) + if (inputdevice_is_tablet () <= 0 && !is_touch_lightpen()) return 0; xmax = -1; ymax = -1; @@ -816,9 +816,14 @@ int close_tablet (void *ctx) return 1; } +int is_touch_lightpen(void) +{ + return dinput_lightpen() >= 0; +} + int is_tablet (void) { - return tablet ? 1 : 0; + return (tablet || os_touch) ? 1 : 0; } static int initialize_tablet (void) @@ -2037,21 +2042,23 @@ static void initialize_windowsmouse (void) int i, j; did += num_mouse; - for (i = 0; i < 1; i++) { + for (i = 0; i < 2; i++) { if (num_mouse >= MAX_INPUT_DEVICES) return; cleardid (did); num_mouse++; - name = (i == 0) ? _T("Windows mouse") : _T("Mousehack mouse"); + name = (i == 0) ? _T("Windows mouse") : _T("Touchscreen light pen"); did->connection = DIDC_WIN; - did->name = my_strdup (i ? _T("Mousehack mouse (Required for tablets)") : _T("Windows mouse")); - did->sortname = my_strdup (i ? _T("Windowsmouse2") : _T("Windowsmouse1")); - did->configname = my_strdup (i ? _T("WINMOUSE2") : _T("WINMOUSE1")); + did->name = my_strdup (i ? _T("Touchscreen light pen") : _T("Windows mouse")); + did->sortname = my_strdup (i ? _T("Lightpen1") : _T("Windowsmouse1")); + did->configname = my_strdup (i ? _T("LIGHTPEN1") : _T("WINMOUSE1")); did->buttons = GetSystemMetrics (SM_CMOUSEBUTTONS); if (did->buttons < 3) did->buttons = 3; if (did->buttons > 5) did->buttons = 5; /* no non-direcinput support for >5 buttons */ + if (i == 1) + did->buttons = 1; did->buttons_real = did->buttons; for (j = 0; j < did->buttons; j++) { did->buttonsort[j] = j; @@ -2059,24 +2066,30 @@ static void initialize_windowsmouse (void) did->buttonname[j] = my_strdup (tmp); } winmousewheelbuttonstart = did->buttons; - did->axles = os_vista ? 4 : 3; - did->axissort[0] = 0; - did->axisname[0] = my_strdup (_T("X Axis")); - did->axissort[1] = 1; - did->axisname[1] = my_strdup (_T("Y Axis")); - if (did->axles > 2) { - did->axissort[2] = 2; - did->axisname[2] = my_strdup (_T("Wheel")); - addplusminus (did, 2); - } - if (did->axles > 3) { - did->axissort[3] = 3; - did->axisname[3] = my_strdup (_T("HWheel")); - addplusminus (did, 3); + if (i == 0) { + did->axles = os_vista ? 4 : 3; + did->axissort[0] = 0; + did->axisname[0] = my_strdup (_T("X Axis")); + did->axissort[1] = 1; + did->axisname[1] = my_strdup (_T("Y Axis")); + if (did->axles > 2) { + did->axissort[2] = 2; + did->axisname[2] = my_strdup (_T("Wheel")); + addplusminus (did, 2); + } + if (did->axles > 3) { + did->axissort[3] = 3; + did->axisname[3] = my_strdup (_T("HWheel")); + addplusminus (did, 3); + } + did->priority = 2; + } else { + did->priority = 1; } - did->priority = 2; did->wininput = i + 1; did++; + if (!is_tablet()) + break; } } @@ -3376,16 +3389,19 @@ static int acquire_mouse (int num, int flags) did->acquired = 1; } if (did->acquired > 0) { - if (did->rawinput) + if (did->rawinput) { rawmouse++; - else if (did->superdevice) + } else if (did->superdevice) { supermouse++; - else if (did->wininput) { + } else if (did->wininput == 1) { winmouse++; winmousenumber = num; - winmousemode = did->wininput == 2; - } else + } else if (did->wininput == 2) { + lightpen++; + lightpennumber = num; + } else { normalmouse++; + } } return did->acquired > 0 ? 1 : 0; } @@ -3403,14 +3419,17 @@ static void unacquire_mouse (int num) unacquire (did->lpdi, _T("mouse")); if (did->acquired > 0) { - if (did->rawinput) + if (did->rawinput) { rawmouse--; - else if (did->superdevice) + } else if (did->superdevice) { supermouse--; - else if (did->wininput) + } else if (did->wininput == 1) { winmouse--; - else + } else if (did->wininput == 2) { + lightpen--; + } else { normalmouse--; + } did->acquired = 0; } } diff --git a/od-win32/win32.cpp b/od-win32/win32.cpp index 254e1fef..6cb52fef 100644 --- a/od-win32/win32.cpp +++ b/od-win32/win32.cpp @@ -654,6 +654,17 @@ bool ismouseactive (void) return mouseactive > 0; } +void target_inputdevice_unacquire(void) +{ + close_tablet(tablet); + tablet = NULL; +} +void target_inputdevice_acquire(void) +{ + target_inputdevice_unacquire(); + tablet = open_tablet(hAmigaWnd); +} + static void setmouseactive2 (int active, bool allowpause) { #ifdef RETROPLATFORM @@ -1109,6 +1120,7 @@ static void add_media_insert_queue(HWND hwnd, const TCHAR *drvname, int retrycnt } #if TOUCH_SUPPORT + static int touch_touched; static DWORD touch_time; @@ -1149,7 +1161,7 @@ static void touch_release(struct touch_store *ts, const RECT *rcontrol) ts->axis = -1; } -static void touch_event(DWORD id, int pressrel, int x, int y, const RECT *rcontrol) +static void tablet_touch(DWORD id, int pressrel, int x, int y, const RECT *rcontrol) { struct touch_store *ts = NULL; int buttony = rcontrol->bottom - (rcontrol->bottom - rcontrol->top) / 4; @@ -1286,6 +1298,19 @@ static void touch_event(DWORD id, int pressrel, int x, int y, const RECT *rcontr } } +static void touch_event(DWORD id, int pressrel, int x, int y, const RECT *rcontrol) +{ + if (is_touch_lightpen()) { + + tablet_lightpen(x, y, -1, -1, pressrel, pressrel > 0, true, dinput_lightpen()); + + } else { + + tablet_touch(id, pressrel, x, y, rcontrol); + + } +} + static int touch_prev_x, touch_prev_y; static DWORD touch_prev_flags; @@ -1294,7 +1319,7 @@ static void processtouch(HWND hwnd, WPARAM wParam, LPARAM lParam) RECT rgui, rcontrol[2]; int bottom; - if (currprefs.input_tablet) + if (currprefs.input_tablet && !is_touch_lightpen()) return; if (isfullscreen()) { @@ -1343,9 +1368,9 @@ static void processtouch(HWND hwnd, WPARAM wParam, LPARAM lParam) touch_prev_y = y; touch_prev_flags = ti->dwFlags; #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); +// 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 && dinput_winmouse() < 0) { + if (is_touch_lightpen() || (currprefs.input_tablet == TABLET_OFF && dinput_winmouse() < 0)) { if (ti->dwFlags & TOUCHEVENTF_DOWN) touch_event(ti->dwID, 1, x, y, rcontrol); if (ti->dwFlags & TOUCHEVENTF_UP) @@ -1643,7 +1668,6 @@ static LRESULT CALLBACK AmigaWindowProc (HWND hWnd, UINT message, WPARAM wParam, rp_set_hwnd (hWnd); #endif DragAcceptFiles (hWnd, TRUE); - tablet = open_tablet (hWnd); normalcursor = LoadCursor (NULL, IDC_ARROW); hwndNextViewer = SetClipboardViewer (hWnd); clipboard_init (hWnd); @@ -1654,7 +1678,6 @@ static LRESULT CALLBACK AmigaWindowProc (HWND hWnd, UINT message, WPARAM wParam, KillTimer(hWnd, 4); device_change_timer = 0; ChangeClipboardChain (hWnd, hwndNextViewer); - close_tablet (tablet); wait_keyrelease (); inputdevice_unacquire (); dinput_window (); @@ -1730,15 +1753,13 @@ static LRESULT CALLBACK AmigaWindowProc (HWND hWnd, UINT message, WPARAM wParam, } if (!focus || !mouseactive) return DefWindowProc (hWnd, message, wParam, lParam); - if (dinput_winmousemode () == 0) { - /* relative */ - int mxx = (amigawinclip_rect.left - amigawin_rect.left) + (amigawinclip_rect.right - amigawinclip_rect.left) / 2; - int myy = (amigawinclip_rect.top - amigawin_rect.top) + (amigawinclip_rect.bottom - amigawinclip_rect.top) / 2; - mx = mx - mxx; - my = my - myy; - setmousestate (dinput_winmouse (), 0, mx, 0); - setmousestate (dinput_winmouse (), 1, my, 0); - } + /* relative */ + int mxx = (amigawinclip_rect.left - amigawin_rect.left) + (amigawinclip_rect.right - amigawinclip_rect.left) / 2; + int myy = (amigawinclip_rect.top - amigawin_rect.top) + (amigawinclip_rect.bottom - amigawinclip_rect.top) / 2; + mx = mx - mxx; + my = my - myy; + setmousestate (dinput_winmouse (), 0, mx, 0); + setmousestate (dinput_winmouse (), 1, my, 0); } else if (isfocus () < 0 && (istablet || currprefs.input_tablet >= TABLET_MOUSEHACK)) { setmousestate (0, 0, mx, 1); setmousestate (0, 1, my, 1); @@ -1991,7 +2012,7 @@ static LRESULT CALLBACK AmigaWindowProc (HWND hWnd, UINT message, WPARAM wParam, typedef BOOL(API* WTPACKET)(HCTX, UINT, LPVOID); extern WTPACKET pWTPacket; PACKET pkt; - if (inputdevice_is_tablet () <= 0 && !currprefs.tablet_library) { + if (inputdevice_is_tablet () <= 0 && !currprefs.tablet_library && !is_touch_lightpen()) { close_tablet (tablet); tablet = NULL; return 0; @@ -5102,7 +5123,7 @@ static int osdetect (void) if (os_win7) { int v = GetSystemMetrics(SM_DIGITIZER); if (v & NID_READY) { - if (v & (NID_INTEGRATED_TOUCH | NID_INTEGRATED_PEN)) + if (v & (NID_INTEGRATED_TOUCH | NID_INTEGRATED_PEN | NID_EXTERNAL_TOUCH | NID_EXTERNAL_PEN)) os_touch = 1; } } -- 2.47.3