From b312bddbd6f55f77f577281481f433df5deb78b3 Mon Sep 17 00:00:00 2001 From: Maho Morichika Date: Sat, 8 Feb 2020 03:55:02 -0500 Subject: [PATCH] set WANTPALM/FINETOUCH properly, disable windows touch feedback --- chuniio/chuniio.c | 5 +++-- chuniio/chuniio.h | 4 ++-- create-touch-window/create-touch-window.c | 24 ++++++++++++++++++++--- create-touch-window/create-touch-window.h | 4 ++-- meson.build | 4 ++-- 5 files changed, 30 insertions(+), 11 deletions(-) diff --git a/chuniio/chuniio.c b/chuniio/chuniio.c index 12b40bd..4b31456 100644 --- a/chuniio/chuniio.c +++ b/chuniio/chuniio.c @@ -56,7 +56,7 @@ LRESULT CALLBACK chuni_winproc_hook(HWND hwnd, UINT msg, WPARAM w_param, LPARAM TOUCHINPUT inputs[MAXFINGERS]; static uint8_t clicked_sliders[32]; - for (UINT i = 0; i < 32; i++) clicked_sliders[i] = 0; + memset(clicked_sliders, 0, 32); uint8_t chuni_ir_map_local = 0; if (GetTouchInputInfo((HTOUCHINPUT)l_param, fingers, inputs, sizeof(TOUCHINPUT))) { @@ -74,10 +74,11 @@ LRESULT CALLBACK chuni_winproc_hook(HWND hwnd, UINT msg, WPARAM w_param, LPARAM if (ir_id >= 0 && ir_id < 6) { chuni_io_ir(&chuni_ir_map_local, ir_id, !(p.dwFlags & TOUCHEVENTF_UP)); } - } } + CloseTouchInputHandle((HTOUCHINPUT)l_param); + memcpy(chuni_sliders, clicked_sliders, 32); chuni_ir_sensor_map = chuni_ir_map_local; return CHUNI_WINPROC; diff --git a/chuniio/chuniio.h b/chuniio/chuniio.h index dee4c86..6899fae 100644 --- a/chuniio/chuniio.h +++ b/chuniio/chuniio.h @@ -1,9 +1,9 @@ #pragma once #ifndef WINVER -#define WINVER 0x0601 +#define WINVER 0x0602 #endif #ifndef _WIN32_WINNT -#define _WIN32_WINNT 0x0601 +#define _WIN32_WINNT 0x0602 #endif #ifndef _WIN32_WINDOWS #define _WIN32_WINDOWS 0x0410 diff --git a/create-touch-window/create-touch-window.c b/create-touch-window/create-touch-window.c index c7a1f9f..288dc7c 100644 --- a/create-touch-window/create-touch-window.c +++ b/create-touch-window/create-touch-window.c @@ -1,7 +1,25 @@ -#include #include "create-touch-window.h" #include "hook/table.h" #include "hook/com-proxy.h" +#include +#include + + +void make_touchable (HWND h) { + const BOOL enabled = FALSE; + SetWindowFeedbackSetting(h, FEEDBACK_TOUCH_CONTACTVISUALIZATION, 0, sizeof(BOOL), &enabled); + SetWindowFeedbackSetting(h, FEEDBACK_PEN_BARRELVISUALIZATION, 0, sizeof(BOOL), &enabled); + SetWindowFeedbackSetting(h, FEEDBACK_PEN_TAP, 0, sizeof(BOOL), &enabled); + SetWindowFeedbackSetting(h, FEEDBACK_PEN_DOUBLETAP, 0, sizeof(BOOL), &enabled); + SetWindowFeedbackSetting(h, FEEDBACK_PEN_PRESSANDHOLD, 0, sizeof(BOOL), &enabled); + SetWindowFeedbackSetting(h, FEEDBACK_PEN_RIGHTTAP, 0, sizeof(BOOL), &enabled); + SetWindowFeedbackSetting(h, FEEDBACK_TOUCH_TAP, 0, sizeof(BOOL), &enabled); + SetWindowFeedbackSetting(h, FEEDBACK_TOUCH_DOUBLETAP, 0, sizeof(BOOL), &enabled); + SetWindowFeedbackSetting(h, FEEDBACK_TOUCH_PRESSANDHOLD, 0, sizeof(BOOL), &enabled); + SetWindowFeedbackSetting(h, FEEDBACK_TOUCH_RIGHTTAP, 0, sizeof(BOOL), &enabled); + SetWindowFeedbackSetting(h, FEEDBACK_GESTURE_PRESSANDTAP, 0, sizeof(BOOL), &enabled); + RegisterTouchWindow(h, TWF_FINETOUCH | TWF_WANTPALM); +} static HWND(WINAPI* n_CreateWindowExW)( DWORD dwExStyle, @@ -48,7 +66,7 @@ HWND WINAPI m_CreateWindowExW( LPVOID lpParam ) { HWND h = n_CreateWindowExW(dwExStyle, lpClassName, lpWindowName, dwStyle, X, Y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam); - RegisterTouchWindow(h, 0); + make_touchable(h); return h; } @@ -67,7 +85,7 @@ HWND WINAPI m_CreateWindowExA( LPVOID lpParam ) { HWND h = n_CreateWindowExA(dwExStyle, lpClassName, lpWindowName, dwStyle, X, Y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam); - RegisterTouchWindow(h, TWF_FINETOUCH | TWF_WANTPALM); + make_touchable(h); return h; } diff --git a/create-touch-window/create-touch-window.h b/create-touch-window/create-touch-window.h index 37fafea..2c39ad6 100644 --- a/create-touch-window/create-touch-window.h +++ b/create-touch-window/create-touch-window.h @@ -1,9 +1,9 @@ #pragma once #ifndef WINVER -#define WINVER 0x0601 +#define WINVER 0x0602 #endif #ifndef _WIN32_WINNT -#define _WIN32_WINNT 0x0601 +#define _WIN32_WINNT 0x0602 #endif #ifndef _WIN32_WINDOWS #define _WIN32_WINDOWS 0x0410 diff --git a/meson.build b/meson.build index 8b86491..4f9d131 100644 --- a/meson.build +++ b/meson.build @@ -1,10 +1,10 @@ -project('chunithm-touch', 'c', version: '0.1.1', default_options: ['warning_level=3']) +project('chunithm-touch', 'c', version: '0.1.2', default_options: ['warning_level=2']) add_project_arguments( '-DCOBJMACROS', '-DDIRECTINPUT_VERSION=0x0800', '-DWIN32_LEAN_AND_MEAN', - '-D_WIN32_WINNT=_WIN32_WINNT_WIN7', + '-D_WIN32_WINNT=_WIN32_WINNT_WIN8', '-DMINGW_HAS_SECURE_API=1', language: 'c', )