SDLRuby 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +4 -0
  3. data/lib/SDLRuby/event/accessor.rb +62 -63
  4. data/lib/SDLRuby/event/type.rb +1 -1
  5. data/lib/SDLRuby/event.rb +98 -80
  6. data/lib/SDLRuby/sdl/include/SDL.h.rb +11 -0
  7. data/lib/SDLRuby/sdl/include/SDL_audio.h.rb +125 -14
  8. data/lib/SDLRuby/sdl/include/SDL_blendmode.h.rb +24 -0
  9. data/lib/SDLRuby/sdl/include/SDL_endian.h.rb +10 -1
  10. data/lib/SDLRuby/sdl/include/SDL_error.h.rb +21 -2
  11. data/lib/SDLRuby/sdl/include/SDL_events.h.rb +458 -18
  12. data/lib/SDLRuby/sdl/include/SDL_gamecontroller.h.rb +92 -11
  13. data/lib/SDLRuby/sdl/include/SDL_guid.h.rb +10 -4
  14. data/lib/SDLRuby/sdl/include/SDL_hints.h.rb +186 -1
  15. data/lib/SDLRuby/sdl/include/SDL_joystick.h.rb +72 -10
  16. data/lib/SDLRuby/sdl/include/SDL_keyboard.h.rb +13 -4
  17. data/lib/SDLRuby/sdl/include/SDL_keycode.h.rb +287 -2
  18. data/lib/SDLRuby/sdl/include/SDL_locale.h.rb +9 -2
  19. data/lib/SDLRuby/sdl/include/SDL_messagebox.h.rb +50 -2
  20. data/lib/SDLRuby/sdl/include/SDL_mouse.h.rb +39 -8
  21. data/lib/SDLRuby/sdl/include/SDL_pixels.h.rb +271 -11
  22. data/lib/SDLRuby/sdl/include/SDL_rect.h.rb +43 -14
  23. data/lib/SDLRuby/sdl/include/SDL_render.h.rb +112 -75
  24. data/lib/SDLRuby/sdl/include/SDL_rwops.h.rb +63 -19
  25. data/lib/SDLRuby/sdl/include/SDL_scancode.h.rb +248 -1
  26. data/lib/SDLRuby/sdl/include/SDL_shape.h.rb +33 -6
  27. data/lib/SDLRuby/sdl/include/SDL_stdinc.h.rb +42 -4
  28. data/lib/SDLRuby/sdl/include/SDL_surface.h.rb +92 -29
  29. data/lib/SDLRuby/sdl/include/SDL_syswm.h.rb +1 -7
  30. data/lib/SDLRuby/sdl/include/SDL_timer.h.rb +11 -3
  31. data/lib/SDLRuby/sdl/include/SDL_version.h.rb +10 -2
  32. data/lib/SDLRuby/sdl/include/SDL_video.h.rb +221 -74
  33. data/lib/SDLRuby/sdl/sdl.rb +0 -50
  34. data/lib/SDLRuby/sdl.rb +7 -8
  35. data/lib/SDLRuby/version.rb +1 -1
  36. data/sig/lib/SDLRuby/event/accessor.rbs +157 -0
  37. data/sig/lib/SDLRuby/event/type.rbs +67 -0
  38. data/sig/lib/SDLRuby/event.rbs +47 -0
  39. data/sig/lib/SDLRuby/sdl.rbs +655 -0
  40. metadata +6 -22
  41. data/lib/SDLRuby/sdl/sdl_audio.rb +0 -75
  42. data/lib/SDLRuby/sdl/sdl_blendmode.rb +0 -10
  43. data/lib/SDLRuby/sdl/sdl_error.rb +0 -5
  44. data/lib/SDLRuby/sdl/sdl_events.rb +0 -470
  45. data/lib/SDLRuby/sdl/sdl_hints.rb +0 -9
  46. data/lib/SDLRuby/sdl/sdl_keyboard.rb +0 -12
  47. data/lib/SDLRuby/sdl/sdl_locale.rb +0 -8
  48. data/lib/SDLRuby/sdl/sdl_message_box.rb +0 -7
  49. data/lib/SDLRuby/sdl/sdl_mouse.rb +0 -32
  50. data/lib/SDLRuby/sdl/sdl_palette.rb +0 -12
  51. data/lib/SDLRuby/sdl/sdl_pixels.rb +0 -138
  52. data/lib/SDLRuby/sdl/sdl_rect.rb +0 -11
  53. data/lib/SDLRuby/sdl/sdl_render.rb +0 -35
  54. data/lib/SDLRuby/sdl/sdl_rw_ops.rb +0 -29
  55. data/lib/SDLRuby/sdl/sdl_scancode.rb +0 -255
  56. data/lib/SDLRuby/sdl/sdl_surface.rb +0 -27
  57. data/lib/SDLRuby/sdl/sdl_version.rb +0 -5
  58. data/lib/SDLRuby/sdl/sdl_video.rb +0 -104
  59. data/sig/SDLRuby/event.rbs +0 -104
  60. data/sig/SDLRuby/sdl.rbs +0 -606
data/lib/SDLRuby/sdl.rb CHANGED
@@ -77,7 +77,7 @@ module SDLRuby
77
77
  def clipboard_text? = SDL.SDL_HasClipboardText == 1
78
78
 
79
79
  def clipboard_text=(s)
80
- err = SDL.SDL_SetClipboardText(s.encord("UTF-8"))
80
+ err = SDL.SDL_SetClipboardText(s.to_s.encode("UTF-8"))
81
81
  raise SDLError if err < 0
82
82
  end
83
83
 
@@ -94,7 +94,7 @@ module SDLRuby
94
94
  def last_error_message = SDL.SDL_GetError.to_s
95
95
 
96
96
  def last_error_message=(s)
97
- SDL.SDL_SetError(s.gsub(/%/, "%%"), nil)
97
+ SDL.SDL_SetError(s.to_s.gsub(/%/, "%%"))
98
98
  end
99
99
 
100
100
  # filesystem
@@ -109,18 +109,17 @@ module SDLRuby
109
109
 
110
110
  # locale
111
111
  #
112
- # 失敗の時 nil を戻す。
113
- #
114
112
  def locales
115
113
  ptr = SDL.SDL_GetPreferredLocales
116
- return if ptr.null?
114
+ return [] if ptr.null?
117
115
 
118
116
  ptr.free = SDL_FREE
119
- pitch = SDL_Locale.size
117
+ size = SDL_Locale.size
120
118
  (0..).inject([]) do |memo, i|
121
- st = SDL_Locale.new(ptr + i * pitch)
119
+ st = SDL_Locale.new(ptr + i * size)
122
120
  break memo if st.language.null?
123
- memo << [st.language.to_s, st.country.to_s]
121
+ memo << [st.language.to_s,
122
+ (c = st.country).null? ? nil : c.to_s]
124
123
  end
125
124
  end
126
125
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SDLRuby
4
- VERSION = "0.1.0"
4
+ VERSION = "0.2.0"
5
5
  end
@@ -0,0 +1,157 @@
1
+ module SDLRuby
2
+ class Event
3
+ module Accessor
4
+ include SDL
5
+
6
+ def self.[]: (Symbol sym) -> Module
7
+
8
+ def axis: () -> Integer?
9
+
10
+ def ball: () -> Integer?
11
+
12
+ def button: () -> Integer?
13
+
14
+ def clicks: () -> Integer?
15
+
16
+ def code: () -> Integer?
17
+
18
+ def dDist: () -> Float?
19
+
20
+ def dTheta: () -> Float?
21
+
22
+ def data: () -> Array[Float]?
23
+
24
+ def data1: () -> (Integer | untyped)?
25
+
26
+ def data2: () -> (Integer | untyped)?
27
+
28
+ def direction: () -> Integer?
29
+
30
+ def display: () -> Integer?
31
+
32
+ def dx: () -> Integer?
33
+
34
+ def dy: () -> Integer?
35
+
36
+ def error: () -> Float?
37
+
38
+ def event: () -> Integer?
39
+
40
+ def file: () -> String?
41
+
42
+ def finger: () -> Integer?
43
+
44
+ def fingerId: () -> Integer?
45
+
46
+ def gestureId: () -> Integer?
47
+
48
+ def hat: () -> Integer?
49
+
50
+ def iscapture: () -> Integer?
51
+
52
+ def keysym: () -> Hash[String, Integer]?
53
+
54
+ def length: () -> Integer?
55
+
56
+ def level: () -> Integer?
57
+
58
+ def mouseX: () -> Integer?
59
+
60
+ def mouseY: () -> Integer?
61
+
62
+ def msg: () -> untyped?
63
+
64
+ def numFingers: () -> Integer?
65
+
66
+ def padding: () -> void
67
+
68
+ def padding1: () -> void
69
+
70
+ def padding2: () -> void
71
+
72
+ def padding3: () -> void
73
+
74
+ def padding4: () -> void
75
+
76
+ def preciseX: () -> Float?
77
+
78
+ def preciseY: () -> Float?
79
+
80
+ def pressure: () -> Float?
81
+
82
+ def repeat: () -> Integer?
83
+
84
+ def sensor: () -> Integer?
85
+
86
+ def start: () -> Integer?
87
+
88
+ def state: () -> Integer?
89
+
90
+ def text: () -> String?
91
+
92
+ def timestamp: () -> Integer
93
+
94
+ def timestamp_us: () -> Integer?
95
+
96
+ def touchId: () -> Integer?
97
+
98
+ def touchpad: () -> Integer?
99
+
100
+ def type: () -> Integer
101
+
102
+ def value: () -> Integer?
103
+
104
+ def which: () -> Integer?
105
+
106
+ def windowID: () -> Integer?
107
+
108
+ def x: () -> (Integer | Float)?
109
+
110
+ def xrel: () -> Integer?
111
+
112
+ def y: () -> (Integer | Float)?
113
+
114
+ def yrel: () -> Integer?
115
+
116
+ alias d_dist dDist
117
+
118
+ alias d_theta dTheta
119
+
120
+ alias finger_id fingerId
121
+
122
+ alias gesture_id gestureId
123
+
124
+ alias mouse_x mouseX
125
+
126
+ alias mouse_y mouseY
127
+
128
+ alias num_fingers numFingers
129
+
130
+ alias precise_x preciseX
131
+
132
+ alias precise_y preciseY
133
+
134
+ alias touch_id touchId
135
+
136
+ alias window_id windowID
137
+
138
+ def capture?: () -> bool
139
+
140
+ def pressed?: () -> bool
141
+
142
+ def scancode: () -> Integer?
143
+
144
+ def sym: () -> Integer?
145
+
146
+ def mod: () -> Integer?
147
+
148
+ private
149
+
150
+ def char_ary_to_str: (Array[Integer] a) -> ("" | String)
151
+
152
+ def char_ptr_to_str: (untyped ptr) -> ("" | String)
153
+
154
+ def keep_member_pointer: (untyped) -> void
155
+ end
156
+ end
157
+ end
@@ -0,0 +1,67 @@
1
+ module SDLRuby
2
+ class Event
3
+ module Type
4
+ include SDL
5
+
6
+ QUIT_EVENT: ::Range[Integer]
7
+
8
+ DISPLAY_EVENT: ::Range[Integer]
9
+
10
+ WINDOW_EVENT: ::Range[Integer]
11
+
12
+ SYSWM_EVENT: ::Range[Integer]
13
+
14
+ KEY_EVENT: ::Range[Integer]
15
+
16
+ EDIT_EVENT: ::Range[Integer]
17
+
18
+ TEXT_EVENT: ::Range[Integer]
19
+
20
+ EDIT_EXT_EVENT: ::Range[Integer]
21
+
22
+ MOTION_EVENT: ::Range[Integer]
23
+
24
+ BUTTON_EVENT: ::Range[Integer]
25
+
26
+ WHEEL_EVENT: ::Range[Integer]
27
+
28
+ JAXIS_EVENT: ::Range[Integer]
29
+
30
+ JBALL_EVENT: ::Range[Integer]
31
+
32
+ JHAT_EVENT: ::Range[Integer]
33
+
34
+ JBUTTON_EVENT: ::Range[Integer]
35
+
36
+ JDEVICE_EVENT: ::Range[Integer]
37
+
38
+ JBATTERY_EVENT: ::Range[Integer]
39
+
40
+ CAXIS_EVENT: ::Range[Integer]
41
+
42
+ CBUTTON_EVENT: ::Range[Integer]
43
+
44
+ CDEVICE_EVENT: ::Range[Integer]
45
+
46
+ CTOUCHPAD_EVENT: ::Range[Integer]
47
+
48
+ CSENSOR_EVENT: ::Range[Integer]
49
+
50
+ TFINGER_EVENT: ::Range[Integer]
51
+
52
+ DGESTURE_EVENT: ::Range[Integer]
53
+
54
+ MGESTURE_EVENT: ::Range[Integer]
55
+
56
+ DROP_EVENT: ::Range[Integer]
57
+
58
+ ADEVICE_EVENT: ::Range[Integer]
59
+
60
+ SENSOR_EVENT: ::Range[Integer]
61
+
62
+ USER_EVENT: ::Range[Integer]
63
+
64
+ def self.to_sym: (Integer `type`) -> Symbol
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,47 @@
1
+ module SDLRuby
2
+ class Event
3
+ include Accessor
4
+
5
+ include SDL
6
+
7
+ private
8
+
9
+ def self.__malloc__: () -> untyped
10
+
11
+ public
12
+
13
+ def self.clear: () -> void
14
+
15
+ def self.deq: (?bool non_block) -> (self | nil)
16
+
17
+ def self.disable: (Integer `type`) -> void
18
+
19
+ def self.empty?: () -> untyped
20
+
21
+ def self.enable: (Integer `type`) -> void
22
+
23
+ def self.get: () -> Event
24
+
25
+ def self.length: () -> Integer
26
+
27
+ alias self.size self.length
28
+
29
+ def self.quit?: () -> bool
30
+
31
+ def self.reserve: (Integer num) -> Integer
32
+
33
+ def self.update: () -> void
34
+
35
+ def self.wait: (?Integer|Float|Rational? timeout) -> boolish
36
+
37
+ def initialize: (untyped ptr) -> void
38
+
39
+ private
40
+
41
+ attr_reader entity: untyped
42
+
43
+ public
44
+
45
+ def to_ptr: () -> untyped
46
+ end
47
+ end