diff --git a/CNFG.h b/CNFG.h index c706cc8..c8a332c 100644 --- a/CNFG.h +++ b/CNFG.h @@ -544,4 +544,3 @@ extern const unsigned short RawdrawFontCharMap[256]; #endif #endif - diff --git a/CNFGWASMDriver.c b/CNFGWASMDriver.c index 10529df..5bffafe 100644 --- a/CNFGWASMDriver.c +++ b/CNFGWASMDriver.c @@ -58,6 +58,10 @@ void CNFGGetScissors( int * xywh ) CNFGGetScissorsInternal( xywh ); } +void CNFGBlitImage(uint32_t *data, int x, int y, int w, int h) { + CNFGBlitImageInternal(data, x, y, w, h); +} + #else //Rasterizer - if you want to do this, you will need to enable blitting in the javascript. @@ -90,7 +94,7 @@ int CNFGHandleInput() { //Do nothing. //Input is handled on swap frame. - return 0; + return 1; } #endif diff --git a/rawdraw_sf.h b/rawdraw_sf.h index 4379937..1bfa0ad 100644 --- a/rawdraw_sf.h +++ b/rawdraw_sf.h @@ -1,5 +1,5 @@ //This file was automatically generated by Makefile at https://github.com/cntools/rawdraw -//Generated from files git hash ee3033ea1ad85ef409139067b1f36e35cef8fd4a on Tue Apr 15 12:54:46 AM PDT 2025 (This is not the git hash of this file) +//Generated from files git hash b1b945260514c1a3b2366b017b1de502b4d78e1c on Mon Jul 21 08:38:02 PM EDT 2025 (This is not the git hash of this file) // Copyright 2010-2021 <>< CNLohr, et. al. (Several other authors, many but not all mentioned) // Licensed under the MIT/x11 or NewBSD License you choose. // @@ -3381,7 +3381,7 @@ int CNFGHandleInput() { //Do nothing. //Input is handled on swap frame. - return 0; + return 1; } #endif @@ -5131,6 +5131,11 @@ void CNFGSetupFullscreen( const char * WindowName, int screen_number ) int debuga, debugb, debugc; +#ifndef MAX_NUM_TOUCHES +#define MAX_NUM_TOUCHES 10 +#endif +bool touch_is_down[MAX_NUM_TOUCHES]; + int32_t handle_input(struct android_app* app, AInputEvent* event) { #ifdef ANDROID @@ -5138,37 +5143,42 @@ int32_t handle_input(struct android_app* app, AInputEvent* event) if (AInputEvent_getType(event) == AINPUT_EVENT_TYPE_MOTION) { - int action = AMotionEvent_getAction( event ); - int whichsource = action >> 8; - action &= AMOTION_EVENT_ACTION_MASK; - size_t pointerCount = AMotionEvent_getPointerCount(event); + int pointer_count = AMotionEvent_getPointerCount(event); + int32_t action = AMotionEvent_getAction(event); + int flags = action & AMOTION_EVENT_ACTION_MASK; + int id = (action & AMOTION_EVENT_ACTION_POINTER_INDEX_MASK) >> AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT; + int pid = AMotionEvent_getPointerId(event, id); - for (size_t i = 0; i < pointerCount; ++i) - { - int x, y, index; - x = AMotionEvent_getX(event, i); - y = AMotionEvent_getY(event, i); - index = AMotionEvent_getPointerId( event, i ); + if(pid > 9 || pointer_count > MAX_NUM_TOUCHES){ + printf("Pointer id larger than MAX_NUM_TOUCHES\n"); + return 0; + } - if( action == AMOTION_EVENT_ACTION_POINTER_DOWN || action == AMOTION_EVENT_ACTION_DOWN ) - { - int id = index; - if( action == AMOTION_EVENT_ACTION_POINTER_DOWN && id != whichsource ) continue; - HandleButton( x, y, id, 1 ); - ANativeActivity_showSoftInput( gapp->activity, ANATIVEACTIVITY_SHOW_SOFT_INPUT_FORCED ); + switch(flags){ + case AMOTION_EVENT_ACTION_POINTER_UP: + case AMOTION_EVENT_ACTION_UP:{ + touch_is_down[pid] = 0; + HandleButton(AMotionEvent_getX(event, id), AMotionEvent_getY(event, id), pid, 0); + break; } - else if( action == AMOTION_EVENT_ACTION_POINTER_UP || action == AMOTION_EVENT_ACTION_UP || action == AMOTION_EVENT_ACTION_CANCEL ) - { - int id = index; - if( action == AMOTION_EVENT_ACTION_POINTER_UP && id != whichsource ) continue; - HandleButton( x, y, id, 0 ); + case AMOTION_EVENT_ACTION_POINTER_DOWN: + case AMOTION_EVENT_ACTION_DOWN:{ + touch_is_down[pid] = 1; + HandleButton(AMotionEvent_getX(event, id), AMotionEvent_getY(event, id), pid, 1); + break; } - else if( action == AMOTION_EVENT_ACTION_MOVE ) - { - HandleMotion( x, y, index ); + case AMOTION_EVENT_ACTION_MOVE:{ + int off = 0; //number of touches preceeding i that are not down + for(int i = 0; i-off < pointer_count && pid+i main.disassembly.txt clean: - rm -rf main.wasm opt.js index.html blob_b64 + rm -rf main.wasm opt.js index.html blob_b64 mid.js subst diff --git a/wasm/rawdraw.c b/wasm/rawdraw.c index dcf04d2..689d1c3 100644 --- a/wasm/rawdraw.c +++ b/wasm/rawdraw.c @@ -8,8 +8,6 @@ #include "CNFG.h" -double OGGetAbsoluteTime(); -void OGUSleep( int us ); void prints( const char * sdebug ); void print( double idebug ); double sin( double x ); @@ -39,8 +37,9 @@ void __attribute__((export_name("HandleMotion"))) HandleMotion( int x, int y, in lastmousey = y; } -void HandleDestroy() +int HandleDestroy() { + return 0; //printf( "Destroying\n" ); } @@ -272,5 +271,3 @@ void DrawHeightmap() CNFGTackSegment( pta[0], pta[1], ptc[0], ptc[1] ); } } - - diff --git a/wasm/subst.c b/wasm/subst.c index 059cffc..05c1ce3 100644 --- a/wasm/subst.c +++ b/wasm/subst.c @@ -77,7 +77,7 @@ void print_help() char *outfile_name = NULL; char *outfile = NULL; size_t outfile_size; -size_t outfile_current_size; +size_t outfile_current_size = 0; int outfile_set = 0; void putchar_in_output(char c) { @@ -200,7 +200,7 @@ int main(int argc, char *argv[]) printf("Failed to open %s for output!\n", outfile_name); exit(1); } - fwrite(outfile, outfile_current_size - 3, 1, file); + fwrite(outfile, outfile_current_size, 1, file); fclose(file); } return 0; diff --git a/wasm/template.js b/wasm/template.js index 2c4a1fb..78e44ea 100644 --- a/wasm/template.js +++ b/wasm/template.js @@ -150,7 +150,9 @@ let imports = { SystemStart( title, w, h ); fullscreen = false; }, - CNFGSetupFullscreen : (title,w,h ) => { + CNFGSetupFullscreen : (title,screenno) => { + let w = document.documentElement.clientWidth; + let h = document.documentElement.clientHeight; SystemStart( title, w, h ); canvas.style = "position:absolute; top:0; left:0;" fullscreen = true; @@ -311,4 +313,3 @@ if( RAWDRAW_NEED_BLITTER ) //Code here would continue executing, but this code is executed *before* main. } -