Author Topic: MultiTouch Capabilities in Windows 7  (Read 7407 times)

0 Members and 1 Guest are viewing this topic.

Offline Patrice Terrier

  • Hero Member
  • *****
  • Posts: 934
  • User-Rate: +62/-1
    • www.zapsolution.com
MultiTouch Capabilities in Windows 7
« on: April 23, 2011, 07:18:56 PM »
You need to use José Roca's API

MSDN documentation

WinUser.inc
Code: [Select]
'/*
' * Gesture flags - GESTUREINFO.dwFlags
' */
%GF_BEGIN   = &H00000001???
%GF_INERTIA = &H00000002???
%GF_END     = &H00000004???

'/*
' * Gesture IDs
' */
%GID_BEGIN        = 1
%GID_END          = 2
%GID_ZOOM         = 3
%GID_PAN          = 4
%GID_ROTATE       = 5
%GID_TWOFINGERTAP = 6
%GID_PRESSANDTAP  = 7
%GID_ROLLOVER     = %GID_PRESSANDTAP

'/*
' * Gesture information structure
' *   - Pass the HGESTUREINFO received in the WM_GESTURE message lParam into the
' *     GetGestureInfo function to retrieve this information.
' *   - If cbExtraArgs is non-zero, pass the HGESTUREINFO received in the WM_GESTURE
' *     message lParam into the GetGestureExtraArgs function to retrieve extended
' *     argument information.
' */
' // Size = 48 bytes
TYPE GESTUREINFO QWORD FILL   ' Must be 8 bytes aligned
   cbSize       AS DWORD    ' UINT // size, in bytes, of this structure (including variable length Args field)
   dwFlags      AS DWORD    ' DWORD // see GF_* flags
   dwID         AS DWORD    ' DWORD // gesture ID, see GID_* defines
   hwndTarget   AS DWORD    ' HWND // handle to window targeted by this gesture
   ptsLocation  AS POINTS   ' POINTS // current location of this gesture
   dwInstanceID AS DWORD    ' DWORD // internally used
   dwSequenceID AS DWORD    ' DWORD // internally used
   ullArguments AS QUAD     ' ULONGLONG // arguments for gestures whose arguments fit in 8 BYTES
   cbExtraArgs  AS DWORD    ' UINT // size, in bytes, of extra arguments, if any, that accompany this gesture
   alignment__  AS DWORD    ' // To keep 8 byte alignment
END TYPE

'/*
' * Gesture notification structure
' *   - The WM_GESTURENOTIFY message lParam contains a pointer to this structure.
' *   - The WM_GESTURENOTIFY message notifies a window that gesture recognition is
' *     in progress and a gesture will be generated if one is recognized under the
' *     current gesture settings.
' */
' // Size = 20 bytes
TYPE GESTURENOTIFYSTRUCT DWORD
   cbSize       AS DWORD    ' UINT // size, in bytes, of this structure
   dwFlags      AS DWORD    ' DWORD // unused
   hwndTarget   AS DWORD    ' HWND // handle to window targeted by the gesture
   ptsLocation  AS POINTS   ' POINTS // starting location
   dwInstanceID AS DWORD    ' DWORD // internally used
END TYPE

'/*
' * Gesture argument helpers
' *   - Angle should be a double in the range of -2pi to +2pi
' *   - Argument should be an unsigned 16-bit value
' */
'#define GID_ROTATE_ANGLE_TO_ARGUMENT(_arg_)     ((USHORT)((((_arg_) + 2.0 * 3.14159265) / (4.0 * 3.14159265)) * 65535.0))
MACRO GID_ROTATE_ANGLE_TO_ARGUMENT(arg) = BITS(WORD, (arg + 2.0 * 3.14159265) / (4.0 * 3.14159265)) * 65535.0

'#define GID_ROTATE_ANGLE_FROM_ARGUMENT(_arg_)   ((((double)(_arg_) / 65535.0) * 4.0 * 3.14159265) - 2.0 * 3.14159265)
MACRO GID_ROTATE_ANGLE_FROM_ARGUMENT(arg) = ((arg / 65535.0) * 4.0 * 3.14159265) - 2.0 * 3.14159265

