@kmamal/sdl 0.3.4 → 0.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -446,7 +446,7 @@ Fired to indicate that the user has requested the window to close (usually by cl
446
446
 
447
447
  ### Event: 'close'
448
448
 
449
- Indicates that the application is about to be destroyed. Handle any cleanup here. This event will be followed by a call to `window.destroy()`.
449
+ Indicates that the window is about to be destroyed. Handle any cleanup here. This event will be followed by a call to `window.destroy()`.
450
450
 
451
451
  ### Event: 'keyDown'
452
452
 
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.3.4",
2
+ "version": "0.3.5",
3
3
  "name": "@kmamal/sdl",
4
4
  "description": "SDL2 bindings for Node.js",
5
5
  "keywords": [
@@ -968,35 +968,32 @@ window_render (
968
968
  unsigned int format,
969
969
  void * pixels
970
970
  ) {
971
- // Update Window
972
- {
973
- SDL_Window * window = SDL_GetWindowFromID(window_id);
974
- if (window == nullptr) {
975
- RETURN_ERROR("SDL_GetWindowFromID(%d) error: %s\n", window_id, SDL_GetError());
976
- }
971
+ SDL_Window * window = SDL_GetWindowFromID(window_id);
972
+ if (window == nullptr) {
973
+ RETURN_ERROR("SDL_GetWindowFromID(%d) error: %s\n", window_id, SDL_GetError());
974
+ }
977
975
 
978
- SDL_Surface* src_surface = SDL_CreateRGBSurfaceWithFormatFrom(pixels, w, h, SDL_BITSPERPIXEL(format), stride, format);
979
- SDL_SetSurfaceBlendMode(src_surface, SDL_BLENDMODE_NONE);
980
- if (src_surface == nullptr) {
981
- RETURN_ERROR("SDL_CreateRGBSurfaceWithFormatFrom(%d, %d, %d) error: %s\n", w, h, format, SDL_GetError());
982
- }
983
- SDL_Rect src_rect = { 0, 0, w, h };
976
+ SDL_Surface* src_surface = SDL_CreateRGBSurfaceWithFormatFrom(pixels, w, h, SDL_BITSPERPIXEL(format), stride, format);
977
+ SDL_SetSurfaceBlendMode(src_surface, SDL_BLENDMODE_NONE);
978
+ if (src_surface == nullptr) {
979
+ RETURN_ERROR("SDL_CreateRGBSurfaceWithFormatFrom(%d, %d, %d) error: %s\n", w, h, format, SDL_GetError());
980
+ }
981
+ SDL_Rect src_rect = { 0, 0, w, h };
984
982
 
985
- SDL_Surface * window_surface = SDL_GetWindowSurface(window);
986
- if (window_surface == nullptr) {
987
- RETURN_ERROR("SDL_GetWindowSurface(%d) error: %s\n", window_id, SDL_GetError());
988
- }
989
- SDL_Rect window_rect = { 0, 0, window_surface->w, window_surface->h };
983
+ SDL_Surface * window_surface = SDL_GetWindowSurface(window);
984
+ if (window_surface == nullptr) {
985
+ RETURN_ERROR("SDL_GetWindowSurface(%d) error: %s\n", window_id, SDL_GetError());
986
+ }
987
+ SDL_Rect window_rect = { 0, 0, window_surface->w, window_surface->h };
990
988
 
991
- if (SDL_LowerBlit(src_surface, &src_rect, window_surface, &window_rect) != 0) {
992
- RETURN_ERROR("SDL_LowerBlit(%d) error: %s\n", window_id, SDL_GetError());
993
- }
989
+ if (SDL_LowerBlit(src_surface, &src_rect, window_surface, &window_rect) != 0) {
990
+ RETURN_ERROR("SDL_LowerBlit(%d) error: %s\n", window_id, SDL_GetError());
991
+ }
994
992
 
995
- SDL_FreeSurface(src_surface);
993
+ SDL_FreeSurface(src_surface);
996
994
 
997
- if (SDL_UpdateWindowSurface(window) != 0) {
998
- RETURN_ERROR("SDL_UpdateWindowSurface(%d) error: %s\n", window_id, SDL_GetError());
999
- }
995
+ if (SDL_UpdateWindowSurface(window) != 0) {
996
+ RETURN_ERROR("SDL_UpdateWindowSurface(%d) error: %s\n", window_id, SDL_GetError());
1000
997
  }
1001
998
 
1002
999
  return nullptr;
@@ -1198,7 +1195,7 @@ packageEvent (const SDL_Event & event, Variant & object)
1198
1195
  SET_STRING(object, "type", event.type == SDL_KEYDOWN
1199
1196
  ? "keyDown"
1200
1197
  : "keyUp");
1201
- SET_NUM(object, "window", event.window.windowID);
1198
+ SET_NUM(object, "window", event.key.windowID);
1202
1199
 
1203
1200
  SDL_Keysym symbol = event.key.keysym;
1204
1201
  SET_NUM(object, "scancode", symbol.scancode);
@@ -1236,7 +1233,7 @@ packageEvent (const SDL_Event & event, Variant & object)
1236
1233
  case SDL_MOUSEMOTION: {
1237
1234
  SET_STRING(object, "family", "mouse");
1238
1235
  SET_STRING(object, "type", "mouseMove");
1239
- SET_NUM(object, "window", event.window.windowID);
1236
+ SET_NUM(object, "window", event.motion.windowID);
1240
1237
  SET_BOOL(object, "touch", event.motion.which == SDL_TOUCH_MOUSEID);
1241
1238
  SET_NUM(object, "x", event.motion.x);
1242
1239
  SET_NUM(object, "y", event.motion.y);
@@ -1248,8 +1245,8 @@ packageEvent (const SDL_Event & event, Variant & object)
1248
1245
  SET_STRING(object, "type", event.type == SDL_MOUSEBUTTONDOWN
1249
1246
  ? "mouseButtonDown"
1250
1247
  : "mouseButtonUp");
1251
- SET_NUM(object, "window", event.window.windowID);
1252
- SET_BOOL(object, "touch", event.motion.which == SDL_TOUCH_MOUSEID);
1248
+ SET_NUM(object, "window", event.button.windowID);
1249
+ SET_BOOL(object, "touch", event.button.which == SDL_TOUCH_MOUSEID);
1253
1250
  SET_NUM(object, "button", event.button.button);
1254
1251
  SET_NUM(object, "x", event.button.x);
1255
1252
  SET_NUM(object, "y", event.button.y);
@@ -1258,11 +1255,11 @@ packageEvent (const SDL_Event & event, Variant & object)
1258
1255
  case SDL_MOUSEWHEEL: {
1259
1256
  SET_STRING(object, "family", "mouse");
1260
1257
  SET_STRING(object, "type", "mouseWheel");
1261
- SET_NUM(object, "window", event.window.windowID);
1262
- SET_BOOL(object, "touch", event.motion.which == SDL_TOUCH_MOUSEID);
1258
+ SET_NUM(object, "window", event.wheel.windowID);
1259
+ SET_BOOL(object, "touch", event.wheel.which == SDL_TOUCH_MOUSEID);
1263
1260
 
1264
1261
  int x, y;
1265
- SDL_GetGlobalMouseState(&x, &y);
1262
+ SDL_GetMouseState(&x, &y);
1266
1263
  SET_NUM(object, "x", x);
1267
1264
  SET_NUM(object, "y", y);
1268
1265