ruby-sdl2 0.1.0 → 0.2.0
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.
- checksums.yaml +4 -4
- data/.gitignore +3 -0
- data/README.md +5 -6
- data/Rakefile +13 -0
- data/clipboard.c +24 -0
- data/event.c +216 -5
- data/filesystem.c +27 -0
- data/gamecontroller.c +244 -30
- data/gamecontroller.c.m4 +408 -0
- data/gl.c.m4 +159 -9
- data/hint.c +51 -8
- data/key.c.m4 +6 -0
- data/lib/sdl2/version.rb +2 -2
- data/messagebox.c +40 -38
- data/mixer.c +138 -21
- data/mixer.c.m4 +1196 -0
- data/mouse.c +5 -5
- data/sample/message_box.rb +5 -5
- data/sample/primitives.rb +1 -1
- data/sample/test_video.rb +3 -3
- data/sample/testgl.rb +1 -1
- data/sample/testsprite.rb +5 -5
- data/ttf.c +193 -14
- data/ttf.c.m4 +375 -0
- data/video.c.m4 +465 -122
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0ba98c59e4cc9e1521e4f521a593f9229f4d3b53
|
4
|
+
data.tar.gz: 8b61b2c7a6bd524b5fd54ef7ed7e4ec6df16df3d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cda57903640382a7780b8ff43faeaebafbfed416ad9003a49069125485c497ad180b17a9f4d403d08da122fdf2bceda509563119fb5b05d8535000ef62053245
|
7
|
+
data.tar.gz: 2b923a1f3e19db9d998040bbbe472798b70b6ae034b838f3fa43990ad7090d441d7567b5cf467216dacf115d0f374863b9b226de18100a32c9fdda07013a034a
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -5,22 +5,21 @@ The simple ruby extension library for SDL 2.x.
|
|
5
5
|
# Install
|
6
6
|
Before installing Ruby/SDL2, you need to install:
|
7
7
|
|
8
|
+
* [devkit](http://rubyinstaller.org/add-ons/devkit/) (only for windows)
|
9
|
+
* M4 (only for installing from git repository)
|
8
10
|
* [SDL 2.x](http://www.libsdl.org/download-2.0.php)
|
9
11
|
* [SDL_image](https://www.libsdl.org/projects/SDL_image/)
|
10
12
|
* [SDL_mixer](https://www.libsdl.org/projects/SDL_mixer/)
|
11
13
|
* [SDL_ttf](https://www.libsdl.org/projects/SDL_ttf/)
|
12
14
|
|
13
15
|
After installing these libraries, you can install Ruby/SDL2
|
14
|
-
from github
|
16
|
+
from github:
|
15
17
|
|
16
18
|
git clone https://github.com/ohai/ruby-sdl2.git
|
17
19
|
cd ruby-sdl2
|
18
|
-
|
19
|
-
gem install ruby-sdl2-x.y.z.gem
|
20
|
+
rake gem
|
21
|
+
gem install pkg/ruby-sdl2-x.y.z.gem
|
20
22
|
|
21
|
-
## Install on Windows
|
22
|
-
Please write this.
|
23
|
-
|
24
23
|
# License
|
25
24
|
|
26
25
|
LGPL v3 (see {file:COPYING.txt}).
|
data/Rakefile
CHANGED
@@ -10,6 +10,8 @@ RB_FILES = Dir.glob("lib/**/*.rb")
|
|
10
10
|
POT_SOURCES = RB_FILES + ["main.c"] + (C_FILES - ["main.c"])
|
11
11
|
YARD_SOURCES = "-m markdown --main README.md --files COPYING.txt #{POT_SOURCES.join(" ")}"
|
12
12
|
|
13
|
+
WATCH_TARGETS = (C_FILES - C_FROM_M4_FILES) + C_M4_FILES + ["README.md"]
|
14
|
+
|
13
15
|
locale = ENV["YARD_LOCALE"]
|
14
16
|
|
15
17
|
def extconf_options
|
@@ -77,6 +79,11 @@ task "doc-all" do
|
|
77
79
|
raise "Not yet implemented"
|
78
80
|
end
|
79
81
|
|
82
|
+
desc "List undocumented classes/modules/methods/constants"
|
83
|
+
task "doc-stat-undocumented" => POT_SOURCES do
|
84
|
+
sh "yard stats --list-undoc --compact #{YARD_SOURCES}"
|
85
|
+
end
|
86
|
+
|
80
87
|
rule ".c" => ".c.m4" do |t|
|
81
88
|
sh "m4 #{t.prerequisites[0]} > #{t.name}"
|
82
89
|
end
|
@@ -93,3 +100,9 @@ Gem::PackageTask.new(gem_spec) do |pkg|
|
|
93
100
|
end
|
94
101
|
|
95
102
|
rule ".gem" => C_FILES
|
103
|
+
|
104
|
+
task "watch-doc" do
|
105
|
+
loop do
|
106
|
+
sh "inotifywait -e modify #{WATCH_TARGETS.join(" ")} && rake doc && notify-send -u low \"Ruby/SDL2 build doc OK\""
|
107
|
+
end
|
108
|
+
end
|
data/clipboard.c
CHANGED
@@ -1,6 +1,19 @@
|
|
1
1
|
#include "rubysdl2_internal.h"
|
2
2
|
#include <SDL_clipboard.h>
|
3
3
|
|
4
|
+
/*
|
5
|
+
* Document-module: SDL2::Clipboard
|
6
|
+
*
|
7
|
+
* This module has clipboard manipulating functions.
|
8
|
+
*
|
9
|
+
*/
|
10
|
+
|
11
|
+
/*
|
12
|
+
* Get the text from the clipboard.
|
13
|
+
*
|
14
|
+
* @return [String] a string in the clipboard
|
15
|
+
* @return [nil] if the clipboard is empty
|
16
|
+
*/
|
4
17
|
static VALUE Clipboard_s_text(VALUE self)
|
5
18
|
{
|
6
19
|
if (SDL_HasClipboardText()) {
|
@@ -16,12 +29,23 @@ static VALUE Clipboard_s_text(VALUE self)
|
|
16
29
|
}
|
17
30
|
}
|
18
31
|
|
32
|
+
/*
|
33
|
+
* @overload text=(text)
|
34
|
+
* Set the text in the clipboard.
|
35
|
+
*
|
36
|
+
* @param text [String] a new text
|
37
|
+
* @return [String] text
|
38
|
+
*/
|
19
39
|
static VALUE Clipboard_s_set_text(VALUE self, VALUE text)
|
20
40
|
{
|
21
41
|
HANDLE_ERROR(SDL_SetClipboardText(StringValueCStr(text)));
|
22
42
|
return text;
|
23
43
|
}
|
24
44
|
|
45
|
+
/*
|
46
|
+
* Return true if the clipboard has any text.
|
47
|
+
*
|
48
|
+
*/
|
25
49
|
static VALUE Clipboard_s_has_text_p(VALUE self)
|
26
50
|
{
|
27
51
|
return INT2BOOL(SDL_HasClipboardText());
|
data/event.c
CHANGED
@@ -33,6 +33,10 @@ static VALUE cEvControllerDevice;
|
|
33
33
|
static VALUE cEvControllerDeviceAdded;
|
34
34
|
static VALUE cEvControllerDeviceRemoved;
|
35
35
|
static VALUE cEvControllerDeviceRemapped;
|
36
|
+
static VALUE cEvTouchFinger;
|
37
|
+
static VALUE cEvFingerDown;
|
38
|
+
static VALUE cEvFingerUp;
|
39
|
+
static VALUE cEvFingerMotion;
|
36
40
|
/* static VALUE cEvUser; */
|
37
41
|
/* static VALUE cEvDrop; */
|
38
42
|
|
@@ -137,7 +141,7 @@ static VALUE Event_s_enabled_p(VALUE self)
|
|
137
141
|
}
|
138
142
|
|
139
143
|
/*
|
140
|
-
* @overload
|
144
|
+
* @overload enable=(bool)
|
141
145
|
* Set wheter the event is enable
|
142
146
|
*
|
143
147
|
* This method is only available for subclasses of SDL2::Event corresponding to
|
@@ -147,7 +151,7 @@ static VALUE Event_s_enabled_p(VALUE self)
|
|
147
151
|
* SDL2::Event::MouseWheel.enable = false
|
148
152
|
*
|
149
153
|
* @param [Boolean] bool true for enabling the event.
|
150
|
-
* @return [
|
154
|
+
* @return [Boolean]
|
151
155
|
* @see SDL2::Event.enabled?
|
152
156
|
*
|
153
157
|
*/
|
@@ -198,6 +202,9 @@ static void set_string(char* field, VALUE str, int maxlength)
|
|
198
202
|
#define EVENT_ACCESSOR_INT(classname, name, field) \
|
199
203
|
EVENT_ACCESSOR(classname, name, field, NUM2INT, INT2NUM)
|
200
204
|
|
205
|
+
#define EVENT_ACCESSOR_DBL(classname, name, field) \
|
206
|
+
EVENT_ACCESSOR(classname, name, field, NUM2DBL, DBL2NUM)
|
207
|
+
|
201
208
|
#define EVENT_ACCESSOR_BOOL(classname, name, field) \
|
202
209
|
EVENT_ACCESSOR(classname, name, field, RTEST, INT2BOOL)
|
203
210
|
|
@@ -635,13 +642,13 @@ static VALUE EvMouseWheel_inspect(VALUE self)
|
|
635
642
|
*
|
636
643
|
* @attribute pressed
|
637
644
|
* button is pressed or not
|
638
|
-
* @return [
|
645
|
+
* @return [Boolean]
|
639
646
|
*
|
640
647
|
*/
|
641
648
|
EVENT_ACCESSOR_INT(JoyButton, which, jbutton.which);
|
642
649
|
EVENT_ACCESSOR_UINT8(JoyButton, button, jbutton.button);
|
643
|
-
EVENT_ACCESSOR_BOOL(JoyButton, pressed, jbutton.state)
|
644
|
-
/* @return [
|
650
|
+
EVENT_ACCESSOR_BOOL(JoyButton, pressed, jbutton.state);
|
651
|
+
/* @return [String] inspection string */
|
645
652
|
static VALUE EvJoyButton_inspect(VALUE self)
|
646
653
|
{
|
647
654
|
SDL_Event* ev; Data_Get_Struct(self, SDL_Event, ev);
|
@@ -765,6 +772,7 @@ static VALUE EvJoyHatMotion_inspect(VALUE self)
|
|
765
772
|
* {SDL2::Event::JoyDeviceRemoved joystick disconnected events}).
|
766
773
|
*/
|
767
774
|
EVENT_ACCESSOR_INT(JoyDevice, which, jdevice.which);
|
775
|
+
/* @return [String] inspection string */
|
768
776
|
static VALUE EvJoyDevice_inspect(VALUE self)
|
769
777
|
{
|
770
778
|
SDL_Event* ev; Data_Get_Struct(self, SDL_Event, ev);
|
@@ -785,9 +793,27 @@ static VALUE EvJoyDevice_inspect(VALUE self)
|
|
785
793
|
*/
|
786
794
|
|
787
795
|
|
796
|
+
/*
|
797
|
+
* Document-class: SDL2::Event::ControllerAxisMotion
|
798
|
+
*
|
799
|
+
* This class represents the {SDL2::GameController controller} axis motion events.
|
800
|
+
*
|
801
|
+
* @attribute which
|
802
|
+
* the controller index
|
803
|
+
* @return [Integer]
|
804
|
+
*
|
805
|
+
* @attribute axis
|
806
|
+
* the axis index
|
807
|
+
* @return [Integer]
|
808
|
+
*
|
809
|
+
* @attribute value
|
810
|
+
* the axis value (range: -32768 to -32767, 0 for newtral)
|
811
|
+
* @return [Integer]
|
812
|
+
*/
|
788
813
|
EVENT_ACCESSOR_INT(ControllerAxis, which, caxis.which);
|
789
814
|
EVENT_ACCESSOR_UINT8(ControllerAxis, axis, caxis.axis);
|
790
815
|
EVENT_ACCESSOR_INT(ControllerAxis, value, caxis.value);
|
816
|
+
/* @return [String] inspection string */
|
791
817
|
static VALUE ControllerAxis_inspect(VALUE self)
|
792
818
|
{
|
793
819
|
SDL_Event* ev; Data_Get_Struct(self, SDL_Event, ev);
|
@@ -798,9 +824,33 @@ static VALUE ControllerAxis_inspect(VALUE self)
|
|
798
824
|
ev->caxis.value);
|
799
825
|
}
|
800
826
|
|
827
|
+
/*
|
828
|
+
* Document-class: SDL2::Event::ControllerButton
|
829
|
+
*
|
830
|
+
* This class represents the {SDL2::GameController controller} button events.
|
831
|
+
*
|
832
|
+
* You don't handle the instance
|
833
|
+
* of this class directly, but you handle the instances of
|
834
|
+
* two subclasses of this subclasses:
|
835
|
+
* {SDL2::Event::ControllerButtonDown} and {SDL2::Event::ControllerButtonUp}.
|
836
|
+
*
|
837
|
+
* @attribute which
|
838
|
+
* the controller index
|
839
|
+
* @return [Integer]
|
840
|
+
*
|
841
|
+
* @attribute button
|
842
|
+
* the controller button index
|
843
|
+
* @return [Integer]
|
844
|
+
*
|
845
|
+
* @attribute pressed
|
846
|
+
* button is pressed or not
|
847
|
+
* @return [Boolean]
|
848
|
+
*
|
849
|
+
*/
|
801
850
|
EVENT_ACCESSOR_INT(ControllerButton, which, cbutton.which);
|
802
851
|
EVENT_ACCESSOR_UINT8(ControllerButton, button, cbutton.button);
|
803
852
|
EVENT_ACCESSOR_BOOL(ControllerButton, pressed, cbutton.state);
|
853
|
+
/* @return [String] inspection string */
|
804
854
|
static VALUE ControllerButton_inspect(VALUE self)
|
805
855
|
{
|
806
856
|
SDL_Event* ev; Data_Get_Struct(self, SDL_Event, ev);
|
@@ -811,8 +861,36 @@ static VALUE ControllerButton_inspect(VALUE self)
|
|
811
861
|
SDL_GameControllerGetStringForButton(ev->cbutton.button),
|
812
862
|
INT2BOOLCSTR(ev->cbutton.state));
|
813
863
|
}
|
864
|
+
/*
|
865
|
+
* Document-class: SDL2::Event::ControllerButtonDown
|
866
|
+
*
|
867
|
+
* This class represents the {SDL2::GameController controller} button press events.
|
868
|
+
*/
|
814
869
|
|
870
|
+
/*
|
871
|
+
* Document-class: SDL2::Event::ControllerButtonUp
|
872
|
+
*
|
873
|
+
* This class represents the {SDL2::GameController controller} button release events.
|
874
|
+
*/
|
875
|
+
|
876
|
+
/*
|
877
|
+
* Document-class: SDL2::Event::ControllerDevice
|
878
|
+
*
|
879
|
+
* This class represents {SDL2::GameController controller} device events (connected/disconnected/remapped).
|
880
|
+
*
|
881
|
+
* The event of this event doesn't occur. Only the event of the following subclasses
|
882
|
+
* occur in Ruby/SDL2.
|
883
|
+
*
|
884
|
+
* * {SDL2::Event::ControllerDeviceAdded}
|
885
|
+
* * {SDL2::Event::ControllerDeviceRemoved}
|
886
|
+
* * {SDL2::Event::ControllerDeviceRemapped}
|
887
|
+
*
|
888
|
+
* @attribute which
|
889
|
+
* the controller index
|
890
|
+
* @return [Integer]
|
891
|
+
*/
|
815
892
|
EVENT_ACCESSOR_INT(ControllerDevice, which, cdevice.which);
|
893
|
+
/* @return [String] inspection string */
|
816
894
|
static VALUE ControllerDevice_inspect(VALUE self)
|
817
895
|
{
|
818
896
|
SDL_Event* ev; Data_Get_Struct(self, SDL_Event, ev);
|
@@ -821,6 +899,119 @@ static VALUE ControllerDevice_inspect(VALUE self)
|
|
821
899
|
ev->cdevice.which);
|
822
900
|
}
|
823
901
|
|
902
|
+
/*
|
903
|
+
* Document-class: SDL2::Event::ControllerDeviceAdded
|
904
|
+
*
|
905
|
+
* This class represents {SDL2::GameController controller} device connected events.
|
906
|
+
*/
|
907
|
+
/*
|
908
|
+
* Document-class: SDL2::Event::ControllerDeviceRemoved
|
909
|
+
*
|
910
|
+
* This class represents {SDL2::GameController controller} device disconnected events.
|
911
|
+
*/
|
912
|
+
/*
|
913
|
+
* Document-class: SDL2::Event::ControllerDeviceRemapped
|
914
|
+
*
|
915
|
+
* This class represents {SDL2::GameController controller} device remapped events.
|
916
|
+
*/
|
917
|
+
|
918
|
+
/*
|
919
|
+
* Document-class: SDL2::Event::TouchFinger
|
920
|
+
*
|
921
|
+
* This class represents touch finger events.
|
922
|
+
*
|
923
|
+
* You don't handle the instance
|
924
|
+
* of this class directly, but you handle the instances of
|
925
|
+
* two subclasses of this subclasses:
|
926
|
+
* {SDL2::Event::FingerMotion} and {SDL2::Event::MouseButtonUp}.
|
927
|
+
*
|
928
|
+
* @attribute touch_id
|
929
|
+
* the touch device id
|
930
|
+
* @return [Integer]
|
931
|
+
*
|
932
|
+
* @attribute finger_id
|
933
|
+
* the finger id
|
934
|
+
* @return [Integer]
|
935
|
+
*
|
936
|
+
* @attribute x
|
937
|
+
* the x-axis location of the touch event, normalized (0...1)
|
938
|
+
* @return [Float]
|
939
|
+
*
|
940
|
+
* @attribute y
|
941
|
+
* the y-axis location of the touch event, normalized (0...1)
|
942
|
+
* @return [Float]
|
943
|
+
*
|
944
|
+
* @attribute pressure
|
945
|
+
* the quantity of pressure applied, normalized (0...1)
|
946
|
+
* @return [Float]
|
947
|
+
*/
|
948
|
+
EVENT_ACCESSOR_INT(TouchFinger, touch_id, tfinger.touchId);
|
949
|
+
EVENT_ACCESSOR_INT(TouchFinger, finger_id, tfinger.fingerId);
|
950
|
+
EVENT_ACCESSOR_DBL(TouchFinger, x, tfinger.x);
|
951
|
+
EVENT_ACCESSOR_DBL(TouchFinger, y, tfinger.y);
|
952
|
+
EVENT_ACCESSOR_DBL(TouchFinger, pressure, tfinger.pressure);
|
953
|
+
/* @return [String] inspection string */
|
954
|
+
static VALUE EvTouchFinger_inspect(VALUE self)
|
955
|
+
{
|
956
|
+
SDL_Event* ev; Data_Get_Struct(self, SDL_Event, ev);
|
957
|
+
return rb_sprintf("<%s: type=%u timestamp=%u"
|
958
|
+
" touch_id=%d finger_id=%d"
|
959
|
+
" x=%f y=%f pressure=%f>",
|
960
|
+
rb_obj_classname(self), ev->common.type, ev->common.timestamp,
|
961
|
+
(int)ev->tfinger.touchId, (int)ev->tfinger.fingerId,
|
962
|
+
ev->tfinger.x, ev->tfinger.y, ev->tfinger.pressure);
|
963
|
+
}
|
964
|
+
|
965
|
+
/*
|
966
|
+
* Document-class: SDL2::Event::FingerUp
|
967
|
+
* This class represents finger touch events.
|
968
|
+
*/
|
969
|
+
/*
|
970
|
+
* Document-class: SDL2::Event::FingerDown
|
971
|
+
* This class represents finger release events.
|
972
|
+
*/
|
973
|
+
|
974
|
+
/*
|
975
|
+
* Document-class: SDL2::Event::FingerMotion
|
976
|
+
*
|
977
|
+
* This class represents touch move events.
|
978
|
+
*
|
979
|
+
* @attribute dx
|
980
|
+
* the distance moved in the x-axis, normalized (0...1)
|
981
|
+
* @return [Float]
|
982
|
+
*
|
983
|
+
* @attribute dy
|
984
|
+
* the distance moved in the x-axis, normalized (0...1)
|
985
|
+
* @return [Float]
|
986
|
+
*
|
987
|
+
*/
|
988
|
+
EVENT_ACCESSOR_DBL(FingerMotion, dx, tfinger.dx);
|
989
|
+
EVENT_ACCESSOR_DBL(FingerMotion, dy, tfinger.dy);
|
990
|
+
/* @return [String] inspection string */
|
991
|
+
static VALUE EvFingerMotion_inspect(VALUE self)
|
992
|
+
{
|
993
|
+
SDL_Event* ev; Data_Get_Struct(self, SDL_Event, ev);
|
994
|
+
return rb_sprintf("<%s: type=%u timestamp=%u"
|
995
|
+
" touch_id=%d finger_id=%d"
|
996
|
+
" x=%f y=%f pressure=%f"
|
997
|
+
" dy=%f dx=%f>",
|
998
|
+
rb_obj_classname(self), ev->common.type, ev->common.timestamp,
|
999
|
+
(int) ev->tfinger.touchId, (int) ev->tfinger.fingerId,
|
1000
|
+
ev->tfinger.x, ev->tfinger.y, ev->tfinger.pressure,
|
1001
|
+
ev->tfinger.dx, ev->tfinger.dx);
|
1002
|
+
}
|
1003
|
+
|
1004
|
+
/*
|
1005
|
+
* Document-class: SDL2::Event::SysWM
|
1006
|
+
*
|
1007
|
+
* This class represents video driver dependent system events.
|
1008
|
+
*
|
1009
|
+
* This event is disabled by default. You can enable it with {SDL2::Event.enable=}.
|
1010
|
+
* This event is now useless because now there is no way to get
|
1011
|
+
* driver dependent information from this event class.
|
1012
|
+
* You are encouraged to avoid this event.
|
1013
|
+
*
|
1014
|
+
*/
|
824
1015
|
static void connect_event_class(SDL_EventType type, VALUE klass)
|
825
1016
|
{
|
826
1017
|
event_type_to_class[type] = klass;
|
@@ -856,6 +1047,9 @@ static void init_event_type_to_class(void)
|
|
856
1047
|
connect_event_class(SDL_CONTROLLERDEVICEADDED, cEvControllerDeviceAdded);
|
857
1048
|
connect_event_class(SDL_CONTROLLERDEVICEREMOVED, cEvControllerDeviceRemoved);
|
858
1049
|
connect_event_class(SDL_CONTROLLERDEVICEREMAPPED, cEvControllerDeviceRemapped);
|
1050
|
+
connect_event_class(SDL_FINGERDOWN, cEvFingerDown);
|
1051
|
+
connect_event_class(SDL_FINGERUP, cEvFingerUp);
|
1052
|
+
connect_event_class(SDL_FINGERMOTION, cEvFingerMotion);
|
859
1053
|
}
|
860
1054
|
|
861
1055
|
#define DEFINE_EVENT_READER(classname, classvar, name) \
|
@@ -908,6 +1102,12 @@ void rubysdl2_init_event(void)
|
|
908
1102
|
cEvControllerDeviceAdded = rb_define_class_under(cEvent, "ControllerDeviceAdded", cEvControllerDevice);
|
909
1103
|
cEvControllerDeviceRemoved = rb_define_class_under(cEvent, "ControllerDeviceRemoved", cEvControllerDevice);
|
910
1104
|
cEvControllerDeviceRemapped = rb_define_class_under(cEvent, "ControllerDeviceRemapped", cEvControllerDevice);
|
1105
|
+
cEvTouchFinger = rb_define_class_under(cEvent, "TouchFinger", cEvent);
|
1106
|
+
cEvFingerUp = rb_define_class_under(cEvent, "FingerUp", cEvTouchFinger);
|
1107
|
+
cEvFingerDown = rb_define_class_under(cEvent, "FingerDown", cEvTouchFinger);
|
1108
|
+
cEvFingerMotion = rb_define_class_under(cEvent, "FingerMotion", cEvTouchFinger);
|
1109
|
+
|
1110
|
+
|
911
1111
|
|
912
1112
|
DEFINE_EVENT_READER(Event, cEvent, type);
|
913
1113
|
DEFINE_EVENT_ACCESSOR(Event, cEvent, timestamp);
|
@@ -1022,6 +1222,17 @@ void rubysdl2_init_event(void)
|
|
1022
1222
|
|
1023
1223
|
DEFINE_EVENT_ACCESSOR(ControllerDevice, cEvControllerDevice, which);
|
1024
1224
|
rb_define_method(cEvControllerDevice, "inspect", ControllerDevice_inspect, 0);
|
1225
|
+
|
1226
|
+
DEFINE_EVENT_ACCESSOR(TouchFinger, cEvTouchFinger, touch_id);
|
1227
|
+
DEFINE_EVENT_ACCESSOR(TouchFinger, cEvTouchFinger, finger_id);
|
1228
|
+
DEFINE_EVENT_ACCESSOR(TouchFinger, cEvTouchFinger, x);
|
1229
|
+
DEFINE_EVENT_ACCESSOR(TouchFinger, cEvTouchFinger, y);
|
1230
|
+
DEFINE_EVENT_ACCESSOR(TouchFinger, cEvTouchFinger, pressure);
|
1231
|
+
rb_define_method(cEvTouchFinger, "inspect", EvTouchFinger_inspect, 0);
|
1232
|
+
|
1233
|
+
DEFINE_EVENT_ACCESSOR(FingerMotion, cEvFingerMotion, dx);
|
1234
|
+
DEFINE_EVENT_ACCESSOR(FingerMotion, cEvFingerMotion, dy);
|
1235
|
+
rb_define_method(cEvFingerMotion, "inspect", EvFingerMotion_inspect, 0);
|
1025
1236
|
|
1026
1237
|
init_event_type_to_class();
|
1027
1238
|
}
|
data/filesystem.c
CHANGED
@@ -2,6 +2,16 @@
|
|
2
2
|
#include "rubysdl2_internal.h"
|
3
3
|
#include <SDL_filesystem.h>
|
4
4
|
|
5
|
+
/*
|
6
|
+
* Get the directory where the application was run from.
|
7
|
+
*
|
8
|
+
* In almost all cases, using this method, you will get the directory where ruby executable is in.
|
9
|
+
* Probably what you hope is $0 or __FILE__.
|
10
|
+
*
|
11
|
+
* @return [String] an absolute path in UTF-8 encoding to the application data directory
|
12
|
+
* @raise [SDL2::Error] raised if your platform doesn't implement this functionality.
|
13
|
+
* @note This method is available since SDL 2.0.1.
|
14
|
+
*/
|
5
15
|
static VALUE SDL2_s_base_path(VALUE self)
|
6
16
|
{
|
7
17
|
char* path = SDL_GetBasePath();
|
@@ -13,6 +23,23 @@ static VALUE SDL2_s_base_path(VALUE self)
|
|
13
23
|
return str;
|
14
24
|
}
|
15
25
|
|
26
|
+
/*
|
27
|
+
* @overload preference_path(org, app)
|
28
|
+
* Get the "pref dir". You can use the directory to write personal files such as
|
29
|
+
* preferences and save games.
|
30
|
+
*
|
31
|
+
* The directory is unique per user and per application.
|
32
|
+
*
|
33
|
+
* @param org [String] the name of your organization
|
34
|
+
* @param app [String] the name of your application
|
35
|
+
* @return [String] a UTF-8 string of the user directory in platform-depnedent notation.
|
36
|
+
*
|
37
|
+
* @raise [SDL2::Error] raised if your platform doesn't implement this functionality.
|
38
|
+
* @note This method is available since SDL 2.0.1.
|
39
|
+
*
|
40
|
+
* @example
|
41
|
+
* SDL2.preference_path("foo", "bar") # => "/home/ohai/.local/share/foo/bar/" (on Linux)
|
42
|
+
*/
|
16
43
|
static VALUE SDL2_s_preference_path(VALUE self, VALUE org, VALUE app)
|
17
44
|
{
|
18
45
|
char* path = SDL_GetPrefPath(StringValueCStr(org), StringValueCStr(app));
|