'/*
' * Gesture information retrieval
' *   - HGESTUREINFO is received by a window in the lParam of a WM_GESTURE message.
' */
DECLARE FUNCTION GetGestureInfo IMPORT "USER32.DLL" ALIAS "GetGestureInfo" ( _
   BYVAL hGestureInfo AS DWORD _                        ' __in HGESTUREINFO hGestureInfo
 , BYREF pGestureInfo AS GESTUREINFO _                  ' __out PGESTUREINFO pGestureInfo
 ) AS LONG                                              ' BOOL

'/*
' * Gesture extra arguments retrieval
' *   - HGESTUREINFO is received by a window in the lParam of a WM_GESTURE message.
' *   - Size, in bytes, of the extra argument data is available in the cbExtraArgs
' *     field of the GESTUREINFO structure retrieved using the GetGestureInfo function.
' */
DECLARE FUNCTION GetGestureExtraArgs IMPORT "USER32.DLL" ALIAS "GetGestureExtraArgs" ( _
   BYVAL hGestureInfo AS DWORD _                        ' __in HGESTUREINFO hGestureInfo
 , BYVAL cbExtraArgs AS DWORD _                         ' __in UINT cbExtraArgs
 , BYREF pExtraArgs AS ANY _                            ' __out_bcount(cbExtraArgs) PBYTE pExtraArgs
 ) AS LONG                                              ' BOOL

'/*
' * Gesture information handle management
' *   - If an application processes the WM_GESTURE message, then once it is done
' *     with the associated HGESTUREINFO, the application is responsible for
' *     closing the handle using this function. Failure to do so may result in
' *     process memory leaks.
' *   - If the message is instead passed to DefWindowProc, or is forwarded using
' *     one of the PostMessage or SendMessage class of API functions, the handle
' *     is transfered with the message and need not be closed by the application.
' */
DECLARE FUNCTION CloseGestureInfoHandle IMPORT "USER32.DLL" ALIAS "CloseGestureInfoHandle" ( _
   BYVAL hGestureInfo AS DWORD _                        ' __in HGESTUREINFO hGestureInfo
 ) AS LONG                                              ' BOOL

'/*
' * Gesture configuration structure
' *   - Used in SetGestureConfig and GetGestureConfig
' *   - Note that any setting not included in either GESTURECONFIG.dwWant or
' *     GESTURECONFIG.dwBlock will use the parent window's preferences or
' *     system defaults.
' */
' // Size = 12 bytes
TYPE GESTURECONFIG DWORD
   dwID    AS DWORD   ' DWORD // gesture ID
   dwWant  AS DWORD   ' DWORD // settings related to gesture ID that are to be turned on
   dwBlock AS DWORD   ' DWORD // settings related to gesture ID that are to be turned off
END TYPE

'/*
' * Gesture configuration flags - GESTURECONFIG.dwWant or GESTURECONFIG.dwBlock
' */

'/*
' * Common gesture configuration flags - set GESTURECONFIG.dwID to zero
' */
%GC_ALLGESTURES                              = &H00000001???

'/*
' * Zoom gesture configuration flags - set GESTURECONFIG.dwID to GID_ZOOM
' */
%GC_ZOOM                                     = &H00000001???

'/*
' * Pan gesture configuration flags - set GESTURECONFIG.dwID to GID_PAN
' */
%GC_PAN                                      = &H00000001???
%GC_PAN_WITH_SINGLE_FINGER_VERTICALLY        = &H00000002???
%GC_PAN_WITH_SINGLE_FINGER_HORIZONTALLY      = &H00000004???
%GC_PAN_WITH_GUTTER                          = &H00000008???
%GC_PAN_WITH_INERTIA                         = &H00000010???

'/*
' * Rotate gesture configuration flags - set GESTURECONFIG.dwID to GID_ROTATE
' */
%GC_ROTATE                                   = &H00000001???

'/*
' * Two finger tap gesture configuration flags - set GESTURECONFIG.dwID to GID_TWOFINGERTAP
' */
%GC_TWOFINGERTAP                             = &H00000001???

'/*
' * PressAndTap gesture configuration flags - set GESTURECONFIG.dwID to GID_PRESSANDTAP
' */
%GC_PRESSANDTAP                              = &H00000001???
%GC_ROLLOVER                                 = %GC_PRESSANDTAP

%GESTURECONFIGMAXCOUNT = 256   ' // Maximum number of gestures that can be included
                               ' // in a single call to SetGestureConfig / GetGestureConfig

