File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -94,6 +94,34 @@ canvas.addEventListener("mouseup", (e) => {
9494 . notifyInput ( 0 , x , y ) ;
9595} ) ;
9696
97+ // Handle Touch Start on HTML Canvas
98+ canvas . addEventListener ( "touchstart" , ( e ) => {
99+ // Notify Zig of Touch Start
100+ e . preventDefault ( ) ;
101+ const touches = e . changedTouches ;
102+ if ( touches . length == 0 ) { return ; }
103+
104+ const x = touches [ 0 ] . pageX ;
105+ const y = touches [ 0 ] . pageY ;
106+ console . log ( { touchstart : { x, y} } ) ;
107+ wasm . instance . exports
108+ . notifyInput ( 1 , x , y ) ;
109+ } ) ;
110+
111+ // Handle Touch End on HTML Canvas
112+ canvas . addEventListener ( "touchend" , ( e ) => {
113+ // Notify Zig of Touch End
114+ e . preventDefault ( ) ;
115+ const touches = e . changedTouches ;
116+ if ( touches . length == 0 ) { return ; }
117+
118+ const x = touches [ 0 ] . pageX ;
119+ const y = touches [ 0 ] . pageY ;
120+ console . log ( { touchend : { x, y} } ) ;
121+ wasm . instance . exports
122+ . notifyInput ( 0 , x , y ) ;
123+ } ) ;
124+
97125// Main Function
98126function main ( ) {
99127 console . log ( "main: start" ) ;
You can’t perform that action at this time.
0 commit comments