Skip to content
Snippets Groups Projects
Commit bf879f1c authored by Deucе's avatar Deucе :ok_hand_tone4:
Browse files

Add simple test for CIO_KEY_QUIT behaviour.

Basically, this allows figuring out if you can intercept and block
closing the window.
parent 297838a1
No related branches found
No related tags found
No related merge requests found
...@@ -68,3 +68,7 @@ $(MTOBJODIR)$(DIRSEP)ciolib_res${OFILE}: ciolib.rc syncicon64.ico ciolib.manifes ...@@ -68,3 +68,7 @@ $(MTOBJODIR)$(DIRSEP)ciolib_res${OFILE}: ciolib.rc syncicon64.ico ciolib.manifes
@echo Creating $< ... @echo Creating $< ...
$(QUIET)${WINDRES} $(WINDRESFLAGS) -O coff -i ciolib.rc -o $@ $(QUIET)${WINDRES} $(WINDRESFLAGS) -O coff -i ciolib.rc -o $@
endif endif
quittest: quittest.c $(CIOLIB-MT_BUILD)
${QUIET}$(CC) $(CFLAGS) $(MT_CFLAGS) $(LDFLAGS) $(MT_LDFLAGS) $(XPDEV-MT_LDFLAGS) quittest.c -o $@ $(CIOLIB-MT_LIBS) $(XPDEV-MT_LIBS)
#include "ciolib.h"
#include "genwrap.h"
int main(int argc, char **argv)
{
int mode = CIOLIB_MODE_AUTO;
for (int i = 1; i < argc; i++) {
switch(argv[i][0]) {
case 'G':
mode = CIOLIB_MODE_GDI_FULLSCREEN;
break;
case 'g':
mode = CIOLIB_MODE_GDI;
break;
case 'S':
mode = CIOLIB_MODE_SDL_FULLSCREEN;
break;
case 's':
mode = CIOLIB_MODE_SDL;
break;
case 'X':
mode = CIOLIB_MODE_X_FULLSCREEN;
break;
case 'x':
mode = CIOLIB_MODE_X;
break;
default:
puts("GgSsXx");
exit(0);
}
}
initciolib(mode);
for (;;) {
if(!kbhit())
SLEEP(100);
int k = getch();
if (k == 0 || k == 0xe0)
k = k | (getch() << 8);
switch(k) {
case 'q':
exit(1);
case CIO_KEY_QUIT:
cputs("Got quit\n");
break;
default:
cprintf("Key: %d (q to quit)\n", k);
break;
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment