using sizeof(int) instead of 4
[bcl.git] / mouse.c
blob91d56e7843c0be21db43c28b6294630abb903ca2
1 #include <string.h>
2 #include <stdlib.h>
3 #include <stdio.h>
4 #include <SDL/SDL.h>
5 #include "mouse.h"
6 mouse *getMouseState(void)
8 mouse *m =kalloc(sizeof(mouse));
9 int k;
10 Uint8 buttons =SDL_GetMouseState(&m -> x, &m ->y);
11 for (k=1;k <=5;k++){
12 *(&mouse +(sizeof(int)*k)) =SDL_BUTTON (k);
14 return m;
17 void setMousePosition(int x, int y)
19 SDL_WarpMouse(x, y);
20 //todo check if propper cast to Uint16 is required
23 int isMouseButtonDown(int b)
25 if (b <1 ||b >5) return 0;
26 return *(&mouse +(sizeof(int)*b)) ==1;