Skip to content

Instantly share code, notes, and snippets.

@bperrenoud
Created April 1, 2014 08:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bperrenoud/9909987 to your computer and use it in GitHub Desktop.
Save bperrenoud/9909987 to your computer and use it in GitHub Desktop.
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);
}
#endregion
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment