~ubuntu-branches/ubuntu/vivid/emscripten/vivid

« back to all changes in this revision

Viewing changes to tests/sdl_key_test.c

  • Committer: Package Import Robot
  • Author(s): Sylvestre Ledru
  • Date: 2013-05-02 13:11:51 UTC
  • Revision ID: package-import@ubuntu.com-20130502131151-q8dvteqr1ef2x7xz
Tags: upstream-1.4.1~20130504~adb56cb
ImportĀ upstreamĀ versionĀ 1.4.1~20130504~adb56cb

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <stdio.h>
 
2
#include <SDL/SDL.h>
 
3
#include <SDL/SDL_ttf.h>
 
4
#include <emscripten.h>
 
5
 
 
6
int result = 1;
 
7
 
 
8
int keys[1000];
 
9
 
 
10
void one() {
 
11
  SDL_Event event;
 
12
  while (SDL_PollEvent(&event)) {
 
13
    switch(event.type) {
 
14
      case SDL_KEYDOWN:
 
15
        if (!keys[event.key.keysym.sym]) {
 
16
          keys[event.key.keysym.sym] = 1;
 
17
          printf("key down: sym %d scancode %d\n", event.key.keysym.sym, event.key.keysym.scancode);
 
18
        }
 
19
        break;
 
20
      case SDL_KEYUP:
 
21
        if (keys[event.key.keysym.sym]) {
 
22
          keys[event.key.keysym.sym] = 0;
 
23
          printf("key up: sym %d scancode %d\n", event.key.keysym.sym, event.key.keysym.scancode);
 
24
        }
 
25
        break;
 
26
    }
 
27
  }
 
28
}
 
29
 
 
30
int main(int argc, char **argv) {
 
31
  memset(keys, 0, 1000*4);
 
32
 
 
33
  SDL_Init(SDL_INIT_VIDEO);
 
34
  SDL_Surface *screen = SDL_SetVideoMode(600, 450, 32, SDL_HWSURFACE);
 
35
 
 
36
  emscripten_set_main_loop(one, 0, 0);
 
37
 
 
38
  return 0;
 
39
}
 
40