本文整理汇总了C++中SDL_EventState函数的典型用法代码示例。如果您正苦于以下问题:C++ SDL_EventState函数的具体用法?C++ SDL_EventState怎么用?C++ SDL_EventState使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SDL_EventState函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: reset
//
// ISDL12KeyboardInputDevice::resume
//
// Sets the internal state to enable all input for this device.
//
// NOTE: SDL_EventState clears the SDL event queue so only call this after all
// SDL events have been processed in all SDL input device instances.
//
void ISDL12KeyboardInputDevice::resume()
{
mActive = true;
reset();
SDL_EventState(SDL_KEYDOWN, SDL_ENABLE);
SDL_EventState(SDL_KEYUP, SDL_ENABLE);
}
示例2: IInputSubsystem
//
// ISDL12InputSubsystem::ISDL12InputSubsystem
//
ISDL12InputSubsystem::ISDL12InputSubsystem() :
IInputSubsystem(),
mInputGrabbed(false)
{
// Initialize the joystick subsystem and open a joystick if use_joystick is enabled. -- Hyper_Eye
SDL_InitSubSystem(SDL_INIT_JOYSTICK);
// Tell SDL to ignore events from the input devices
// IInputDevice constructors will enable these events when they're initialized.
SDL_EventState(SDL_KEYDOWN, SDL_IGNORE);
SDL_EventState(SDL_KEYUP, SDL_IGNORE);
SDL_EventState(SDL_MOUSEMOTION, SDL_IGNORE);
SDL_EventState(SDL_MOUSEBUTTONDOWN, SDL_IGNORE);
SDL_EventState(SDL_MOUSEBUTTONUP, SDL_IGNORE);
SDL_EventState(SDL_JOYAXISMOTION, SDL_IGNORE);
SDL_EventState(SDL_JOYBALLMOTION, SDL_IGNORE);
SDL_EventState(SDL_JOYHATMOTION, SDL_IGNORE);
SDL_EventState(SDL_JOYBUTTONDOWN, SDL_IGNORE);
SDL_EventState(SDL_JOYBUTTONUP, SDL_IGNORE);
SDL_ShowCursor(false);
grabInput();
}
示例3: stick_init
int stick_init( int device_index ) {
int cnt = 0;
/* Initialize SDL with joystick support and event support (through video) */
if (SDL_Init(SDL_INIT_JOYSTICK|SDL_INIT_VIDEO) < 0)
{
printf("Could not initialize SDL: %s.\n", SDL_GetError());
exit(-1);
}
//Quit SDL at exit
atexit(SDL_Quit);
//Start the event handler, disable all but joystick events and quit handler
SDL_EventState(SDL_ACTIVEEVENT,SDL_IGNORE);
SDL_EventState(SDL_KEYDOWN,SDL_IGNORE);
SDL_EventState(SDL_KEYUP,SDL_IGNORE);
SDL_EventState(SDL_MOUSEMOTION,SDL_IGNORE);
SDL_EventState(SDL_MOUSEBUTTONDOWN,SDL_IGNORE);
SDL_EventState(SDL_MOUSEBUTTONUP,SDL_IGNORE);
//SDL_EventState(SDL_JOYAXISMOTION,SDL_IGNORE);
//SDL_EventState(SDL_JOYBALLMOTION,SDL_IGNORE);
//SDL_EventState(SDL_JOYHATMOTION,SDL_IGNORE);
//SDL_EventState(SDL_JOYBUTTONDOWN,SDL_IGNORE);
//SDL_EventState(SDL_JOYBUTTONUP,SDL_IGNORE);
SDL_EventState(SDL_VIDEORESIZE,SDL_IGNORE);
SDL_EventState(SDL_VIDEOEXPOSE,SDL_IGNORE);
//SDL_EventState(SDL_QUIT,SDL_IGNORE);
SDL_EventState(SDL_USEREVENT,SDL_IGNORE);
SDL_EventState(SDL_SYSWMEVENT,SDL_IGNORE);
//Check there are actually joysticks attached
if (!SDL_NumJoysticks())
{
fprintf(stderr,"Error: No joysticks attached!\n");
SDL_Quit();
return(1);
}
/* test device_index, else look for a suitable device */
if (init_sdl_device(device_index) != 0)
{
printf("Failed to open joystick at SDL device index %d, attempting to find a suitable joystick...\n",device_index);
for (cnt = 0; cnt < STICK_INPUT_DEV_MAX; cnt++) {
if (init_sdl_device(cnt) == 0) break;
}
printf("Found an alternative device!\n");
}
/* return 1 if no device found */
if (cnt == STICK_INPUT_DEV_MAX) {
fprintf(stderr,"ERROR: no suitable joystick found [%s:%d]\n",
__FILE__,__LINE__);
SDL_Quit();
return(1);
}
return 0;
}
示例4: srand
Index::Index()
{
/** random **/
srand(time(0));
/** SDL **/
SDL_Init(SDL_INIT_VIDEO);
SDL_WM_SetCaption("Snake by Ceytix",NULL);
screen = SDL_SetVideoMode(750, 810, 32, SDL_HWSURFACE|SDL_DOUBLEBUF);
indexPicture = IMG_Load("files/pictures/index.png");
levelChoicePicture = IMG_Load("files/pictures/levelchoice.png");
creditsPicture = IMG_Load("files/pictures/credits.png");
pos.x = 0;
pos.y = 0;
/** SDL Events **/
SDL_EventState(SDL_MOUSEMOTION, SDL_IGNORE);
SDL_EventState(SDL_MOUSEBUTTONUP, SDL_IGNORE);
SDL_EventState(SDL_KEYUP, SDL_IGNORE);
/** Snake **/
game = new Snake();
}
示例5: SDL_GameControllerEventState
/*
* Turn off controller events
*/
int
SDL_GameControllerEventState(int state)
{
#if SDL_EVENTS_DISABLED
return SDL_IGNORE;
#else
const Uint32 event_list[] = {
SDL_CONTROLLERAXISMOTION, SDL_CONTROLLERBUTTONDOWN, SDL_CONTROLLERBUTTONUP,
SDL_CONTROLLERDEVICEADDED, SDL_CONTROLLERDEVICEREMOVED, SDL_CONTROLLERDEVICEREMAPPED,
};
unsigned int i;
switch (state) {
case SDL_QUERY:
state = SDL_IGNORE;
for (i = 0; i < SDL_arraysize(event_list); ++i) {
state = SDL_EventState(event_list[i], SDL_QUERY);
if (state == SDL_ENABLE) {
break;
}
}
break;
default:
for (i = 0; i < SDL_arraysize(event_list); ++i) {
SDL_EventState(event_list[i], state);
}
break;
}
return (state);
#endif /* SDL_EVENTS_DISABLED */
}
示例6: initSDL
static void initSDL(void)
{
//SDL initialisation
if (SDL_Init(SDL_INIT_JOYSTICK) < 0 )
{
printf("Could not initialize SDL(%s)\n", SDL_GetError());
fe_exit();
}
atexit(SDL_Quit);
keyssnes = SDL_GetKeyState(NULL);
SDL_SetVideoMode(0, 0, 16, SDL_SWSURFACE);
SDL_EventState(SDL_ACTIVEEVENT,SDL_IGNORE);
SDL_EventState(SDL_SYSWMEVENT,SDL_IGNORE);
SDL_EventState(SDL_VIDEORESIZE,SDL_IGNORE);
SDL_EventState(SDL_USEREVENT,SDL_IGNORE);
SDL_ShowCursor(SDL_DISABLE);
joy[0] = SDL_JoystickOpen(0);
if(joy[0]) {
if(SDL_JoystickEventState(SDL_ENABLE) != SDL_ENABLE) {
printf("Could not set joystick event state: %s\n", SDL_GetError());
fe_exit();
}
}
}
示例7: SDL_JoystickEventState
int
SDL_JoystickEventState(int state)
{
#if SDL_EVENTS_DISABLED
return SDL_DISABLE;
#else
const Uint32 event_list[] = {
SDL_JOYAXISMOTION, SDL_JOYBALLMOTION, SDL_JOYHATMOTION,
SDL_JOYBUTTONDOWN, SDL_JOYBUTTONUP, SDL_JOYDEVICEADDED, SDL_JOYDEVICEREMOVED
};
unsigned int i;
switch (state) {
case SDL_QUERY:
state = SDL_DISABLE;
for (i = 0; i < SDL_arraysize(event_list); ++i) {
state = SDL_EventState(event_list[i], SDL_QUERY);
if (state == SDL_ENABLE) {
break;
}
}
break;
default:
for (i = 0; i < SDL_arraysize(event_list); ++i) {
SDL_EventState(event_list[i], state);
}
break;
}
return (state);
#endif /* SDL_EVENTS_DISABLED */
}
示例8: main
int main(int argc, char **argv)
{
int i, rc;
SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER);
SDL_EventState(SDL_KEYDOWN, SDL_ENABLE);
SDL_EventState(SDL_QUIT, SDL_ENABLE);
for (i = 1; i < argc; i++) {
if (argv[i][0] == '-') {
switch (argv[i][1]) {
case 'h':
usage(argc, argv);
return 0;
default:
usage(argc, argv);
return 1;
}
continue;
}
rc = mng_read(argv[i], argv[i], mng_callback);
if (rc < 0)
fprintf(stderr, "reading '%s' returned %d\n", argv[i], rc);
}
return 0;
}
示例9: SDL_JoystickEventState
int SDL_JoystickEventState(int state)
{
#ifdef DISABLE_EVENTS
return SDL_IGNORE;
#else
const Uint8 event_list[] = {
SDL_JOYAXISMOTION, SDL_JOYBALLMOTION, SDL_JOYHATMOTION,
SDL_JOYBUTTONDOWN, SDL_JOYBUTTONUP,
};
int i;
switch (state) {
case SDL_QUERY:
state = SDL_IGNORE;
for ( i=0; i<SDL_TABLESIZE(event_list); ++i ) {
state = SDL_EventState(event_list[i],SDL_QUERY);
if ( state == SDL_ENABLE ) {
break;
}
}
break;
default:
for ( i=0; i<SDL_TABLESIZE(event_list); ++i ) {
SDL_EventState(event_list[i], state);
}
break;
}
return(state);
#endif /* DISABLE_EVENTS */
}
示例10: vo_sdl_init
int vo_sdl_init(void)
{
reinit = 0;
if (!SDL_WasInit(SDL_INIT_VIDEO)) {
// Unfortunately SDL_WINDOWID must be set at SDL_Init
// and is ignored afterwards, thus it cannot work per-file.
// Also, a value of 0 does not work for selecting the root window.
if (WinID > 0) {
char envstr[20];
snprintf(envstr, sizeof(envstr), "0x%"PRIx64, WinID);
setenv("SDL_WINDOWID", envstr, 1);
}
if (SDL_Init(SDL_INIT_VIDEO|SDL_INIT_NOPARACHUTE) < 0)
return 0;
}
// Setup Keyrepeats (500/30 are defaults)
SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, 100 /*SDL_DEFAULT_REPEAT_INTERVAL*/);
// Easiest way to get uppercase characters
SDL_EnableUNICODE(1);
// We don't want those in our event queue.
SDL_EventState(SDL_ACTIVEEVENT, SDL_IGNORE);
SDL_EventState(SDL_SYSWMEVENT, SDL_IGNORE);
SDL_EventState(SDL_USEREVENT, SDL_IGNORE);
// Try to get a sensible default for fullscreen.
get_screensize();
return 1;
}
示例11: getConfig
void
MainMenu::optionsBackButtonClicked(Button* )
{
getConfig()->save();
if( getConfig()->videoX != SDL_GetVideoSurface()->w || getConfig()->videoY != SDL_GetVideoSurface()->h)
{
if( getConfig()->restartOnChangeScreen )
{
quitState = RESTART;
running = false;
}
else
{
//SDL_IGNORE to avoid forth and back jumping resolution
SDL_EventState(SDL_VIDEORESIZE, SDL_IGNORE);
initVideo( getConfig()->videoX, getConfig()->videoY);
currentMenu->resize(getConfig()->videoX, getConfig()->videoY);
SDL_EventState(SDL_VIDEORESIZE, SDL_ENABLE);
gotoMainMenu();
}
}
else if( currentLanguage != getConfig()->language )
{
unsetenv("LINCITY_LANG");
quitState = RESTART;
running = false;
}
else
{
gotoMainMenu();
}
}
示例12: init_SDL
int init_SDL(void)
{
joy[0]=0;
joy[1]=0;
joy[2]=0;
joy[3]=0;
if (SDL_Init(SDL_INIT_JOYSTICK) < 0) {
fprintf(stderr, "Unable to init SDL: %s\n", SDL_GetError());
return(0);
}
sdlscreen = SDL_SetVideoMode(0,0, 16, SDL_SWSURFACE);
//We handle up to four joysticks
if(SDL_NumJoysticks())
{
int i;
SDL_JoystickEventState(SDL_ENABLE);
for(i=0;i<SDL_NumJoysticks();i++) {
joy[i]=SDL_JoystickOpen(i);
//Check for valid joystick, some keyboards
//aren't SDL compatible
if(joy[i])
{
if (SDL_JoystickNumAxes(joy[i]) > 28)
{
SDL_JoystickClose(joy[i]);
joy[i]=0;
logoutput("Error detected invalid joystick/keyboard\n");
}
else
joyCount++;
}
}
if(joy[0])
logoutput("Found %d joysticks\n",joyCount);
}
else
joyCount=1;
//sq frig number of players for keyboard
//joyCount=2;
SDL_EventState(SDL_ACTIVEEVENT,SDL_IGNORE);
SDL_EventState(SDL_SYSWMEVENT,SDL_IGNORE);
SDL_EventState(SDL_VIDEORESIZE,SDL_IGNORE);
SDL_EventState(SDL_USEREVENT,SDL_IGNORE);
SDL_ShowCursor(SDL_DISABLE);
//Initialise dispmanx
bcm_host_init();
//Clean exits, hopefully!
atexit(exitfunc);
return(1);
}
示例13: while
Direction TBFE::runEngine()
{
frame_++;
bool checkOnce=false;
while(logic_.pollEvent() || !checkOnce)
{
SDL_Event currentSdlEvent=logic_.getEvent();
checkEvents();
//Normal KeyBoard Events
if (currentSdlEvent.type==SDL_KEYDOWN && logic_.isEventNew())
{
if (logic_.checkKeyDown(27))
{
quit_=true;
};
};
checkOnce=true;
};
PositionI mapDimensions=Current_Map.getDimensions();
if (keyControl_==true)
{
logic_.playerMovement(Main_Player);
};
renderWindow_.finalRender(true);
if (frameRate_.GetTicks() > 1000)
{
frameRate_.Start();
time_++;
int Minutes=time_-(time_/100)*100;
if (Minutes>=60)
{
time_+=100-Minutes;
};
if (time_>2400)
{
time_=0;
};
frame_=0;
if (!showMouse_ && (mousePosition_.X!=screenDimensions_.X/2 || mousePosition_.Y!=screenDimensions_.Y/2))
{
SDL_EventState(SDL_MOUSEMOTION, SDL_IGNORE);
SDL_WarpMouse(mouseCenter_.X,mouseCenter_.Y);
SDL_WM_GrabInput( SDL_GRAB_ON );
SDL_EventState(SDL_MOUSEMOTION, SDL_ENABLE);
};
return SECOND;
};
gameSpeed_=60/(frame_*1000/frameRate_.GetTicks());
if (gameSpeed_>3)
{
gameSpeed_=3;
};
if (quit_==true)
{
return QUIT;
};
return NORMAL;
};
示例14: SDL_EventState
//
// ISDL12MouseInputDevice::pause
//
// Sets the internal state to ignore all input for this device.
//
// NOTE: SDL_EventState clears the SDL event queue so only call this after all
// SDL events have been processed in all SDL input device instances.
//
void ISDL12MouseInputDevice::pause()
{
mActive = false;
SDL_EventState(SDL_MOUSEMOTION, SDL_IGNORE);
SDL_EventState(SDL_MOUSEBUTTONDOWN, SDL_IGNORE);
SDL_EventState(SDL_MOUSEBUTTONUP, SDL_IGNORE);
SDL_ShowCursor(true);
}
示例15: initkeyb
void initkeyb(void)
{
SDL_EventState(SDL_MOUSEMOTION, SDL_IGNORE);
SDL_EventState(SDL_MOUSEBUTTONDOWN, SDL_IGNORE);
SDL_EventState(SDL_MOUSEBUTTONUP, SDL_IGNORE);
SDL_SetEventFilter(Handler);
}