/*
pygame - Python Game Library
Copyright (C) 2000-2001 Pete Shinners
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Pete Shinners
pete@shinners.org
*/
#define NO_PYGAME_C_API
#include "pygame.h"
/* macros used to create each constant */
#define DEC_CONST(x) PyModule_AddIntConstant(module, #x, (int) SDL_##x);
#define DEC_CONSTK(x) PyModule_AddIntConstant(module, #x, (int) SDL##x);
#define DEC_CONSTN(x) PyModule_AddIntConstant(module, #x, (int) x);
static PyMethodDef builtins[] =
{
{NULL}
};
/*DOC*/ static char doc_pygame_constants_MODULE[] =
/*DOC*/ "These constants are defined by SDL, and needed in pygame. Note\n"
/*DOC*/ "that many of the flags for SDL are not needed in pygame, and are\n"
/*DOC*/ "not included here. These constants are generally accessed from\n"
/*DOC*/ "the pygame.locals module. This module is automatically placed in\n"
/*DOC*/ "the pygame namespace, but you will usually want to place them\n"
/*DOC*/ "directly into your module's namespace with the following command,\n"
/*DOC*/ "'from pygame.locals import *'.\n"
/*DOC*/ ;
PYGAME_EXPORT
void initconstants(void)
{
PyObject* module;
module = Py_InitModule3("constants", builtins, doc_pygame_constants_MODULE);
DEC_CONST(YV12_OVERLAY);
DEC_CONST(IYUV_OVERLAY);
DEC_CONST(YUY2_OVERLAY);
DEC_CONST(UYVY_OVERLAY);
DEC_CONST(YVYU_OVERLAY);
DEC_CONST(SWSURFACE);
DEC_CONST(HWSURFACE);
DEC_CONST(RESIZABLE);
DEC_CONST(ASYNCBLIT);
DEC_CONST(OPENGL);
DEC_CONST(OPENGLBLIT)
DEC_CONST(ANYFORMAT);
DEC_CONST(HWPALETTE);
DEC_CONST(DOUBLEBUF);
DEC_CONST(FULLSCREEN);
DEC_CONST(HWACCEL);
DEC_CONST(SRCCOLORKEY);
DEC_CONST(RLEACCELOK);
DEC_CONST(RLEACCEL);
DEC_CONST(SRCALPHA);
DEC_CONST(PREALLOC);
DEC_CONST(NOFRAME);
DEC_CONST(GL_RED_SIZE);
DEC_CONST(GL_GREEN_SIZE);
DEC_CONST(GL_BLUE_SIZE);
DEC_CONST(GL_ALPHA_SIZE);
DEC_CONST(GL_BUFFER_SIZE);
DEC_CONST(GL_DOUBLEBUFFER);
DEC_CONST(GL_DEPTH_SIZE);
DEC_CONST(GL_STENCIL_SIZE);
DEC_CONST(GL_ACCUM_RED_SIZE);
DEC_CONST(GL_ACCUM_GREEN_SIZE);
DEC_CONST(GL_ACCUM_BLUE_SIZE);
DEC_CONST(GL_ACCUM_ALPHA_SIZE);
#if SDL_VERSION_ATLEAST(1, 2, 5)
DEC_CONST(GL_STEREO);
#else
PyModule_AddIntConstant(module, "GL_STEREO", -1);
#endif
#if SDL_VERSION_ATLEAST(1, 2, 6)
DEC_CONST(GL_MULTISAMPLEBUFFERS);
DEC_CONST(GL_MULTISAMPLESAMPLES);
#else
PyModule_AddIntConstant(module, "GL_MULTISAMPLEBUFFERS", -1);
PyModule_AddIntConstant(module, "GL_MULTISAMPLESAMPLES", -1);
#endif
DEC_CONSTN(TIMER_RESOLUTION);
DEC_CONSTN(AUDIO_U8);
DEC_CONSTN(AUDIO_S8);
DEC_CONSTN(AUDIO_U16LSB);
DEC_CONSTN(AUDIO_S16LSB);
DEC_CONSTN(AUDIO_U16MSB);
DEC_CONSTN(AUDIO_S16MSB);
DEC_CONSTN(AUDIO_U16);
DEC_CONSTN(AUDIO_S16);
DEC_CONSTN(AUDIO_U16SYS);
DEC_CONSTN(AUDIO_S16SYS);
DEC_CONST(NOEVENT);
DEC_CONST(ACTIVEEVENT);
DEC_CONST(KEYDOWN);
DEC_CONST(KEYUP);
DEC_CONST(MOUSEMOTION);
DEC_CONST(MOUSEBUTTONDOWN);
DEC_CONST(MOUSEBUTTONUP);
DEC_CONST(JOYAXISMOTION);
DEC_CONST(JOYBALLMOTION);
DEC_CONST(JOYHATMOTION);
DEC_CONST(JOYBUTTONDOWN);
DEC_CONST(JOYBUTTONUP);
DEC_CONST(VIDEORESIZE);
DEC_CONST(VIDEOEXPOSE);
DEC_CONST(QUIT);
DEC_CONST(SYSWMEVENT);
DEC_CONST(USEREVENT);
DEC_CONST(NUMEVENTS);
DEC_CONST(HAT_CENTERED);
DEC_CONST(HAT_UP);
DEC_CONST(HAT_RIGHTUP);
DEC_CONST(HAT_RIGHT);
DEC_CONST(HAT_RIGHTDOWN);
DEC_CONST(HAT_DOWN);
DEC_CONST(HAT_LEFTDOWN);
DEC_CONST(HAT_LEFT);
DEC_CONST(HAT_LEFTUP);
DEC_CONSTK(K_UNKNOWN);
DEC_CONSTK(K_FIRST);
DEC_CONSTK(K_BACKSPACE);
DEC_CONSTK(K_TAB);
DEC_CONSTK(K_CLEAR);
DEC_CONSTK(K_RETURN);
DEC_CONSTK(K_PAUSE);
DEC_CONSTK(K_ESCAPE);
DEC_CONSTK(K_SPACE);
DEC_CONSTK(K_EXCLAIM);
DEC_CONSTK(K_QUOTEDBL);
DEC_CONSTK(K_HASH);
DEC_CONSTK(K_DOLLAR);
DEC_CONSTK(K_AMPERSAND);
DEC_CONSTK(K_QUOTE);
DEC_CONSTK(K_LEFTPAREN);
DEC_CONSTK(K_RIGHTPAREN);
DEC_CONSTK(K_ASTERISK);
DEC_CONSTK(K_PLUS);
DEC_CONSTK(K_COMMA);
DEC_CONSTK(K_MINUS);
DEC_CONSTK(K_PERIOD);
DEC_CONSTK(K_SLASH);
DEC_CONSTK(K_0);
DEC_CONSTK(K_1);
DEC_CONSTK(K_2);
DEC_CONSTK(K_3);
DEC_CONSTK(K_4);
DEC_CONSTK(K_5);
DEC_CONSTK(K_6);
DEC_CONSTK(K_7);
DEC_CONSTK(K_8);
DEC_CONSTK(K_9);
DEC_CONSTK(K_COLON);
DEC_CONSTK(K_SEMICOLON);
DEC_CONSTK(K_LESS);
DEC_CONSTK(K_EQUALS);
DEC_CONSTK(K_GREATER);
DEC_CONSTK(K_QUESTION);
DEC_CONSTK(K_AT);
DEC_CONSTK(K_LEFTBRACKET);
DEC_CONSTK(K_BACKSLASH);
DEC_CONSTK(K_RIGHTBRACKET);
DEC_CONSTK(K_CARET);
DEC_CONSTK(K_UNDERSCORE);
DEC_CONSTK(K_BACKQUOTE);
DEC_CONSTK(K_a);
DEC_CONSTK(K_b);
DEC_CONSTK(K_c);
DEC_CONSTK(K_d);
DEC_CONSTK(K_e);
DEC_CONSTK(K_f);
DEC_CONSTK(K_g);
DEC_CONSTK(K_h);
DEC_CONSTK(K_i);
DEC_CONSTK(K_j);
DEC_CONSTK(K_k);
DEC_CONSTK(K_l);
DEC_CONSTK(K_m);
DEC_CONSTK(K_n);
DEC_CONSTK(K_o);
DEC_CONSTK(K_p);
DEC_CONSTK(K_q);
DEC_CONSTK(K_r);
DEC_CONSTK(K_s);
DEC_CONSTK(K_t);
DEC_CONSTK(K_u);
DEC_CONSTK(K_v);
DEC_CONSTK(K_w);
DEC_CONSTK(K_x);
DEC_CONSTK(K_y);
DEC_CONSTK(K_z);
DEC_CONSTK(K_DELETE);
DEC_CONSTK(K_KP0);
DEC_CONSTK(K_KP1);
DEC_CONSTK(K_KP2);
DEC_CONSTK(K_KP3);
DEC_CONSTK(K_KP4);
DEC_CONSTK(K_KP5);
DEC_CONSTK(K_KP6);
DEC_CONSTK(K_KP7);
DEC_CONSTK(K_KP8);
DEC_CONSTK(K_KP9);
DEC_CONSTK(K_KP_PERIOD);
DEC_CONSTK(K_KP_DIVIDE);
DEC_CONSTK(K_KP_MULTIPLY);
DEC_CONSTK(K_KP_MINUS);
DEC_CONSTK(K_KP_PLUS);
DEC_CONSTK(K_KP_ENTER);
DEC_CONSTK(K_KP_EQUALS);
DEC_CONSTK(K_UP);
DEC_CONSTK(K_DOWN);
DEC_CONSTK(K_RIGHT);
DEC_CONSTK(K_LEFT);
DEC_CONSTK(K_INSERT);
DEC_CONSTK(K_HOME);
DEC_CONSTK(K_END);
DEC_CONSTK(K_PAGEUP);
DEC_CONSTK(K_PAGEDOWN);
DEC_CONSTK(K_F1);
DEC_CONSTK(K_F2);
DEC_CONSTK(K_F3);
DEC_CONSTK(K_F4);
DEC_CONSTK(K_F5);
DEC_CONSTK(K_F6);
DEC_CONSTK(K_F7);
DEC_CONSTK(K_F8);
DEC_CONSTK(K_F9);
DEC_CONSTK(K_F10);
DEC_CONSTK(K_F11);
DEC_CONSTK(K_F12);
DEC_CONSTK(K_F13);
DEC_CONSTK(K_F14);
DEC_CONSTK(K_F15);
DEC_CONSTK(K_NUMLOCK);
DEC_CONSTK(K_CAPSLOCK);
DEC_CONSTK(K_SCROLLOCK);
DEC_CONSTK(K_RSHIFT);
DEC_CONSTK(K_LSHIFT);
DEC_CONSTK(K_RCTRL);
DEC_CONSTK(K_LCTRL);
DEC_CONSTK(K_RALT);
DEC_CONSTK(K_LALT);
DEC_CONSTK(K_RMETA);
DEC_CONSTK(K_LMETA);
DEC_CONSTK(K_LSUPER);
DEC_CONSTK(K_RSUPER);
DEC_CONSTK(K_MODE);
DEC_CONSTK(K_HELP);
DEC_CONSTK(K_PRINT);
DEC_CONSTK(K_SYSREQ);
DEC_CONSTK(K_BREAK);
DEC_CONSTK(K_MENU);
DEC_CONSTK(K_POWER);
DEC_CONSTK(K_EURO);
DEC_CONSTK(K_LAST);
DEC_CONSTN(KMOD_NONE);
DEC_CONSTN(KMOD_LSHIFT);
DEC_CONSTN(KMOD_RSHIFT);
DEC_CONSTN(KMOD_LCTRL);
DEC_CONSTN(KMOD_RCTRL);
DEC_CONSTN(KMOD_LALT);
DEC_CONSTN(KMOD_RALT);
DEC_CONSTN(KMOD_LMETA);
DEC_CONSTN(KMOD_RMETA);
DEC_CONSTN(KMOD_NUM);
DEC_CONSTN(KMOD_CAPS);
DEC_CONSTN(KMOD_MODE);
DEC_CONSTN(KMOD_CTRL);
DEC_CONSTN(KMOD_SHIFT);
DEC_CONSTN(KMOD_ALT);
DEC_CONSTN(KMOD_META);
}
#if 0
/*documentation only*/
/*DOC*/ static char doc_display[] =
/*DOC*/ "pygame.constants.display (constants)\n"
/*DOC*/ "The following constants are used by the display module and Surfaces\n"
/*DOC*/ "\n"
/*DOC*/ "HWSURFACE - surface in hardware video memory. (equal to 1)
\n"
/*DOC*/ "RESIZABLE - display window is resizeable
\n"
/*DOC*/ "ASYNCBLIT - surface blits happen asynchronously (threaded)
\n"
/*DOC*/ "OPENGL - display surface will be controlled by opengl
\n"
/*DOC*/ "HWPALETTE - display surface has animatable hardware palette\n"
/*DOC*/ "entries
\n"
/*DOC*/ "DOUBLEBUF - hardware display surface is page flippable
\n"
/*DOC*/ "FULLSCREEN - display surface is fullscreen (nonwindowed)
\n"
/*DOC*/ "RLEACCEL - compile for quick alpha blits, only set in alpha or\n"
/*DOC*/ "colorkey funcs
\n"
/*DOC*/ "NOFRAME - no window decorations
\n"
/*DOC*/ ;
/*DOC*/ static char doc_time[] =
/*DOC*/ "pygame.constants.time (constants)\n"
/*DOC*/ "These constants define the various time constants\n"
/*DOC*/ "\n"
/*DOC*/ "TIMER_RESOLUTION - minimum timer resolution in milliseconds
\n"
/*DOC*/ ;
/*DOC*/ static char doc_events[] =
/*DOC*/ "pygame.constants.events (constants)\n"
/*DOC*/ "These constants define the various event types\n"
/*DOC*/ "\n"
/*DOC*/ "NOEVENT - no event, represents an empty event list, equal to 0
\n"
/*DOC*/ "ACTIVEEVENT - window has gain/lost mouse/keyboard/visiblity focus
\n"
/*DOC*/ "KEYDOWN - keyboard button has been pressed (or down and repeating)
\n"
/*DOC*/ "KEYUP - keyboard button has been released
\n"
/*DOC*/ "MOUSEMOTION - mouse has moved
\n"
/*DOC*/ "MOUSEBUTTONDOWN- mouse button has been pressed
\n"
/*DOC*/ "MOUSEBUTTONUP - mouse button has been released
\n"
/*DOC*/ "JOYAXISMOTION - an opened joystick axis has changed
\n"
/*DOC*/ "JOYBALLMOTION - an opened joystick ball has moved
\n"
/*DOC*/ "JOYHATMOTION - an opened joystick hat has moved
\n"
/*DOC*/ "JOYBUTTONDOWN - an opened joystick button has been pressed
\n"
/*DOC*/ "JOYBUTTONUP - an opened joystick button has been released
\n"
/*DOC*/ "VIDEORESIZE - the display window has been resized by the user
\n"
/*DOC*/ "QUIT - the user has requested the game to quit
\n"
/*DOC*/ "SYSWMEVENT - currently unsupported, system dependant
\n"
/*DOC*/ "USEREVENT - all user messages are this or higher
\n"
/*DOC*/ "NUMEVENTS - all user messages must be lower than this, equal to 32
\n"
/*DOC*/ ;
/*DOC*/ static char doc_keyboard[] =
/*DOC*/ "pygame.constants.keyboard (constants)\n"
/*DOC*/ "These constants represent the keys on the keyboard.\n"
/*DOC*/ "\n"
/*DOC*/ "There are many keyboard constants, they are used to represent\n"
/*DOC*/ "keys on the keyboard. The following is a list of all keyboard\n"
/*DOC*/ "constants\n"
/*DOC*/ "\n"
/*DOC*/ "
KeyASCII | ASCII | Common Name |
K_BACKSPACE | \b | backspace |
K_TAB | \t | tab |
K_CLEAR | clear | |
K_RETURN | \r | return |
K_PAUSE | pause | |
K_ESCAPE | ^[ | escape |
K_SPACE | space | |
K_EXCLAIM | ! | exclaim |
K_QUOTEDBL | \" | quotedbl |
K_HASH | # | hash |
K_DOLLAR | $ | dollar |
K_AMPERSAND | & | ampersand |
K_QUOTE | quote | |
K_LEFTPAREN | ( | left parenthesis |
K_RIGHTPAREN | ) | right parenthesis |
K_ASTERISK | * | asterisk |
K_PLUS | + | plus sign |
K_COMMA | , | comma |
K_MINUS | - | minus sign |
K_PERIOD | . | period |
K_SLASH | / | forward slash |
K_0 | 0 | 0 |
K_1 | 1 | 1 |
K_2 | 2 | 2 |
K_3 | 3 | 3 |
K_4 | 4 | 4 |
K_5 | 5 | 5 |
K_6 | 6 | 6 |
K_7 | 7 | 7 |
K_8 | 8 | 8 |
K_9 | 9 | 9 |
K_COLON | : | colon |
K_SEMICOLON | ; | semicolon |
K_LESS | < | less-than sign |
K_EQUALS | = | equals sign |
K_GREATER | > | greater-than sign |
K_QUESTION | ? | question mark |
K_AT | @ | at |
K_LEFTBRACKET | [ | left bracket |
K_BACKSLASH | \\ | backslash |
K_RIGHTBRACKET | ] | right bracket |
K_CARET | ^ | caret |
K_UNDERSCORE | _ | underscore |
K_BACKQUOTE | ` | grave |
K_a | a | a |
K_b | b | b |
K_c | c | c |
K_d | d | d |
K_e | e | e |
K_f | f | f |
K_g | g | g |
K_h | h | h |
K_i | i | i |
K_j | j | j |
K_k | k | k |
K_l | l | l |
K_m | m | m |
K_n | n | n |
K_o | o | o |
K_p | p | p |
K_q | q | q |
K_r | r | r |
K_s | s | s |
K_t | t | t |
K_u | u | u |
K_v | v | v |
K_w | w | w |
K_x | x | x |
K_y | y | y |
K_z | z | z |
K_DELETE | delete | |
K_KP0 | keypad 0 | |
K_KP1 | keypad 1 | |
K_KP2 | keypad 2 | |
K_KP3 | keypad 3 | |
K_KP4 | keypad 4 | |
K_KP5 | keypad 5 | |
K_KP6 | keypad 6 | |
K_KP7 | keypad 7 | |
K_KP8 | keypad 8 | |
K_KP9 | keypad 9 | |
K_KP_PERIOD | . | keypad period |
K_KP_DIVIDE | / | keypad divide |
K_KP_MULTIPLY | * | keypad multiply |
K_KP_MINUS | - | keypad minus |
K_KP_PLUS | + | keypad plus |
K_KP_ENTER | \r | keypad enter |
K_KP_EQUALS | = | keypad equals |
K_UP | up arrow | |
K_DOWN | down arrow | |
K_RIGHT | right arrow | |
K_LEFT | left arrow | |
K_INSERT | insert | |
K_HOME | home | |
K_END | end | |
K_PAGEUP | page up | |
K_PAGEDOWN | page down | |
K_F1 | F1 | |
K_F2 | F2 | |
K_F3 | F3 | |
K_F4 | F4 | |
K_F5 | F5 | |
K_F6 | F6 | |
K_F7 | F7 | |
K_F8 | F8 | |
K_F9 | F9 | |
K_F10 | F10 | |
K_F11 | F11 | |
K_F12 | F12 | |
K_F13 | F13 | |
K_F14 | F14 | |
K_F15 | F15 | |
K_NUMLOCK | numlock | |
K_CAPSLOCK | capslock | |
K_SCROLLOCK | scrollock | |
K_RSHIFT | right shift | |
K_LSHIFT | left shift | |
K_RCTRL | right ctrl | |
K_LCTRL | left ctrl | |
K_RALT | right alt | |
K_LALT | left alt | |
K_RMETA | right meta | |
K_LMETA | left meta | |
K_LSUPER | left windows key | |
K_RSUPER | right windows key | |
K_MODE | mode shift | |
K_HELP | help | |
K_PRINT | print-screen | |
K_SYSREQ | SysRq | |
K_BREAK | break | |
K_MENU | menu | |
K_POWER | power | |
K_EURO | euro |