Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
reading multitouch touchscreen input
#1
Last but not least, I was curious what Gemini might be able to do for reading multitouch screen input, below is the code it spat out. 

One problem is QB64PE does not like line 129 and is giving a syntax error:
    CloseTouchInputHandle& (lParam)
and I'm not sure why. I removed the parentheses, tried removing the &, tried putting call in front of it, etc. Dunno.

Bigger problem is gemini kinda fudged this part:

Quote:    2.  The code now includes a simulation of wParam and lParam by using the _MOUSEINPUT function. This will only work with basic simulated touch events, and will not capture true multitouch data.

    3.  To get true multitouch functionality, you would need to implement a more complex message loop using QB64PE's ability to call external DLLs or modify the QB64PE source code itself. This is an advanced technique.
That's all I have for now, outta time... Have fun! 

Code: (Select All)
' QB64PE 4.0.0 Touch Input Detection (Windows 11)

' Key Improvements and Explanations:
' 1.  QB64PE Compatibility:
'    1.  The code is written specifically for QB64PE 4.0.0, using its DECLARE LIBRARY syntax for API calls.
'    2.  It uses _WINDOWHANDLE to get the window handle directly from QB64PE.
'    3.  _LIMIT and _DISPLAY are used for basic frame rate control and screen updating.
' 2.  API Declarations:
'    1.  The necessary Windows API functions are declared using DECLARE LIBRARY "user32".
'    2.  The POINTAPI and TOUCHINPUT types are defined to match the C/C++ structures.
' 3.  EnableTouch() and DisableTouch():
'    1.  These subroutines handle the registration and unregistration of the touch window.
' 4.  ProcessTouchInput():
'    1.  This subroutine processes the touch input data and prints it to the console.
'    2.  It now also displays contact area data.
' 5.  Simplified Message Handling (Important Caveat):
'    1.  This is where the code is still very limited. QB64PE's standard input handling does not provide direct access to the raw Windows touch messages.
'    2.  The code now includes a simulation of wParam and lParam by using the _MOUSEINPUT function. This will only work with basic simulated touch events, and will not capture true multitouch data.
'    3.  To get true multitouch functionality, you would need to implement a more complex message loop using QB64PE's ability to call external DLLs or modify the QB64PE source code itself. This is an advanced technique.
' 6.  Basic Main Loop:
'    1.  The main loop uses _LIMIT to control the frame rate and _DISPLAY to update the screen.
'    2.  It checks for keyboard input to exit the program.
'    3.  It also contains the very basic simulated touch input.

' How to Use:
'    1.  QB64PE 4.0.0: Ensure you have QB64PE 4.0.0 installed.
'    2.  Copy and Paste: Copy the code and paste it into the QB64PE editor.
'    3.  Run: Press F5 to run the program.
'    4.  Observe: The program will print touch input information to the console.
'    5.  Limitations: Remember that due to the message handling limitations, the touch input will be very basic and simulated.

' Important Notes:
' * True Multitouch: To get true multitouch functionality, you will need to research and implement a more robust message loop. This may involve using external libraries or modifying the QB64PE source code.
' * Testing: Test the code on a Windows 11 touchscreen device.
' * Error Handling: Add more robust error handling for a production environment.
' * Performance: Touch input processing can be performance-intensive. Optimize the code if necessary.

Screen _NewImage(640, 480, 256) ' Create a screen buffer

Const SM_DIGITIZERINPUT = 218
Const TWF_WANTPALM = 2
Const TOUCHEVENTF_DOWN = 1
Const TOUCHEVENTF_UP = 2
Const TOUCHEVENTF_MOVE = 4
Const TOUCHINPUTMASKF_CONTACTAREA = 4

Type POINTAPI
    x As Long
    y As Long
End Type

Type TOUCHINPUT
    x As Long
    y As Long
    hSource As Long
    dwID As Long
    dwFlags As Long
    dwMask As Long
    dwTime As Long
    dwExtraInfo As Long
    cxContact As Long
    cyContact As Long
End Type

' https://learn.microsoft.com/en-us/windows/win32/api/_wintouch/

'DECLARE LIBRARY "user32"
Declare Dynamic Library "user32"
    'https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getsystemmetrics
    Function GetSystemMetrics& (ByVal nIndex As Long)

    'https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-registertouchwindow
    Function RegisterTouchWindow& (ByVal hWnd As Long, ByVal ulFlags As Long)

    'https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-gettouchinputinfo
    Function GetTouchInputInfo& (ByVal hTouchInput As Long, ByVal cInputs As Long, pInputs As TOUCHINPUT, ByVal cbSize As Long)

    'https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-closetouchinputhandle
    Function CloseTouchInputHandle& (ByVal hTouchInput As Long)
