2020-04-10 18:31:51 +03:00
|
|
|
#include <SDL2/SDL.h>
|
2017-06-26 12:15:03 +03:00
|
|
|
|
2018-03-20 18:18:44 +03:00
|
|
|
// Event
|
2018-03-20 18:05:52 +03:00
|
|
|
SDL_Event SDL_Event_init() {
|
2017-06-26 12:15:03 +03:00
|
|
|
SDL_Event e;
|
2019-06-14 14:13:22 +03:00
|
|
|
memset(&e, 0, sizeof(e));
|
2017-06-26 12:15:03 +03:00
|
|
|
return e;
|
|
|
|
}
|
|
|
|
|
2019-10-30 13:07:32 +03:00
|
|
|
int SDL_Event_type(SDL_Event *e) {
|
|
|
|
return e->type;
|
|
|
|
}
|
2017-06-26 12:15:03 +03:00
|
|
|
|
2019-10-30 13:07:32 +03:00
|
|
|
SDL_Keycode SDL_Event_keycode(SDL_Event *e) {
|
|
|
|
return e->key.keysym.sym;
|
|
|
|
}
|
2017-06-26 12:15:03 +03:00
|
|
|
|
2019-10-30 13:07:32 +03:00
|
|
|
bool SDL_Event__EQ_(SDL_EventType a, SDL_EventType b) {
|
|
|
|
return a == b;
|
|
|
|
}
|
2018-03-20 18:18:44 +03:00
|
|
|
|
2019-10-30 13:07:32 +03:00
|
|
|
SDL_Event SDL_Event_copy(SDL_Event *e) {
|
|
|
|
return *e;
|
|
|
|
}
|
2018-03-24 13:17:56 +03:00
|
|
|
|
2018-03-20 18:18:44 +03:00
|
|
|
// Keycode
|
2017-06-26 12:15:03 +03:00
|
|
|
|
2019-10-30 13:07:32 +03:00
|
|
|
SDL_Keycode SDL_Keycode_copy(SDL_Keycode *a) {
|
|
|
|
return *a;
|
|
|
|
}
|
2017-12-04 21:14:38 +03:00
|
|
|
|
2018-03-19 15:01:14 +03:00
|
|
|
String SDL_Keycode_str(SDL_Keycode a) {
|
2017-12-04 21:14:38 +03:00
|
|
|
char *buffer = CARP_MALLOC(32);
|
|
|
|
snprintf(buffer, 32, "%d", a);
|
|
|
|
return buffer;
|
|
|
|
}
|
|
|
|
|
2018-03-20 18:18:44 +03:00
|
|
|
// Helpers
|
2018-03-20 14:49:46 +03:00
|
|
|
SDL_Rect SDL_rect(int x, int y, int w, int h) {
|
2017-06-26 12:15:03 +03:00
|
|
|
SDL_Rect r;
|
|
|
|
r.x = x;
|
|
|
|
r.y = y;
|
|
|
|
r.w = w;
|
|
|
|
r.h = h;
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2018-03-20 14:49:46 +03:00
|
|
|
SDL_Point SDL_point(int x, int y) {
|
2017-06-26 12:15:03 +03:00
|
|
|
SDL_Point p;
|
|
|
|
p.x = x;
|
|
|
|
p.y = y;
|
|
|
|
return p;
|
|
|
|
}
|
2018-03-22 15:25:30 +03:00
|
|
|
|
2018-03-22 15:36:16 +03:00
|
|
|
SDL_Color SDL_rgb(int r, int g, int b) {
|
2018-03-22 15:25:30 +03:00
|
|
|
SDL_Color p;
|
|
|
|
p.r = r;
|
|
|
|
p.g = g;
|
|
|
|
p.b = b;
|
|
|
|
p.a = 255;
|
|
|
|
return p;
|
|
|
|
}
|
2018-03-22 15:36:16 +03:00
|
|
|
|
|
|
|
SDL_Color SDL_rgba(int r, int g, int b, int a) {
|
|
|
|
SDL_Color p;
|
|
|
|
p.r = r;
|
|
|
|
p.g = g;
|
|
|
|
p.b = b;
|
|
|
|
p.a = a;
|
|
|
|
return p;
|
|
|
|
}
|
2018-03-22 16:17:26 +03:00
|
|
|
|
2019-10-30 13:07:32 +03:00
|
|
|
int SDL_Color_r(SDL_Color *col) {
|
|
|
|
return (int)(col->r);
|
|
|
|
}
|
2018-03-22 16:17:26 +03:00
|
|
|
|
2019-10-30 13:07:32 +03:00
|
|
|
int SDL_Color_g(SDL_Color *col) {
|
|
|
|
return (int)(col->g);
|
|
|
|
}
|
2018-03-22 16:17:26 +03:00
|
|
|
|
2019-10-30 13:07:32 +03:00
|
|
|
int SDL_Color_b(SDL_Color *col) {
|
|
|
|
return (int)(col->b);
|
|
|
|
}
|
2018-03-22 16:17:26 +03:00
|
|
|
|
2019-10-30 13:07:32 +03:00
|
|
|
int SDL_Color_a(SDL_Color *col) {
|
|
|
|
return (int)(col->a);
|
|
|
|
}
|
2018-11-15 17:25:57 +03:00
|
|
|
|
2019-10-30 13:07:32 +03:00
|
|
|
void *SDL_SurfacePixels(SDL_Surface *s) {
|
|
|
|
return s->pixels;
|
|
|
|
}
|
2018-11-15 17:25:57 +03:00
|
|
|
|
2019-10-30 13:07:32 +03:00
|
|
|
int SDL_SurfacePitch(SDL_Surface *s) {
|
|
|
|
return s->pitch;
|
|
|
|
}
|