void LocalEvent::SetStateDefaults(void) { // enable events SetState(SDL_ACTIVEEVENT, true); SetState(SDL_USEREVENT, true); SetState(SDL_KEYDOWN, true); SetState(SDL_KEYUP, true); SetState(SDL_MOUSEMOTION, true); SetState(SDL_MOUSEBUTTONDOWN, true); SetState(SDL_MOUSEBUTTONUP, true); SetState(SDL_QUIT, true); // ignore events SetState(SDL_JOYAXISMOTION, false); SetState(SDL_JOYBALLMOTION, false); SetState(SDL_JOYHATMOTION, false); SetState(SDL_JOYBUTTONUP, false); SetState(SDL_JOYBUTTONDOWN, false); SetState(SDL_SYSWMEVENT, false); SetState(SDL_VIDEORESIZE, false); SetState(SDL_VIDEOEXPOSE, false); #if SDL_VERSION_ATLEAST(1, 3, 0) SDL_SetEventFilter(GlobalFilterEvents, NULL); #else SDL_SetEventFilter(GlobalFilterEvents); #endif }
void GerenciadorDeEventos::setFiltroDeEventosDeApp(FiltroDeEventosDeApp* filtro) { filtroEventosApp = filtro; if(filtro) SDL_SetEventFilter(filtrarEventosDeApp, filtroEventosApp); else SDL_SetEventFilter(NULL, NULL); }
VOID PAL_InitInput( VOID ) /*++ Purpose: Initialize the input subsystem. Parameters: None. Return value: None. --*/ { memset(&g_InputState, 0, sizeof(g_InputState)); g_InputState.dir = kDirUnknown; g_InputState.prevdir = kDirUnknown; #if SDL_MAJOR_VERSION == 1 && SDL_MINOR_VERSION <= 2 SDL_SetEventFilter(PAL_EventFilter); #else SDL_SetEventFilter(PAL_EventFilter, NULL); #endif // // Setup input // sceCtrlSetSamplingCycle(0); sceCtrlSetSamplingMode(PSP_CTRL_MODE_ANALOG); pad.Buttons = 0; // // Start thread to read data // if((pad_sem = SDL_CreateSemaphore(1)) == NULL) { TerminateOnError("Can't create input semaphore\n"); return; } running = 1; if((bthread = SDL_CreateThread(PSP_JoystickUpdate, NULL)) == NULL) { TerminateOnError("Can't create input thread\n"); return; } }
void InitEventFilter(EventFilter filter_function) { #if defined(TARGET_SDL) /* set event filter to filter out certain events */ SDL_SetEventFilter(filter_function); #endif }
void clippy_init(void) { SDL_SysWMinfo info; has_sys_clip = 0; memset(&info, 0, sizeof(info)); SDL_VERSION(&info.version); if (SDL_GetWMInfo(&info)) { #if defined(USE_X11) if (info.subsystem == SDL_SYSWM_X11) { SDL_Display = info.info.x11.display; SDL_Window = info.info.x11.window; lock_display = info.info.x11.lock_func; unlock_display = info.info.x11.unlock_func; SDL_EventState(SDL_SYSWMEVENT, SDL_ENABLE); SDL_SetEventFilter(_x11_clip_filter); has_sys_clip = 1; atom_sel = XInternAtom(SDL_Display, "SDL_SELECTION", False); atom_clip = XInternAtom(SDL_Display, "CLIPBOARD", False); orig_xlib_err = XSetErrorHandler(handle_xlib_err); } if (!lock_display) lock_display = __noop_v; if (!unlock_display) unlock_display = __noop_v; #elif defined(WIN32) has_sys_clip = 1; SDL_Window = info.window; #elif defined(__QNXNTO__) has_sys_clip = 1; inputgroup = PhInputGroup(NULL); #endif } }
static void IN_EndIgnoringMouseEvents(void) { SDL_EventFilter currentFilter; void *currentUserdata; if (SDL_GetEventFilter(¤tFilter, ¤tUserdata) == SDL_TRUE) SDL_SetEventFilter(NULL, NULL); }
int main( int argc, char* args[] ) { unsigned int i; printf("starting keyboard test\n"); //Initialize SDL if( SDL_Init( SDL_INIT_EVENTS ) < 0 ) { printf( "SDL could not initialize! SDL_Error: %s\n", SDL_GetError() ); } for (i = 0; i < SDL_NUM_SCANCODES; i++) { myKeyState[i] = 0; } #if !SDL_VERSION_ATLEAST(2,0,0) SDL_EnableKeyRepeat(0, 0); #endif SDL_SetEventFilter(event_sdl_filter, NULL); while (ok) { printf("."); fflush(stdout); SDL_PumpEvents(); usleep(100000); } //Quit SDL subsystems SDL_Quit(); printf("finished\n"); return 0; }
void Initialize( void ) { #if __APPLE__ // Shiny OS X InitResources(); #else #if _WIN32 HMODULE module; char name[MAX_PATH+1], *lastBackslash; module = GetModuleHandle( NULL ); GetModuleFileName( module, name, MAX_PATH ); lastBackslash = strrchr( name, '\\' ); if( lastBackslash != NULL ) { *lastBackslash = '\0'; strcpy( candyCrisisResources, name ); strcat( candyCrisisResources, "\\CandyCrisisResources\\" ); } #endif #if TARGET_API_MAC_CARBON // Classic MacOS strcpy( candyCrisisResources, ":CandyCrisisResources:" ); #endif #ifdef linux strcpy( candyCrisisResources, "CandyCrisisResources/" ); #endif #endif atexit( SDL_Quit ); SDL_SetEventFilter( SDLU_EventFilter ); }
void event_initialize(void) { const char *event_str = NULL; int i; /* set initial state of all joystick commands to 'off' */ for (i = 0; i < NumJoyCommands; i++) JoyCmdActive[i] = 0; /* activate any joysticks which are referenced in the joystick event command strings */ for (i = 0; i < NumJoyCommands; i++) { event_str = ConfigGetParamString(g_CoreConfig, JoyCmdName[i]); if (event_str != NULL && strlen(event_str) >= 4 && event_str[0] == 'J' && event_str[1] >= '0' && event_str[1] <= '9') { int device = event_str[1] - '0'; if (!SDL_WasInit(SDL_INIT_JOYSTICK)) SDL_InitSubSystem(SDL_INIT_JOYSTICK); if (!SDL_JoystickOpened(device)) SDL_JoystickOpen(device); } } /* set up SDL event filter and disable key repeat */ SDL_EnableKeyRepeat(0, 0); SDL_SetEventFilter(event_sdl_filter); }
VOID PAL_InitInput(VOID ) /*++ Purpose: Initialize the input subsystem. Parameters: None. Return value: None. --*/ { memset(&g_InputState, 0, sizeof(g_InputState)); g_InputState.dir = kDirUnknown; g_InputState.prevdir = kDirUnknown; SDL_SetEventFilter(PAL_EventFilter); // // Check for joystick // /*if (SDL_NumJoysticks() > 0) { g_pJoy = SDL_JoystickOpen(0); if (g_pJoy != NULL) { SDL_JoystickEventState(SDL_ENABLE); } }*/ }
Vga::Vga(sc_core::sc_module_name name) : sc_core::sc_module(name), address(0), intr(false) { SC_THREAD(thread); if(SDL_Init(SDL_INIT_VIDEO) < 0) { SC_REPORT_FATAL(sc_module::name(), SDL_GetError()); } atexit(SDL_Quit); SDL_SetEventFilter(filter); screen = SDL_SetVideoMode(VGA_WIDTH, VGA_HEIGHT, 16, SDL_DOUBLEBUF | SDL_HWSURFACE); if(screen->format->BytesPerPixel != 2) { SC_REPORT_FATAL(sc_module::name(), SDL_GetError()); } black = SDL_MapRGB(screen->format, 0x00, 0x00, 0x00); white = SDL_MapRGB(screen->format, 0xFF, 0xFF, 0xFF); SDL_WM_SetCaption(sc_module::name(), NULL); #ifdef DEBUG std::cout << "Debug: " << sc_module::name() << ": LCD controller TLM model\n"; #endif }
void initWindow(std::string name, int w, int h, int wflags, int rflags){ init(); SDL_SetHint(SDL_HINT_RENDER_OPENGL_SHADERS, "1"); SDL_SetHint(SDL_HINT_RENDER_DRIVER, "opengl"); GRAPHICS::window = SDL_CreateWindow(name.c_str(), SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, w, h, wflags | SDL_WINDOW_OPENGL); if (GRAPHICS::window == NULL) {std::cout << SDL_GetError() << std::endl;} GRAPHICS::renderer = SDL_CreateRenderer(GRAPHICS::window, -1, rflags | SDL_RENDERER_TARGETTEXTURE); if (GRAPHICS::renderer == NULL) {std::cout << SDL_GetError() << std::endl;} GRAPHICS::glcontext = SDL_GL_CreateContext(GRAPHICS::window); GRAPHICS::glcontext = SDL_GL_GetCurrentContext(); GRAPHICS::setColor(255,255,255,255); GRAPHICS::setBackgroundColor(0,0,0,255); setViewport(w, h); //yay workarounds SDL_SetWindowSize(GRAPHICS::window, w, h); GRAPHICS::resize(); initGL(); /* Explanation for window resize work-around: The first resize of an application will reset the openGL context, all following resizes will have no effect. To get around this, a resize is forced to the window. */ SDL_SetEventFilter(resize_sdl_event, nullptr); std::cout << "JE: Initiated Window." << std::endl; }
static int eventAddFilter(lua_State *L, int type) { Filter *f; luaL_checktype(L, 1, LUA_TFUNCTION); if ((f = malloc(sizeof (Filter))) == NULL) return commonPushErrno(L, 1); f->L = L; f->type = type; /* Push the function and ref it */ lua_pushvalue(L, 1); f->ref = luaL_ref(L, LUA_REGISTRYINDEX); if (type == EventTypeWatcher) SDL_AddEventWatch((SDL_EventFilter)eventFilter, f); else if (type == EventTypeFilter) SDL_SetEventFilter((SDL_EventFilter)eventFilter, f); /* Push the object to the user */ commonPushUserdata(L, EventFilterName, f); return 1; }
void fv_error_message(const char *format, ...) { struct fv_buffer buffer; va_list ap; /* Stop drawing or processing any further events */ SDL_SetEventFilter(NULL, NULL); emscripten_cancel_main_loop(); va_start(ap, format); fv_buffer_init(&buffer); fv_buffer_append_vprintf(&buffer, format, ap); va_end(ap); EM_ASM_({ console.error(Module.Pointer_stringify($0)); var canvas = document.getElementById("canvas"); canvas.style.display = "none"; var errorMessage = document.getElementById("error-message"); errorMessage.style.display = "block"; },
int main(int argc, char **argv) { opts=new SGraphOptions(); d=new DemoData(opts); plotter = new SDLPlotter(opts,d); SDL_Thread *controller = SDL_CreateThread (control,NULL); SDL_Thread *plotThread= SDL_CreateThread (plot,NULL); SDL_SetEventFilter(pollforquit); while(!done) { SDL_Delay(50); if(opts->follow) { d->SetEofReached(0); SDL_Delay(1000); plotter->PlotData(d); } if(opts->update) { d->ResetData(); SDL_Delay(1000); plotter->PlotData(d); } } plotter->QuitPlotting(); SDL_KillThread(controller); SDL_KillThread(plotThread); SDL_Quit(); exit(0); }
void initkeyb(void) { SDL_EventState(SDL_MOUSEMOTION, SDL_IGNORE); SDL_EventState(SDL_MOUSEBUTTONDOWN, SDL_IGNORE); SDL_EventState(SDL_MOUSEBUTTONUP, SDL_IGNORE); SDL_SetEventFilter(Handler); }
void close_pause_chat( void ) { gui_widget_hide( dlg_pauseroom ); set_state( CS_PLAY ); /* enable event filter */ SDL_SetEventFilter( event_filter ); gui_widget_enable_event( dlg_chatroom, GUI_TIME_PASSED ); }
static void IN_BeginIgnoringMouseEvents(void) { SDL_EventFilter currentFilter = NULL; void *currentUserdata = NULL; SDL_GetEventFilter(¤tFilter, ¤tUserdata); if (currentFilter != IN_SDL2_FilterMouseEvents) SDL_SetEventFilter(IN_SDL2_FilterMouseEvents, NULL); }
static void _CloseOverlay() { if (_this->currentEventFilter != NULL) { SDL_SetEventFilter(_this->currentEventFilter, _this->currentEventFilterData); } _this->open = SDL_FALSE; SDL_Log("Overlay closed\n"); }
bool SDL2Window::initializeFramework() { arx_assert(s_mainWindow == NULL, "SDL only supports one window"); // TODO it supports multiple windows now! arx_assert(m_displayModes.empty()); const char * headerVersion = ARX_STR(SDL_MAJOR_VERSION) "." ARX_STR(SDL_MINOR_VERSION) "." ARX_STR(SDL_PATCHLEVEL); CrashHandler::setVariable("SDL version (headers)", headerVersion); if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTS) < 0) { LogError << "Failed to initialize SDL: " << SDL_GetError(); return false; } #ifdef ARX_DEBUG // No SDL, this is more annoying than helpful! #if defined(SIGINT) signal(SIGINT, SIG_DFL); #endif #if defined(SIGTERM) signal(SIGTERM, SIG_DFL); #endif #endif SDL_version ver; SDL_GetVersion(&ver); std::ostringstream runtimeVersion; runtimeVersion << int(ver.major) << '.' << int(ver.minor) << '.' << int(ver.patch); CrashHandler::setVariable("SDL version (runtime)", runtimeVersion.str()); LogInfo << "Using SDL " << runtimeVersion.str(); int ndisplays = SDL_GetNumVideoDisplays(); for(int display = 0; display < ndisplays; display++) { int modes = SDL_GetNumDisplayModes(display); for(int i = 0; i < modes; i++) { SDL_DisplayMode mode; if(SDL_GetDisplayMode(display, i, &mode) >= 0) { m_displayModes.push_back(Vec2i(mode.w, mode.h)); } } } std::sort(m_displayModes.begin(), m_displayModes.end()); m_displayModes.erase(std::unique(m_displayModes.begin(), m_displayModes.end()), m_displayModes.end()); s_mainWindow = this; SDL_SetEventFilter(eventFilter, NULL); SDL_EventState(SDL_WINDOWEVENT, SDL_ENABLE); SDL_EventState(SDL_QUIT, SDL_ENABLE); SDL_EventState(SDL_SYSWMEVENT, SDL_IGNORE); SDL_EventState(SDL_USEREVENT, SDL_IGNORE); return true; }
VOID PAL_InitInput( VOID ) /*++ Purpose: Initialize the input subsystem. Parameters: None. Return value: None. --*/ { memset(&g_InputState, 0, sizeof(g_InputState)); g_InputState.dir = kDirUnknown; g_InputState.prevdir = kDirUnknown; #if SDL_MAJOR_VERSION == 1 && SDL_MINOR_VERSION <= 2 SDL_SetEventFilter(PAL_EventFilter); #else SDL_SetEventFilter(PAL_EventFilter, NULL); #endif // // Check for joystick // #ifdef PAL_HAS_JOYSTICKS if (SDL_NumJoysticks() > 0 && g_fUseJoystick) { g_pJoy = SDL_JoystickOpen(0); if (g_pJoy != NULL) { SDL_JoystickEventState(SDL_ENABLE); } } #endif }
SDLEventManager::SDLEventManager(bool multi, Event_Filter eventFilter) { // intialize the class parameters multi_ = multi; event_listener_map_ = new EventListenerMap(); events_ = new SDL_Event[EVENT_QUEUE_SIZE]; // fuction for user to define for filtering events if (eventFilter != NULL) SDL_SetEventFilter((SDL_EventFilter)eventFilter, NULL); }
void SDLApp::initX11ClipboardEventFilter() { SDL_SysWMinfo wininfo; SDL_VERSION(&wininfo.version); SDL_GetWMInfo(&wininfo); SDL_EventState(SDL_SYSWMEVENT, SDL_ENABLE); SDL_SetEventFilter(SDLApp::X11ClipboardEventFilter); xa_targets = XInternAtom(wininfo.info.x11.display, "TARGETS", False); xa_clipboard = XInternAtom(wininfo.info.x11.display, "CLIPBOARD", False); }
static AM_ErrorCode_t sdl_open (AM_INP_Device_t *dev, const AM_INP_OpenPara_t *para) { SDL_InitSubSystem(SDL_INIT_VIDEO|SDL_INIT_EVENTTHREAD); pthread_mutex_init(&lock, NULL); pthread_cond_init(&cond, NULL); curr_event.type = SDL_NOEVENT; SDL_SetEventFilter(evt_filter); return AM_SUCCESS; }
MediaWidget::JoystickIniter::JoystickIniter() { SDL_JoystickInit(); SDL_SetEventFilter(SDL_JOYAXISMOTION | SDL_JOYBUTTONCHANGE | SDL_JOYHATMOTION); for (int i = 0, n = SDL_NumJoysticks(); i < n; ++i) { if (SDL_Joystick *joy = SDL_JoystickOpen(i)) joysticks_.push_back(joy); } SDL_JoystickUpdate(); SDL_ClearEvents(); }
int initCtrl (){ if(!(SDL_Init(SDL_INIT_EVERYTHING))){ SDL_SetEventFilter(eventFilter); SDL_SetVideoMode(200, 200, 0, 0); // SDL_WM_GrabInput(SDL_GRAB_ON); // If gamepad mode specified, open gamepad if(ctrlmode == GAMEPAD){ int num_pads; // If more than one joystick attached, let user choose which one if((num_pads = SDL_NumJoysticks()) > 1){ sprintf(termbuf, "Select gamepad index (number from 0 to %d): ", (num_pads-1)); printmsg(); while((pad_index = fgetc(stdin)) == EOF); } if((pad = SDL_JoystickOpen(pad_index))){ sprintf(termbuf, "%s opened successfully.\n", SDL_JoystickName(pad_index)); printmsg(); // Set initial modes cur_move = MOV_STOP; cur_turn = TRN_NONE; cur_h_aim = AIM_H_STRGHT; cur_v_aim = AIM_V_STRGHT; cur_fire = FIRE_OFF; cur_l_strf = STRF_L_OFF; cur_r_strf = STRF_R_OFF; SDL_JoystickEventState(SDL_ENABLE); } else{ sprintf(termbuf, "Gamepad %s not opened successfully.\nReverting to keyboard control\n", SDL_JoystickName(pad_index)); printmsg(); ctrlmode = KEYBOARD; } } return -1; } return 0; }
int main(int argc, char *argv[]) { LoadCfg(); // load the configuration file // Initialize defaults, video and audio if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_TIMER | SDL_INIT_NOPARACHUTE) == -1) { fprintf(stderr, "FATAL ERROR: Could not initialize SDL: %s.\n", SDL_GetError()); exit(1); } // Initialize the display in a 640x480 24-bit mode int f = (atoi(cfg.Get("OPTIONS", "FullScreen", "0")) > 0); if (f) { f = SDL_FULLSCREEN; } gpScreen = SDL_SetVideoMode(640, 480, 24, SDL_HWSURFACE | f); if (gpScreen == NULL) { gpScreen = SDL_SetVideoMode(640, 480, 24, SDL_SWSURFACE | f); } if (gpScreen == NULL) { fprintf(stderr, "FATAL ERROR: Could not set video mode: %s\n", SDL_GetError()); exit(1); } SDL_WM_SetCaption("Dou Di Zhu", NULL); g_fNoSound = (atoi(cfg.Get("OPTIONS", "NoSound", "0")) > 0); // Open the audio device if (SOUND_OpenAudio(22050, AUDIO_S16, 1, 1024) < 0) { fprintf(stderr, "WARNING: Couldn't open audio device: %s\n", SDL_GetError()); g_fNoSound = true; } InitTextMessage(); SDL_SetEventFilter(EventFilter); gpGeneral = new CGeneral; gpGame = new CGame; g_UI.OpeningUI(); UserQuit(); return 255; }
int input_init(void) { #if SDL_VERSION_ATLEAST(2,0,0) /* SDL_EnableKeyRepeat(500, 30); */ /* TODO ? */ last_press_ms = 0; last_repeat_ms = 0; #else SDL_EnableKeyRepeat(INPUT_REP_DELAY_MS, INPUT_REP_INTERVAL_MS); #endif m_focus = !!(SDL_GetAppState() & SDL_APPMOUSEFOCUS); #ifdef IOS SDL_SetEventFilter(HandleAppEvents, NULL); #endif return 0; }
int init_scrap(void) { SDL_SysWMinfo info; int retval; /* Grab the window manager specific information */ retval = -1; SDL_SetError("SDL is not running on known window manager"); SDL_VERSION(&info.version); if ( SDL_GetWMInfo(&info) ) { /* Save the information for later use */ #if defined(WZ_WS_X11) /* * */ if ( info.subsystem == SDL_SYSWM_X11 ) { SDL_Display = info.info.x11.display; SDL_Window = info.info.x11.window; Lock_Display = info.info.x11.lock_func; Unlock_Display = info.info.x11.unlock_func; /* Enable the special window hook events */ SDL_EventState(SDL_SYSWMEVENT, SDL_ENABLE); SDL_SetEventFilter(clipboard_filter); retval = 0; } else { SDL_SetError("SDL is not running on X11"); } #elif defined(WZ_WS_WIN) /* * */ SDL_Window = info.window; retval = 0; #elif defined(WZ_WS_QNX) /* * */ InputGroup=PhInputGroup(NULL); retval = 0; #endif /* scrap type */ } return(retval); }
int scrap_init_x11 (void) { SDL_SysWMinfo info; int retval = 0; SDL_VERSION (&info.version); if (SDL_GetWMInfo (&info)) { /* Save the information for later use */ if (info.subsystem == SDL_SYSWM_X11) { XWindowAttributes setattrs; XSetWindowAttributes newattrs; newattrs.event_mask = PropertyChangeMask; _sdldisplay = info.info.x11.display; _sdlwindow = info.info.x11.window; Lock_Display = info.info.x11.lock_func; Unlock_Display = info.info.x11.unlock_func; Lock_Display (); /* We need the PropertyNotify event for the timestap, so * modify the event attributes. */ XGetWindowAttributes (_sdldisplay, _sdlwindow, &setattrs); newattrs.event_mask |= setattrs.all_event_masks; XChangeWindowAttributes (_sdldisplay, _sdlwindow, CWEventMask, &newattrs); Unlock_Display (); /* Enable the special window hook events */ SDL_EventState (SDL_SYSWMEVENT, SDL_ENABLE); SDL_SetEventFilter (_clipboard_filter); /* Create the atom types we need. */ _init_atom_types (); retval = 1; } else SDL_SetError ("SDL is not running on X11"); } return retval; }