Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
Touch/Mouse events for Desktop — Gideros Forum

Touch/Mouse events for Desktop

kussakovkussakov Member
edited August 2015 in General questions
Hi Guys,

Need some advice/help...

I am trying to port one of our apps for Windows Desktop.
What are the best project settings, so that the app can be played with the touch screen and the mouse without an issue?

I only "Listen" to touch events.

I have the following problem:

- If I set "Mouse events generate touch events" I get a weird double touch event when I use the touchscreen and tap. The app can be played with the mouse with no issues.

- If I DON'T set "Mouse events generate touch events" - the game plays just fine with touchscreen(no double event), but the mouse stops working.


Any suggestions?

Thanks

Vlad

Comments

  • http://giderosmobile.com/forum/discussion/5870/new-desktop-api-test#Item_30

    Can you download gideros-2015.07.15 - Custom[6].zip and see the event generated.
    At that, you can detect event.touch.type that would shown whether it was from generated-mouse or real touch. With this, you can ignore one of the double event.

    Can this fix your problem?

    ( i will include this in the future release, but not at the next release)
  • interesting, but it should not do double events at all.
    On which platform do you experience it?
  • Windows 8.1. Gideros 2015.08.

    It does it only on tap. Looks like Windows is trying to be smart and help apps that are not written to work with touches by generating an extra mouse click event or something ...
    I will do some tests as per @tkhnoman's instructions and post the results here.
  • kussakovkussakov Member
    edited September 2015
    While I am doing the research: You can open one of the examples that come with Gideros and see the effect yourself.

    E.g. Open the "Bloom" example(by the way: kudos guys for adding this to Gideros - very nice).
    Open the example on a Windows 8.1 PC with a touch screen. Play it in the player.
    In the "bloom" example you can toggle the bloom effect (on/off) by clicking/tapping the app.
    For me:
    - it works with the mouse
    - Does not work with the touch(tap) since it gets two quick events.
    Does it work for you with the tap?

  • From what i know, for some reason, windows register touch input as both mouse and touch, so this would indeed create that problem.
    Not sure whether it is device/driver related though.
  • john26john26 Maintainer
    It makes sense that Windows should generate a mouse event in this way to deal with older apps that were designed purely for mouse input. But is there some way to switch this off in windows? It's almost like a compatibility function.

    Or maybe our Gideros app needs to announce itself as "touch aware" to the OS so it will not receive these extra events. We will investigate...
  • kussakovkussakov Member
    edited September 2015
    It does make sense for desktop apps.

    I did some more tests.
    I compiled the app with Visual studio for WinRT.
    The app opens in a full screen as a tablet/phone app. In this case windows does NOT do that - give extra events, I guess because it knows that the app must be touch aware to run in this mode.
    In this case the app can be played with a mouse and touch just fine :-)

    I don't see a good solution for desktop apps and desktop player in the Gideros code itself.
    Unless there is a way to programmatically tell Windows that the desktop app is touch aware and it somehow stops trying to be smart (as @john26 suggests)

    However I can see a simple workaround if @tkhnoman adds the extra touch value (touch.type) in some next release:
    In the app code - we add a hidden touch receiving sprite on top of everything, which uses the touch.type to filter the extra mouse events. Simple logic - e.g: if the new touch is type "mouse" and there was a "touch" type event that happened prior to it, say less than 2 sec back - stop propagation of the mouse event.
    Basically it will stop the extra events from propagating to your game below. This way you don't have to rewrite all your touch code...

  • @john In windows (win32, I'm not sure about RT) you have to reply to every gesture message or windows will stop sending them to your app. You also have to register your window as touch aware if you want to receive more advanced multi-touch messages.

    Without touch registration you get the WM_GESTURE message, this is the one that has to be replied to in order to keep getting messages. You should check to see if 'GetGestureInfo' is in user32.dll and if it is then call it using lParam. You then look at gi\dwID to see what stage the gesture is at. Return false at the end of the message to indicate you know what is going on. If you get a WM_GESTURENOTIFY then check from 'SetGestureConfig' in user32.dll and if it's there call it with the address and length of a gesture config table.

    To register a touch window, just check to see if 'RegisterTouchWindow' is present in user32.dll, if it is then call it with the window handle. That window will then get multi-touch messages.

    For multi-touch, the messages to look for are WM_TOUCH and WM_TOUCHHITTESTING.

    In win32 also look for WM_SETTINGCHANGE as that lets you know if a modern laptop has gone from Desktop to Slate mode (there is a string pointed to by lParam if not nil).

    Desktop mode is when a laptop look like a laptop, slate mode is when a laptop looks like a tablet. On some laptops this means the screen has been flipped over the keyboard, on others this means the screen has been push far back and pulled underneath the keyboard, on some it means the screen has been pulled off the keyboard!

    From what I've been led to believe, if you get the text "desktop" then it's a desktop and anything else means it's a slate.

    Here are some equates from none gideros project I have...
    #SM_DIGITIZER=94
    #NID_READY=$80
     
    ; touch_capabilities=GetSystemMatrics(SM_DIGITIZER)
    ; 
    #WM_TABLET_QUERYSYSTEMGESTURESTATUS=716
     
    ; // Value used in WebViewWndProc For Gestures
    #WM_GESTURE =$0119
    #WM_GESTURENOTIFY =$011A
     
    #WM_TOUCH=$0240
    #WM_TOUCHHITTESTING=$024D
     
    #TOUCH_HIT_TESTING_PROXIMITY_CLOSEST = $0000
    #TOUCH_HIT_TESTING_PROXIMITY_FARTHEST = $0FFF
    #TOUCH_HIT_TESTING_DEFAULT = $0
    #TOUCH_HIT_TESTING_CLIENT = $1
    #TOUCH_HIT_TESTING_NONE = $2
    #TOUCH_FLAGS_NONE=0
    #TOUCH_MASK_NONE=0
    #TOUCH_MASK_CONTACTAREA=$1
    #TOUCH_MASK_ORIENTATION=$2
    #TOUCH_MASK_PRESSURE=$4
     
    #WM_POINTERDEVICECHANGE=$0238
    #WM_POINTERDEVICEINRANGE=$0239
    #WM_POINTERDEVICEOUTOFRANGE=$023a
    #WM_NCPOINTERUPDATE=$0241
    #WM_NCPOINTERDOWN=$0242
    #WM_NCPOINTERUP=$0243
    #WM_POINTERUPDATE=$0245
    #WM_POINTERDOWN=$0246
    #WM_POINTERUP=$0247
    #WM_POINTERENTER=$0249
    #WM_POINTERLEAVE=$024a
    #WM_POINTERACTIVATE=$024b
    #WM_POINTERCAPTURECHANGED=$024c
     
    #WM_POINTERWHEEL=$024e
    #WM_POINTERHWHEEL=$024f
     
    ; wParam values for wm_pointerdevicechange
    #PDC_ARRIVAL				=$001
    #PDC_REMOVAL				=$002
    #PDC_ORIENTATION_0	=$004
    #PDC_ORIENTATION_90	=$008
    #PDC_ORIENTATION_180 =$010
    #PDC_ORIENTATION_270 =$020
    #PDC_MODE_DEFAULT		=$040
    #PDC_CENTERED				=$080
    #PDC_MAPPING_CHANGED =$100
    #PDC_RESOLUTION			=$200
    #PDC_ORIGIN					=$400
    #PDC_ASPECTRATIOPRESERVED =$800
    #PDC_MODE_ASPECTrATIOPRESERVED =$900
    ; 
    #POINTER_FLAG_NEW=$1
    #POINTER_FLAG_INRANGE=$2
    #POINTER_FLAG_INCONTACT=$4
    #POINTER_FLAG_FIRSTBUTTON=$10
    #POINTER_FLAG_SECONDBUTTON=$20
    #POINTER_FLAG_THIRDBUTTON=$40
    #POINTER_FLAG_FOURTHBUTTON=$80
    #POINTER_FLAG_FIFTHBUTTON=$100
    #POINTER_FLAG_PRIMARY=$2000
    #POINTER_FLAG_CONFIDENCE=$4000
    #POINTER_FLAG_CANCELED=$8000
    #POINTER_FLAG_DOWN=$10000
    #POINTER_FLAG_UPDATE=$20000
    #POINTER_FLAG_UP=$40000
    #POINTER_FLAG_WHEEL=$80000
    #POINTER_FLAG_HwHEEL=$100000
    #POINTER_FLAG_CAPTURECHANGED=$200000
     
    #POINTER_MOD_SHIFT=$0004
    #POINTER_MOD_CTRL=$0008
     
    #PEN_MASK_NONE=$0
    #PEN_MASK_PRESSURE=$1
    #PEN_MASK_ROTATION=$2
    #PEN_MASK_TILT_X=$4
    #PEN_MASK_TILT_Y=$8
     
    #PEN_FLAG_NONE=0
    #PEN_FLAG_BARREL=1
    #PEN_FLAG_INVERTED=2
    #PEN_FLAG_ERASER=4
     
     
    #PT_POINTER=$1
    #PT_TOUCH=$2
    #PT_PEN=$3
    #PT_MOUSE=$4
     
    Enumeration
    	#POINTER_CHANGE_NONE
    	#POINTER_CHANGE_FIRSTBUTTON_DOWN
    	#POINTER_CHANGE_FIRSTBUTTON_UP
    	#POINTER_CHANGE_SECONDBUTTON_DOWN
    	#POINTER_CHANGE_SECONDBUTTON_UP	
    	#POINTER_CHANGE_THIRDBUTTON_DOWN
    	#POINTER_CHANGE_THIRDBUTTON_UP	
    	#POINTER_CHANGE_FOURTHBUTTON_DOWN
    	#POINTER_CHANGE_FOURTHBUTTON_UP	
    	#POINTER_CHANGE_FIFTHBUTTON_DOWN
    	#POINTER_CHANGE_FIFTHBUTTON_UP	
    EndEnumeration
     
    ; // Gesture Information Flags
    #GF_BEGIN=$01
    #GF_INERTIA=$02
    #GF_END=$04
    ; 
    ; // Gesture IDs
    Enumeration 1
    	#GID_BEGIN ; 1
    	#GID_END ;2
    	#GID_ZOOM ;3
    	#GID_PAN ;4
    	#GID_ROTATE ;5
    	#GID_TWOFINGERTAP ;6
    	#GID_PRESSANDTAP ;7
    EndEnumeration
    #GID_ROLLOVER=#GID_PRESSANDTAP
    ; 
    #GC_ALLGESTURES=$01
     
    ; // Zoom Gesture Confiration Flags
    #GC_ZOOM=$01
    ; 
    ; // Pan Gesture Configuration Flags
    #GC_PAN=$01
    #GC_PAN_WITH_SINGLE_FINGER_VERTICALLY=$02
    #GC_PAN_WITH_SINGLE_FINGER_HORIZONTALLY=$04
    #GC_PAN_WITH_GUTTER=$08
    #GC_PAN_WITH_INERTIA=$10
    ; 
    ; // Rotate Gesture Configuration Flags
    #GC_ROTATE=$01
    ; 
    ; // Two finger tap configuration flags
    #GC_TWOFINGERTAP=$01
    ; 
    ; // Press And tap Configuration Flags
    #GC_PRESSANDTAP=$01
    #GC_ROLLOVER=#GC_PRESSANDTAP
     
     
    #PA_ACTIVATE=#MA_ACTIVATE
    #PA_NOACTIVATE=#MA_NOACTIVATE
     
    	Structure GESTUREINFO
    		cbSize.l
    		dwFlags.l
    		dwID.l
    		PB_Align(0,4)
    		hwndTarget.i
    		ptsLocation.POINTS
    		dwInstanceID.l
    		dwSequenceID.l
    		PB_Align(4,4,1)
    		ullArguments.q
    		cbExtraArgs.l
    		PB_Align(4,4,2)
    	EndStructure
     
    ;
    ; // GESTURECONFIG struct defintion
    	Structure   GESTURECONFIG
    		dwID.l               ; gesture ID
    		dwWant.l             ; settings related to gesture ID that are to be turned on
    		dwBlock.l            ; settings related to gesture ID that are to be turned off
    	EndStructure
     
    ;  * 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.
    	Structure GESTURENOTIFY ; GESTURENOTIFYSTRUCT
    		cbSize.l             ; size, in bytes, of this structure
    		dwFlags.l            ; unused
    		hwndTarget.i         ; handle to window targeted by the gesture
    		ptsLocation.points   ; starting location
    		dwInstanceID.l       ; internally used
    	EndStructure
     
    	Structure TOUCH_HIT_TESTING_PROXIMITY_EVALUATION
    		score.w
    		adjustedPoint.POINT
    	EndStructure
     
    	Structure INPUT_TRANSFORM
    		_11.f
    		_12.f
    		_13.f
    		_14.f
    		_21.f
    		_22.f
    		_23.f
    		_24.f
    		_31.f
    		_32.f
    		_33.f
    		_34.f
    		_41.f
    		_42.f
    		_43.f
    		_44.f
    	EndStructure
     
    	Structure POINTER_INFO
    		pointerType.l
    		pointerId.l
    		frameId.l
    		pointerFlags.l
    		sourceDevice.i
    		hwndTarget.i
    		ptPixelLocation.POINT
    		ptHimetricLocation.POINT
    		ptPixelLocationRaw.POINT
    		ptHimetricLocationRaw.POINT
    		dwTime.l
    		historyCount.l
    		inputData.l
    		dwKeyStates.l
    		PerformanceCount.q
    		ButtonChangeType.l
    	EndStructure
     
    	Structure POINTER_PEN_INFO
    		pointerInfo.l
    		penFlags.l
    		penMask.l
    		pressure.l
    		rotation.l
    		tiltX.l
    		tiltY.l
    	EndStructure
     
    	Structure POINTER_TOUCH_INFO
    		pointerInfo.l
    		touchFlags.l
    		touchMask.l
    		rcContact.RECT
    		rcContactRaw.RECT
    		orientation.l
    		pressure.l
    	EndStructure
     
    	Structure TOUCH_HIT_TESTING_INPUT
    		pointerId.l
    		point.POINT
    		boundingBox.RECT
    		nonOccludedBoundingBox.RECT
    		orientation.l
    	EndStructure
     
    	Structure TouchPredictionParameters
    		cbSize.l
    		dwLatency.l
    		dwSampleTime.l
    		vUseHWTimeStamp.l
    	EndStructure
    Coder, video game industry veteran (since the '80s, ❤'s assembler), arrested - never convicted hacker (in the '90s), dad of five, he/him (if that even matters!).
    https://deluxepixel.com
Sign In or Register to comment.