rubygame 2.2.0-mswin32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (94) hide show
  1. data/CREDITS +60 -0
  2. data/LICENSE +504 -0
  3. data/NEWS +201 -0
  4. data/README +139 -0
  5. data/ROADMAP +43 -0
  6. data/Rakefile +409 -0
  7. data/doc/extended_readme.rdoc +49 -0
  8. data/doc/getting_started.rdoc +47 -0
  9. data/doc/macosx_install.rdoc +70 -0
  10. data/doc/windows_install.rdoc +127 -0
  11. data/ext/rubygame/MANIFEST +25 -0
  12. data/ext/rubygame/rubygame_core.so +0 -0
  13. data/ext/rubygame/rubygame_event.c +644 -0
  14. data/ext/rubygame/rubygame_event.h +48 -0
  15. data/ext/rubygame/rubygame_event.obj +0 -0
  16. data/ext/rubygame/rubygame_gfx.c +942 -0
  17. data/ext/rubygame/rubygame_gfx.h +101 -0
  18. data/ext/rubygame/rubygame_gfx.obj +0 -0
  19. data/ext/rubygame/rubygame_gfx.so +0 -0
  20. data/ext/rubygame/rubygame_gl.c +154 -0
  21. data/ext/rubygame/rubygame_gl.h +32 -0
  22. data/ext/rubygame/rubygame_gl.obj +0 -0
  23. data/ext/rubygame/rubygame_image.c +108 -0
  24. data/ext/rubygame/rubygame_image.h +41 -0
  25. data/ext/rubygame/rubygame_image.obj +0 -0
  26. data/ext/rubygame/rubygame_image.so +0 -0
  27. data/ext/rubygame/rubygame_joystick.c +247 -0
  28. data/ext/rubygame/rubygame_joystick.h +41 -0
  29. data/ext/rubygame/rubygame_joystick.obj +0 -0
  30. data/ext/rubygame/rubygame_main.c +155 -0
  31. data/ext/rubygame/rubygame_main.h +33 -0
  32. data/ext/rubygame/rubygame_main.obj +0 -0
  33. data/ext/rubygame/rubygame_mixer.c +764 -0
  34. data/ext/rubygame/rubygame_mixer.h +62 -0
  35. data/ext/rubygame/rubygame_mixer.obj +0 -0
  36. data/ext/rubygame/rubygame_mixer.so +0 -0
  37. data/ext/rubygame/rubygame_screen.c +448 -0
  38. data/ext/rubygame/rubygame_screen.h +43 -0
  39. data/ext/rubygame/rubygame_screen.obj +0 -0
  40. data/ext/rubygame/rubygame_shared.c +209 -0
  41. data/ext/rubygame/rubygame_shared.h +60 -0
  42. data/ext/rubygame/rubygame_shared.obj +0 -0
  43. data/ext/rubygame/rubygame_surface.c +1147 -0
  44. data/ext/rubygame/rubygame_surface.h +62 -0
  45. data/ext/rubygame/rubygame_surface.obj +0 -0
  46. data/ext/rubygame/rubygame_time.c +183 -0
  47. data/ext/rubygame/rubygame_time.h +32 -0
  48. data/ext/rubygame/rubygame_time.obj +0 -0
  49. data/ext/rubygame/rubygame_ttf.c +599 -0
  50. data/ext/rubygame/rubygame_ttf.h +69 -0
  51. data/ext/rubygame/rubygame_ttf.obj +0 -0
  52. data/ext/rubygame/rubygame_ttf.so +0 -0
  53. data/lib/rubygame.rb +41 -0
  54. data/lib/rubygame/MANIFEST +12 -0
  55. data/lib/rubygame/clock.rb +128 -0
  56. data/lib/rubygame/color.rb +79 -0
  57. data/lib/rubygame/color/models/base.rb +106 -0
  58. data/lib/rubygame/color/models/hsl.rb +153 -0
  59. data/lib/rubygame/color/models/hsv.rb +149 -0
  60. data/lib/rubygame/color/models/rgb.rb +78 -0
  61. data/lib/rubygame/color/palettes/css.rb +49 -0
  62. data/lib/rubygame/color/palettes/palette.rb +100 -0
  63. data/lib/rubygame/color/palettes/x11.rb +177 -0
  64. data/lib/rubygame/constants.rb +238 -0
  65. data/lib/rubygame/event.rb +313 -0
  66. data/lib/rubygame/ftor.rb +370 -0
  67. data/lib/rubygame/hotspot.rb +265 -0
  68. data/lib/rubygame/keyconstants.rb +237 -0
  69. data/lib/rubygame/mediabag.rb +94 -0
  70. data/lib/rubygame/queue.rb +288 -0
  71. data/lib/rubygame/rect.rb +612 -0
  72. data/lib/rubygame/sfont.rb +223 -0
  73. data/lib/rubygame/sprite.rb +511 -0
  74. data/samples/FreeSans.ttf +0 -0
  75. data/samples/GPL.txt +340 -0
  76. data/samples/README +40 -0
  77. data/samples/chimp.bmp +0 -0
  78. data/samples/chimp.rb +313 -0
  79. data/samples/demo_gl.rb +151 -0
  80. data/samples/demo_gl_tex.rb +197 -0
  81. data/samples/demo_music.rb +75 -0
  82. data/samples/demo_rubygame.rb +284 -0
  83. data/samples/demo_sfont.rb +52 -0
  84. data/samples/demo_ttf.rb +193 -0
  85. data/samples/demo_utf8.rb +53 -0
  86. data/samples/fist.bmp +0 -0
  87. data/samples/load_and_blit.rb +22 -0
  88. data/samples/panda.png +0 -0
  89. data/samples/punch.wav +0 -0
  90. data/samples/ruby.png +0 -0
  91. data/samples/song.ogg +0 -0
  92. data/samples/term16.png +0 -0
  93. data/samples/whiff.wav +0 -0
  94. metadata +152 -0
@@ -0,0 +1,49 @@
1
+ = Extended README
2
+
3
+ (Stuff that didn't make it into the main README file.)
4
+
5
+ == Internal structure of Rubygame
6
+
7
+ Rubygame's core is a low-level extension written in C; it
8
+ provides a basic interface to SDL and its companion libraries.
9
+ Building upon that is a ruby library which implements high-level
10
+ concepts like game objects, event management, etc.
11
+
12
+ Rubygame is modular, meaning you can pick and choose which parts to use.
13
+ For example, if you don't need TrueType font support, SDL_ttf is not
14
+ required to compile Rubygame. It is possible for a game to detect at
15
+ run-time which features are present, and behave accordingly (for example,
16
+ the game might disable certain optional features).
17
+
18
+ Rubygame is multi-tiered, meaning you can access Rubygame's functionality
19
+ on a number of levels, each level being built on the level below it.
20
+ Each higher level is closer to a complete game, but is also less flexible.
21
+ The idea here is that developers will use the higher levels most of the
22
+ time, but be free to hack lower levels when they need to do something
23
+ special.
24
+
25
+ == About the version number
26
+
27
+ The version number of Rubygame has a strict meaning, to help you decide
28
+ whether the new version might break your application. The version number has
29
+ 3 parts: the major version number, the minor version number, and the patch
30
+ number. For the example of Rubygame 2.0.0:
31
+
32
+ 2 . 0 . 0
33
+ MAJOR . MINOR . PATCH
34
+
35
+ When a new release of Rubygame is made, one of the version numbers will
36
+ go up, and the numbers that come after it will be reset to 0. Which number
37
+ will go up depends on how much the Rubygame API changed:
38
+
39
+ - *MAJOR*: API has changed, and old apps must be updated.
40
+ An example of this is when a class has been significantly changed, or a
41
+ method has renamed/moved to another module and the old name is removed.
42
+
43
+ - *MINOR*: API has changed, but old apps will still work.
44
+ An example of this is when a new feature has been added, or a
45
+ method has been renamed but the old name is still supported.
46
+
47
+ - *PATCH*: API has not changed at all.
48
+ An example of this is when a bug has been fixed, or existing code has
49
+ been improved beneath the surface.
@@ -0,0 +1,47 @@
1
+ = Getting Started with Rubygame
2
+
3
+ == About Rubygame
4
+
5
+ Rubygame is a combination extension and library for the Ruby language,
6
+ designed for creating computer games (and having fun doing it!).
7
+ As an extension, it provides an interface to the Simple DirectMedia Library
8
+ (SDL) and its companion libraries SDL_gfx, SDL_image, SDL_ttf, and SDL_mixer.
9
+ As a Ruby library, it provides classes/modules which implement some useful
10
+ concepts such as Sprites, Event Queues, and rasterized fonts (SFont).
11
+
12
+ == Suggested Order
13
+
14
+ To get acquainted with Rubygame, we recommend exploring the available classes
15
+ and modules in this order.
16
+
17
+ First, take a look at the most fundamental classes:
18
+ - Rubygame::Screen (the display window, what the user sees)
19
+ - Rubygame::Surface (stores image data which can be copied to the Screen)
20
+ - Rubygame::Rect (stores a rectangular area, like part of the Screen)
21
+
22
+ As a next step, read about the event Queue and the hardware events, which
23
+ allow you to take keyboard and mouse input, among other things.
24
+ - Rubygame::EventQueue (stores events for processing)
25
+ - Rubygame::KeyDownEvent (keyboard button is pressed)
26
+ - Rubygame::KeyUpEvent (keyboard button is released)
27
+ - Rubygame::MouseDownEvent (mouse button is clicked)
28
+ - Rubygame::MouseUpEvent (mouse button is released)
29
+ - Rubygame::MouseMotionEvent (mouse cursor is moved)
30
+ - Rubygame::QuitEvent (user tries to close the window)
31
+ - Rubygame::JoyDownEvent (joystick button is pressed)
32
+ - Rubygame::JoyUpEvent (joystick button is released)
33
+ - Rubygame::JoyAxisEvent (joystick axis is moved)
34
+ - Rubygame::JoyBallEvent (joystick trackball is moved)
35
+ - Rubygame::JoyHatEvent (joystick 8-directional hat switch is moved)
36
+ - Rubygame::ActiveEvent (the Screen gets keyboard and/or mouse focus)
37
+ - Rubygame::ResizeEvent (the Screen is resized)
38
+ - Rubygame::ExposeEvent (the Screen is redrawn, mostly for OpenGL)
39
+
40
+ Finally, familiarize yourself with:
41
+ - Rubygame::Clock for monitoring and controlling framerate to save resources
42
+ - Rubygame::Sprites for an easy-to-use yet flexible on-screen object framework
43
+ - Rubygame::TTF and Rubygame::SFont for rendering text
44
+ - Rubygame::GL for hardware-accelerated 3D graphics with OpenGL
45
+
46
+ There are several sample applications in the rubygame/samples/ directory
47
+ packaged with Rubygame which can also help you get started.
@@ -0,0 +1,70 @@
1
+ = How to install Rubygame on Mac OS X
2
+
3
+ This is an outline of the steps to compile and use Rubygame on Mac OS X!
4
+
5
+ == Installing dependencies...
6
+
7
+ You have two options for installing the software libraries that Rubygame
8
+ depends on: Darwinports or Fink. Which option you choose is just a matter of
9
+ preference.
10
+
11
+ === ...with Darwinports[http://darwinports.opendarwin.org/]
12
+
13
+
14
+ 1. {Install darwinports}[http://darwinports.opendarwin.org/getdp/]
15
+ 2. Open a new terminal (can be found in /Applications/Utilities).
16
+ 3. Install SDL:
17
+
18
+ sudo port install libsdl
19
+
20
+ 4. (Optional, but *highly* recommended:) Install the SDL companion
21
+ libraries:
22
+
23
+ sudo port install libsdl_gfx libsdl_image libsdl_mixer libsdl_ttf
24
+
25
+ === ...with Fink[http://www.finkproject.org/]
26
+
27
+ 1. {Install Fink}[http://www.finkproject.org/download/index.php?phpLang=en]
28
+ and update to the latest version.
29
+ 2. Open a new terminal (can be found in /Applications/Utilities).
30
+ 3. Install SDL:
31
+
32
+ sudo apt-get install sdl
33
+
34
+ 4. (Optional, but *highly* recommended:) Install the SDL companion
35
+ libraries:
36
+
37
+ sudo apt-get install sdl-gfx13 sdl-image sdl-mixer sdl-ttf
38
+
39
+ == Installing rsdl
40
+
41
+ In order to use Rubygame applications on Mac OS X, you must use a special wrapper for the ruby interpreter, called rsdl.
42
+
43
+ 1. {Download and unpack rsdl}[http://www.kumaryu.net/?c=plugin;plugin=attach_download;p=%28Ruby%29+Ruby%2FSDL%CD%D1ruby;file_name=rsdl.tar.gz].
44
+ 2. From within the rsdl directory:
45
+
46
+ make
47
+ sudo cp rsdl /usr/local/bin/
48
+
49
+
50
+ == Installing Rubygame
51
+ 1. {Download and unpack Rubygame}[https://sourceforge.net/project/showfiles.php?group_id=172781].
52
+ 2. From within the rubygame directory:
53
+
54
+ sudo rake install
55
+
56
+ 3. Please refer to the README file for options that you can pass to setup.rb
57
+ or rake (depending on your version of Rubygame)
58
+
59
+ == Running an application
60
+
61
+ If all went well, you can now run Rubygame applications like so:
62
+ <code>rsdl a_rubygame_app.rb</code>
63
+
64
+ If something bad happened along the way, you can {submit a support request}[https://sourceforge.net/tracker/?func=add&group_id=172781&atid=862995]
65
+ and we'll try to help! Be sure to include plenty of details and paste any error
66
+ messages that occur (plus a good bit of the text right before the error
67
+ messages).
68
+
69
+ (Many thanks to Raffael Mancini (sepisultrum) and Matt Crinklaw for
70
+ instructions to install dependencies with darwinports and fink, respectively.)
@@ -0,0 +1,127 @@
1
+ = Compiling Rubygame on Windows
2
+
3
+ (For the most up-to-date version of this document, see the Rubygame wiki:
4
+ http://rubygame.wiki.sourceforge.net/win32_compile)
5
+
6
+ This document gives some helpful guidelines to for compiling and installing
7
+ Rubygame on Microsoft Windows. However, these instructions are not perfect,
8
+ so they might not work for you. If you use this guide, we'd love to hear about
9
+ what worked and what didn't; just send a message to the {rubygame-users mailing
10
+ list}[https://sourceforge.net/mail/?group_id=172781]!
11
+
12
+ The usual caveats apply: follow these instructions at your own risk and so
13
+ forth. Please direct comments or questions to the {Rubygame user's mailing
14
+ list}[http://sourceforge.net/mail/?group_id=172781].
15
+
16
+ == Step 1: Gather Dependencies
17
+
18
+ - You'll need a build environment for Windows. In this guide, we'll use
19
+ {MinGW}[http://www.mingw.org/MinGWiki/index.php/GettingStarted].
20
+ - Grab MinGW-NNN.exe (e.g. MinGW-5.12.exe) from the {downloads page}[http://sourceforge.net/project/showfiles.php?group_id=2435&package_id=82721]
21
+ and install it. (Note: you might need to expand the "MinGW" section to see
22
+ the MinGW-NNN.exe files.)
23
+ - Optional, but recommended: install MSYS-NNNN.exe (e.g. MSYS-1.0.10.exe)
24
+ from the same page as above. (You might have to expand the MSYS section.)
25
+ - Add the full path to the compiler executible to your system PATH if it
26
+ isn't there already. You should be able to type <code>gcc -v</code> at a
27
+ command line and see a version number.
28
+
29
+ - {Download Ruby}[http://www.ruby-lang.org/en/downloads/], the language itself.
30
+ The easiest option here is the one-click installer. This will install
31
+ Ruby and a number of useful libraries without any hassle.
32
+
33
+ - {SDL}[http://www.libsdl.org/download-1.2.php]. In the <b>Development
34
+ Libraries</b> section (near the bottom of the page), grab the
35
+ SDL-devel-1.2.??-VC6.zip file. (The VC6 package is just fine, even though
36
+ we're using with MinGW to compile.)
37
+
38
+ The rest are optional dependencies, but highly recommended. If you don't have
39
+ them, you won't be able to use certain features of Rubygame.
40
+
41
+ - {SDL_image}[http://www.libsdl.org/projects/SDL_image/]. Grab the Win32
42
+ binary package with 'devel' in the name.
43
+ - {SDL_mixer}[http://www.libsdl.org/projects/SDL_mixer/]. Just like before,
44
+ grab the Win32 binary package with 'devel' in the name.
45
+ - {SDL_ttf}[http://www.libsdl.org/projects/SDL_ttf/]. Again, get the
46
+ Win32 binary package with 'devel' in the name
47
+ - {SDL_gfx}[http://www.ferzkopp.net/joomla/content/view/19/14/]. This is
48
+ the trickiest dependency, because there is currently no official package for
49
+ a precompiled version of SDL_gfx. If you are able to compile this yourself,
50
+ great! Otherwise, some nice features of Rubygame have to be disabled;
51
+ make sure you add the --no-gfx flag when you get to the "Set up environment
52
+ variables" section, below.
53
+
54
+ Once you have downloaded everything, extract each archive into a convenient
55
+ location on your hard drive. You'll thank yourself later if you use a short
56
+ path with no spaces in it. For this example, we'll unzip everything under
57
+ <code>C:\\src\\</code>.
58
+
59
+ Next, copy the *.dll file from each library's folder into
60
+ <code>C:\\windows\\system32\\</code>.
61
+ This will allow the libraries to be detected properly later on.
62
+
63
+ == Step 2: Get Rubygame
64
+
65
+ If you haven't already, download the latest Rubygame source from the
66
+ {download page}[http://sourceforge.net/project/showfiles.php?group_id=172781].
67
+ If you're feeling adventurous, you could try the in-development code from
68
+ the {Subversion repository}[http://sourceforge.net/svn/?group_id=172781].
69
+ You can decompress the .tar.bz2 file with either MSYS' <code>tar</code>
70
+ (<code>tar xvjf rubygame-2.0.0.tar.bz2</code>) or a program like
71
+ {7zip}[http://www.7-zip.org].
72
+
73
+ Extract the source into another folder of your choice, such as
74
+ <code>C:\\src\\rubygame</code>.
75
+
76
+ == Step 3: Set up environment variables
77
+
78
+ Environment variables are used to configure the build process for your
79
+ system; it helps the compiler to locate the headers and libraries it needs to
80
+ compile Rubygame.
81
+
82
+ Create a text file in your Rubygame directory called "envsetup.bat".
83
+ In it, use code based on the following to set your variables. Be sure to replace
84
+ 'c:\src\' (lines 3-7) with the path to where you unpacked the libraries. Also,
85
+ make sure that you set 'c:\ruby\bin' in the last line to the 'bin' directory of
86
+ your own Ruby installation. You will need to add quotes around any paths that
87
+ include spaces.
88
+
89
+ echo off
90
+
91
+ set CC=gcc
92
+
93
+ set CFLAGS=-DHAVE_ISINF -D_MSC_VER=1200
94
+ set CFLAGS=%CFLAGS% -I c:\src\SDL-1.2.11\include
95
+ set CFLAGS=%CFLAGS% -I c:\src\SDL_gfx-2.0.15
96
+ set CFLAGS=%CFLAGS% -I c:\src\SDL_image-1.2.5\include
97
+ set CFLAGS=%CFLAGS% -I c:\src\SDL_mixer-1.2.7\include
98
+ set CFLAGS=%CFLAGS% -I c:\src\SDL_ttf-2.0.8\include
99
+
100
+ set LDSHARED=gcc -shared
101
+ set LDFLAGS=-L c:\windows\system32 -lSDL
102
+ set LIBRUBYARG_SHARED=-L c:\ruby\bin -lmsvcrt-ruby18
103
+
104
+ == Step 4: Compile and install Rubygame
105
+
106
+ Open a command prompt and navigate to the root of your Rubygame source
107
+ directory. Type:
108
+
109
+ envsetup.bat
110
+ rake install
111
+
112
+ IMPORTANT: If you are missing an optional library (such as SDL_gfx), you must
113
+ disable optional features by passing a "no-???" command to rake before the word
114
+ "install". For example, to disable features that depend on SDL_gfx, you would
115
+ type this instead of the above:
116
+
117
+ envsetup.bat
118
+ rake no-sdl-gfx install
119
+
120
+ If all goes well, you have built and installed Rubygame.
121
+ Try to execute <code>require 'rubygame'</code> in an irb session and run
122
+ the provided samples to ensure that everything is acceptable.
123
+
124
+ These instructions were last verified on 30 December, 2007 with Rubygame 2.2.0.
125
+
126
+ (Thanks to Ash Wilson (smashwilson) for contributing the original version of
127
+ these instructions.)
@@ -0,0 +1,25 @@
1
+ MANIFEST
2
+ rubygame_event.c
3
+ rubygame_event.h
4
+ rubygame_gfx.c
5
+ rubygame_gfx.h
6
+ rubygame_gl.c
7
+ rubygame_gl.h
8
+ rubygame_image.c
9
+ rubygame_image.h
10
+ rubygame_joystick.c
11
+ rubygame_joystick.h
12
+ rubygame_main.c
13
+ rubygame_main.h
14
+ rubygame_mixer.c
15
+ rubygame_mixer.h
16
+ rubygame_screen.c
17
+ rubygame_screen.h
18
+ rubygame_shared.c
19
+ rubygame_shared.h
20
+ rubygame_surface.c
21
+ rubygame_surface.h
22
+ rubygame_time.c
23
+ rubygame_time.h
24
+ rubygame_ttf.c
25
+ rubygame_ttf.h
Binary file
@@ -0,0 +1,644 @@
1
+ /*--
2
+ * Rubygame -- Ruby bindings to SDL to facilitate game creation
3
+ * Copyright (C) 2004-2007 John Croisant
4
+ *
5
+ * This library is free software; you can redistribute it and/or
6
+ * modify it under the terms of the GNU Lesser General Public
7
+ * License as published by the Free Software Foundation; either
8
+ * version 2.1 of the License, or (at your option) any later version.
9
+ *
10
+ * This library is distributed in the hope that it will be useful,
11
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
+ * Lesser General Public License for more details.
14
+ *
15
+ * You should have received a copy of the GNU Lesser General Public
16
+ * License along with this library; if not, write to the Free Software
17
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
+ *++
19
+ */
20
+
21
+ #include "rubygame_shared.h"
22
+ #include "rubygame_event.h"
23
+
24
+ void Rubygame_Init_Event();
25
+ VALUE cEvent;
26
+ VALUE cActiveEvent;
27
+ VALUE cKeyDownEvent;
28
+ VALUE cKeyUpEvent;
29
+ VALUE cMouseMotionEvent;
30
+ VALUE cMouseDownEvent;
31
+ VALUE cMouseUpEvent;
32
+ VALUE cJoyAxisEvent;
33
+ VALUE cJoyBallEvent;
34
+ VALUE cJoyHatEvent;
35
+ VALUE cJoyDownEvent;
36
+ VALUE cJoyUpEvent;
37
+ VALUE cQuitEvent;
38
+ VALUE cSysWMEvent;
39
+ VALUE cResizeEvent;
40
+ VALUE cExposeEvent;
41
+ VALUE convert_active(Uint8);
42
+ VALUE convert_keymod(SDLMod);
43
+ VALUE convert_mousebuttons(Uint8);
44
+ VALUE rbgm_convert_sdlevent(SDL_Event);
45
+ VALUE rbgm_queue_getsdl(VALUE);
46
+
47
+ /*
48
+ *--
49
+ *
50
+ * SDL Type Ruby type Ruby new() args
51
+ * ---------------------------------------------------------------------------
52
+ * SDL_ACTIVEEVENT ActiveEvent gain,state
53
+ * SDL_KEYDOWN KeyDownEvent key,[mods,...]
54
+ * SDL_KEYUP KeyUpEvent key,[mods,...]
55
+ * SDL_MOUSEMOTION MouseMotionEvent [x,y],[xrel,yrel],[buttons,...]
56
+ * SDL_MOUSEBUTTONDOWN MouseDownEvent [x,y],button
57
+ * SDL_MOUSEBUTTONUP MouseUpEvent [x,y],button
58
+ * SDL_JOYAXISMOTION JoyAxisEvent joy,axis,value
59
+ * SDL_JOYBALLMOTION JoyBallEvent joy,ball,[xrel,yrel]
60
+ * SDL_JOYHATMOTION JoyHatEvent joy,hat,value
61
+ * SDL_JOYBUTTONDOWN JoyDownEvent joy,button
62
+ * SDL_JOYBUTTONUP JoyUpEvent joy,button
63
+ * SDL_VIDEORESIZE VideoResizeEvent [w,h]
64
+ * SDL_QUIT QuitEvent (no args)
65
+ * --------------------------------------------------------------------------
66
+ *
67
+ *++
68
+ */
69
+
70
+ /* Convert info about whether the window has mouse/keyboard focus */
71
+ VALUE convert_active( Uint8 state )
72
+ {
73
+ VALUE array;
74
+
75
+ array = rb_ary_new();
76
+ if(state != 0)
77
+ {
78
+ if(state & SDL_APPMOUSEFOCUS)
79
+ rb_ary_push(array,rb_str_new2("mouse\0"));
80
+ if(state & SDL_APPINPUTFOCUS)
81
+ rb_ary_push(array,rb_str_new2("keyboard\0"));
82
+ if(state & SDL_APPACTIVE)
83
+ rb_ary_push(array,rb_str_new2("active\0"));
84
+ }
85
+ return array;
86
+ }
87
+
88
+ /* Convert an OR'd list of KMODs into a Ruby array of keysyms. */
89
+ VALUE convert_keymod( SDLMod mods )
90
+ {
91
+ VALUE array;
92
+
93
+ array = rb_ary_new();
94
+ if(mods != 0)
95
+ {
96
+ /* KEY MODIFIER KEY SYM */
97
+ if(mods & KMOD_LSHIFT) rb_ary_push(array,INT2NUM( SDLK_LSHIFT ));
98
+ if(mods & KMOD_RSHIFT) rb_ary_push(array,INT2NUM( SDLK_RSHIFT ));
99
+ if(mods & KMOD_LCTRL) rb_ary_push(array,INT2NUM( SDLK_LCTRL ));
100
+ if(mods & KMOD_RCTRL) rb_ary_push(array,INT2NUM( SDLK_RCTRL ));
101
+ if(mods & KMOD_LALT) rb_ary_push(array,INT2NUM( SDLK_LALT ));
102
+ if(mods & KMOD_RALT) rb_ary_push(array,INT2NUM( SDLK_RALT ));
103
+ if(mods & KMOD_LMETA) rb_ary_push(array,INT2NUM( SDLK_LMETA ));
104
+ if(mods & KMOD_RMETA) rb_ary_push(array,INT2NUM( SDLK_RMETA ));
105
+ if(mods & KMOD_NUM) rb_ary_push(array,INT2NUM( SDLK_NUMLOCK ));
106
+ if(mods & KMOD_CAPS) rb_ary_push(array,INT2NUM( SDLK_CAPSLOCK ));
107
+ if(mods & KMOD_MODE) rb_ary_push(array,INT2NUM( SDLK_MODE ));
108
+ }
109
+ return array;
110
+ }
111
+
112
+ /* convert a button state into a list of mouse button sym */
113
+ VALUE convert_mousebuttons( Uint8 state )
114
+ {
115
+ VALUE buttons;
116
+
117
+ buttons = rb_ary_new();
118
+ if(state & SDL_BUTTON(1))
119
+ rb_ary_push(buttons, INT2NUM(SDL_BUTTON_LEFT));
120
+ if(state & SDL_BUTTON(2))
121
+ rb_ary_push(buttons, INT2NUM(SDL_BUTTON_MIDDLE));
122
+ if(state & SDL_BUTTON(3))
123
+ rb_ary_push(buttons, INT2NUM(SDL_BUTTON_RIGHT));
124
+ return buttons;
125
+ }
126
+
127
+
128
+ #if 0
129
+ /*
130
+ * (This method is no longer used, as it depends on unicode enabled in SDL,
131
+ * and doesn't work for KeyUpEvents)
132
+ */
133
+ /* Convert a unicode char into an ascii string or hex if it is not ascii */
134
+ VALUE convert_unicode( Uint16 unicode )
135
+ {
136
+ char *str;
137
+ if( unicode < 0x80 && unicode > 0 )
138
+ asprintf( &str,"%c\0",(char)unicode );
139
+ else
140
+ asprintf( &str,"0x%04X\0",unicode );
141
+ return rb_str_new2(str);
142
+ }
143
+ #endif
144
+
145
+
146
+ /*--
147
+ *
148
+ * Queue-related functions.
149
+ *
150
+ *++
151
+ */
152
+
153
+ /*--
154
+ *
155
+ * call-seq:
156
+ * rbgm_convert_sdlevent( SDL_Event ) -> Rubygame_Event
157
+ *
158
+ * Converts an SDL_Event (C type) into a Rubygame Event of the corresponding
159
+ * class.
160
+ *
161
+ *++
162
+ */
163
+
164
+ VALUE rbgm_convert_sdlevent( SDL_Event ev )
165
+ {
166
+ VALUE new = rb_intern("new"); /* to call new() for any class */
167
+
168
+ /*
169
+ switch for each particular type, call new() for the corresponding
170
+ Rubygame class, with the proper arguments.
171
+ */
172
+ switch(ev.type)
173
+ {
174
+ case SDL_ACTIVEEVENT:
175
+ /* ActiveEvent.new(gain,state) */
176
+ return rb_funcall(cActiveEvent,new,2,\
177
+ ev.active.gain, convert_active(ev.active.state));
178
+ break;
179
+ case SDL_KEYDOWN:
180
+ /* KeyDownEvent.new(keysym,[mods,...]) */
181
+ return rb_funcall(cKeyDownEvent,new,2,\
182
+ /* keysym, string version is set in new()*/
183
+ INT2NUM(ev.key.keysym.sym),\
184
+ /* convert OR'd list of mods into Array of keysyms */
185
+ convert_keymod(ev.key.keysym.mod)\
186
+ );
187
+ break;
188
+ case SDL_KEYUP: /* Same as SDL_KEYDOWN */
189
+ /* KeyUpEvent.new(keysym,[mods,...]) */
190
+ return rb_funcall(cKeyUpEvent,new,2,\
191
+ INT2NUM(ev.key.keysym.sym),\
192
+ convert_keymod(ev.key.keysym.mod));
193
+ break;
194
+ case SDL_MOUSEMOTION:;
195
+
196
+ /* MouseMotionEvent.new([x,y],[xrel,yrel],[buttons,...]) */
197
+ return rb_funcall(cMouseMotionEvent,new,3,\
198
+ rb_ary_new3(2,INT2NUM(ev.motion.x),INT2NUM(ev.motion.y)),\
199
+ rb_ary_new3(2,INT2NUM(ev.motion.xrel),\
200
+ INT2NUM(ev.motion.yrel)),\
201
+ /* Prepare list of buttons from OR'd list */
202
+ convert_mousebuttons(ev.motion.state));
203
+ break;
204
+ case SDL_MOUSEBUTTONDOWN:
205
+ /* MouseDownEvent.new([x,y],button) */
206
+ return rb_funcall(cMouseDownEvent,new,2,\
207
+ rb_ary_new3(2,INT2NUM(ev.button.x),INT2NUM(ev.button.y)),\
208
+ INT2NUM(ev.button.button));
209
+ break;
210
+ case SDL_MOUSEBUTTONUP:
211
+ /* MouseUpEvent.new([x,y],button) */
212
+ return rb_funcall(cMouseUpEvent,new,2,\
213
+ rb_ary_new3(2,INT2NUM(ev.button.x),INT2NUM(ev.button.y)),\
214
+ INT2NUM(ev.button.button));
215
+ break;
216
+ case SDL_JOYAXISMOTION:
217
+ /* JoyAxisEvent.new(joy,axis,value) */
218
+ /* Eventually, joy might be a reference to a Joystick instance? */
219
+ return rb_funcall(cJoyAxisEvent,new,3,\
220
+ INT2NUM(ev.jaxis.which),INT2NUM(ev.jaxis.axis),\
221
+ INT2NUM(ev.jaxis.value));
222
+ break;
223
+ case SDL_JOYBALLMOTION:
224
+ /* JoyBallEvent.new(joy,ball,) */
225
+ /* Eventually, joy might be a reference to a Joystick instance? */
226
+ return rb_funcall(cJoyBallEvent,new,3,\
227
+ INT2NUM(ev.jball.which),INT2NUM(ev.jball.ball),
228
+ rb_ary_new3(2,INT2NUM(ev.jball.xrel),INT2NUM(ev.jball.yrel)));
229
+ break;
230
+ case SDL_JOYHATMOTION:
231
+ /* JoyHatEvent.new(joy,hat,value) */
232
+ /* Eventually, joy might be a reference to a Joystick instance? */
233
+ return rb_funcall(cJoyHatEvent,new,3,\
234
+ INT2NUM(ev.jhat.which),INT2NUM(ev.jhat.hat),\
235
+ INT2NUM(ev.jhat.value));
236
+ break;
237
+ case SDL_JOYBUTTONDOWN:
238
+ /* JoyDownEvent.new(joy,button) */
239
+ /* Eventually, joy might be a reference to a Joystick instance? */
240
+ return rb_funcall(cJoyDownEvent,new,2,\
241
+ INT2NUM(ev.jbutton.which),INT2NUM(ev.jbutton.button));
242
+ break;
243
+ case SDL_JOYBUTTONUP:
244
+ /* JoyUp.new(joy,button) */
245
+ /* Eventually, joy might be a reference to a Joystick instance? */
246
+ return rb_funcall(cJoyUpEvent,new,2,\
247
+ INT2NUM(ev.jbutton.which),INT2NUM(ev.jbutton.button));
248
+ break;
249
+ case SDL_VIDEORESIZE:
250
+ /* ResizeEvent.new([w,h]) */
251
+ return rb_funcall(cResizeEvent,new,1,\
252
+ rb_ary_new3(2,INT2NUM(ev.resize.w),INT2NUM(ev.resize.h)));
253
+ break;
254
+ case SDL_VIDEOEXPOSE:
255
+ /* ExposeEvent.new( ) */
256
+ return rb_funcall(cExposeEvent,new,0);
257
+ break;
258
+ case SDL_QUIT:
259
+ /* QuitEvent.new( ) */
260
+ return rb_funcall(cQuitEvent,new,0);
261
+ break;
262
+ default:
263
+ rb_warn("Cannot convert unknown event type (%d).", ev.type);
264
+ return Qnil;
265
+ break;
266
+ }
267
+ return Qnil; /* should never get here */
268
+ }
269
+
270
+ /*
271
+ * call-seq:
272
+ * fetch_sdl_events -> [Event, ...]
273
+ *
274
+ * Retrieves all pending events from SDL's event stack and converts them
275
+ * into Rubygame Event objects. Returns an Array of all the events, in
276
+ * the order they were read.
277
+ *
278
+ * This method is used by the EventQueue class, so don't call it if you are
279
+ * using EventQueue for event management! If you do, the EventQueue will not
280
+ * receive all the events, because they will have been removed from SDL's
281
+ * event stack by this method.
282
+ *
283
+ * However, if you aren't using EventQueue, you can safely use this method
284
+ * to make your own event management system.
285
+ */
286
+ VALUE rbgm_fetchevents(VALUE self)
287
+ {
288
+ SDL_Event event;
289
+ VALUE event_array;
290
+
291
+ event_array = rb_ary_new();
292
+ /* put each in *event until no pending events are in SDL's queue */
293
+ /* for now, we don't care what type the event in. Filtering comes later */
294
+ while(SDL_PollEvent(&event)==1)
295
+ {
296
+ rb_ary_push(event_array, rbgm_convert_sdlevent(event) );
297
+ }
298
+ return event_array;
299
+ }
300
+
301
+ /*
302
+ *--
303
+ * The event documentation is in rubygame/lib/rubygame/event.rb
304
+ *++
305
+ */
306
+ void Rubygame_Init_Event()
307
+ {
308
+ #if 0
309
+ mRubygame = rb_define_module("Rubygame");
310
+ #endif
311
+
312
+ rb_define_singleton_method(mRubygame, "fetch_sdl_events",rbgm_fetchevents,0);
313
+
314
+ cEvent = rb_define_class_under(mRubygame,"Event",rb_cObject);
315
+ cActiveEvent = rb_define_class_under(mRubygame,"ActiveEvent",cEvent);
316
+ cKeyDownEvent = rb_define_class_under(mRubygame,"KeyDownEvent",cEvent);
317
+ cKeyUpEvent = rb_define_class_under(mRubygame,"KeyUpEvent",cEvent);
318
+ cMouseMotionEvent = rb_define_class_under(mRubygame,"MouseMotionEvent",\
319
+ cEvent);
320
+ cMouseDownEvent = rb_define_class_under(mRubygame,"MouseDownEvent",cEvent);
321
+ cMouseUpEvent = rb_define_class_under(mRubygame,"MouseUpEvent",cEvent);
322
+ cJoyAxisEvent = rb_define_class_under(mRubygame,"JoyAxisEvent",cEvent);
323
+ cJoyBallEvent = rb_define_class_under(mRubygame,"JoyBallEvent",cEvent);
324
+ cJoyHatEvent = rb_define_class_under(mRubygame,"JoyHatEvent",cEvent);
325
+ cJoyDownEvent = rb_define_class_under(mRubygame,"JoyDownEvent",cEvent);
326
+ cJoyUpEvent = rb_define_class_under(mRubygame,"JoyUpEvent",cEvent);
327
+ cQuitEvent = rb_define_class_under(mRubygame,"QuitEvent",cEvent);
328
+ cResizeEvent = rb_define_class_under(mRubygame,"ResizeEvent",cEvent);
329
+ cExposeEvent = rb_define_class_under(mRubygame,"ExposeEvent",cEvent);
330
+
331
+ /* Event constants */
332
+ rb_define_const(mRubygame,"NOEVENT",UINT2NUM(SDL_NOEVENT));
333
+ rb_define_const(mRubygame,"ACTIVEEVENT",UINT2NUM(SDL_ACTIVEEVENT));
334
+ rb_define_const(mRubygame,"KEYDOWN",UINT2NUM(SDL_KEYDOWN));
335
+ rb_define_const(mRubygame,"KEYUP",UINT2NUM(SDL_KEYUP));
336
+ rb_define_const(mRubygame,"MOUSEMOTION",UINT2NUM(SDL_MOUSEMOTION));
337
+ rb_define_const(mRubygame,"MOUSEBUTTONDOWN",UINT2NUM(SDL_MOUSEBUTTONDOWN));
338
+ rb_define_const(mRubygame,"MOUSEBUTTONUP",UINT2NUM(SDL_MOUSEBUTTONUP));
339
+ rb_define_const(mRubygame,"JOYAXISMOTION",UINT2NUM(SDL_JOYAXISMOTION));
340
+ rb_define_const(mRubygame,"JOYBALLMOTION",UINT2NUM(SDL_JOYBALLMOTION));
341
+ rb_define_const(mRubygame,"JOYHATMOTION",UINT2NUM(SDL_JOYHATMOTION));
342
+ rb_define_const(mRubygame,"JOYBUTTONDOWN",UINT2NUM(SDL_JOYBUTTONDOWN));
343
+ rb_define_const(mRubygame,"JOYBUTTONUP",UINT2NUM(SDL_JOYBUTTONUP));
344
+ rb_define_const(mRubygame,"QUIT",UINT2NUM(SDL_QUIT));
345
+ rb_define_const(mRubygame,"SYSWMEVENT",UINT2NUM(SDL_SYSWMEVENT));
346
+ rb_define_const(mRubygame,"VIDEORESIZE",UINT2NUM(SDL_VIDEORESIZE));
347
+ rb_define_const(mRubygame,"VIDEOEXPOSE",UINT2NUM(SDL_VIDEOEXPOSE));
348
+ rb_define_const(mRubygame,"USEREVENT",UINT2NUM(SDL_USEREVENT));
349
+
350
+ /* Joystick constants */
351
+ rb_define_const(mRubygame,"HAT_CENTERED",UINT2NUM(SDL_HAT_CENTERED));
352
+ rb_define_const(mRubygame,"HAT_UP",UINT2NUM(SDL_HAT_UP));
353
+ rb_define_const(mRubygame,"HAT_RIGHT",UINT2NUM(SDL_HAT_RIGHT));
354
+ rb_define_const(mRubygame,"HAT_DOWN",UINT2NUM(SDL_HAT_DOWN));
355
+ rb_define_const(mRubygame,"HAT_LEFT",UINT2NUM(SDL_HAT_LEFT));
356
+ rb_define_const(mRubygame,"HAT_RIGHTUP",UINT2NUM(SDL_HAT_RIGHTUP));
357
+ rb_define_const(mRubygame,"HAT_RIGHTDOWN",UINT2NUM(SDL_HAT_RIGHTDOWN));
358
+ rb_define_const(mRubygame,"HAT_LEFTUP",UINT2NUM(SDL_HAT_LEFTUP));
359
+ rb_define_const(mRubygame,"HAT_LEFTDOWN",UINT2NUM(SDL_HAT_LEFTDOWN));
360
+
361
+
362
+ /* Mouse constants */
363
+ rb_define_const(mRubygame,"MOUSE_LEFT",UINT2NUM(SDL_BUTTON_LEFT));
364
+ rb_define_const(mRubygame,"MOUSE_MIDDLE",UINT2NUM(SDL_BUTTON_MIDDLE));
365
+ rb_define_const(mRubygame,"MOUSE_RIGHT",UINT2NUM(SDL_BUTTON_RIGHT));
366
+ rb_define_const(mRubygame,"MOUSE_LMASK",UINT2NUM(SDL_BUTTON_LMASK));
367
+ rb_define_const(mRubygame,"MOUSE_MMASK",UINT2NUM(SDL_BUTTON_MMASK));
368
+ rb_define_const(mRubygame,"MOUSE_RMASK",UINT2NUM(SDL_BUTTON_RMASK));
369
+
370
+ /* ASCII key symbols */
371
+ rb_define_const(mRubygame,"K_UNKNOWN",UINT2NUM(SDLK_UNKNOWN));
372
+ rb_define_const(mRubygame,"K_FIRST",UINT2NUM(SDLK_FIRST));
373
+ rb_define_const(mRubygame,"K_BACKSPACE",UINT2NUM(SDLK_BACKSPACE));
374
+ rb_define_const(mRubygame,"K_TAB",UINT2NUM(SDLK_TAB));
375
+ rb_define_const(mRubygame,"K_CLEAR",UINT2NUM(SDLK_CLEAR));
376
+ rb_define_const(mRubygame,"K_RETURN",UINT2NUM(SDLK_RETURN));
377
+ rb_define_const(mRubygame,"K_PAUSE",UINT2NUM(SDLK_PAUSE));
378
+ rb_define_const(mRubygame,"K_ESCAPE",UINT2NUM(SDLK_ESCAPE));
379
+ rb_define_const(mRubygame,"K_SPACE",UINT2NUM(SDLK_SPACE));
380
+ rb_define_const(mRubygame,"K_EXCLAIM",UINT2NUM(SDLK_EXCLAIM));
381
+ rb_define_const(mRubygame,"K_QUOTEDBL",UINT2NUM(SDLK_QUOTEDBL));
382
+ rb_define_const(mRubygame,"K_HASH",UINT2NUM(SDLK_HASH));
383
+ rb_define_const(mRubygame,"K_DOLLAR",UINT2NUM(SDLK_DOLLAR));
384
+ rb_define_const(mRubygame,"K_AMPERSAND",UINT2NUM(SDLK_AMPERSAND));
385
+ rb_define_const(mRubygame,"K_QUOTE",UINT2NUM(SDLK_QUOTE));
386
+ rb_define_const(mRubygame,"K_LEFTPAREN",UINT2NUM(SDLK_LEFTPAREN));
387
+ rb_define_const(mRubygame,"K_RIGHTPAREN",UINT2NUM(SDLK_RIGHTPAREN));
388
+ rb_define_const(mRubygame,"K_ASTERISK",UINT2NUM(SDLK_ASTERISK));
389
+ rb_define_const(mRubygame,"K_PLUS",UINT2NUM(SDLK_PLUS));
390
+ rb_define_const(mRubygame,"K_COMMA",UINT2NUM(SDLK_COMMA));
391
+ rb_define_const(mRubygame,"K_MINUS",UINT2NUM(SDLK_MINUS));
392
+ rb_define_const(mRubygame,"K_PERIOD",UINT2NUM(SDLK_PERIOD));
393
+ rb_define_const(mRubygame,"K_SLASH",UINT2NUM(SDLK_SLASH));
394
+ rb_define_const(mRubygame,"K_0",UINT2NUM(SDLK_0));
395
+ rb_define_const(mRubygame,"K_1",UINT2NUM(SDLK_1));
396
+ rb_define_const(mRubygame,"K_2",UINT2NUM(SDLK_2));
397
+ rb_define_const(mRubygame,"K_3",UINT2NUM(SDLK_3));
398
+ rb_define_const(mRubygame,"K_4",UINT2NUM(SDLK_4));
399
+ rb_define_const(mRubygame,"K_5",UINT2NUM(SDLK_5));
400
+ rb_define_const(mRubygame,"K_6",UINT2NUM(SDLK_6));
401
+ rb_define_const(mRubygame,"K_7",UINT2NUM(SDLK_7));
402
+ rb_define_const(mRubygame,"K_8",UINT2NUM(SDLK_8));
403
+ rb_define_const(mRubygame,"K_9",UINT2NUM(SDLK_9));
404
+ rb_define_const(mRubygame,"K_COLON",UINT2NUM(SDLK_COLON));
405
+ rb_define_const(mRubygame,"K_SEMICOLON",UINT2NUM(SDLK_SEMICOLON));
406
+ rb_define_const(mRubygame,"K_LESS",UINT2NUM(SDLK_LESS));
407
+ rb_define_const(mRubygame,"K_EQUALS",UINT2NUM(SDLK_EQUALS));
408
+ rb_define_const(mRubygame,"K_GREATER",UINT2NUM(SDLK_GREATER));
409
+ rb_define_const(mRubygame,"K_QUESTION",UINT2NUM(SDLK_QUESTION));
410
+ rb_define_const(mRubygame,"K_AT",UINT2NUM(SDLK_AT));
411
+ rb_define_const(mRubygame,"K_LEFTBRACKET",UINT2NUM(SDLK_LEFTBRACKET));
412
+ rb_define_const(mRubygame,"K_BACKSLASH",UINT2NUM(SDLK_BACKSLASH));
413
+ rb_define_const(mRubygame,"K_RIGHTBRACKET",UINT2NUM(SDLK_RIGHTBRACKET));
414
+ rb_define_const(mRubygame,"K_CARET",UINT2NUM(SDLK_CARET));
415
+ rb_define_const(mRubygame,"K_UNDERSCORE",UINT2NUM(SDLK_UNDERSCORE));
416
+ rb_define_const(mRubygame,"K_BACKQUOTE",UINT2NUM(SDLK_BACKQUOTE));
417
+ rb_define_const(mRubygame,"K_A",UINT2NUM(SDLK_a));
418
+ rb_define_const(mRubygame,"K_B",UINT2NUM(SDLK_b));
419
+ rb_define_const(mRubygame,"K_C",UINT2NUM(SDLK_c));
420
+ rb_define_const(mRubygame,"K_D",UINT2NUM(SDLK_d));
421
+ rb_define_const(mRubygame,"K_E",UINT2NUM(SDLK_e));
422
+ rb_define_const(mRubygame,"K_F",UINT2NUM(SDLK_f));
423
+ rb_define_const(mRubygame,"K_G",UINT2NUM(SDLK_g));
424
+ rb_define_const(mRubygame,"K_H",UINT2NUM(SDLK_h));
425
+ rb_define_const(mRubygame,"K_I",UINT2NUM(SDLK_i));
426
+ rb_define_const(mRubygame,"K_J",UINT2NUM(SDLK_j));
427
+ rb_define_const(mRubygame,"K_K",UINT2NUM(SDLK_k));
428
+ rb_define_const(mRubygame,"K_L",UINT2NUM(SDLK_l));
429
+ rb_define_const(mRubygame,"K_M",UINT2NUM(SDLK_m));
430
+ rb_define_const(mRubygame,"K_N",UINT2NUM(SDLK_n));
431
+ rb_define_const(mRubygame,"K_O",UINT2NUM(SDLK_o));
432
+ rb_define_const(mRubygame,"K_P",UINT2NUM(SDLK_p));
433
+ rb_define_const(mRubygame,"K_Q",UINT2NUM(SDLK_q));
434
+ rb_define_const(mRubygame,"K_R",UINT2NUM(SDLK_r));
435
+ rb_define_const(mRubygame,"K_S",UINT2NUM(SDLK_s));
436
+ rb_define_const(mRubygame,"K_T",UINT2NUM(SDLK_t));
437
+ rb_define_const(mRubygame,"K_U",UINT2NUM(SDLK_u));
438
+ rb_define_const(mRubygame,"K_V",UINT2NUM(SDLK_v));
439
+ rb_define_const(mRubygame,"K_W",UINT2NUM(SDLK_w));
440
+ rb_define_const(mRubygame,"K_X",UINT2NUM(SDLK_x));
441
+ rb_define_const(mRubygame,"K_Y",UINT2NUM(SDLK_y));
442
+ rb_define_const(mRubygame,"K_Z",UINT2NUM(SDLK_z));
443
+ rb_define_const(mRubygame,"K_DELETE",UINT2NUM(SDLK_DELETE));
444
+
445
+
446
+ /* International keyboard symbols */
447
+ rb_define_const(mRubygame,"K_WORLD_0",UINT2NUM(SDLK_WORLD_0));
448
+ rb_define_const(mRubygame,"K_WORLD_1",UINT2NUM(SDLK_WORLD_1));
449
+ rb_define_const(mRubygame,"K_WORLD_2",UINT2NUM(SDLK_WORLD_2));
450
+ rb_define_const(mRubygame,"K_WORLD_3",UINT2NUM(SDLK_WORLD_3));
451
+ rb_define_const(mRubygame,"K_WORLD_4",UINT2NUM(SDLK_WORLD_4));
452
+ rb_define_const(mRubygame,"K_WORLD_5",UINT2NUM(SDLK_WORLD_5));
453
+ rb_define_const(mRubygame,"K_WORLD_6",UINT2NUM(SDLK_WORLD_6));
454
+ rb_define_const(mRubygame,"K_WORLD_7",UINT2NUM(SDLK_WORLD_7));
455
+ rb_define_const(mRubygame,"K_WORLD_8",UINT2NUM(SDLK_WORLD_8));
456
+ rb_define_const(mRubygame,"K_WORLD_9",UINT2NUM(SDLK_WORLD_9));
457
+ rb_define_const(mRubygame,"K_WORLD_10",UINT2NUM(SDLK_WORLD_10));
458
+ rb_define_const(mRubygame,"K_WORLD_11",UINT2NUM(SDLK_WORLD_11));
459
+ rb_define_const(mRubygame,"K_WORLD_12",UINT2NUM(SDLK_WORLD_12));
460
+ rb_define_const(mRubygame,"K_WORLD_13",UINT2NUM(SDLK_WORLD_13));
461
+ rb_define_const(mRubygame,"K_WORLD_14",UINT2NUM(SDLK_WORLD_14));
462
+ rb_define_const(mRubygame,"K_WORLD_15",UINT2NUM(SDLK_WORLD_15));
463
+ rb_define_const(mRubygame,"K_WORLD_16",UINT2NUM(SDLK_WORLD_16));
464
+ rb_define_const(mRubygame,"K_WORLD_17",UINT2NUM(SDLK_WORLD_17));
465
+ rb_define_const(mRubygame,"K_WORLD_18",UINT2NUM(SDLK_WORLD_18));
466
+ rb_define_const(mRubygame,"K_WORLD_19",UINT2NUM(SDLK_WORLD_19));
467
+ rb_define_const(mRubygame,"K_WORLD_20",UINT2NUM(SDLK_WORLD_20));
468
+ rb_define_const(mRubygame,"K_WORLD_21",UINT2NUM(SDLK_WORLD_21));
469
+ rb_define_const(mRubygame,"K_WORLD_22",UINT2NUM(SDLK_WORLD_22));
470
+ rb_define_const(mRubygame,"K_WORLD_23",UINT2NUM(SDLK_WORLD_23));
471
+ rb_define_const(mRubygame,"K_WORLD_24",UINT2NUM(SDLK_WORLD_24));
472
+ rb_define_const(mRubygame,"K_WORLD_25",UINT2NUM(SDLK_WORLD_25));
473
+ rb_define_const(mRubygame,"K_WORLD_26",UINT2NUM(SDLK_WORLD_26));
474
+ rb_define_const(mRubygame,"K_WORLD_27",UINT2NUM(SDLK_WORLD_27));
475
+ rb_define_const(mRubygame,"K_WORLD_28",UINT2NUM(SDLK_WORLD_28));
476
+ rb_define_const(mRubygame,"K_WORLD_29",UINT2NUM(SDLK_WORLD_29));
477
+ rb_define_const(mRubygame,"K_WORLD_30",UINT2NUM(SDLK_WORLD_30));
478
+ rb_define_const(mRubygame,"K_WORLD_31",UINT2NUM(SDLK_WORLD_31));
479
+ rb_define_const(mRubygame,"K_WORLD_32",UINT2NUM(SDLK_WORLD_32));
480
+ rb_define_const(mRubygame,"K_WORLD_33",UINT2NUM(SDLK_WORLD_33));
481
+ rb_define_const(mRubygame,"K_WORLD_34",UINT2NUM(SDLK_WORLD_34));
482
+ rb_define_const(mRubygame,"K_WORLD_35",UINT2NUM(SDLK_WORLD_35));
483
+ rb_define_const(mRubygame,"K_WORLD_36",UINT2NUM(SDLK_WORLD_36));
484
+ rb_define_const(mRubygame,"K_WORLD_37",UINT2NUM(SDLK_WORLD_37));
485
+ rb_define_const(mRubygame,"K_WORLD_38",UINT2NUM(SDLK_WORLD_38));
486
+ rb_define_const(mRubygame,"K_WORLD_39",UINT2NUM(SDLK_WORLD_39));
487
+ rb_define_const(mRubygame,"K_WORLD_40",UINT2NUM(SDLK_WORLD_40));
488
+ rb_define_const(mRubygame,"K_WORLD_41",UINT2NUM(SDLK_WORLD_41));
489
+ rb_define_const(mRubygame,"K_WORLD_42",UINT2NUM(SDLK_WORLD_42));
490
+ rb_define_const(mRubygame,"K_WORLD_43",UINT2NUM(SDLK_WORLD_43));
491
+ rb_define_const(mRubygame,"K_WORLD_44",UINT2NUM(SDLK_WORLD_44));
492
+ rb_define_const(mRubygame,"K_WORLD_45",UINT2NUM(SDLK_WORLD_45));
493
+ rb_define_const(mRubygame,"K_WORLD_46",UINT2NUM(SDLK_WORLD_46));
494
+ rb_define_const(mRubygame,"K_WORLD_47",UINT2NUM(SDLK_WORLD_47));
495
+ rb_define_const(mRubygame,"K_WORLD_48",UINT2NUM(SDLK_WORLD_48));
496
+ rb_define_const(mRubygame,"K_WORLD_49",UINT2NUM(SDLK_WORLD_49));
497
+ rb_define_const(mRubygame,"K_WORLD_50",UINT2NUM(SDLK_WORLD_50));
498
+ rb_define_const(mRubygame,"K_WORLD_51",UINT2NUM(SDLK_WORLD_51));
499
+ rb_define_const(mRubygame,"K_WORLD_52",UINT2NUM(SDLK_WORLD_52));
500
+ rb_define_const(mRubygame,"K_WORLD_53",UINT2NUM(SDLK_WORLD_53));
501
+ rb_define_const(mRubygame,"K_WORLD_54",UINT2NUM(SDLK_WORLD_54));
502
+ rb_define_const(mRubygame,"K_WORLD_55",UINT2NUM(SDLK_WORLD_55));
503
+ rb_define_const(mRubygame,"K_WORLD_56",UINT2NUM(SDLK_WORLD_56));
504
+ rb_define_const(mRubygame,"K_WORLD_57",UINT2NUM(SDLK_WORLD_57));
505
+ rb_define_const(mRubygame,"K_WORLD_58",UINT2NUM(SDLK_WORLD_58));
506
+ rb_define_const(mRubygame,"K_WORLD_59",UINT2NUM(SDLK_WORLD_59));
507
+ rb_define_const(mRubygame,"K_WORLD_60",UINT2NUM(SDLK_WORLD_60));
508
+ rb_define_const(mRubygame,"K_WORLD_61",UINT2NUM(SDLK_WORLD_61));
509
+ rb_define_const(mRubygame,"K_WORLD_62",UINT2NUM(SDLK_WORLD_62));
510
+ rb_define_const(mRubygame,"K_WORLD_63",UINT2NUM(SDLK_WORLD_63));
511
+ rb_define_const(mRubygame,"K_WORLD_64",UINT2NUM(SDLK_WORLD_64));
512
+ rb_define_const(mRubygame,"K_WORLD_65",UINT2NUM(SDLK_WORLD_65));
513
+ rb_define_const(mRubygame,"K_WORLD_66",UINT2NUM(SDLK_WORLD_66));
514
+ rb_define_const(mRubygame,"K_WORLD_67",UINT2NUM(SDLK_WORLD_67));
515
+ rb_define_const(mRubygame,"K_WORLD_68",UINT2NUM(SDLK_WORLD_68));
516
+ rb_define_const(mRubygame,"K_WORLD_69",UINT2NUM(SDLK_WORLD_69));
517
+ rb_define_const(mRubygame,"K_WORLD_70",UINT2NUM(SDLK_WORLD_70));
518
+ rb_define_const(mRubygame,"K_WORLD_71",UINT2NUM(SDLK_WORLD_71));
519
+ rb_define_const(mRubygame,"K_WORLD_72",UINT2NUM(SDLK_WORLD_72));
520
+ rb_define_const(mRubygame,"K_WORLD_73",UINT2NUM(SDLK_WORLD_73));
521
+ rb_define_const(mRubygame,"K_WORLD_74",UINT2NUM(SDLK_WORLD_74));
522
+ rb_define_const(mRubygame,"K_WORLD_75",UINT2NUM(SDLK_WORLD_75));
523
+ rb_define_const(mRubygame,"K_WORLD_76",UINT2NUM(SDLK_WORLD_76));
524
+ rb_define_const(mRubygame,"K_WORLD_77",UINT2NUM(SDLK_WORLD_77));
525
+ rb_define_const(mRubygame,"K_WORLD_78",UINT2NUM(SDLK_WORLD_78));
526
+ rb_define_const(mRubygame,"K_WORLD_79",UINT2NUM(SDLK_WORLD_79));
527
+ rb_define_const(mRubygame,"K_WORLD_80",UINT2NUM(SDLK_WORLD_80));
528
+ rb_define_const(mRubygame,"K_WORLD_81",UINT2NUM(SDLK_WORLD_81));
529
+ rb_define_const(mRubygame,"K_WORLD_82",UINT2NUM(SDLK_WORLD_82));
530
+ rb_define_const(mRubygame,"K_WORLD_83",UINT2NUM(SDLK_WORLD_83));
531
+ rb_define_const(mRubygame,"K_WORLD_84",UINT2NUM(SDLK_WORLD_84));
532
+ rb_define_const(mRubygame,"K_WORLD_85",UINT2NUM(SDLK_WORLD_85));
533
+ rb_define_const(mRubygame,"K_WORLD_86",UINT2NUM(SDLK_WORLD_86));
534
+ rb_define_const(mRubygame,"K_WORLD_87",UINT2NUM(SDLK_WORLD_87));
535
+ rb_define_const(mRubygame,"K_WORLD_88",UINT2NUM(SDLK_WORLD_88));
536
+ rb_define_const(mRubygame,"K_WORLD_89",UINT2NUM(SDLK_WORLD_89));
537
+ rb_define_const(mRubygame,"K_WORLD_90",UINT2NUM(SDLK_WORLD_90));
538
+ rb_define_const(mRubygame,"K_WORLD_91",UINT2NUM(SDLK_WORLD_91));
539
+ rb_define_const(mRubygame,"K_WORLD_92",UINT2NUM(SDLK_WORLD_92));
540
+ rb_define_const(mRubygame,"K_WORLD_93",UINT2NUM(SDLK_WORLD_93));
541
+ rb_define_const(mRubygame,"K_WORLD_94",UINT2NUM(SDLK_WORLD_94));
542
+ rb_define_const(mRubygame,"K_WORLD_95",UINT2NUM(SDLK_WORLD_95));
543
+
544
+
545
+ /* Numeric keypad symbols */
546
+ rb_define_const(mRubygame,"K_KP0",UINT2NUM(SDLK_KP0));
547
+ rb_define_const(mRubygame,"K_KP1",UINT2NUM(SDLK_KP1));
548
+ rb_define_const(mRubygame,"K_KP2",UINT2NUM(SDLK_KP2));
549
+ rb_define_const(mRubygame,"K_KP3",UINT2NUM(SDLK_KP3));
550
+ rb_define_const(mRubygame,"K_KP4",UINT2NUM(SDLK_KP4));
551
+ rb_define_const(mRubygame,"K_KP5",UINT2NUM(SDLK_KP5));
552
+ rb_define_const(mRubygame,"K_KP6",UINT2NUM(SDLK_KP6));
553
+ rb_define_const(mRubygame,"K_KP7",UINT2NUM(SDLK_KP7));
554
+ rb_define_const(mRubygame,"K_KP8",UINT2NUM(SDLK_KP8));
555
+ rb_define_const(mRubygame,"K_KP9",UINT2NUM(SDLK_KP9));
556
+ rb_define_const(mRubygame,"K_KP_PERIOD",UINT2NUM(SDLK_KP_PERIOD));
557
+ rb_define_const(mRubygame,"K_KP_DIVIDE",UINT2NUM(SDLK_KP_DIVIDE));
558
+ rb_define_const(mRubygame,"K_KP_MULTIPLY",UINT2NUM(SDLK_KP_MULTIPLY));
559
+ rb_define_const(mRubygame,"K_KP_MINUS",UINT2NUM(SDLK_KP_MINUS));
560
+ rb_define_const(mRubygame,"K_KP_PLUS",UINT2NUM(SDLK_KP_PLUS));
561
+ rb_define_const(mRubygame,"K_KP_ENTER",UINT2NUM(SDLK_KP_ENTER));
562
+ rb_define_const(mRubygame,"K_KP_EQUALS",UINT2NUM(SDLK_KP_EQUALS));
563
+
564
+
565
+ /* Arrows + Home/End pad */
566
+ rb_define_const(mRubygame,"K_UP",UINT2NUM(SDLK_UP));
567
+ rb_define_const(mRubygame,"K_DOWN",UINT2NUM(SDLK_DOWN));
568
+ rb_define_const(mRubygame,"K_RIGHT",UINT2NUM(SDLK_RIGHT));
569
+ rb_define_const(mRubygame,"K_LEFT",UINT2NUM(SDLK_LEFT));
570
+ rb_define_const(mRubygame,"K_INSERT",UINT2NUM(SDLK_INSERT));
571
+ rb_define_const(mRubygame,"K_HOME",UINT2NUM(SDLK_HOME));
572
+ rb_define_const(mRubygame,"K_END",UINT2NUM(SDLK_END));
573
+ rb_define_const(mRubygame,"K_PAGEUP",UINT2NUM(SDLK_PAGEUP));
574
+ rb_define_const(mRubygame,"K_PAGEDOWN",UINT2NUM(SDLK_PAGEDOWN));
575
+
576
+
577
+ /* Function keys */
578
+ rb_define_const(mRubygame,"K_F1",UINT2NUM(SDLK_F1));
579
+ rb_define_const(mRubygame,"K_F2",UINT2NUM(SDLK_F2));
580
+ rb_define_const(mRubygame,"K_F3",UINT2NUM(SDLK_F3));
581
+ rb_define_const(mRubygame,"K_F4",UINT2NUM(SDLK_F4));
582
+ rb_define_const(mRubygame,"K_F5",UINT2NUM(SDLK_F5));
583
+ rb_define_const(mRubygame,"K_F6",UINT2NUM(SDLK_F6));
584
+ rb_define_const(mRubygame,"K_F7",UINT2NUM(SDLK_F7));
585
+ rb_define_const(mRubygame,"K_F8",UINT2NUM(SDLK_F8));
586
+ rb_define_const(mRubygame,"K_F9",UINT2NUM(SDLK_F9));
587
+ rb_define_const(mRubygame,"K_F10",UINT2NUM(SDLK_F10));
588
+ rb_define_const(mRubygame,"K_F11",UINT2NUM(SDLK_F11));
589
+ rb_define_const(mRubygame,"K_F12",UINT2NUM(SDLK_F12));
590
+ rb_define_const(mRubygame,"K_F13",UINT2NUM(SDLK_F13));
591
+ rb_define_const(mRubygame,"K_F14",UINT2NUM(SDLK_F14));
592
+ rb_define_const(mRubygame,"K_F15",UINT2NUM(SDLK_F15));
593
+
594
+
595
+ /* Key state modifier keys */
596
+ rb_define_const(mRubygame,"K_NUMLOCK",UINT2NUM(SDLK_NUMLOCK));
597
+ rb_define_const(mRubygame,"K_CAPSLOCK",UINT2NUM(SDLK_CAPSLOCK));
598
+ rb_define_const(mRubygame,"K_SCROLLOCK",UINT2NUM(SDLK_SCROLLOCK));
599
+ rb_define_const(mRubygame,"K_RSHIFT",UINT2NUM(SDLK_RSHIFT));
600
+ rb_define_const(mRubygame,"K_LSHIFT",UINT2NUM(SDLK_LSHIFT));
601
+ rb_define_const(mRubygame,"K_RCTRL",UINT2NUM(SDLK_RCTRL));
602
+ rb_define_const(mRubygame,"K_LCTRL",UINT2NUM(SDLK_LCTRL));
603
+ rb_define_const(mRubygame,"K_RALT",UINT2NUM(SDLK_RALT));
604
+ rb_define_const(mRubygame,"K_LALT",UINT2NUM(SDLK_LALT));
605
+ rb_define_const(mRubygame,"K_RMETA",UINT2NUM(SDLK_RMETA));
606
+ rb_define_const(mRubygame,"K_LMETA",UINT2NUM(SDLK_LMETA));
607
+ rb_define_const(mRubygame,"K_LSUPER",UINT2NUM(SDLK_LSUPER));
608
+ rb_define_const(mRubygame,"K_RSUPER",UINT2NUM(SDLK_RSUPER));
609
+ rb_define_const(mRubygame,"K_MODE",UINT2NUM(SDLK_MODE));
610
+
611
+
612
+ /* Miscellaneous keys */
613
+ rb_define_const(mRubygame,"K_HELP",UINT2NUM(SDLK_HELP));
614
+ rb_define_const(mRubygame,"K_PRINT",UINT2NUM(SDLK_PRINT));
615
+ rb_define_const(mRubygame,"K_SYSREQ",UINT2NUM(SDLK_SYSREQ));
616
+ rb_define_const(mRubygame,"K_BREAK",UINT2NUM(SDLK_BREAK));
617
+ rb_define_const(mRubygame,"K_MENU",UINT2NUM(SDLK_MENU));
618
+ rb_define_const(mRubygame,"K_POWER",UINT2NUM(SDLK_POWER));
619
+ rb_define_const(mRubygame,"K_EURO",UINT2NUM(SDLK_EURO));
620
+ rb_define_const(mRubygame,"K_LAST",UINT2NUM(SDLK_LAST));
621
+
622
+
623
+ #if 0
624
+ /* key mods */
625
+ /* rb_define_const(mRubygame,"K_MOD_NONE",UINT2NUM(KMOD_NONE)); */
626
+ /* rb_define_const(mRubygame,"K_MOD_LSHIFT",UINT2NUM(KMOD_LSHIFT)); */
627
+ /* rb_define_const(mRubygame,"K_MOD_RSHIFT",UINT2NUM(KMOD_RSHIFT)); */
628
+ /* rb_define_const(mRubygame,"K_MOD_LCTRL",UINT2NUM(KMOD_LCTRL)); */
629
+ /* rb_define_const(mRubygame,"K_MOD_RCTRL",UINT2NUM(KMOD_RCTRL)); */
630
+ /* rb_define_const(mRubygame,"K_MOD_LALT",UINT2NUM(KMOD_LALT)); */
631
+ /* rb_define_const(mRubygame,"K_MOD_RALT",UINT2NUM(KMOD_RALT)); */
632
+ /* rb_define_const(mRubygame,"K_MOD_LMETA",UINT2NUM(KMOD_LMETA)); */
633
+ /* rb_define_const(mRubygame,"K_MOD_RMETA",UINT2NUM(KMOD_RMETA)); */
634
+ /* rb_define_const(mRubygame,"K_MOD_NUM",UINT2NUM(KMOD_NUM)); */
635
+ /* rb_define_const(mRubygame,"K_MOD_CAPS",UINT2NUM(KMOD_CAPS)); */
636
+ /* rb_define_const(mRubygame,"K_MOD_MODE",UINT2NUM(KMOD_MODE)); */
637
+ /* rb_define_const(mRubygame,"K_MOD_RESERVED",UINT2NUM(KMOD_RESERVED)); */
638
+
639
+ /* rb_define_const(mRubygame,"K_MOD_CTRL",UINT2NUM(KMOD_CTRL)); */
640
+ /* rb_define_const(mRubygame,"K_MOD_SHIFT",UINT2NUM(KMOD_SHIFT)); */
641
+ /* rb_define_const(mRubygame,"K_MOD_ALT",UINT2NUM(KMOD_ALT)); */
642
+ /* rb_define_const(mRubygame,"K_MOD_META",UINT2NUM(KMOD_META)); */
643
+ #endif
644
+ }