DECLARE FUNCTION SetGestureConfig IMPORT "USER32.DLL" ALIAS "SetGestureConfig" ( _
   BYVAL hwnd AS DWORD _                                ' __in HWND hwnd                                  // window for which configuration is specified
 , BYVAL dwReserved AS DWORD _                          ' __in DWORD dwReserved                           // reserved, must be 0
 , BYVAL cIDs AS DWORD _                                ' __in UINT cIDs                                  // count of GESTURECONFIG structures
 , BYREF pGestureConfig AS GESTURECONFIG _              ' __in_ecount(cIDs) PGESTURECONFIG pGestureConfig // array of GESTURECONFIG structures, dwIDs will be processed in the order specified and repeated occurances will overwrite previous ones
 , BYVAL cbSize AS DWORD _                              ' __in UINT cbSize                                // sizeof(GESTURECONFIG)
 ) AS LONG                                              ' BOOL

%GCF_INCLUDE_ANCESTORS           = &H00000001???   ' // If specified, GetGestureConfig returns consolidated configuration
                                                   ' // for the specified window and it's parent window chain

DECLARE FUNCTION GetGestureConfig IMPORT "USER32.DLL" ALIAS "GetGestureConfig" ( _
   BYVAL hwnd AS DWORD _                                ' __in HWND hwnd        // window for which configuration is required
 , BYVAL dwReserved AS DWORD _                          ' __in DWORD dwReserved // reserved, must be 0
 , BYVAL dwFlags AS DWORD _                             ' __in DWORD dwFlags    // see GCF_* flags
 , BYVAL pcIDs AS DWORD _                               ' __in PUINT pcIDs      // *pcIDs contains the size, in number of GESTURECONFIG structures, of the buffer pointed to by pGestureConfig
 , BYREF pGestureConfig AS GESTURECONFIG _              ' __inout_ecount(*pcIDs) PGESTURECONFIG pGestureConfig pointer to buffer to receive the returned array of GESTURECONFIG structures
 , BYVAL cbSize AS DWORD _                              ' __in UINT cbSize      // sizeof(GESTURECONFIG)
 ) AS LONG                                              ' BOOL

...
Patrice Terrier
GDImage (advanced graphic addon)
http://www.zapsolution.com

Offline Petr Schreiber

  • Full Member
  • ***
  • Posts: 183
  • User-Rate: +14/-4
Re: MultiTouch Capabilities in Windows 7
« Reply #1 on: April 25, 2011, 09:20:42 AM »
Thank you very much Patrice (and José)!


Petr
AMD Sempron 3400+ | 1GB RAM @ 533MHz | GeForce 6200 / GeForce 9500GT | 32bit Windows XP SP3

psch.thinbasic.com

Christopher Boss

  • Guest
Re: MultiTouch Capabilities in Windows 7
« Reply #2 on: November 15, 2011, 12:41:23 AM »
Glad I found this post.

I have trying ti figure out what was wrong with my call to GetGestureInfo and the type was wrong.
I checked MSDN, but wouldn't have realized the QUAD FILL (and alignment) was needed.

Thanks Patrice.

Offline José Roca

  • Administrator
  • Hero Member
  • *****
  • Posts: 2513
  • User-Rate: +209/-0
Re: MultiTouch Capabilities in Windows 7
« Reply #3 on: November 15, 2011, 04:29:04 AM »
I have noticed an small error in my translation. The pcIDs parameter must be BYREF.

Code: [Select]

DECLARE FUNCTION GetGestureConfig IMPORT "USER32.DLL" ALIAS "GetGestureConfig" ( _
   BYVAL hwnd AS DWORD _                                ' __in HWND hwnd        // window for which configuration is required
 , BYVAL dwReserved AS DWORD _                          ' __in DWORD dwReserved // reserved, must be 0
 , BYVAL dwFlags AS DWORD _                             ' __in DWORD dwFlags    // see GCF_* flags
 , BYREF pcIDs AS DWORD _                               ' __in PUINT pcIDs      // *pcIDs contains the size, in number of GESTURECONFIG structures, of the buffer pointed to by pGestureConfig
 , BYREF pGestureConfig AS GESTURECONFIG _              ' __inout_ecount(*pcIDs) PGESTURECONFIG pGestureConfig pointer to buffer to receive the returned array of GESTURECONFIG structures
 , BYVAL cbSize AS DWORD _                              ' __in UINT cbSize      // sizeof(GESTURECONFIG)
 ) AS LONG                                              ' BOOL