summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOliver Schinagl <oliver@schinagl.nl>2008-05-15 14:00:20 (GMT)
committerOliver Schinagl <oliver@schinagl.nl>2008-05-15 14:00:20 (GMT)
commitafc966e22a4a2f8f76fc5daa27044606f4c5bb4a (patch)
treea623c3ce9504a443d40b5bb424c8663b15b9ee80
parent93c5592b7acd57946dc8734bf0f507e27af1f827 (diff)
download2iv55-afc966e22a4a2f8f76fc5daa27044606f4c5bb4a.zip
2iv55-afc966e22a4a2f8f76fc5daa27044606f4c5bb4a.tar.gz
2iv55-afc966e22a4a2f8f76fc5daa27044606f4c5bb4a.tar.bz2
Menu now uses message queue to process input events.
-rw-r--r--matchblox/menu/menu.c37
-rw-r--r--matchblox/menu/menu.h21
2 files changed, 46 insertions, 12 deletions
diff --git a/matchblox/menu/menu.c b/matchblox/menu/menu.c
index c92c2b8..8766ef8 100644
--- a/matchblox/menu/menu.c
+++ b/matchblox/menu/menu.c
@@ -7,9 +7,11 @@
#endif
#include <string.h>
-#include <GL/gl.h>
#include <GL/glut.h>
-#include <string.h>
+
+
+#include "message_queue.h"
+#include "message_input.h"
#include "menu.h"
#include "button.h"
@@ -251,6 +253,37 @@ void MenuRender(void)
} // MenuRender
+void MenuRun(void)
+{
+ struct messageq_s *message;
+ struct input_payload_keyboard *payload;
+
+ message = messageq_get(MESSAGE_MENU);
+ if (message) {
+ payload = message->payload;
+ printf("got a message! %c\n", (unsigned char)payload->key);
+ switch (payload->key) {
+ default:
+ case ' ':
+ MenuNext();
+ break;
+ case '0':
+ g_pCurMenu = &g_sMenuOff;
+ break;
+ case '1':
+ g_pCurMenu = &g_sMenuMain;
+ break;
+ case '2':
+ g_pCurMenu = &g_sMenuStart;
+ break;
+ case '3':
+ g_pCurMenu = &g_sMenuOptions;
+ break;
+ }
+ }
+}
+
+
int MenuCollision(struct ButtonStruct *f_sButton, int f_iXPos, int f_iYPos)
{
int l_bCollision;
diff --git a/matchblox/menu/menu.h b/matchblox/menu/menu.h
index b5e1d9f..656d259 100644
--- a/matchblox/menu/menu.h
+++ b/matchblox/menu/menu.h
@@ -1,20 +1,21 @@
-#ifndef _CMENU_H
-#define _CMENU_H
+#ifndef _CMENU_H
+#define _CMENU_H
#ifdef __cplusplus
extern "C" {
#endif
-
-void MenuNext(void);
-void MenuInit(int f_iWinWidth, int f_iWinHeight);
-void MenuRender(void);
-void MenuMouseClick(int button, int state, int x, int y);
+
+void MenuNext(void);
+void MenuInit(int f_iWinWidth, int f_iWinHeight);
+void MenuRender(void);
+void MenuRun(void);
+void MenuMouseClick(int button, int state, int x, int y);
void MenuMouseMove(int x, int y);
-
+
#ifdef __cplusplus
}
#endif
-
-#endif
+
+#endif