summaryrefslogtreecommitdiff
path: root/apps/plugins/rockboy/events.c
diff options
context:
space:
mode:
authorJens Arnold <amiconn@rockbox.org>2005-03-02 23:49:38 +0000
committerJens Arnold <amiconn@rockbox.org>2005-03-02 23:49:38 +0000
commit384de102469fee4e0792df8fe38586d3206774ed (patch)
treeee5342103e17738acfb8421328ea7c57433f55e6 /apps/plugins/rockboy/events.c
parent48dad47df98bdec632e8930b6a97359dc2c428f5 (diff)
downloadrockbox-384de102469fee4e0792df8fe38586d3206774ed.zip
rockbox-384de102469fee4e0792df8fe38586d3206774ed.tar.gz
rockbox-384de102469fee4e0792df8fe38586d3206774ed.tar.bz2
rockbox-384de102469fee4e0792df8fe38586d3206774ed.tar.xz
Rockboy - gameboy emulation for rockbox, based on gnuboy. Still a bit early, but already playable on iRiver H1xx and the simulators. The archos recorder version is currently rather slow...
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6104 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/rockboy/events.c')
-rw-r--r--apps/plugins/rockboy/events.c61
1 files changed, 61 insertions, 0 deletions
diff --git a/apps/plugins/rockboy/events.c b/apps/plugins/rockboy/events.c
new file mode 100644
index 0000000..5558dd8
--- /dev/null
+++ b/apps/plugins/rockboy/events.c
@@ -0,0 +1,61 @@
+/*
+ * events.c
+ *
+ * Event queue.
+ */
+
+
+#include "rockmacros.h"
+#include "input.h"
+
+
+char keystates[MAX_KEYS];
+int nkeysdown;
+
+#define MAX_EVENTS 32
+
+static event_t eventqueue[MAX_EVENTS];
+static int eventhead, eventpos;
+
+
+int ev_postevent(event_t *ev)
+{
+ int nextevent;
+ nextevent = (eventhead+1)%MAX_EVENTS;
+ if (nextevent == eventpos)
+ return 0;
+ eventqueue[eventhead] = *ev;
+ eventhead = nextevent;
+ return 1;
+}
+
+int ev_getevent(event_t *ev)
+{
+ if (eventpos == eventhead)
+ {
+ ev->type = EV_NONE;
+ return 0;
+ }
+ *ev = eventqueue[eventpos];
+ eventpos = (eventpos+1)%MAX_EVENTS;
+ if (ev->type == EV_PRESS)
+ {
+ keystates[ev->code] = 1;
+ nkeysdown++;
+ }
+ if (ev->type == EV_RELEASE)
+ {
+ keystates[ev->code] = 0;
+ nkeysdown--;
+ if (nkeysdown < 0) nkeysdown = 0;
+ }
+ return 1;
+}
+
+
+
+
+
+
+
+