Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Update for unity's touchscript library. Disable windows 7 long touch event and visual feedback. Allow to catch press events immediately. Update the Win7TouchInput file with this code
// Current Init Method with one call added
private void init()
if (Application.platform != RuntimePlatform.WindowsPlayer) return;
touchInputSize = Marshal.SizeOf(typeof(TOUCHINPUT));
hMainWindow = GetForegroundWindow();
RegisterTouchWindow(hMainWindow, 0);
newWndProc = wndProc;
newWndProcPtr = Marshal.GetFunctionPointerForDelegate(newWndProc);
oldWndProcPtr = SetWindowLongPtr(hMainWindow, -4, newWndProcPtr);
EnableTabletGestures(false); // Added this call
isInitialized = true;
// NEW CODE (anywhere in the class)
#region removing windows long touch
[DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
public static extern short GlobalAddAtom(string atom);
[DllImport("user32.dll", CharSet = CharSet.Unicode)]
public static extern IntPtr RemoveProp(IntPtr hWnd, string atom);
[DllImport("user32.dll", CharSet = CharSet.Unicode)]
public static extern int SetProp(IntPtr hWnd, string atom, IntPtr handle);
public bool EnableTabletGestures(bool enable)
var hWnd = this.hMainWindow;
long num = 0L;
string atom = "MicrosoftTabletPenServiceProperty";
num = GlobalAddAtom(atom);
if (num == 0L)
return false;
if (enable)
return (RemoveProp(hWnd, atom).ToInt64() == 1L);
int num2 = 0x1010019;
return (SetProp(hWnd, atom, new IntPtr(num2)) == 1);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment