sfml3-rb 0.2.2 → 0.3.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.
Files changed (137) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +9 -0
  3. data/CHANGELOG.md +43 -17
  4. data/README.md +97 -29
  5. data/ext/audio/audio_enums.c +58 -20
  6. data/ext/audio/listener.c +89 -6
  7. data/ext/audio/music.c +206 -5
  8. data/ext/audio/sound.c +175 -5
  9. data/ext/audio/sound_buffer.c +189 -47
  10. data/ext/audio/sound_buffer_recorder.c +83 -16
  11. data/ext/audio/sound_recorder.c +172 -52
  12. data/ext/audio/sound_source_cone.c +108 -29
  13. data/ext/audio/sound_stream.c +178 -5
  14. data/ext/core/exceptions.c +10 -8
  15. data/ext/core/unicode.c +12 -2
  16. data/ext/ext.c +4 -0
  17. data/ext/graphics/blend_mode.c +203 -53
  18. data/ext/graphics/circle.c +271 -4
  19. data/ext/graphics/color.c +240 -90
  20. data/ext/graphics/drawable.c +15 -4
  21. data/ext/graphics/font.c +138 -25
  22. data/ext/graphics/glyph.c +31 -8
  23. data/ext/graphics/image.c +180 -37
  24. data/ext/graphics/polygon.c +293 -26
  25. data/ext/graphics/rect.c +211 -54
  26. data/ext/graphics/rectangle.c +279 -26
  27. data/ext/graphics/render_state.c +116 -2
  28. data/ext/graphics/render_texture.c +163 -2
  29. data/ext/graphics/shader.c +283 -17
  30. data/ext/graphics/shape.c +252 -26
  31. data/ext/graphics/sprite.c +216 -25
  32. data/ext/graphics/stencil_mode.c +148 -39
  33. data/ext/graphics/target.c +67 -22
  34. data/ext/graphics/target.h +15 -15
  35. data/ext/graphics/text.c +306 -6
  36. data/ext/graphics/texture.c +257 -3
  37. data/ext/graphics/transform.c +178 -5
  38. data/ext/graphics/transformable.c +126 -2
  39. data/ext/graphics/vertex.c +79 -2
  40. data/ext/graphics/vertex_array.c +128 -16
  41. data/ext/graphics/vertex_buffer.c +124 -2
  42. data/ext/graphics/view.c +130 -2
  43. data/ext/network/ftp.c +249 -10
  44. data/ext/network/http.c +156 -38
  45. data/ext/network/ip_address.c +107 -26
  46. data/ext/network/network_enums.c +248 -141
  47. data/ext/network/packet.c +273 -39
  48. data/ext/network/socket_selector.c +91 -19
  49. data/ext/network/tcp_listener.c +75 -16
  50. data/ext/network/tcp_socket.c +128 -25
  51. data/ext/network/udp_socket.c +122 -26
  52. data/ext/ports.rb +7 -0
  53. data/ext/system/buffer.c +41 -12
  54. data/ext/system/clock.c +68 -9
  55. data/ext/system/input_stream.c +94 -42
  56. data/ext/system/sleep.c +10 -2
  57. data/ext/system/time.c +172 -34
  58. data/ext/system/vec2.c +156 -35
  59. data/ext/system/vec3.c +166 -35
  60. data/ext/window/clipboard.c +47 -17
  61. data/ext/window/context.c +59 -9
  62. data/ext/window/context_settings.c +116 -38
  63. data/ext/window/cursor.c +39 -9
  64. data/ext/window/event.c +163 -42
  65. data/ext/window/joystick.c +69 -3
  66. data/ext/window/keyboard.c +168 -116
  67. data/ext/window/mouse.c +36 -2
  68. data/ext/window/sensor.c +28 -2
  69. data/ext/window/touch.c +20 -2
  70. data/ext/window/video_mode.c +90 -19
  71. data/ext/window/vulkan.c +34 -6
  72. data/ext/window/window.c +340 -16
  73. data/lib/sfml/version.rb +1 -1
  74. data/sig/audio/audio_enums.rbs +30 -0
  75. data/sig/audio/listener.rbs +16 -0
  76. data/sig/audio/music.rbs +56 -0
  77. data/sig/audio/sound.rbs +51 -0
  78. data/sig/audio/sound_buffer.rbs +17 -0
  79. data/sig/audio/sound_buffer_recorder.rbs +14 -0
  80. data/sig/audio/sound_recorder.rbs +17 -0
  81. data/sig/audio/sound_source_cone.rbs +14 -0
  82. data/sig/audio/sound_stream.rbs +51 -0
  83. data/sig/graphics/blend_mode.rbs +29 -0
  84. data/sig/graphics/circle.rbs +44 -0
  85. data/sig/graphics/color.rbs +39 -0
  86. data/sig/graphics/drawable.rbs +5 -0
  87. data/sig/graphics/font.rbs +20 -0
  88. data/sig/graphics/glyph.rbs +7 -0
  89. data/sig/graphics/image.rbs +22 -0
  90. data/sig/graphics/polygon.rbs +42 -0
  91. data/sig/graphics/rect.rbs +33 -0
  92. data/sig/graphics/rectangle.rbs +42 -0
  93. data/sig/graphics/render_state.rbs +21 -0
  94. data/sig/graphics/render_texture.rbs +37 -0
  95. data/sig/graphics/shader.rbs +39 -0
  96. data/sig/graphics/shape.rbs +38 -0
  97. data/sig/graphics/sprite.rbs +34 -0
  98. data/sig/graphics/stencil_mode.rbs +18 -0
  99. data/sig/graphics/target.rbs +10 -0
  100. data/sig/graphics/text.rbs +48 -0
  101. data/sig/graphics/texture.rbs +34 -0
  102. data/sig/graphics/transform.rbs +37 -0
  103. data/sig/graphics/transformable.rbs +25 -0
  104. data/sig/graphics/vertex.rbs +17 -0
  105. data/sig/graphics/vertex_array.rbs +17 -0
  106. data/sig/graphics/vertex_buffer.rbs +22 -0
  107. data/sig/graphics/view.rbs +24 -0
  108. data/sig/network/ftp.rbs +46 -0
  109. data/sig/network/http.rbs +27 -0
  110. data/sig/network/ip_address.rbs +22 -0
  111. data/sig/network/network_enums.rbs +95 -0
  112. data/sig/network/packet.rbs +40 -0
  113. data/sig/network/socket_selector.rbs +14 -0
  114. data/sig/network/tcp_listener.rbs +13 -0
  115. data/sig/network/tcp_socket.rbs +18 -0
  116. data/sig/network/udp_socket.rbs +17 -0
  117. data/sig/system/buffer.rbs +11 -0
  118. data/sig/system/clock.rbs +13 -0
  119. data/sig/system/input_stream.rbs +7 -0
  120. data/sig/system/sleep.rbs +3 -0
  121. data/sig/system/time.rbs +28 -0
  122. data/sig/system/vec2.rbs +26 -0
  123. data/sig/system/vec3.rbs +27 -0
  124. data/sig/window/clipboard.rbs +8 -0
  125. data/sig/window/context.rbs +11 -0
  126. data/sig/window/context_settings.rbs +20 -0
  127. data/sig/window/cursor.rbs +6 -0
  128. data/sig/window/event.rbs +20 -0
  129. data/sig/window/joystick.rbs +15 -0
  130. data/sig/window/keyboard.rbs +10 -0
  131. data/sig/window/mouse.rbs +9 -0
  132. data/sig/window/sensor.rbs +8 -0
  133. data/sig/window/touch.rbs +6 -0
  134. data/sig/window/video_mode.rbs +16 -0
  135. data/sig/window/vulkan.rbs +7 -0
  136. data/sig/window/window.rbs +57 -0
  137. metadata +66 -2
@@ -11,125 +11,125 @@
11
11
  /* Indexed by sfKeyCode rather than by position: if upstream reorders or
12
12
  removes a key, this fails to compile instead of silently renaming every
13
13
  key after the change. sfKeyUnknown is -1 and so has no entry. */
14
- static const char *keys[] = {
15
- [sfKeyA] = "a",
16
- [sfKeyB] = "b",
17
- [sfKeyC] = "c",
18
- [sfKeyD] = "d",
19
- [sfKeyE] = "e",
20
- [sfKeyF] = "f",
21
- [sfKeyG] = "g",
22
- [sfKeyH] = "h",
23
- [sfKeyI] = "i",
24
- [sfKeyJ] = "j",
25
- [sfKeyK] = "k",
26
- [sfKeyL] = "l",
27
- [sfKeyM] = "m",
28
- [sfKeyN] = "n",
29
- [sfKeyO] = "o",
30
- [sfKeyP] = "p",
31
- [sfKeyQ] = "q",
32
- [sfKeyR] = "r",
33
- [sfKeyS] = "s",
34
- [sfKeyT] = "t",
35
- [sfKeyU] = "u",
36
- [sfKeyV] = "v",
37
- [sfKeyW] = "w",
38
- [sfKeyX] = "x",
39
- [sfKeyY] = "y",
40
- [sfKeyZ] = "z",
41
- [sfKeyNum0] = "num0",
42
- [sfKeyNum1] = "num1",
43
- [sfKeyNum2] = "num2",
44
- [sfKeyNum3] = "num3",
45
- [sfKeyNum4] = "num4",
46
- [sfKeyNum5] = "num5",
47
- [sfKeyNum6] = "num6",
48
- [sfKeyNum7] = "num7",
49
- [sfKeyNum8] = "num8",
50
- [sfKeyNum9] = "num9",
51
- [sfKeyEscape] = "escape",
52
- [sfKeyLControl] = "LControl",
53
- [sfKeyLShift] = "LShift",
54
- [sfKeyLAlt] = "LAlt",
55
- [sfKeyLSystem] = "LSystem",
56
- [sfKeyRControl] = "RControl",
57
- [sfKeyRShift] = "RShift",
58
- [sfKeyRAlt] = "RAlt",
59
- [sfKeyRSystem] = "RSystem",
60
- [sfKeyMenu] = "Menu",
61
- [sfKeyLBracket] = "LBracket",
62
- [sfKeyRBracket] = "RBracket",
63
- [sfKeySemicolon] = "Semicolon",
64
- [sfKeyComma] = "Comma",
65
- [sfKeyPeriod] = "Period",
66
- [sfKeyApostrophe] = "Quote",
67
- [sfKeySlash] = "Slash",
68
- [sfKeyBackslash] = "Backslash",
69
- [sfKeyGrave] = "Tilde",
70
- [sfKeyEqual] = "Equal",
71
- [sfKeyHyphen] = "Hyphen",
72
- [sfKeySpace] = "Space",
73
- [sfKeyEnter] = "Enter",
74
- [sfKeyBackspace] = "Backspace",
75
- [sfKeyTab] = "Tab",
76
- [sfKeyPageUp] = "PageUp",
77
- [sfKeyPageDown] = "PageDown",
78
- [sfKeyEnd] = "End",
79
- [sfKeyHome] = "Home",
80
- [sfKeyInsert] = "Insert",
81
- [sfKeyDelete] = "Delete",
82
- [sfKeyAdd] = "Add",
83
- [sfKeySubtract] = "Subtract",
84
- [sfKeyMultiply] = "Multiply",
85
- [sfKeyDivide] = "Divide",
86
- [sfKeyLeft] = "Left",
87
- [sfKeyRight] = "Right",
88
- [sfKeyUp] = "Up",
89
- [sfKeyDown] = "Down",
90
- [sfKeyNumpad0] = "Numpad0",
91
- [sfKeyNumpad1] = "Numpad1",
92
- [sfKeyNumpad2] = "Numpad2",
93
- [sfKeyNumpad3] = "Numpad3",
94
- [sfKeyNumpad4] = "Numpad4",
95
- [sfKeyNumpad5] = "Numpad5",
96
- [sfKeyNumpad6] = "Numpad6",
97
- [sfKeyNumpad7] = "Numpad7",
98
- [sfKeyNumpad8] = "Numpad8",
99
- [sfKeyNumpad9] = "Numpad9",
100
- [sfKeyF1] = "f1",
101
- [sfKeyF2] = "f2",
102
- [sfKeyF3] = "f3",
103
- [sfKeyF4] = "f4",
104
- [sfKeyF5] = "f5",
105
- [sfKeyF6] = "f6",
106
- [sfKeyF7] = "f7",
107
- [sfKeyF8] = "f8",
108
- [sfKeyF9] = "f9",
109
- [sfKeyF10] = "f10",
110
- [sfKeyF11] = "f11",
111
- [sfKeyF12] = "f12",
112
- [sfKeyF13] = "f13",
113
- [sfKeyF14] = "f14",
114
- [sfKeyF15] = "f15",
115
- [sfKeyPause] = "pause",
14
+ static const char* keys[] = {
15
+ [sfKeyA] = "a",
16
+ [sfKeyB] = "b",
17
+ [sfKeyC] = "c",
18
+ [sfKeyD] = "d",
19
+ [sfKeyE] = "e",
20
+ [sfKeyF] = "f",
21
+ [sfKeyG] = "g",
22
+ [sfKeyH] = "h",
23
+ [sfKeyI] = "i",
24
+ [sfKeyJ] = "j",
25
+ [sfKeyK] = "k",
26
+ [sfKeyL] = "l",
27
+ [sfKeyM] = "m",
28
+ [sfKeyN] = "n",
29
+ [sfKeyO] = "o",
30
+ [sfKeyP] = "p",
31
+ [sfKeyQ] = "q",
32
+ [sfKeyR] = "r",
33
+ [sfKeyS] = "s",
34
+ [sfKeyT] = "t",
35
+ [sfKeyU] = "u",
36
+ [sfKeyV] = "v",
37
+ [sfKeyW] = "w",
38
+ [sfKeyX] = "x",
39
+ [sfKeyY] = "y",
40
+ [sfKeyZ] = "z",
41
+ [sfKeyNum0] = "num0",
42
+ [sfKeyNum1] = "num1",
43
+ [sfKeyNum2] = "num2",
44
+ [sfKeyNum3] = "num3",
45
+ [sfKeyNum4] = "num4",
46
+ [sfKeyNum5] = "num5",
47
+ [sfKeyNum6] = "num6",
48
+ [sfKeyNum7] = "num7",
49
+ [sfKeyNum8] = "num8",
50
+ [sfKeyNum9] = "num9",
51
+ [sfKeyEscape] = "escape",
52
+ [sfKeyLControl] = "LControl",
53
+ [sfKeyLShift] = "LShift",
54
+ [sfKeyLAlt] = "LAlt",
55
+ [sfKeyLSystem] = "LSystem",
56
+ [sfKeyRControl] = "RControl",
57
+ [sfKeyRShift] = "RShift",
58
+ [sfKeyRAlt] = "RAlt",
59
+ [sfKeyRSystem] = "RSystem",
60
+ [sfKeyMenu] = "Menu",
61
+ [sfKeyLBracket] = "LBracket",
62
+ [sfKeyRBracket] = "RBracket",
63
+ [sfKeySemicolon] = "Semicolon",
64
+ [sfKeyComma] = "Comma",
65
+ [sfKeyPeriod] = "Period",
66
+ [sfKeyApostrophe] = "Quote",
67
+ [sfKeySlash] = "Slash",
68
+ [sfKeyBackslash] = "Backslash",
69
+ [sfKeyGrave] = "Tilde",
70
+ [sfKeyEqual] = "Equal",
71
+ [sfKeyHyphen] = "Hyphen",
72
+ [sfKeySpace] = "Space",
73
+ [sfKeyEnter] = "Enter",
74
+ [sfKeyBackspace] = "Backspace",
75
+ [sfKeyTab] = "Tab",
76
+ [sfKeyPageUp] = "PageUp",
77
+ [sfKeyPageDown] = "PageDown",
78
+ [sfKeyEnd] = "End",
79
+ [sfKeyHome] = "Home",
80
+ [sfKeyInsert] = "Insert",
81
+ [sfKeyDelete] = "Delete",
82
+ [sfKeyAdd] = "Add",
83
+ [sfKeySubtract] = "Subtract",
84
+ [sfKeyMultiply] = "Multiply",
85
+ [sfKeyDivide] = "Divide",
86
+ [sfKeyLeft] = "Left",
87
+ [sfKeyRight] = "Right",
88
+ [sfKeyUp] = "Up",
89
+ [sfKeyDown] = "Down",
90
+ [sfKeyNumpad0] = "Numpad0",
91
+ [sfKeyNumpad1] = "Numpad1",
92
+ [sfKeyNumpad2] = "Numpad2",
93
+ [sfKeyNumpad3] = "Numpad3",
94
+ [sfKeyNumpad4] = "Numpad4",
95
+ [sfKeyNumpad5] = "Numpad5",
96
+ [sfKeyNumpad6] = "Numpad6",
97
+ [sfKeyNumpad7] = "Numpad7",
98
+ [sfKeyNumpad8] = "Numpad8",
99
+ [sfKeyNumpad9] = "Numpad9",
100
+ [sfKeyF1] = "f1",
101
+ [sfKeyF2] = "f2",
102
+ [sfKeyF3] = "f3",
103
+ [sfKeyF4] = "f4",
104
+ [sfKeyF5] = "f5",
105
+ [sfKeyF6] = "f6",
106
+ [sfKeyF7] = "f7",
107
+ [sfKeyF8] = "f8",
108
+ [sfKeyF9] = "f9",
109
+ [sfKeyF10] = "f10",
110
+ [sfKeyF11] = "f11",
111
+ [sfKeyF12] = "f12",
112
+ [sfKeyF13] = "f13",
113
+ [sfKeyF14] = "f14",
114
+ [sfKeyF15] = "f15",
115
+ [sfKeyPause] = "pause",
116
116
  };
117
117
 
118
118
  #define LENGTH_KEYS (sizeof(keys) / sizeof(keys[0]))
119
119
 
120
- int find_key(const char *name) {
120
+ int find_key(const char* name) {
121
121
  size_t i;
122
122
 
123
123
  for (i = 0; i < LENGTH_KEYS; i++) {
124
124
  if (keys[i] != NULL && strcmp(keys[i], name) == 0) {
125
- return (int) i;
125
+ return (int)i;
126
126
  }
127
127
  }
128
128
 
129
129
  return -1;
130
130
  }
131
131
 
132
- const char *get_key_event(unsigned int key) {
132
+ const char* get_key_event(unsigned int key) {
133
133
  if (key < LENGTH_KEYS && keys[key] != NULL) {
134
134
  return keys[key];
135
135
  }
@@ -141,7 +141,7 @@ static int Keyboard_key_code(VALUE rb_key) {
141
141
  int code;
142
142
 
143
143
  if (SYMBOL_P(rb_key)) {
144
- const char *name = rb_id2name(SYM2ID(rb_key));
144
+ const char* name = rb_id2name(SYM2ID(rb_key));
145
145
 
146
146
  code = find_key(name);
147
147
 
@@ -153,7 +153,7 @@ static int Keyboard_key_code(VALUE rb_key) {
153
153
  }
154
154
 
155
155
  if (RB_TYPE_P(rb_key, T_STRING)) {
156
- const char *name = StringValueCStr(rb_key);
156
+ const char* name = StringValueCStr(rb_key);
157
157
 
158
158
  code = find_key(name);
159
159
 
@@ -167,41 +167,93 @@ static int Keyboard_key_code(VALUE rb_key) {
167
167
  return NUM2INT(rb_key);
168
168
  }
169
169
 
170
+ /* call-seq:
171
+ * pressed?(key) -> true or false
172
+ *
173
+ * +key+ may be a key Symbol (e.g. +:a+, +:Enter+, +:LShift+), a String key
174
+ * name, or an Integer key code.
175
+ *
176
+ * @return [Boolean]
177
+ * @raise [ArgumentError] if +key+ is a Symbol/String naming an unknown key
178
+ */
170
179
  static VALUE Keyboard_pressed_p(VALUE module, VALUE rb_key) {
171
- return BOOL2RB(sfKeyboard_isKeyPressed((sfKeyCode) Keyboard_key_code(rb_key)));
180
+ return BOOL2RB(sfKeyboard_isKeyPressed((sfKeyCode)Keyboard_key_code(rb_key)));
172
181
  }
173
182
 
183
+ /* call-seq:
184
+ * scancode_pressed?(scancode) -> true or false
185
+ *
186
+ * Unlike #pressed?, +scancode+ identifies a physical key position rather
187
+ * than the character it currently produces.
188
+ *
189
+ * @return [Boolean]
190
+ */
174
191
  static VALUE Keyboard_scancode_pressed_p(VALUE module, VALUE rb_scancode) {
175
- return BOOL2RB(sfKeyboard_isScancodePressed((sfScancode) NUM2INT(rb_scancode)));
192
+ return BOOL2RB(sfKeyboard_isScancodePressed((sfScancode)NUM2INT(rb_scancode)));
176
193
  }
177
194
 
195
+ /* call-seq:
196
+ * localize(scancode) -> Symbol
197
+ *
198
+ * Returns the key Symbol that +scancode+ produces on the current layout.
199
+ *
200
+ * @return [Symbol] the key that +scancode+ produces on the current keyboard
201
+ * layout
202
+ */
178
203
  static VALUE Keyboard_localize(VALUE module, VALUE rb_scancode) {
179
- return ID2SYM(rb_intern(get_key_event((unsigned int) sfKeyboard_localize((sfScancode) NUM2INT(rb_scancode)))));
204
+ return ID2SYM(rb_intern(
205
+ get_key_event((unsigned int)sfKeyboard_localize((sfScancode)NUM2INT(rb_scancode)))));
180
206
  }
181
207
 
208
+ /* call-seq:
209
+ * delocalize(key) -> Integer
210
+ *
211
+ * Returns the scancode that produces +key+ on the current keyboard layout.
212
+ *
213
+ * @return [Integer] the scancode that produces +key+ on the current keyboard
214
+ * layout
215
+ * @raise [ArgumentError] if +key+ is a Symbol/String naming an unknown key
216
+ */
182
217
  static VALUE Keyboard_delocalize(VALUE module, VALUE rb_key) {
183
- return INT2NUM(sfKeyboard_delocalize((sfKeyCode) Keyboard_key_code(rb_key)));
218
+ return INT2NUM(sfKeyboard_delocalize((sfKeyCode)Keyboard_key_code(rb_key)));
184
219
  }
185
220
 
221
+ /* call-seq:
222
+ * description(scancode) -> String
223
+ *
224
+ * Returns a human-readable, localized name for +scancode+.
225
+ *
226
+ * @return [String] a human-readable, localized name for +scancode+
227
+ */
186
228
  static VALUE Keyboard_description(VALUE module, VALUE rb_scancode) {
187
- const char *description = sfKeyboard_getDescription((sfScancode) NUM2INT(rb_scancode));
229
+ const char* description = sfKeyboard_getDescription((sfScancode)NUM2INT(rb_scancode));
188
230
 
189
231
  return rb_str_new_cstr(description != NULL ? description : "");
190
232
  }
191
233
 
234
+ /* call-seq:
235
+ * virtual_keyboard_visible=(value) -> true or false
236
+ *
237
+ * Shows or hides the on-screen keyboard, where the platform provides one.
238
+ *
239
+ * @return [Boolean] +value+
240
+ */
192
241
  static VALUE Keyboard_set_virtual_keyboard_visible(VALUE module, VALUE rb_visible) {
193
242
  sfKeyboard_setVirtualKeyboardVisible(RTEST(rb_visible));
194
243
  return rb_visible;
195
244
  }
196
245
 
197
- void Init_Keyboard(VALUE rb_module) {
198
- VALUE rb_mKeyboard = rb_define_module_under(rb_module, "Keyboard");
246
+ /* Document-module: SFML::Keyboard
247
+ * Real-time keyboard state and key/scancode lookups.
248
+ */
249
+ void Init_Keyboard(VALUE rb_mSFML) {
250
+ VALUE rb_mKeyboard = rb_define_module_under(rb_mSFML, "Keyboard");
199
251
 
200
252
  rb_define_module_function(rb_mKeyboard, "pressed?", Keyboard_pressed_p, 1);
201
253
  rb_define_module_function(rb_mKeyboard, "scancode_pressed?", Keyboard_scancode_pressed_p, 1);
202
254
  rb_define_module_function(rb_mKeyboard, "localize", Keyboard_localize, 1);
203
255
  rb_define_module_function(rb_mKeyboard, "delocalize", Keyboard_delocalize, 1);
204
256
  rb_define_module_function(rb_mKeyboard, "description", Keyboard_description, 1);
205
- rb_define_module_function(rb_mKeyboard, "virtual_keyboard_visible=",
206
- Keyboard_set_virtual_keyboard_visible, 1);
257
+ rb_define_module_function(
258
+ rb_mKeyboard, "virtual_keyboard_visible=", Keyboard_set_virtual_keyboard_visible, 1);
207
259
  }
data/ext/window/mouse.c CHANGED
@@ -23,10 +23,26 @@ static const sfRenderWindow* Mouse_relative_window(VALUE rb_window) {
23
23
  return Get_Window_Struct(rb_window);
24
24
  }
25
25
 
26
+ /* call-seq:
27
+ * button_pressed?(button) -> true or false
28
+ *
29
+ * Returns +true+ if +button+ is currently pressed.
30
+ *
31
+ * @return [Boolean] whether +button+ (a Symbol like +:left+, +:right+,
32
+ * +:middle+, or an Integer) is currently pressed
33
+ */
26
34
  static VALUE Mouse_is_button_pressed(VALUE module, VALUE rb_button) {
27
35
  return BOOL2RB(sfMouse_isButtonPressed(mouse_button_from_rb(rb_button)));
28
36
  }
29
37
 
38
+ /* call-seq:
39
+ * position(window = nil) -> Vector2
40
+ *
41
+ * Returns the mouse position in desktop coordinates, or relative to +window+.
42
+ *
43
+ * @return [Vector2] the mouse position in desktop coordinates, or relative
44
+ * to +window+'s client area when given
45
+ */
30
46
  static VALUE Mouse_get_position(int argc, VALUE* argv, VALUE module) {
31
47
  VALUE rb_window;
32
48
  sfVector2i position;
@@ -41,6 +57,14 @@ static VALUE Mouse_get_position(int argc, VALUE* argv, VALUE module) {
41
57
  return vec2f_to_rb((sfVector2f){(float)position.x, (float)position.y});
42
58
  }
43
59
 
60
+ /* call-seq:
61
+ * set_position(position, window = nil) -> position
62
+ *
63
+ * Moves the mouse cursor to +position+, in desktop coordinates, or relative
64
+ * to +window+'s client area when given.
65
+ *
66
+ * @return [Vector2] +position+
67
+ */
44
68
  static VALUE Mouse_set_position(int argc, VALUE* argv, VALUE module) {
45
69
  VALUE rb_position, rb_window;
46
70
 
@@ -55,12 +79,22 @@ static VALUE Mouse_set_position(int argc, VALUE* argv, VALUE module) {
55
79
  return rb_position;
56
80
  }
57
81
 
82
+ /* call-seq:
83
+ * position=(value) -> value
84
+ *
85
+ * Moves the mouse cursor to +value+, in desktop coordinates.
86
+ *
87
+ * @return [Vector2] +value+
88
+ */
58
89
  static VALUE Mouse_position_eq(VALUE module, VALUE rb_position) {
59
90
  return Mouse_set_position(1, &rb_position, module);
60
91
  }
61
92
 
62
- void Init_Mouse(VALUE rb_module) {
63
- VALUE rb_mMouse = rb_define_module_under(rb_module, "Mouse");
93
+ /* Document-module: SFML::Mouse
94
+ * Real-time mouse state and cursor positioning.
95
+ */
96
+ void Init_Mouse(VALUE rb_mSFML) {
97
+ VALUE rb_mMouse = rb_define_module_under(rb_mSFML, "Mouse");
64
98
 
65
99
  rb_define_module_function(rb_mMouse, "button_pressed?", Mouse_is_button_pressed, 1);
66
100
  rb_define_module_function(rb_mMouse, "pressed?", Mouse_is_button_pressed, 1);
data/ext/window/sensor.c CHANGED
@@ -7,21 +7,47 @@
7
7
  #include "core/macros.h"
8
8
  #include "core/sfml.h"
9
9
 
10
+ /* call-seq:
11
+ * available?(type) -> true or false
12
+ *
13
+ * Returns +true+ if sensor +type+ is available on this device.
14
+ *
15
+ * @return [Boolean] whether sensor +type+ (a Symbol like
16
+ * +:accelerometer+, +:gyroscope+) is available on this device
17
+ */
10
18
  static VALUE Sensor_is_available(VALUE module, VALUE rb_type) {
11
19
  return BOOL2RB(sfSensor_isAvailable(sensor_type_from_rb(rb_type)));
12
20
  }
13
21
 
22
+ /* call-seq:
23
+ * set_enabled(type, value) -> value
24
+ *
25
+ * Enables or disables sensor +type+. All sensors are disabled by default.
26
+ *
27
+ * @return [Boolean] +value+
28
+ */
14
29
  static VALUE Sensor_set_enabled(VALUE module, VALUE rb_type, VALUE rb_enabled) {
15
30
  sfSensor_setEnabled(sensor_type_from_rb(rb_type), RTEST(rb_enabled));
16
31
  return rb_enabled;
17
32
  }
18
33
 
34
+ /* call-seq:
35
+ * value(type) -> Vector3
36
+ *
37
+ * Returns the current value of sensor +type+.
38
+ *
39
+ * @return [Vector3] the current value of sensor +type+
40
+ */
19
41
  static VALUE Sensor_get_value(VALUE module, VALUE rb_type) {
20
42
  return vec3f_to_rb(sfSensor_getValue(sensor_type_from_rb(rb_type)));
21
43
  }
22
44
 
23
- void Init_Sensor(VALUE rb_module) {
24
- VALUE rb_mSensor = rb_define_module_under(rb_module, "Sensor");
45
+ /* Document-module: SFML::Sensor
46
+ * Access to hardware sensors (accelerometer, gyroscope, etc.), mainly
47
+ * relevant on mobile platforms.
48
+ */
49
+ void Init_Sensor(VALUE rb_mSFML) {
50
+ VALUE rb_mSensor = rb_define_module_under(rb_mSFML, "Sensor");
25
51
 
26
52
  rb_define_module_function(rb_mSensor, "available?", Sensor_is_available, 1);
27
53
  rb_define_module_function(rb_mSensor, "set_enabled", Sensor_set_enabled, 2);
data/ext/window/touch.c CHANGED
@@ -22,10 +22,25 @@ static const sfRenderWindow* Touch_relative_window(VALUE rb_window) {
22
22
  return Get_Window_Struct(rb_window);
23
23
  }
24
24
 
25
+ /* call-seq:
26
+ * down?(finger) -> true or false
27
+ *
28
+ * Returns +true+ if touch point +finger+ is currently down.
29
+ *
30
+ * @return [Boolean] whether touch point +finger+ is currently down
31
+ */
25
32
  static VALUE Touch_is_down(VALUE module, VALUE rb_finger) {
26
33
  return BOOL2RB(sfTouch_isDown(NUM2UINT(rb_finger)));
27
34
  }
28
35
 
36
+ /* call-seq:
37
+ * position(finger, window = nil) -> Vector2
38
+ *
39
+ * Returns the position of touch point +finger+.
40
+ *
41
+ * @return [Vector2] the position of touch point +finger+, in desktop
42
+ * coordinates, or relative to +window+'s client area when given
43
+ */
29
44
  static VALUE Touch_get_position(int argc, VALUE* argv, VALUE module) {
30
45
  VALUE rb_finger, rb_window;
31
46
  sfVector2i position;
@@ -41,8 +56,11 @@ static VALUE Touch_get_position(int argc, VALUE* argv, VALUE module) {
41
56
  return vec2f_to_rb((sfVector2f){(float)position.x, (float)position.y});
42
57
  }
43
58
 
44
- void Init_Touch(VALUE rb_module) {
45
- VALUE rb_mTouch = rb_define_module_under(rb_module, "Touch");
59
+ /* Document-module: SFML::Touch
60
+ * Real-time touch-screen state.
61
+ */
62
+ void Init_Touch(VALUE rb_mSFML) {
63
+ VALUE rb_mTouch = rb_define_module_under(rb_mSFML, "Touch");
46
64
 
47
65
  rb_define_module_function(rb_mTouch, "down?", Touch_is_down, 1);
48
66
  rb_define_module_function(rb_mTouch, "position", Touch_get_position, -1);