From a6539c7cc5f410047dcf59d02f48f55deb8bfe41 Mon Sep 17 00:00:00 2001 From: John Tsiombikas Date: Wed, 27 May 2020 16:22:19 +0300 Subject: [PATCH] addes special key enumerations and translation --- Makefile.wat | 44 ++++++++++++++++++++++---------------------- miniglut.c | 25 ++++++++++++++++++++++++- miniglut.h | 24 ++++++++++++++++++++++++ 3 files changed, 70 insertions(+), 23 deletions(-) diff --git a/Makefile.wat b/Makefile.wat index f9a94cd..78190d4 100644 --- a/Makefile.wat +++ b/Makefile.wat @@ -1,22 +1,22 @@ -obj = test.obj miniglut.obj -bin = test.exe - -CC = wcc386 -LD = wlink -CFLAGS = -d3 -6r -otexan -zq -bt=nt -LDFLAGS = system nt library { opengl32 winmm } - -$(bin): $(obj) - $(LD) name $@ debug all file { $(obj) } $(LDFLAGS) - -.c.obj: .autodepend - $(CC) -fo=$@ $(CFLAGS) $[* - -!ifdef __UNIX__ -clean: .symbolic - rm -f $(obj) $(bin) -!else -clean: .symbolic - del $(obj) - del $(bin) -!endif +obj = test.obj miniglut.obj +bin = test.exe + +CC = wcc386 +LD = wlink +CFLAGS = -d3 -6r -otexan -zq -bt=nt +LDFLAGS = system nt library { opengl32 winmm } + +$(bin): $(obj) + $(LD) name $@ debug all file { $(obj) } $(LDFLAGS) + +.c.obj: .autodepend + $(CC) -fo=$@ $(CFLAGS) $[* + +!ifdef __UNIX__ +clean: .symbolic + rm -f $(obj) $(bin) +!else +clean: .symbolic + del $(obj) + del $(bin) +!endif diff --git a/miniglut.c b/miniglut.c index c9cc1f0..346b1d4 100644 --- a/miniglut.c +++ b/miniglut.c @@ -946,6 +946,15 @@ static void update_modkeys(void); static int translate_vkey(int vkey); static void handle_mbutton(int bn, int st, WPARAM wparam, LPARAM lparam); +#ifdef MINIGLUT_WINMAIN +int WINAPI WinMain(HINSTANCE hinst, HINSTANCE hprev, char *cmdline, int showcmd) +{ + int argc = 1; + char *argv[] = { "miniglut.exe", 0 }; + return main(argc, argv); +} +#endif + void glutMainLoopEvent(void) { MSG msg; @@ -1209,7 +1218,21 @@ static void update_modkeys(void) static int translate_vkey(int vkey) { - return vkey; /* TODO */ + switch(vkey) { + case VK_PRIOR: return GLUT_KEY_PAGE_UP; + case VK_NEXT: return GLUT_KEY_PAGE_DOWN; + case VK_END: return GLUT_KEY_END; + case VK_HOME: return GLUT_KEY_HOME; + case VK_LEFT: return GLUT_KEY_LEFT; + case VK_UP: return GLUT_KEY_UP; + case VK_RIGHT: return GLUT_KEY_RIGHT; + case VK_DOWN: return GLUT_KEY_DOWN; + default: + if(vkey >= VK_F1 && vkey <= VK_F12) { + return vkey - VK_F1 + GLUT_KEY_F1; + } + } + return vkey; } static void handle_mbutton(int bn, int st, WPARAM wparam, LPARAM lparam) diff --git a/miniglut.h b/miniglut.h index a7b8659..7b927dd 100644 --- a/miniglut.h +++ b/miniglut.h @@ -87,6 +87,30 @@ enum { GLUT_ELAPSED_TIME }; +enum { + GLUT_KEY_HOME = 0xff50, + GLUT_KEY_LEFT = 0xff51, + GLUT_KEY_UP, + GLUT_KEY_RIGHT, + GLUT_KEY_DOWN, + GLUT_KEY_PAGE_UP, + GLUT_KEY_PAGE_DOWN, + GLUT_KEY_END = 0xff57, + GLUT_KEY_INSERT = 0xff63, + GLUT_KEY_F1 = 0xffbe, + GLUT_KEY_F2, + GLUT_KEY_F3, + GLUT_KEY_F4, + GLUT_KEY_F5, + GLUT_KEY_F6, + GLUT_KEY_F7, + GLUT_KEY_F8, + GLUT_KEY_F9, + GLUT_KEY_F10, + GLUT_KEY_F11, + GLUT_KEY_F12 +}; + /* returned by glutGetModifiers */ #define GLUT_ACTIVE_SHIFT 1 #define GLUT_ACTIVE_CTRL 4 -- 1.7.10.4