more keys

git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@267 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
NishiOwO
2025-10-11 11:39:41 +00:00
parent 6979c9dcbd
commit 927f9577ca
7 changed files with 38 additions and 1 deletions

View File

@@ -153,3 +153,7 @@ static void init(void) {
glDisable(GL_DITHER);
glShadeModel(GL_FLAT);
}
static void key(int k) {
(void)k;
}

View File

@@ -73,3 +73,7 @@ static void init(void) {
glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
}
static void key(int k) {
(void)k;
}

View File

@@ -228,3 +228,17 @@ static void init(void) {
glEnable(GL_NORMALIZE);
}
static void key(int k) {
(void)k;
if(k == MwLLKeyLeft) {
view_roty += 5.0;
} else if(k == MwLLKeyRight) {
view_roty -= 5.0;
} else if(k == MwLLKeyUp) {
view_rotx += 5.0;
} else if(k == MwLLKeyDown) {
view_rotx -= 5.0;
}
}

View File

@@ -9,6 +9,7 @@ static void draw(void);
static void idle(void);
static void reshape(int width, int height);
static void init(void);
static void key(int k);
static void tick(MwWidget handle, void* user, void* client) {
(void)handle;
@@ -39,6 +40,10 @@ static void resize(MwWidget handle, void* user, void* client) {
reshape(ww, wh);
}
static void key_pressed(MwWidget handle, void* user, void* client) {
key(*(int*)client);
}
int main() {
MwWidget window;
@@ -55,5 +60,7 @@ int main() {
MwAddUserHandler(window, MwNresizeHandler, resize, NULL);
MwAddUserHandler(window, MwNtickHandler, tick, NULL);
MwAddUserHandler(opengl, MwNkeyHandler, key_pressed, NULL);
MwLoop(window);
}

View File

@@ -39,7 +39,9 @@ typedef void* MwLLPixmap;
enum MwLLKey {
MwLLKeyBackSpace = (1 << 31) | 1,
MwLLKeyLeft,
MwLLKeyRight
MwLLKeyRight,
MwLLKeyUp,
MwLLKeyDown
};
struct _MwLLHandler {

View File

@@ -85,6 +85,8 @@ static LRESULT CALLBACK wndproc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp) {
int n = -1;
if(wp == VK_LEFT) n = MwLLKeyLeft;
if(wp == VK_RIGHT) n = MwLLKeyRight;
if(wp == VK_UP) n = MwLLKeyUp;
if(wp == VK_DOWN) n = MwLLKeyDown;
if(n != -1) MwLLDispatch(u->ll, key, &n);
} else if(msg == WM_GETMINMAXINFO) {
if(u->min_set || u->max_set) {

View File

@@ -231,6 +231,10 @@ void MwLLNextEvent(MwLL handle) {
n = MwLLKeyLeft;
} else if(strcmp(str, "Right") == 0) {
n = MwLLKeyRight;
} else if(strcmp(str, "Up") == 0) {
n = MwLLKeyUp;
} else if(strcmp(str, "Down") == 0) {
n = MwLLKeyDown;
}
if(n != -1) MwLLDispatch(handle, key, &n);