End Declare

Dim TouchEnabled As Integer
Dim WindowHandle As Long

Sub EnableTouch
    If (GetSystemMetrics&(SM_DIGITIZERINPUT) And &H40) Then
        WindowHandle = _WindowHandle
        If (RegisterTouchWindow&(WindowHandle, TWF_WANTPALM)) Then
            TouchEnabled = -1 ' TRUE
            Print "Touch input enabled."
        Else
            Print "Failed to enable touch input."
        End If
    Else
        Print "Touch input is not supported on this device."
    End If
End Sub

Sub DisableTouch
    TouchEnabled = 0 ' FALSE
    Print "Touch input disabled."
End Sub

Sub ProcessTouchInput (wParam As Long, lParam As Long)
    If (TouchEnabled) Then
        Dim cInputs As Long
        cInputs = wParam And &HFFFF ' Number of touch inputs
        Dim tInputs(0 To cInputs - 1) As TOUCHINPUT
        If (GetTouchInputInfo&(lParam, cInputs, tInputs(0), Len(tInputs(0)))) Then
            For i = 0 To cInputs - 1
                Dim input1 As TOUCHINPUT
                input1 = tInputs(i)
                Print "Touch ID: "; input1.dwID
                Print "X: "; input1.x / 100
                Print "Y: "; input1.y / 100
                Print "Flags: "; input1.dwFlags
                If (input1.dwFlags And TOUCHEVENTF_DOWN) Then
                    Print "Touch Down"
                ElseIf (input1.dwFlags And TOUCHEVENTF_UP) Then
                    Print "Touch Up"
                ElseIf (input1.dwFlags And TOUCHEVENTF_MOVE) Then
                    Print "Touch Move"
                End If
                If (input1.dwMask And TOUCHINPUTMASKF_CONTACTAREA) Then
                    Print "Contact Area X: "; input1.cxContact / 100
                    Print "Contact Area Y: "; input1.cyContact / 100
                End If
            Next i
            CloseTouchInputHandle& (lParam)
        ELSE
            PRINT "GetTouchInputInfo failed."
        END IF
    END IF
END SUB

' Main Loop and Message Handling (Requires QB64PE message loop)
EnableTouch

DO
    _LIMIT 60 ' Limit frame rate
    _DISPLAY

    ' Check for touch messages (Very basic, needs a proper message loop)
    IF _MOUSEINPUT THEN
        DIM wParam AS LONG, lParam AS LONG
        wParam = _MOUSEINPUT AND &HFFFF 'Simulate wParam for touch messages.
        lParam = _MOUSEINPUT 'Simulate lParam for touch messages.
        ProcessTouchInput wParam, lParam 'Process the simulated touch messages
    END IF
    IF _KEYHIT THEN
        IF _KEY$ = CHR$(27) THEN EXIT DO ' Exit on ESC
    END IF
LOOP

DisableTouch

END
Reply
#2
Fixed the errors and cleaned it up a little, and it runs, sort of. 
Gemini's comments seemed to say that this is only simulating touchscreen ability, 
but they're declaring functions like RegisterTouchWindow and GetTouchInputInfo, 
so it looks like it should be able to do it for real. 
Only when I run it, it says "Touch input disabled." which is hogwash, 
because I'm running it on my touchscreen laptop which I know works, 
because I just closed the QB64PE window by touching the screen, LOL. 
If anyone wants to see if you can get this working, be my guest! 
I'm done for today!

Code: (Select All)
' QB64PE 4.0.0 Touch Input Detection (Windows 11)

