本文整理汇总了C++中SDL_EnableKeyRepeat函数的典型用法代码示例。如果您正苦于以下问题:C++ SDL_EnableKeyRepeat函数的具体用法?C++ SDL_EnableKeyRepeat怎么用?C++ SDL_EnableKeyRepeat使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SDL_EnableKeyRepeat函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int
main(int argc, char **argv) {
int result = EXIT_FAILURE;
if(SDL_Init(SDL_INIT_VIDEO) < 0)
goto out;
setupformat();
if(resize(1024, 768, false, Diagonal))
goto out_sdl;
SDL_WM_SetCaption("Radmire", NULL);
SDL_EnableKeyRepeat(0, 0);
glinit();
setupclock();
result = run();
out_sdl:
SDL_Quit();
out:
return result;
}
示例2: OpenGLViewer
// Create a new SDL window
SDLViewer::SDLViewer() : OpenGLViewer(), screen(NULL)
{
const SDL_VideoInfo *pSDLVideoInfo;
putenv(strdup("SDL_VIDEO_WINDOW_POS=center"));
// Initialise SDL Video subsystem
if( SDL_Init( SDL_INIT_VIDEO | SDL_INIT_TIMER ) < 0 )
abort_program("Unable to initialize SDL: %s", SDL_GetError());
pSDLVideoInfo = SDL_GetVideoInfo();
if( !pSDLVideoInfo )
{
SDL_Quit();
abort_program("SDL_GetVideoInfo() failed. SDL Error: %s", SDL_GetError());
}
timer_id = 0;
// NOTE: still want Ctrl-C to work, undo the SDL redirections
#ifndef _WIN32
signal(SIGINT, SIG_DFL);
signal(SIGQUIT, SIG_DFL);
#endif
// Keyboard setup
SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
//#ifndef PDF_CAPTURE
SDL_EnableUNICODE(1); //Enable unicode character translation
//Above prevents adobe 3d capture from detecting print screen key?
//#endif
// Save fullscreen width/height
savewidth = pSDLVideoInfo->current_w;
saveheight = pSDLVideoInfo->current_h;
resized = false;
screen = NULL;
debug_print("SDL viewer created\n");
}
示例3: fprintf
//constructor
SDLview::SDLview()
{
// Init SDL video subsystem
if ( SDL_Init (SDL_INIT_VIDEO) < 0 ) {
fprintf(stderr, "Couldn't initialize SDL video: %s\n",
SDL_GetError());
exit(1);
}
// Init SDL audio subsystem
if ( SDL_Init (SDL_INIT_AUDIO) < 0 )
{
fprintf(stderr, "Couldn't initialize SDL audio: %s\n",
SDL_GetError());
exit(1);
}
// Set GL context attributes
OpenGL_Init();
// Create GL context
createSurface();
// Get GL context attributes
//printAttributes ();
Timing = GL_TRUE;
count = 0;
StrMode = GL_VENDOR;
//SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY,SDL_DEFAULT_REPEAT_INTERVAL);
SDL_EnableKeyRepeat(1,1);
SDL_WM_GrabInput(SDL_GRAB_ON);
SDL_WM_SetCaption("The Sentinel", "The Sentinel");
SDL_WarpMouse(int(w_win / 2.0), int(h_win / 2.0));
}
示例4: zdebug
void SDLManagerPrivate::setKeyboardRepeatRate()
{
int delay = SDL_DEFAULT_REPEAT_DELAY;
int interval = SDL_DEFAULT_REPEAT_INTERVAL;
ZString delayStr = dotFile.getValue("keyboard.repeat_delay", 1);
if ( delayStr.upper() != "DEFAULT" ) {
int val = dotFile.getInt("keyboard.repeat_delay", 1, delay);
if ( val > 0 ) delay = val;
}
ZString intervalStr = dotFile.getValue("keyboard.repeat_interval", 1);
if ( intervalStr.upper() != "DEFAULT" ) {
int val = dotFile.getInt("keyboard.repeat_interval", 1, interval);
if ( val > 0 ) interval = val;
}
zdebug() << "SetKeyboardRepeatRate delay" << delay
<< "interval" << interval;
SDL_EnableKeyRepeat( delay, interval );
}
示例5: SDL_EnableKeyRepeat
void Chat::ShowInput()
{
if (!check_input) {
check_input = true;
/* Enable key repeat when chatting :) */
SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
}
if (!input) {
input = new Text("", c_white);
msg = new Text(_("Say: "), c_red);
}
/* FIXME where do those constants come from ?*/
int ypos = GetMainWindow().GetHeight() - 100;
msg->DrawLeftTop(Point2i(25, ypos));
if (input->GetText() != "") {
input->DrawLeftTop(Point2i(25 + msg->GetWidth() + 5, ypos));
input->DrawCursor(Point2i(25 + msg->GetWidth() + 5, ypos), cursor_pos);
}
}
示例6: init
/**
* Initialises the OpenGL and SDL application. This function creates the global
* Gui object that can be populated by various examples.
*/
void init()
{
// We simply initialise OpenGL and SDL as we would do with any OpenGL
// and SDL application.
SDL_Init(SDL_INIT_VIDEO);
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
screen = SDL_SetVideoMode(640, 480, 32, SDL_HWSURFACE | SDL_OPENGL | SDL_HWACCEL);
glViewport(0, 0, 640, 480);
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
// We want unicode for the SDLInput object to function properly.
SDL_EnableUNICODE(1);
// We also want to enable key repeat.
SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL);
// Now it's time to initialise the Guichan OpenGL back end
// and the Guichan SDL back end.
imageLoader = new gcn::OpenGLSDLImageLoader();
// The ImageLoader Guichan should use needs to be passed to the Image object
// using a static function.
gcn::Image::setImageLoader(imageLoader);
graphics = new gcn::OpenGLGraphics();
// We need to tell the OpenGL Graphics object how big the screen is.
graphics->setTargetPlane(640, 480);
input = new gcn::SDLInput();
// Now we create the Gui object to be used with this OpenGL
// and SDL application.
globals::gui = new gcn::Gui();
// The Gui object needs a Graphics to be able to draw itself and an Input
// object to be able to check for user input. In this case we provide the
// Gui object with OpenGL and SDL implementations of these objects hence
// making Guichan able to utilise OpenGL and SDL.
globals::gui->setGraphics(graphics);
globals::gui->setInput(input);
}
示例7: SDL_EventState
/**
* Initialize the SDL-FrameWork. Initialize SDL-Video and set some properties.
* @return either NR_OK or:
* - NR_FW_CANNOT_INITIALIZE
* - NR_FW_ALREADY_INIT if already initialized
**/
nrResult nrCFrameworkSDL::init() {
if (isInitialized()) {
nrLog.Log(NR_LOG_ENGINE, "nrCFrameworkSDL: WARNING: Framework already initialized");
return NR_FW_ALREADY_INIT;
}
// Log it
nrLog.Log(NR_LOG_ENGINE, "nrCFrameworkSDL: Initialize SDL framework");
// initialize SDL-Video Interface
if( SDL_Init( SDL_INIT_VIDEO ) < 0 ) {
nrLog.Log(NR_LOG_ENGINE, "nrCFrameworkSDL: Failed initializing SDL Video : %s"
,SDL_GetError());
return NR_FW_CANNOT_INITIALIZE;
}
// activate SDL-events
SDL_EventState (SDL_KEYDOWN, SDL_ENABLE);
SDL_EventState (SDL_KEYUP, SDL_ENABLE);
SDL_EventState (SDL_QUIT, SDL_ENABLE);
SDL_EventState (SDL_MOUSEMOTION, SDL_ENABLE);
SDL_EnableKeyRepeat (1,0);
SDL_GetKeyState(&_keyCount);
// create and full the keyboard state arrays
_keyState.reset(new byte[_keyCount]);
_oldKeyState.reset(new byte[_keyCount]);
byte* ks = SDL_GetKeyState(NULL);
memcpy(_oldKeyState.get(), ks, sizeof(byte) * _keyCount);
memcpy(_keyState.get(), ks, sizeof(byte) * _keyCount);
_isInitialized = true;
return NR_OK;
}
示例8: WinCreate
//Registers, creates, and shows the Window!!
bool WinCreate()
{
//const SDL_VideoInfo* video_info;
int init_flags = SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER;
if(SDL_Init(init_flags) < 0)
{
return false;
}
if(TTF_Init()<0)
{
return false;
}
SDL_EnableUNICODE(1);
SDL_EnableKeyRepeat(500, 60);
atexit(SDL_Quit);
std::string version = string_format("Cataclysm: Dark Days Ahead - %s", getVersionString());
SDL_WM_SetCaption(version.c_str(), NULL);
char center_string[] = "SDL_VIDEO_CENTERED=center"; // indirection needed to avoid a warning
SDL_putenv(center_string);
screen = SDL_SetVideoMode(WindowWidth, WindowHeight, 32, (SDL_SWSURFACE|SDL_DOUBLEBUF));
//SDL_SetColors(screen,windowsPalette,0,256);
if(screen==NULL) return false;
ClearScreen();
if(OPTIONS["HIDE_CURSOR"] > 0 && SDL_ShowCursor(-1))
SDL_ShowCursor(SDL_DISABLE);
else
SDL_ShowCursor(SDL_ENABLE);
return true;
};
示例9: SDL_Flip
void Frame::run() {
for (int i = 0; i < sprites.size(); i++)
sprites[i]->draw();
SDL_Flip(sys.screen);
SDL_EnableKeyRepeat(1, SDL_DEFAULT_REPEAT_INTERVAL);
// Händelseloop
bool running = true;
while(running) {
SDL_Event ev;
while (SDL_PollEvent(&ev)) {
switch (ev.type) {
case SDL_QUIT:
running = false;
break;
case SDL_KEYDOWN:
for(int i=0; i<sprites.size();i++)
sprites[i]->keyDown(ev.key.keysym.sym);
break;
} // switch
} // while SDL_PollEvent
Uint32 white = SDL_MapRGB(sys.screen->format, 255, 255, 255);
SDL_FillRect(sys.screen, NULL, white); // Fyll hela skärmen vit
for(int i=0; i<sprites.size(); i++)
sprites[i]->draw();
SDL_Flip(sys.screen);
} // while running
}
示例10: IN_BackendInit
/*
* Initializes the backend
*/
void
IN_BackendInit ( in_state_t *in_state_p )
{
in_state = in_state_p;
m_filter = ri.Cvar_Get( "m_filter", "0", CVAR_ARCHIVE );
in_mouse = ri.Cvar_Get( "in_mouse", "0", CVAR_ARCHIVE );
freelook = ri.Cvar_Get( "freelook", "1", 0 );
lookstrafe = ri.Cvar_Get( "lookstrafe", "0", 0 );
sensitivity = ri.Cvar_Get( "sensitivity", "3", 0 );
exponential_speedup = ri.Cvar_Get( "exponential_speedup", "0", CVAR_ARCHIVE );
m_pitch = ri.Cvar_Get( "m_pitch", "0.022", 0 );
m_yaw = ri.Cvar_Get( "m_yaw", "0.022", 0 );
m_forward = ri.Cvar_Get( "m_forward", "1", 0 );
m_side = ri.Cvar_Get( "m_side", "0.8", 0 );
ri.Cmd_AddCommand( "+mlook", IN_MLookDown );
ri.Cmd_AddCommand( "-mlook", IN_MLookUp );
ri.Cmd_AddCommand( "force_centerview", IN_ForceCenterView );
mouse_x = mouse_y = 0.0;
#if defined(PI)
SDL_Surface *surface = SDL_SetVideoMode(0,0, 32, SDL_SWSURFACE);
#endif
/* SDL stuff */
SDL_EnableUNICODE( 0 );
SDL_EnableKeyRepeat( SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL );
windowed_mouse = ri.Cvar_Get ("windowed_mouse", "1", CVAR_USERINFO | CVAR_ARCHIVE);
in_grab = ri.Cvar_Get ("in_grab", "2", CVAR_ARCHIVE);
#if defined(WIZ) || defined(CAANOO)
GPH_Open();
#endif
Com_Printf( "Input initialized.\n" );
}
示例11: main
int main(int argc, char* argv[])
{
srand(7);
plat_logf("SDL init");
SDL_Init(SDL_INIT_VIDEO);
screen = SDL_SetVideoMode(LCD_WIDTH, LCD_HEIGHT, 32, SDL_HWSURFACE | SDL_HWACCEL);
SDL_EnableKeyRepeat(1, SDL_DEFAULT_REPEAT_INTERVAL);
assert(screen != NULL);
fgcol = LCD_RGBPACK(255,255,255);
bgcol = LCD_RGBPACK(0,0,0);
action = NONE;
SDL_WM_SetCaption(GAME_TITLE, GAME_TITLE);
atexit(SDL_Quit);
plat_logf("TTF init");
if(TTF_Init() < 0)
{
plat_logf("TTF init fail!\n");
}
gameover_font = TTF_OpenFont("/usr/share/fonts/TTF/LiberationSans-Regular.ttf", LCD_HEIGHT / 12);
font = TTF_OpenFont("/usr/share/fonts/TTF/LiberationSans-Regular.ttf", LCD_HEIGHT / 24);
if(!gameover_font)
{
plat_logf("WARNING: font loading failed");
}
atexit(TTF_Quit);
dash_main();
return 0;
}
示例12: init
static void init()
{
// Start SDL
if ( SDL_Init( SDL_INIT_VIDEO | SDL_INIT_AUDIO ) < 0 )
exit( EXIT_FAILURE );
atexit( SDL_Quit );
SDL_EnableKeyRepeat( 500, 80 );
// Init scope
scope = new Audio_Scope;
if ( !scope )
handle_error( "Out of memory" );
if ( scope->init( scope_width, 256 ) )
handle_error( "Couldn't initialize scope" );
memset( scope_buf, 0, sizeof scope_buf );
// Create player
player = new Music_Player;
if ( !player )
handle_error( "Out of memory" );
handle_error( player->init() );
player->set_scope_buffer( scope_buf, scope_width * 2 );
}
示例13: I_InitInput
//
// I_InitInput
//
bool I_InitInput (void)
{
if(Args.CheckParm("-nomouse"))
{
nomouse = true;
}
atterm (I_ShutdownInput);
noidle = Args.CheckParm ("-noidle");
SDL_EnableUNICODE(true);
// denis - disable key repeats as they mess with the mouse in XP
SDL_EnableKeyRepeat(0, SDL_DEFAULT_REPEAT_INTERVAL);
#ifdef WIN32
// denis - in fullscreen, prevent exit on accidental windows key press
g_hKeyboardHook = SetWindowsHookEx(WH_KEYBOARD_LL, LowLevelKeyboardProc, GetModuleHandle(NULL), 0);
#endif
return true;
}
示例14: WinCreate
//Registers, creates, and shows the Window!!
bool WinCreate()
{
const SDL_VideoInfo* video_info;
int init_flags = SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER;
if(SDL_Init(init_flags) < 0)
{
return false;
}
if(TTF_Init()<0)
{
return false;
}
SDL_EnableUNICODE(1);
SDL_EnableKeyRepeat(500, 25);
atexit(SDL_Quit);
SDL_WM_SetCaption("Cataclysm: Goon Days Ahead - 0.35 SDL", NULL);
video_info = SDL_GetVideoInfo();
nativeWidth = video_info->current_w;
nativeHeight = video_info->current_h;
char center_string[] = "SDL_VIDEO_CENTERED=center"; // indirection needed to avoid a warning
SDL_putenv(center_string);
screen = SDL_SetVideoMode(WindowWidth, WindowHeight, 32, (SDL_SWSURFACE|SDL_DOUBLEBUF));
//SDL_SetColors(screen,windowsPalette,0,256);
if(screen==NULL) return false;
ClearScreen();
return true;
};
示例15: I_InitInput
//
// I_InitInput
//
bool I_InitInput (void)
{
if(Args.CheckParm("-nomouse"))
{
nomouse = true;
}
atterm (I_ShutdownInput);
SDL_EnableUNICODE(true);
// denis - disable key repeats as they mess with the mouse in XP
// mike - maybe not?
//SDL_EnableKeyRepeat(0, SDL_DEFAULT_REPEAT_INTERVAL);
SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL*2);
// Initialize the joystick subsystem and open a joystick if use_joystick is enabled. -- Hyper_Eye
Printf(PRINT_HIGH, "I_InitInput: Initializing SDL's joystick subsystem.\n");
SDL_InitSubSystem(SDL_INIT_JOYSTICK);
if((int)use_joystick && I_GetJoystickCount())
{
I_OpenJoystick();
EnableJoystickPolling();
}
#ifdef WIN32
// denis - in fullscreen, prevent exit on accidental windows key press
// [Russell] - Disabled because it screws with the mouse
//g_hKeyboardHook = SetWindowsHookEx(WH_KEYBOARD_LL, LowLevelKeyboardProc, GetModuleHandle(NULL), 0);
#endif
//CreateCursors();
UpdateFocus();
UpdateGrab();
return true;
}