ruby2d 0.9.2 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/assets/README.md +7 -8
- data/assets/Rakefile +85 -0
- data/assets/include/SDL2/SDL.h +4 -1
- data/assets/include/SDL2/SDL_assert.h +3 -1
- data/assets/include/SDL2/SDL_atomic.h +20 -2
- data/assets/include/SDL2/SDL_audio.h +47 -14
- data/assets/include/SDL2/SDL_bits.h +10 -1
- data/assets/include/SDL2/SDL_blendmode.h +10 -7
- data/assets/include/SDL2/SDL_clipboard.h +1 -1
- data/assets/include/SDL2/SDL_config.h +24 -390
- data/assets/include/SDL2/SDL_config_android.h +182 -0
- data/assets/include/SDL2/SDL_config_iphoneos.h +207 -0
- data/assets/include/SDL2/SDL_config_macosx.h +266 -0
- data/assets/include/SDL2/SDL_config_minimal.h +85 -0
- data/assets/include/SDL2/SDL_config_os2.h +188 -0
- data/assets/include/SDL2/SDL_config_pandora.h +135 -0
- data/assets/include/SDL2/SDL_config_psp.h +165 -0
- data/assets/include/SDL2/SDL_config_windows.h +288 -0
- data/assets/include/SDL2/SDL_config_winrt.h +243 -0
- data/assets/include/SDL2/SDL_config_wiz.h +149 -0
- data/assets/include/SDL2/SDL_copying.h +20 -0
- data/assets/include/SDL2/SDL_cpuinfo.h +119 -8
- data/assets/include/SDL2/SDL_egl.h +4 -1
- data/assets/include/SDL2/SDL_endian.h +6 -3
- data/assets/include/SDL2/SDL_error.h +38 -2
- data/assets/include/SDL2/SDL_events.h +67 -28
- data/assets/include/SDL2/SDL_filesystem.h +1 -1
- data/assets/include/SDL2/SDL_gamecontroller.h +160 -9
- data/assets/include/SDL2/SDL_gesture.h +1 -1
- data/assets/include/SDL2/SDL_haptic.h +10 -1
- data/assets/include/SDL2/SDL_hints.h +460 -17
- data/assets/include/SDL2/SDL_image.h +2 -2
- data/assets/include/SDL2/SDL_joystick.h +115 -24
- data/assets/include/SDL2/SDL_keyboard.h +1 -1
- data/assets/include/SDL2/SDL_keycode.h +11 -9
- data/assets/include/SDL2/SDL_loadso.h +1 -1
- data/assets/include/SDL2/SDL_locale.h +101 -0
- data/assets/include/SDL2/SDL_log.h +3 -3
- data/assets/include/SDL2/SDL_main.h +28 -16
- data/assets/include/SDL2/SDL_messagebox.h +6 -4
- data/assets/include/SDL2/SDL_metal.h +117 -0
- data/assets/include/SDL2/SDL_misc.h +75 -0
- data/assets/include/SDL2/SDL_mouse.h +1 -1
- data/assets/include/SDL2/SDL_mutex.h +1 -1
- data/assets/include/SDL2/SDL_name.h +1 -1
- data/assets/include/SDL2/SDL_opengl.h +1 -1
- data/assets/include/SDL2/SDL_opengl_glext.h +3 -0
- data/assets/include/SDL2/SDL_opengles.h +1 -1
- data/assets/include/SDL2/SDL_opengles2.h +1 -1
- data/assets/include/SDL2/SDL_pixels.h +27 -18
- data/assets/include/SDL2/SDL_platform.h +1 -1
- data/assets/include/SDL2/SDL_power.h +1 -1
- data/assets/include/SDL2/SDL_quit.h +1 -1
- data/assets/include/SDL2/SDL_rect.h +29 -3
- data/assets/include/SDL2/SDL_render.h +230 -3
- data/assets/include/SDL2/SDL_revision.h +2 -2
- data/assets/include/SDL2/SDL_rwops.h +51 -22
- data/assets/include/SDL2/SDL_scancode.h +2 -2
- data/assets/include/SDL2/SDL_sensor.h +28 -12
- data/assets/include/SDL2/SDL_shape.h +1 -1
- data/assets/include/SDL2/SDL_stdinc.h +44 -4
- data/assets/include/SDL2/SDL_surface.h +12 -2
- data/assets/include/SDL2/SDL_system.h +50 -4
- data/assets/include/SDL2/SDL_syswm.h +39 -9
- data/assets/include/SDL2/SDL_test.h +1 -1
- data/assets/include/SDL2/SDL_test_assert.h +1 -1
- data/assets/include/SDL2/SDL_test_common.h +32 -2
- data/assets/include/SDL2/SDL_test_compare.h +1 -1
- data/assets/include/SDL2/SDL_test_crc32.h +1 -1
- data/assets/include/SDL2/SDL_test_font.h +1 -1
- data/assets/include/SDL2/SDL_test_fuzzer.h +1 -1
- data/assets/include/SDL2/SDL_test_harness.h +1 -1
- data/assets/include/SDL2/SDL_test_images.h +1 -1
- data/assets/include/SDL2/SDL_test_log.h +1 -1
- data/assets/include/SDL2/SDL_test_md5.h +1 -1
- data/assets/include/SDL2/SDL_test_memory.h +3 -3
- data/assets/include/SDL2/SDL_test_random.h +1 -1
- data/assets/include/SDL2/SDL_thread.h +34 -11
- data/assets/include/SDL2/SDL_timer.h +1 -1
- data/assets/include/SDL2/SDL_touch.h +17 -1
- data/assets/include/SDL2/SDL_types.h +1 -1
- data/assets/include/SDL2/SDL_version.h +2 -2
- data/assets/include/SDL2/SDL_video.h +11 -5
- data/assets/include/SDL2/SDL_vulkan.h +9 -11
- data/assets/include/SDL2/begin_code.h +8 -9
- data/assets/include/SDL2/close_code.h +4 -1
- data/assets/macos/lib/libFLAC.a +0 -0
- data/assets/macos/lib/libSDL2.a +0 -0
- data/assets/macos/lib/libSDL2_image.a +0 -0
- data/assets/macos/lib/libSDL2_mixer.a +0 -0
- data/assets/macos/lib/libSDL2_ttf.a +0 -0
- data/assets/macos/lib/libfreetype.a +0 -0
- data/assets/macos/lib/libjpeg.a +0 -0
- data/assets/macos/lib/libmpg123.a +0 -0
- data/assets/macos/lib/libogg.a +0 -0
- data/assets/macos/lib/libpng16.a +0 -0
- data/assets/macos/lib/libtiff.a +0 -0
- data/assets/macos/lib/libvorbis.a +0 -0
- data/assets/macos/lib/libvorbisfile.a +0 -0
- data/assets/macos/lib/libwebp.a +0 -0
- data/assets/mingw/bin/SDL2.dll +0 -0
- data/assets/mingw/bin/SDL2_image.dll +0 -0
- data/assets/mingw/bin/libpng16-16.dll +0 -0
- data/assets/mingw/bin/libtiff-5.dll +0 -0
- data/assets/mingw/bin/libwebp-7.dll +0 -0
- data/assets/mingw/lib/libSDL2.a +0 -0
- data/assets/mingw/lib/libSDL2.dll.a +0 -0
- data/assets/mingw/lib/libSDL2_image.a +0 -0
- data/assets/mingw/lib/libSDL2_image.dll.a +0 -0
- data/assets/mingw/lib/libSDL2_test.a +0 -0
- data/assets/mingw/lib/libSDL2main.a +0 -0
- data/bin/ruby2d +2 -1
- data/{assets/linux/simple2d/src/simple2d.c → ext/ruby2d/common.c} +32 -32
- data/{assets/linux/simple2d/src → ext/ruby2d}/controllers.c +17 -17
- data/ext/ruby2d/extconf.rb +6 -36
- data/{assets/linux/simple2d/src → ext/ruby2d}/gl.c +106 -85
- data/{assets/linux/simple2d/src → ext/ruby2d}/gl2.c +35 -20
- data/{assets/linux/simple2d/src → ext/ruby2d}/gl3.c +146 -58
- data/{assets/linux/simple2d/src → ext/ruby2d}/gles.c +41 -26
- data/{assets/linux/simple2d/src → ext/ruby2d}/image.c +16 -16
- data/{assets/linux/simple2d/src → ext/ruby2d}/input.c +8 -8
- data/{assets/linux/simple2d/src → ext/ruby2d}/music.c +30 -17
- data/ext/ruby2d/ruby2d.c +427 -290
- data/ext/ruby2d/ruby2d.h +789 -0
- data/{assets/linux/simple2d/src → ext/ruby2d}/shapes.c +18 -18
- data/ext/ruby2d/sound.c +118 -0
- data/{assets/linux/simple2d/src → ext/ruby2d}/sprite.c +16 -16
- data/{assets/linux/simple2d/src → ext/ruby2d}/text.c +22 -22
- data/ext/ruby2d/tileset.c +30 -0
- data/{assets/linux/simple2d/src → ext/ruby2d}/window.c +71 -60
- data/lib/ruby2d.rb +5 -2
- data/lib/ruby2d/circle.rb +18 -2
- data/lib/ruby2d/cli/build.rb +3 -8
- data/lib/ruby2d/cli/colorize.rb +10 -0
- data/lib/ruby2d/dsl.rb +16 -9
- data/lib/ruby2d/entity.rb +17 -0
- data/lib/ruby2d/font.rb +4 -3
- data/lib/ruby2d/image.rb +24 -1
- data/lib/ruby2d/line.rb +20 -0
- data/lib/ruby2d/music.rb +5 -0
- data/lib/ruby2d/pixel.rb +17 -0
- data/lib/ruby2d/quad.rb +18 -0
- data/lib/ruby2d/rectangle.rb +11 -2
- data/lib/ruby2d/renderable.rb +4 -8
- data/lib/ruby2d/sound.rb +5 -0
- data/lib/ruby2d/sprite.rb +35 -3
- data/lib/ruby2d/square.rb +9 -0
- data/lib/ruby2d/text.rb +22 -1
- data/lib/ruby2d/tileset.rb +69 -0
- data/lib/ruby2d/triangle.rb +16 -0
- data/lib/ruby2d/version.rb +1 -1
- data/lib/ruby2d/window.rb +249 -22
- metadata +41 -27
- data/assets/include/simple2d.h +0 -735
- data/assets/linux/simple2d/Makefile +0 -250
- data/assets/linux/simple2d/bin/simple2d.sh +0 -1249
- data/assets/linux/simple2d/include/simple2d.h +0 -735
- data/assets/linux/simple2d/src/sound.c +0 -56
- data/assets/macos/lib/libsimple2d.a +0 -0
- data/assets/mingw/lib/libsimple2d.a +0 -0
- data/lib/ruby2d/colorize.rb +0 -10
@@ -1,6 +1,6 @@
|
|
1
1
|
/*
|
2
2
|
Simple DirectMedia Layer
|
3
|
-
Copyright (C) 1997-
|
3
|
+
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
4
4
|
|
5
5
|
This software is provided 'as-is', without any express or implied
|
6
6
|
warranty. In no event will the authors be held liable for any damages
|
@@ -51,15 +51,11 @@
|
|
51
51
|
|
52
52
|
/* Some compilers use a special export keyword */
|
53
53
|
#ifndef DECLSPEC
|
54
|
-
# if defined(__WIN32__) || defined(__WINRT__)
|
55
|
-
# ifdef
|
56
|
-
# ifdef BUILD_SDL
|
57
|
-
# define DECLSPEC
|
58
|
-
# else
|
59
|
-
# define DECLSPEC __declspec(dllimport)
|
60
|
-
# endif
|
61
|
-
# else
|
54
|
+
# if defined(__WIN32__) || defined(__WINRT__) || defined(__CYGWIN__)
|
55
|
+
# ifdef DLL_EXPORT
|
62
56
|
# define DECLSPEC __declspec(dllexport)
|
57
|
+
# else
|
58
|
+
# define DECLSPEC
|
63
59
|
# endif
|
64
60
|
# elif defined(__OS2__)
|
65
61
|
# ifdef BUILD_SDL
|
@@ -105,6 +101,9 @@
|
|
105
101
|
#ifdef _MSC_VER
|
106
102
|
#pragma warning(disable: 4103)
|
107
103
|
#endif
|
104
|
+
#ifdef __clang__
|
105
|
+
#pragma clang diagnostic ignored "-Wpragma-pack"
|
106
|
+
#endif
|
108
107
|
#ifdef __BORLANDC__
|
109
108
|
#pragma nopackwarning
|
110
109
|
#endif
|
@@ -1,6 +1,6 @@
|
|
1
1
|
/*
|
2
2
|
Simple DirectMedia Layer
|
3
|
-
Copyright (C) 1997-
|
3
|
+
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
|
4
4
|
|
5
5
|
This software is provided 'as-is', without any express or implied
|
6
6
|
warranty. In no event will the authors be held liable for any damages
|
@@ -26,6 +26,9 @@
|
|
26
26
|
* after you finish any function and structure declarations in your headers
|
27
27
|
*/
|
28
28
|
|
29
|
+
#ifndef _begin_code_h
|
30
|
+
#error close_code.h included without matching begin_code.h
|
31
|
+
#endif
|
29
32
|
#undef _begin_code_h
|
30
33
|
|
31
34
|
/* Reset structure packing at previous byte alignment */
|
data/assets/macos/lib/libFLAC.a
CHANGED
Binary file
|
data/assets/macos/lib/libSDL2.a
CHANGED
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/assets/macos/lib/libjpeg.a
CHANGED
Binary file
|
Binary file
|
data/assets/macos/lib/libogg.a
CHANGED
Binary file
|
data/assets/macos/lib/libpng16.a
CHANGED
Binary file
|
data/assets/macos/lib/libtiff.a
CHANGED
Binary file
|
Binary file
|
Binary file
|
data/assets/macos/lib/libwebp.a
CHANGED
Binary file
|
data/assets/mingw/bin/SDL2.dll
CHANGED
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/assets/mingw/lib/libSDL2.a
CHANGED
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/bin/ruby2d
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require 'ruby2d/colorize'
|
3
|
+
require 'ruby2d/cli/colorize'
|
4
4
|
require 'ruby2d/version'
|
5
5
|
|
6
6
|
# Debugging command-line flag
|
@@ -115,6 +115,7 @@ when 'launch'
|
|
115
115
|
else
|
116
116
|
puts usage_launch
|
117
117
|
end
|
118
|
+
# TODO: Need add this functionality to the gem
|
118
119
|
when 'simulator'
|
119
120
|
case ARGV[1]
|
120
121
|
when '--list'
|
@@ -1,11 +1,11 @@
|
|
1
|
-
//
|
1
|
+
// Ruby 2D Shared functions and data
|
2
2
|
|
3
|
-
#include "
|
3
|
+
#include "ruby2d.h"
|
4
4
|
|
5
|
-
// Initalize
|
6
|
-
bool
|
5
|
+
// Initalize shared data
|
6
|
+
bool R2D_diagnostics = false;
|
7
7
|
|
8
|
-
//
|
8
|
+
// Initialization status
|
9
9
|
static bool initted = false;
|
10
10
|
|
11
11
|
|
@@ -30,7 +30,7 @@ int vasprintf(char **strp, const char *fmt, va_list ap) {
|
|
30
30
|
/*
|
31
31
|
* Checks if a file exists and can be accessed
|
32
32
|
*/
|
33
|
-
bool
|
33
|
+
bool R2D_FileExists(const char *path) {
|
34
34
|
if (!path) return false;
|
35
35
|
|
36
36
|
if (access(path, F_OK) != -1) {
|
@@ -44,22 +44,22 @@ bool S2D_FileExists(const char *path) {
|
|
44
44
|
/*
|
45
45
|
* Logs standard messages to the console
|
46
46
|
*/
|
47
|
-
void
|
47
|
+
void R2D_Log(int type, const char *msg, ...) {
|
48
48
|
|
49
49
|
// Always log if diagnostics set, or if a warning or error message
|
50
|
-
if (
|
50
|
+
if (R2D_diagnostics || type != R2D_INFO) {
|
51
51
|
|
52
52
|
va_list args;
|
53
53
|
va_start(args, msg);
|
54
54
|
|
55
55
|
switch (type) {
|
56
|
-
case
|
56
|
+
case R2D_INFO:
|
57
57
|
printf("\033[1;36mInfo:\033[0m ");
|
58
58
|
break;
|
59
|
-
case
|
59
|
+
case R2D_WARN:
|
60
60
|
printf("\033[1;33mWarning:\033[0m ");
|
61
61
|
break;
|
62
|
-
case
|
62
|
+
case R2D_ERROR:
|
63
63
|
printf("\033[1;31mError:\033[0m ");
|
64
64
|
break;
|
65
65
|
}
|
@@ -72,14 +72,14 @@ void S2D_Log(int type, const char *msg, ...) {
|
|
72
72
|
|
73
73
|
|
74
74
|
/*
|
75
|
-
* Logs
|
75
|
+
* Logs Ruby 2D errors to the console, with caller and message body
|
76
76
|
*/
|
77
|
-
void
|
77
|
+
void R2D_Error(const char *caller, const char *msg, ...) {
|
78
78
|
va_list args;
|
79
79
|
va_start(args, msg);
|
80
80
|
char *fmsg;
|
81
81
|
vasprintf(&fmsg, msg, args);
|
82
|
-
|
82
|
+
R2D_Log(R2D_ERROR, "(%s) %s", caller, fmsg);
|
83
83
|
free(fmsg);
|
84
84
|
va_end(args);
|
85
85
|
}
|
@@ -88,15 +88,15 @@ void S2D_Error(const char *caller, const char *msg, ...) {
|
|
88
88
|
/*
|
89
89
|
* Enable/disable logging of diagnostics
|
90
90
|
*/
|
91
|
-
void
|
92
|
-
|
91
|
+
void R2D_Diagnostics(bool status) {
|
92
|
+
R2D_diagnostics = status;
|
93
93
|
}
|
94
94
|
|
95
95
|
|
96
96
|
/*
|
97
97
|
* Enable terminal colors in Windows
|
98
98
|
*/
|
99
|
-
void
|
99
|
+
void R2D_Windows_EnableTerminalColors() {
|
100
100
|
#if WINDOWS
|
101
101
|
HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
|
102
102
|
DWORD dwMode = 0;
|
@@ -108,25 +108,25 @@ void S2D_Windows_EnableTerminalColors() {
|
|
108
108
|
|
109
109
|
|
110
110
|
/*
|
111
|
-
* Initialize
|
111
|
+
* Initialize Ruby 2D subsystems
|
112
112
|
*/
|
113
|
-
bool
|
113
|
+
bool R2D_Init() {
|
114
114
|
if (initted) return true;
|
115
115
|
|
116
116
|
// Enable terminal colors in Windows
|
117
|
-
|
117
|
+
R2D_Windows_EnableTerminalColors();
|
118
118
|
|
119
|
-
|
119
|
+
R2D_Log(R2D_INFO, "Initializing Ruby 2D");
|
120
120
|
|
121
121
|
// Initialize SDL
|
122
122
|
if (SDL_Init(SDL_INIT_EVERYTHING) != 0) {
|
123
|
-
|
123
|
+
R2D_Error("SDL_Init", SDL_GetError());
|
124
124
|
return false;
|
125
125
|
}
|
126
126
|
|
127
127
|
// Initialize SDL_ttf
|
128
128
|
if (TTF_Init() != 0) {
|
129
|
-
|
129
|
+
R2D_Error("TTF_Init", TTF_GetError());
|
130
130
|
return false;
|
131
131
|
}
|
132
132
|
|
@@ -142,17 +142,17 @@ bool S2D_Init() {
|
|
142
142
|
// It's version 2.0.2, don't check for Mix_Init errors
|
143
143
|
} else {
|
144
144
|
if ((mix_initted&mix_flags) != mix_flags) {
|
145
|
-
|
145
|
+
R2D_Error("Mix_Init", Mix_GetError());
|
146
146
|
}
|
147
147
|
}
|
148
148
|
|
149
149
|
if (Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 2, 4096) != 0) {
|
150
|
-
|
150
|
+
R2D_Error("Mix_OpenAudio", Mix_GetError());
|
151
151
|
return false;
|
152
152
|
}
|
153
153
|
|
154
|
-
// Call `
|
155
|
-
atexit(
|
154
|
+
// Call `R2D_Quit` at program exit
|
155
|
+
atexit(R2D_Quit);
|
156
156
|
|
157
157
|
// All subsystems initted
|
158
158
|
initted = true;
|
@@ -161,10 +161,10 @@ bool S2D_Init() {
|
|
161
161
|
|
162
162
|
|
163
163
|
/*
|
164
|
-
* Gets the primary display's
|
164
|
+
* Gets the primary display's dimensions
|
165
165
|
*/
|
166
|
-
void
|
167
|
-
|
166
|
+
void R2D_GetDisplayDimensions(int *w, int *h) {
|
167
|
+
R2D_Init();
|
168
168
|
SDL_DisplayMode dm;
|
169
169
|
SDL_GetCurrentDisplayMode(0, &dm);
|
170
170
|
*w = dm.w;
|
@@ -173,9 +173,9 @@ void S2D_GetDisplayDimensions(int *w, int *h) {
|
|
173
173
|
|
174
174
|
|
175
175
|
/*
|
176
|
-
* Quits
|
176
|
+
* Quits Ruby 2D subsystems
|
177
177
|
*/
|
178
|
-
void
|
178
|
+
void R2D_Quit() {
|
179
179
|
IMG_Quit();
|
180
180
|
Mix_CloseAudio();
|
181
181
|
Mix_Quit();
|
@@ -1,6 +1,6 @@
|
|
1
1
|
// controllers.c
|
2
2
|
|
3
|
-
#include "
|
3
|
+
#include "ruby2d.h"
|
4
4
|
|
5
5
|
// Stores the last joystick instance ID seen by the system. These instance IDs
|
6
6
|
// are unique and increment with each new joystick connected.
|
@@ -10,7 +10,7 @@ static int last_intance_id = -1;
|
|
10
10
|
/*
|
11
11
|
* Add controller mapping from string
|
12
12
|
*/
|
13
|
-
void
|
13
|
+
void R2D_AddControllerMapping(const char *map) {
|
14
14
|
int result = SDL_GameControllerAddMapping(map);
|
15
15
|
|
16
16
|
char guid[33];
|
@@ -18,13 +18,13 @@ void S2D_AddControllerMapping(const char *map) {
|
|
18
18
|
|
19
19
|
switch (result) {
|
20
20
|
case 1:
|
21
|
-
|
21
|
+
R2D_Log(R2D_INFO, "Mapping added for GUID: %s", guid);
|
22
22
|
break;
|
23
23
|
case 0:
|
24
|
-
|
24
|
+
R2D_Log(R2D_INFO, "Mapping updated for GUID: %s", guid);
|
25
25
|
break;
|
26
26
|
case -1:
|
27
|
-
|
27
|
+
R2D_Error("SDL_GameControllerAddMapping", SDL_GetError());
|
28
28
|
break;
|
29
29
|
}
|
30
30
|
}
|
@@ -33,17 +33,17 @@ void S2D_AddControllerMapping(const char *map) {
|
|
33
33
|
/*
|
34
34
|
* Add controller mappings from the specified file
|
35
35
|
*/
|
36
|
-
void
|
37
|
-
if (!
|
38
|
-
|
36
|
+
void R2D_AddControllerMappingsFromFile(const char *path) {
|
37
|
+
if (!R2D_FileExists(path)) {
|
38
|
+
R2D_Log(R2D_WARN, "Controller mappings file not found: %s", path);
|
39
39
|
return;
|
40
40
|
}
|
41
41
|
|
42
42
|
int mappings_added = SDL_GameControllerAddMappingsFromFile(path);
|
43
43
|
if (mappings_added == -1) {
|
44
|
-
|
44
|
+
R2D_Error("SDL_GameControllerAddMappingsFromFile", SDL_GetError());
|
45
45
|
} else {
|
46
|
-
|
46
|
+
R2D_Log(R2D_INFO, "Added %i controller mapping(s)", mappings_added);
|
47
47
|
}
|
48
48
|
}
|
49
49
|
|
@@ -51,7 +51,7 @@ void S2D_AddControllerMappingsFromFile(const char *path) {
|
|
51
51
|
/*
|
52
52
|
* Check if joystick is a controller
|
53
53
|
*/
|
54
|
-
bool
|
54
|
+
bool R2D_IsController(SDL_JoystickID id) {
|
55
55
|
return SDL_GameControllerFromInstanceID(id) == NULL ? false : true;
|
56
56
|
}
|
57
57
|
|
@@ -59,7 +59,7 @@ bool S2D_IsController(SDL_JoystickID id) {
|
|
59
59
|
/*
|
60
60
|
* Open controllers and joysticks
|
61
61
|
*/
|
62
|
-
void
|
62
|
+
void R2D_OpenControllers() {
|
63
63
|
|
64
64
|
char guid_str[33];
|
65
65
|
|
@@ -78,9 +78,9 @@ void S2D_OpenControllers() {
|
|
78
78
|
|
79
79
|
if (intance_id > last_intance_id) {
|
80
80
|
if (controller) {
|
81
|
-
|
81
|
+
R2D_Log(R2D_INFO, "Controller #%i: %s\n GUID: %s", intance_id, SDL_GameControllerName(controller), guid_str);
|
82
82
|
} else {
|
83
|
-
|
83
|
+
R2D_Log(R2D_ERROR, "Could not open controller #%i: %s", intance_id, SDL_GetError());
|
84
84
|
}
|
85
85
|
last_intance_id = intance_id;
|
86
86
|
}
|
@@ -91,18 +91,18 @@ void S2D_OpenControllers() {
|
|
91
91
|
SDL_JoystickID intance_id = SDL_JoystickInstanceID(joy);
|
92
92
|
|
93
93
|
if (!joy) {
|
94
|
-
|
94
|
+
R2D_Log(R2D_ERROR, "Could not open controller");
|
95
95
|
} else if(intance_id > last_intance_id) {
|
96
96
|
SDL_JoystickGetGUIDString(
|
97
97
|
SDL_JoystickGetGUID(joy),
|
98
98
|
guid_str, 33
|
99
99
|
);
|
100
|
-
|
100
|
+
R2D_Log(R2D_INFO,
|
101
101
|
"Controller #%i: %s\n GUID: %s\n Axes: %d\n Buttons: %d\n Balls: %d",
|
102
102
|
intance_id, SDL_JoystickName(joy), guid_str, SDL_JoystickNumAxes(joy),
|
103
103
|
SDL_JoystickNumButtons(joy), SDL_JoystickNumBalls(joy)
|
104
104
|
);
|
105
|
-
|
105
|
+
R2D_Log(R2D_WARN, "Controller #%i does not have a mapping available", intance_id);
|
106
106
|
last_intance_id = intance_id;
|
107
107
|
}
|
108
108
|
}
|
data/ext/ruby2d/extconf.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
require 'mkmf'
|
2
|
-
require_relative '../../lib/ruby2d/colorize'
|
2
|
+
require_relative '../../lib/ruby2d/cli/colorize'
|
3
3
|
|
4
|
-
S2D_VERSION = '1.1.0' # Simple 2D minimum version required
|
5
4
|
$errors = [] # Holds errors
|
6
5
|
|
7
6
|
# Set the OS platform
|
@@ -31,27 +30,6 @@ def print_errors
|
|
31
30
|
end
|
32
31
|
|
33
32
|
|
34
|
-
# Check that Simple 2D is installed and meets minimum version requirements
|
35
|
-
def check_s2d
|
36
|
-
|
37
|
-
# Simple 2D not installed
|
38
|
-
if `which simple2d`.empty?
|
39
|
-
$errors << "Ruby 2D uses a native library called Simple 2D, which was not found." <<
|
40
|
-
"To install, follow the instructions at #{"ruby2d.com".bold}"
|
41
|
-
print_errors; exit
|
42
|
-
|
43
|
-
# Simple 2D installed, checking version
|
44
|
-
else
|
45
|
-
unless Gem::Version.new(`bash simple2d --version`) >= Gem::Version.new(S2D_VERSION)
|
46
|
-
$errors << "Simple 2D needs to be updated for this version of Ruby 2D." <<
|
47
|
-
"Run the following, then try reinstalling this gem:\n" <<
|
48
|
-
" simple2d update".bold
|
49
|
-
print_errors; exit
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
|
55
33
|
# Add compiler and linker flags
|
56
34
|
def add_flags(type, flags)
|
57
35
|
case type
|
@@ -106,14 +84,11 @@ def set_rpi_flags
|
|
106
84
|
end
|
107
85
|
|
108
86
|
|
109
|
-
# Use
|
87
|
+
# Use SDL and other libraries installed by the user (not those bundled with the gem)
|
110
88
|
def use_usr_libs
|
111
|
-
check_s2d
|
112
|
-
|
113
89
|
# Add flags
|
114
90
|
set_rpi_flags
|
115
91
|
add_flags(:c, '-I/usr/local/include')
|
116
|
-
add_flags(:ld, `bash simple2d --libs`)
|
117
92
|
end
|
118
93
|
|
119
94
|
|
@@ -134,27 +109,22 @@ else
|
|
134
109
|
add_flags(:c, '-I../../assets/include')
|
135
110
|
ldir = "#{Dir.pwd}/../../assets/macos/lib"
|
136
111
|
|
137
|
-
add_flags(:ld, "#{ldir}/libsimple2d.a")
|
138
112
|
add_flags(:ld, "#{ldir}/libSDL2.a #{ldir}/libSDL2_image.a #{ldir}/libSDL2_mixer.a #{ldir}/libSDL2_ttf.a")
|
139
113
|
add_flags(:ld, "#{ldir}/libjpeg.a #{ldir}/libpng16.a #{ldir}/libtiff.a #{ldir}/libwebp.a")
|
140
114
|
add_flags(:ld, "#{ldir}/libmpg123.a #{ldir}/libogg.a #{ldir}/libFLAC.a #{ldir}/libvorbis.a #{ldir}/libvorbisfile.a")
|
141
115
|
add_flags(:ld, "#{ldir}/libfreetype.a")
|
142
|
-
add_flags(:ld, "-Wl,-framework,Cocoa -Wl,-framework,ForceFeedback")
|
116
|
+
add_flags(:ld, "-Wl,-framework,Cocoa -Wl,-framework,GameController -Wl,-framework,ForceFeedback")
|
143
117
|
|
144
118
|
when :linux, :linux_rpi
|
145
119
|
check_sdl_linux
|
146
|
-
simple2d_dir = "#{Dir.pwd}/../../assets/linux/simple2d"
|
147
|
-
|
148
|
-
`(cd #{simple2d_dir} && make)`
|
149
120
|
|
150
121
|
set_rpi_flags
|
151
|
-
add_flags(:
|
152
|
-
add_flags(:ld, "#{simple2d_dir}/build/libsimple2d.a -lSDL2 -lSDL2_image -lSDL2_mixer -lSDL2_ttf -lm")
|
122
|
+
add_flags(:ld, "-lSDL2 -lSDL2_image -lSDL2_mixer -lSDL2_ttf -lm")
|
153
123
|
if $platform == :linux then add_flags(:ld, '-lGL') end
|
154
124
|
|
155
125
|
when :windows
|
156
126
|
add_flags(:c, '-I../../assets/include')
|
157
|
-
add_flags(:ld, '-L../../assets/mingw/lib -
|
127
|
+
add_flags(:ld, '-L../../assets/mingw/lib -lSDL2 -lSDL2_image -lSDL2_mixer -lSDL2_ttf')
|
158
128
|
add_flags(:ld, '-lmingw32 -lopengl32 -lglew32')
|
159
129
|
|
160
130
|
# If can't detect the platform, use libraries installed by the user
|
@@ -165,5 +135,5 @@ end
|
|
165
135
|
|
166
136
|
$LDFLAGS.gsub!(/\n/, ' ') # remove newlines in flags, they can cause problems
|
167
137
|
|
168
|
-
# Create
|
138
|
+
# Create Makefile
|
169
139
|
create_makefile('ruby2d/ruby2d')
|