Skip to content

Commit

Permalink
set WANTPALM/FINETOUCH properly, disable windows touch feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
magicnat committed Feb 8, 2020
1 parent f64c14b commit b312bdd
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 11 deletions.
5 changes: 3 additions & 2 deletions chuniio/chuniio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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))) {
Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions chuniio/chuniio.h
Original file line number Diff line number Diff line change
@@ -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
Expand Down
24 changes: 21 additions & 3 deletions create-touch-window/create-touch-window.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,25 @@
#include <windows.h>
#include "create-touch-window.h"
#include "hook/table.h"
#include "hook/com-proxy.h"
#include <windows.h>
#include <winuser.h>


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,
Expand Down Expand Up @@ -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;
}

Expand All @@ -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;
}

Expand Down
4 changes: 2 additions & 2 deletions create-touch-window/create-touch-window.h
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions meson.build
Original file line number Diff line number Diff line change
@@ -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',
)
Expand Down

0 comments on commit b312bdd

Please sign in to comment.