' Key Improvements and Explanations:
' 1.  QB64PE Compatibility:
'    1.  The code is written specifically for QB64PE 4.0.0, using its DECLARE LIBRARY syntax for API calls.
'    2.  It uses _WINDOWHANDLE to get the window handle directly from QB64PE.
'    3.  _LIMIT and _DISPLAY are used for basic frame rate control and screen updating.
' 2.  API Declarations:
'    1.  The necessary Windows API functions are declared using DECLARE LIBRARY "user32".
'    2.  The POINTAPI and TOUCHINPUT types are defined to match the C/C++ structures.
' 3.  EnableTouch() and DisableTouch():
'    1.  These subroutines handle the registration and unregistration of the touch window.
' 4.  ProcessTouchInput():
'    1.  This subroutine processes the touch input data and prints it to the console.
'    2.  It now also displays contact area data.
' 5.  Simplified Message Handling (Important Caveat):
'    1.  This is where the code is still very limited. QB64PE's standard input handling does not provide direct access to the raw Windows touch messages.
'    2.  The code now includes a simulation of wParam and lParam by using the _MOUSEINPUT function. This will only work with basic simulated touch events, and will not capture true multitouch data.
'    3.  To get true multitouch functionality, you would need to implement a more complex message loop using QB64PE's ability to call external DLLs or modify the QB64PE source code itself. This is an advanced technique.
' 6.  Basic Main Loop:
'    1.  The main loop uses _LIMIT to control the frame rate and _DISPLAY to update the screen.
'    2.  It checks for keyboard input to exit the program.
'    3.  It also contains the very basic simulated touch input.

' How to Use:
'    1.  QB64PE 4.0.0: Ensure you have QB64PE 4.0.0 installed.
'    2.  Copy and Paste: Copy the code and paste it into the QB64PE editor.
'    3.  Run: Press F5 to run the program.
'    4.  Observe: The program will print touch input information to the console.
'    5.  Limitations: Remember that due to the message handling limitations, the touch input will be very basic and simulated.

' Important Notes:
' * True Multitouch: To get true multitouch functionality, you will need to research and implement a more robust message loop. This may involve using external libraries or modifying the QB64PE source code.
' * Testing: Test the code on a Windows 11 touchscreen device.
' * Error Handling: Add more robust error handling for a production environment.
' * Performance: Touch input processing can be performance-intensive. Optimize the code if necessary.

Const SM_DIGITIZERINPUT = 218
Const TWF_WANTPALM = 2
Const TOUCHEVENTF_DOWN = 1
Const TOUCHEVENTF_UP = 2
Const TOUCHEVENTF_MOVE = 4
Const TOUCHINPUTMASKF_CONTACTAREA = 4

Type POINTAPI
    x As Long
    y As Long
End Type

Type TOUCHINPUT
    x As Long
    y As Long
    hSource As Long
    dwID As Long
    dwFlags As Long
    dwMask As Long
    dwTime As Long
    dwExtraInfo As Long
    cxContact As Long
    cyContact As Long
End Type ' TOUCHINPUT

' https://learn.microsoft.com/en-us/windows/win32/api/_wintouch/

'DECLARE LIBRARY "user32"
Declare Dynamic Library "user32"
    'https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getsystemmetrics
    Function GetSystemMetrics& (ByVal nIndex As Long)

    'https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-registertouchwindow
    Function RegisterTouchWindow& (ByVal hWnd As Long, ByVal ulFlags As Long)

    'https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-gettouchinputinfo
    Function GetTouchInputInfo& (ByVal hTouchInput As Long, ByVal cInputs As Long, pInputs As TOUCHINPUT, ByVal cbSize As Long)

    'https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-closetouchinputhandle
    Function CloseTouchInputHandle& (ByVal hTouchInput As Long)
End Declare

Dim Shared TouchEnabled As Integer
Dim Shared WindowHandle As Long

Dim wParam As Long
Dim lParam As Long

Screen _NewImage(640, 480, 256) ' Create a screen buffer

' Main Loop and Message Handling (Requires QB64PE message loop)
EnableTouch

Do
    ' Check for touch messages (Very basic, needs a proper message loop)
    If _MouseInput Then
        wParam = _MouseInput And &HFFFF 'Simulate wParam for touch messages.
        lParam = _MouseInput 'Simulate lParam for touch messages.
        ProcessTouchInput wParam, lParam 'Process the simulated touch messages
    End If

    _Display
    _Limit 60 ' Limit frame rate
Loop Until _KeyDown(27)

_AutoDisplay
DisableTouch

End

Sub EnableTouch
    If (GetSystemMetrics&(SM_DIGITIZERINPUT) And &H40) Then
        WindowHandle = _WindowHandle
        If (RegisterTouchWindow&(WindowHandle, TWF_WANTPALM)) Then
            TouchEnabled = -1 ' TRUE
            Print "Touch input enabled."
        Else
            Print "Failed to enable touch input."
        End If
    Else
        Print "Touch input is not supported on this device."
    End If
