Skip to content

Touch not working correctly #122

Description

@QQQQWAS

When there are more then 2 fingers, HandleButton isn't called sometimes.
my test.c:

#include <rawdraw/os_generic.h>
#include "android_native_app_glue.h"
#include <byteswap.h>
#include <fcntl.h>
#include <stdint.h>
#include <stdio.h>

#include <string.h>

#define CNFG_IMPLEMENTATION
#define CNFG3D

#include <rawdraw/CNFGAndroid.h>
#include <rawdraw/CNFG.h>

void HandleKey(int code, int state){}

struct touch{
	int pos_begin[2];
	int pos[2];
	int down;
};

char console[10000];

typedef struct touch touch;
touch touches[10];
int last_updated;

void HandleButton(int x, int y, int mask, int down){
	touches[mask].pos[0] = x;
	touches[mask].pos[1] = y;
	touches[mask].pos_begin[0] = x;
	touches[mask].pos_begin[1] = y;
	touches[mask].down = down;
	last_updated = mask;
	char out[128];
	sprintf(out, "HandleButton(x: %i, y: %i, mask: %i, bDown: %i)\n", x, y, mask, down);
	strcat(console, out);
}
void HandleMotion(int x, int y, int mask){
	touches[mask].pos[0] = x;
	touches[mask].pos[1] = y;
}

void HandleResume(){}
void HandleSuspend(){}
int HandleDestroy(){return 0;}

int main(int argc, char ** argv){
	CNFGBGColor = 0x002040ff;
	CNFGSetupFullscreen( "Test Bench", 0 );
	while(CNFGHandleInput()){
		CNFGClearFrame();
		CNFGColor( 0xFFFFFFFF );

		for(int i = 0; i < 10; i++){
			char cat[128];
			sprintf(cat, "--%i--\nX: %i\nY: %i\nS: %i\n", last_updated==i ,touches[i].pos[0], touches[i].pos[1], touches[i].down);
			if(touches[i].down){
				CNFGDrawBox(touches[i].pos_begin[0], touches[i].pos_begin[1], touches[i].pos[0], touches[i].pos[1]);
				CNFGPenX = (touches[i].pos_begin[0] + touches[i].pos[0])/2-50;
				CNFGPenY = (touches[i].pos_begin[1] + touches[i].pos[1])/2-60;
				CNFGDrawText(cat, 6);
			}
		}
		CNFGPenX = 0;
		CNFGPenY = 0;

		CNFGDrawText(console, 4);

		CNFGFlushRender();
		CNFGSwapBuffers();
	}
}

video:
https://github.com/user-attachments/assets/2c8089ef-9994-49af-b49e-575f90e99cd2

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions