Permalink
Browse files

collapse mouse events

  • Loading branch information...
1 parent 79ae4fb commit 9fdb0bd574448f2211128282e54317f395a1c867 @creationix committed Jul 24, 2011
Showing with 13 additions and 1 deletion.
  1. +1 −0 .npmignore
  2. +1 −1 package.json
  3. +11 −0 sdl.js
View
@@ -1,2 +1,3 @@
build
examples
+examples/*
View
@@ -2,7 +2,7 @@
"author": "Tim Caswell <tim@creationix.com> (http://creationix.com/)",
"name": "sdl",
"description": "SDL bindings for node",
- "version": "0.1.2",
+ "version": "0.1.3",
"repository": {
"type": "git",
"url": "git://github.com/creationix/node-sdl.git"
View
11 sdl.js
@@ -10,10 +10,21 @@ Object.defineProperty(SDL, 'events', {
function getEvent(err) {
if (err) events.emit('error', err);
var data;
+ var mousemotion;
while (data = SDL.pollEvent()) {
+ if (data.type === "MOUSEMOTION") {
+ // Collapse motion events to just the last position
+ // TODO: collapse other high frequency events
+ mousemotion = data;
+ continue;
+ }
events.emit(data.type, data);
events.emit("event", data);
}
+ if (mousemotion) {
+ events.emit(mousemotion.type, mousemotion);
+ events.emit("event", mousemotion);
+ }
SDL.waitEvent(getEvent);
}
SDL.waitEvent(getEvent);

0 comments on commit 9fdb0bd

Please sign in to comment.