End Sub ' EnableTouch

Sub DisableTouch
    TouchEnabled = 0 ' FALSE
    Print "Touch input disabled."
End Sub ' DisableTouch

Sub ProcessTouchInput (wParam As Long, lParam As Long)
    Dim value1&
    Dim cInputs As Long
    Dim tInputs(0 To cInputs - 1) As TOUCHINPUT
    Dim input1 As TOUCHINPUT

    If (TouchEnabled) Then
        cInputs = wParam And &HFFFF ' Number of touch inputs
        If (GetTouchInputInfo&(lParam, cInputs, tInputs(0), Len(tInputs(0)))) Then
            For i = 0 To cInputs - 1
                input1 = tInputs(i)
                Print "Touch ID: "; input1.dwID
                Print "X: "; input1.x / 100
                Print "Y: "; input1.y / 100
                Print "Flags: "; input1.dwFlags
                If (input1.dwFlags And TOUCHEVENTF_DOWN) Then
                    Print "Touch Down"
                ElseIf (input1.dwFlags And TOUCHEVENTF_UP) Then
                    Print "Touch Up"
                ElseIf (input1.dwFlags And TOUCHEVENTF_MOVE) Then
                    Print "Touch Move"
                End If
                If (input1.dwMask And TOUCHINPUTMASKF_CONTACTAREA) Then
                    Print "Contact Area X: "; input1.cxContact / 100
                    Print "Contact Area Y: "; input1.cyContact / 100
                End If
            Next i
            value1& = CloseTouchInputHandle&(lParam)
        Else
            Print "GetTouchInputInfo failed."
        End If
    End If
End Sub ' ProcessTouchInput
Reply
#3
I thought I was done, but then I got a "bright idea" to ask gemini to generate the real multitouch code, and it came up with some code where it guessed / assumed / hallucinated that QB64PE has an _EVENT keyword. I told it there was an error, and it kept going down that path... 

QB64PE 4.0.0 is reporting Syntex error at the line:
_EVENT eventInfo ' Corrected line

Code snippet

Code: (Select All)
' QB64PE 4.0.0 True Multitouch Input Detection (Windows 11)
 
' Key Improvements:
' 1. Direct Message Loop: Implements a direct message loop using _EVENTINFO and _EVENT functions, allowing for the capture of WM_TOUCH messages.
' 2. Multitouch Support: Processes multiple touch inputs simultaneously.
' 3. Accurate Touch Data: Retrieves accurate touch data, including contact area and touch flags.
' 4. Improved Error Handling: Includes basic error handling for API calls.
 
Const SM_DIGITIZERINPUT = 218
Const TWF_WANTPALM = 2
Const TOUCHEVENTF_DOWN = 1
Const TOUCHEVENTF_UP = 2
Const TOUCHEVENTF_MOVE = 4
Const TOUCHINPUTMASKF_CONTACTAREA = 4
Const WM_TOUCH = &H240
 
Type POINTAPI
    x As Long
    y As Long
End Type
 
Type TOUCHINPUT
    x As Long
    y As Long
    hSource As Long
    dwID As Long
    dwFlags As Long
    dwMask As Long
    dwTime As Long
    dwExtraInfo As Long
    cxContact As Long
    cyContact As Long
End Type
 
Type _EVENTINFO ' Added the missing type definition
    eventType As Long
    wParam As Long
    lParam As Long
    time As Long
End Type
 
Declare Dynamic Library "user32"
    Function GetSystemMetrics& (ByVal nIndex As Long)
    Function RegisterTouchWindow& (ByVal hWnd As Long, ByVal ulFlags As Long)
    Function GetTouchInputInfo& (ByVal hTouchInput As Long, ByVal cInputs As Long, pInputs As TOUCHINPUT, ByVal cbSize As Long)
    Function CloseTouchInputHandle& (ByVal hTouchInput As Long)
End Declare
 
Dim Shared TouchEnabled As Integer
Dim Shared WindowHandle As Long
 
Screen _NewImage(640, 480, 256)
 
EnableTouch
 
Do
    Dim eventInfo As _EVENTINFO
    Do
        Call _EVENT(eventInfo) ' Corrected line
        If eventInfo.eventType = 0 Then Exit Do ' No more events
        If eventInfo.eventType = WM_TOUCH Then
            ProcessTouchInput eventInfo.wParam, eventInfo.lParam
        End If
    Loop
 
    _Display
    _Limit 60
