Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion CNFG.h
Original file line number Diff line number Diff line change
Expand Up @@ -544,4 +544,3 @@ extern const unsigned short RawdrawFontCharMap[256];
#endif

#endif

6 changes: 5 additions & 1 deletion CNFGWASMDriver.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -90,7 +94,7 @@ int CNFGHandleInput()
{
//Do nothing.
//Input is handled on swap frame.
return 0;
return 1;
}

#endif
65 changes: 37 additions & 28 deletions rawdraw_sf.h
Original file line number Diff line number Diff line change
@@ -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.
//
Expand Down Expand Up @@ -3381,7 +3381,7 @@ int CNFGHandleInput()
{
//Do nothing.
//Input is handled on swap frame.
return 0;
return 1;
}

#endif
Expand Down Expand Up @@ -5131,44 +5131,54 @@ 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
//Potentially do other things here.

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<MAX_NUM_TOUCHES; i++){
if(touch_is_down[pid+i] == 0){
off++;
continue;
}
HandleMotion(AMotionEvent_getX(event, i-off), AMotionEvent_getY(event, i-off), pid+i);
}
break;
}
}
return 1;
}
else if (AInputEvent_getType(event) == AINPUT_EVENT_TYPE_KEY)
{
Expand Down Expand Up @@ -8174,4 +8184,3 @@ float tdPerlin2D( float x, float y )

#endif


8 changes: 7 additions & 1 deletion wasm/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
index.html
node_modules
node_modules

subst
blob_b64
main.wasm
mid.js
opt.js
2 changes: 1 addition & 1 deletion wasm/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ main.wasm: rawdraw.c
#wasm-objdump -d main.wasm > 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
7 changes: 2 additions & 5 deletions wasm/rawdraw.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down Expand Up @@ -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" );
}

Expand Down Expand Up @@ -272,5 +271,3 @@ void DrawHeightmap()
CNFGTackSegment( pta[0], pta[1], ptc[0], ptc[1] );
}
}


4 changes: 2 additions & 2 deletions wasm/subst.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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;
Expand Down
5 changes: 3 additions & 2 deletions wasm/template.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -311,4 +313,3 @@ if( RAWDRAW_NEED_BLITTER )

//Code here would continue executing, but this code is executed *before* main.
}