tests for inputs

This commit is contained in:
Zy 2024-09-25 01:06:17 +02:00
parent 89fcea15b0
commit e9e4c3e930
2 changed files with 37 additions and 123 deletions

View file

@ -56,7 +56,7 @@ RSF := $(TOPDIR)/$(RESOURCES)/template.rsf
# options for code generation # options for code generation
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft
COMMON := -Wall -O2 -mword-relocations -fomit-frame-pointer -ffunction-sections $(ARCH) $(INCLUDE) -D__3DS__ COMMON := -Wall -Wextra -O2 -mword-relocations -fomit-frame-pointer -ffunction-sections $(ARCH) $(INCLUDE) -D__3DS__
CFLAGS := $(COMMON) -std=gnu99 CFLAGS := $(COMMON) -std=gnu99
CXXFLAGS := $(COMMON) -fno-rtti -fno-exceptions -std=gnu++11 CXXFLAGS := $(COMMON) -fno-rtti -fno-exceptions -std=gnu++11
ASFLAGS := $(ARCH) ASFLAGS := $(ARCH)

View file

@ -1,127 +1,41 @@
#include <3ds.h> #include <3ds.h>
#include <stdio.h> #include <iostream>
int main(int argc, char **argv) { using namespace std;
gfxInitDefault();
// draw top screen static void locateBits(u32 bits) {
consoleInit(GFX_TOP, NULL); bool first = true;
printf("hi lol"); for (int i = 0; i < 32; i++) {
gspWaitForVBlank(); if ((bits >> i) & 1) {
gfxFlushBuffers(); if (!first)
gfxSwapBuffers(); cout << ",";
first = false;
consoleInit(GFX_BOTTOM, NULL); cout << i;
printf("\r \r"); }
// Start
printf("Press Start for test 1.\n");
while(aptMainLoop()) {
gspWaitForVBlank();
hidScanInput();
if(hidKeysDown() & KEY_START)
break;
gfxFlushBuffers();
gfxSwapBuffers();
} }
cout << endl;
// Test 1 }
printf("TEST 1: without VBlank\n");
printf("Press Start for test 2.\n"); static void showAll(void) {
consoleClear();
while(aptMainLoop()) {
hidScanInput(); touchPosition touch;
circlePosition circle;
if(hidKeysDown() & KEY_START) hidScanInput();
break; hidTouchRead(&touch);
hidCircleRead(&circle);
gfxFlushBuffers(); cout << "=========================" << endl;
gfxSwapBuffers(); cout << "KEYS: "; locateBits(hidKeysHeld()); cout << endl;
} cout << "TOUCH SCREEN: " << touch.px << "," << touch.py << endl;
cout << "CIRCLE PAD: " << circle.dx << "," << circle.dy << endl;
// Test 2 }
printf("TEST 2: without scan input\n");
printf("Press Start for test 3.\n"); int main(void) {
gfxInitDefault();
while(aptMainLoop()) { consoleInit(GFX_TOP, NULL);
gspWaitForVBlank(); while (aptMainLoop()) {
gspWaitForVBlank();
if(hidKeysDown() & KEY_START) showAll();
break; }
gfxExit();
gfxFlushBuffers();
gfxSwapBuffers();
}
// Test 3
printf("TEST 3: without flush\n");
printf("Press Start for test 4.\n");
while(aptMainLoop()) {
gspWaitForVBlank();
hidScanInput();
if(hidKeysDown() & KEY_START)
break;
gfxSwapBuffers();
}
// Test 4
printf("TEST 4: without swap\n");
printf("Press Start for test 5.\n");
while(aptMainLoop()) {
gspWaitForVBlank();
hidScanInput();
if(hidKeysDown() & KEY_START)
break;
gfxFlushBuffers();
}
// Test 5
printf("TEST 5: without anything\n");
printf("Press A to test something.\n");
printf("Press Start for test 6.\n");
while(aptMainLoop()) {
hidScanInput();
if(hidKeysDown() & KEY_A)
printf("\e[32msomething :)\e[0m\n");
if(hidKeysDown() & KEY_START)
break;
}
// Test 6
printf("TEST 6: literally without anything\n");
printf("Press Start to end.\n");
while(true) {
hidScanInput();
if(hidKeysDown() & KEY_START)
break;
gfxFlushBuffers();
}
// End
printf("Press Start to exit.\n");
while(aptMainLoop()) {
gspWaitForVBlank();
hidScanInput();
if(hidKeysDown() & KEY_START)
break;
gfxFlushBuffers();
gfxSwapBuffers();
}
gfxExit();
return 0;
} }