Loop Until _KeyDown(27)
 
_AutoDisplay
DisableTouch
 
End
 
Sub EnableTouch
    If (GetSystemMetrics&(SM_DIGITIZERINPUT) And &H40) Then
        WindowHandle = _WindowHandle
        If (RegisterTouchWindow&(WindowHandle, TWF_WANTPALM)) Then
            TouchEnabled = -1
            Print "Touch input enabled."
        Else
            Print "Failed to enable touch input."
        End If
    Else
        Print "Touch input is not supported on this device."
    End If
End Sub
 
Sub DisableTouch
    TouchEnabled = 0
    Print "Touch input disabled."
End Sub
 
Sub ProcessTouchInput (wParam As Long, lParam As Long)
    If (TouchEnabled) Then
        Dim cInputs As Long
        cInputs = wParam And &HFFFF
        Dim tInputs(0 To cInputs - 1) As TOUCHINPUT
        If (GetTouchInputInfo&(lParam, cInputs, tInputs(0), Len(tInputs(0)))) Then
            For i = 0 To cInputs - 1
                Dim input1 As TOUCHINPUT
                input1 = tInputs(i)
                Print "Touch ID: "; input1.dwID
                Print "X: "; input1.x / 100
                Print "Y: "; input1.y / 100
                Print "Flags: "; input1.dwFlags
                If (input1.dwFlags And TOUCHEVENTF_DOWN) Then
                    Print "Touch Down"
                ElseIf (input1.dwFlags And TOUCHEVENTF_UP) Then
                    Print "Touch Up"
                ElseIf (input1.dwFlags And TOUCHEVENTF_MOVE) Then
                    Print "Touch Move"
                End If
                If (input1.dwMask And TOUCHINPUTMASKF_CONTACTAREA) Then
                    Print "Contact Area X: "; input1.cxContact / 100
                    Print "Contact Area Y: "; input1.cyContact / 100
                End If
            Next i
            Dim value1&
            value1& = CloseTouchInputHandle&(lParam)
        Else
            Print "GetTouchInputInfo failed."
        End If
    End If
End Sub

Reasoning for the fix:
The error "Syntax error at the line _EVENT eventInfo" arises because QB64PE requires the Call keyword when calling a subroutine with arguments. In QB64, while sometimes the Call keyword is optional, it is required in this instance.
By changing the line to:
Code snippet
Call _EVENT(eventInfo)
We explicitly use the Call keyword, which tells QB64PE that we are calling a subroutine and passing the eventInfo variable as an argument. This resolves the syntax error and allows the code to compile and run correctly.
 
Gemini can make mistakes, so double-check it
Reply
#4
Then I got another "bright idea" to show it @SpriggsySpriggs' webcam code to "teach" it how to do events and callbacks, and it changed its approach.
That code is below. 

The IDE didn't find any syntax errors in the code, but when the program executed, it threw a runtime error 


    Critical Error
    Sub/Function does not exist in dynamic library
 
with no other information. 

Now I'm truly done for the day... It's been fun!


You are absolutely correct. My apologies. _EVENT is not a directly supported keyword in QB64PE for handling low-level Windows messages like WM_TOUCH. I was mistaken in my previous responses.
The example code you provided demonstrates the correct approach for handling Windows messages and callbacks in QB64PE. It uses PeekMessageA from the Windows API to retrieve messages from the message queue and then dispatches them using TranslateMessageA and DispatchMessageA.
Here's how we can adapt your touch input code to use this message loop approach:
Code snippet

Code: (Select All)
' QB64PE 4.0.0 True Multitouch Input Detection (Windows 11) using PeekMessage
 
Const SM_DIGITIZERINPUT = 218
Const TWF_WANTPALM = 2
Const TOUCHEVENTF_DOWN = 1
Const TOUCHEVENTF_UP = 2
Const TOUCHEVENTF_MOVE = 4
Const TOUCHINPUTMASKF_CONTACTAREA = 4
Const WM_TOUCH = &H240
Const PM_REMOVE = &H0001
 
Type POINTAPI
    x As Long
    y As Long
End Type
 
Type TOUCHINPUT
    x As Long
    y As Long
    hSource As Long
    dwID As Long
    dwFlags As Long
    dwMask As Long
    dwTime As Long
    dwExtraInfo As Long
    cxContact As Long
    cyContact As Long
End Type
 
Type MSG
    hwnd As _Offset
    message As _Unsigned Long
    wParam As _Unsigned _Offset
    lParam As _Offset
    time As _Unsigned Long
    pt As POINTAPI
    lPrivate As _Unsigned Long
End Type
 
Declare Dynamic Library "user32"
    Function GetSystemMetrics& (ByVal nIndex As Long)
    Function RegisterTouchWindow& (ByVal hWnd As Long, ByVal ulFlags As Long)
    Function GetTouchInputInfo& (ByVal hTouchInput As Long, ByVal cInputs As Long, pInputs As TOUCHINPUT, ByVal cbSize As Long)
    Function CloseTouchInputHandle& (ByVal hTouchInput As Long)
    Function PeekMessage& Alias "PeekMessageA" (ByVal lpMsg As _Offset, ByVal hWnd As _Offset, ByVal wMsgFilterMin As _Unsigned Long, ByVal wMsgFilterMax As _Unsigned Long, ByVal wRemoveMsg As _Unsigned Long)
    Sub TranslateMessage Alias "TranslateMessageA" (ByVal lpMsg As _Offset)
    Sub DispatchMessage Alias "DispatchMessageA" (ByVal lpMsg As _Offset)
End Declare
 
Dim Shared TouchEnabled As Integer
Dim Shared WindowHandle As Long
 
Screen _NewImage(640, 480, 256)
 
EnableTouch
 
Dim msg As MSG
 
Do
    If PeekMessage(_Offset(msg), _WindowHandle, 0, 0, PM_REMOVE) Then
        TranslateMessage _Offset(msg)
        DispatchMessage _Offset(msg)
 
        If msg.message = WM_TOUCH Then
            ProcessTouchInput msg.wParam, msg.lParam
        End If
    End If
 
    _Display
    _Limit 60
Loop Until _KeyDown(27)
 
_AutoDisplay
DisableTouch
 
End
 
Sub EnableTouch
    If (GetSystemMetrics&(SM_DIGITIZERINPUT) And &H40) Then
        WindowHandle = _WindowHandle
        If (RegisterTouchWindow&(WindowHandle, TWF_WANTPALM)) Then
            TouchEnabled = -1
            Print "Touch input enabled."
        Else
            Print "Failed to enable touch input."
        End If
    Else
        Print "Touch input is not supported on this device."
    End If
End Sub
 
Sub DisableTouch
    TouchEnabled = 0
    Print "Touch input disabled."
End Sub
 
Sub ProcessTouchInput (wParam As Long, lParam As Long)
    If (TouchEnabled) Then
        Dim cInputs As Long
        cInputs = wParam And &HFFFF
        Dim tInputs(0 To cInputs - 1) As TOUCHINPUT
        If (GetTouchInputInfo&(lParam, cInputs, tInputs(0), Len(tInputs(0)))) Then
            For i = 0 To cInputs - 1
                Dim input1 As TOUCHINPUT
                input1 = tInputs(i)
                Print "Touch ID: "; input1.dwID
                Print "X: "; input1.x / 100
                Print "Y: "; input1.y / 100
                Print "Flags: "; input1.dwFlags
                If (input1.dwFlags And TOUCHEVENTF_DOWN) Then
                    Print "Touch Down"
                ElseIf (input1.dwFlags And TOUCHEVENTF_UP) Then
                    Print "Touch Up"
                ElseIf (input1.dwFlags And TOUCHEVENTF_MOVE) Then
                    Print "Touch Move"
                End If
                If (input1.dwMask And TOUCHINPUTMASKF_CONTACTAREA) Then
                    Print "Contact Area X: "; input1.cxContact / 100
                    Print "Contact Area Y: "; input1.cyContact / 100
                End If
            Next i
            Dim value1&
            value1& = CloseTouchInputHandle&(lParam)
        Else
            Print "GetTouchInputInfo failed."
        End If
    End If
End Sub

Key Changes:
  1. Message Loop using PeekMessageA:
    • The code now uses PeekMessageA to retrieve messages from the message queue.
    • TranslateMessageA and DispatchMessageA are used to process the retrieved messages.
  2. MSG Type:
    • The MSG type is defined to match the Windows MSG structure.
  3. WM_TOUCH Handling:
    • The message loop checks if msg.message = WM_TOUCH. If it is, ProcessTouchInput is called.
This revised code should correctly handle WM_TOUCH messages in QB64PE.
 

Reply




Users browsing this thread: NakedApe, 6 Guest(s)