Esempio n. 1
0
void PeTable:: Purge() {
  for (int i=0; i<NumPes;i++) {
    if (msgnum[i]) {
      // ComlibPrintf("%d Warning: %d Undelivered Messages for %d\n", CkMyPe(), msgnum[i], i);
      //msgnum[i]=0;
    }
  }
  GarbageCollect();
  //  ComlibPrintf("combcount = %d\n", combcount);
  //combcount = 0;
}
Esempio n. 2
0
void InterfaceReloadSystem()
{
	EnterServerLock();
	
	lprintf("InterfaceReloadSystem reloading system\n");
	
	PauseTimers();
	
	SendBlakodBeginSystemEvent(SYSEVENT_RELOAD_SYSTEM);
	
	GarbageCollect();
	SaveAll();
	
	ResetAdminConstants();
	ResetUser();
	ResetString();
	ResetRoomData();
	ResetLoadMotd();
	ResetLoadBof();
	ResetDLlist();
	ResetNameID();
	ResetResource();
	ResetTimer();
	ResetList();
	ResetObject();
	ResetMessage();
	ResetClass();
	
	LoadMotd();
	LoadBof();
	LoadRsc();
	
	LoadKodbase();
	
	UpdateSecurityRedbook();
	
	LoadAdminConstants();
	/* can't reload accounts because sessions have pointers to accounts */
	if (!LoadAllButAccount()) 
		eprintf("InterfaceReloadSystem couldn't load game.  You are dead.\n");
	
	AllocateParseClientListNodes(); /* it needs a list to send to users */
	AddBuiltInDLlist();
	
	SendBlakodEndSystemEvent(SYSEVENT_RELOAD_SYSTEM);
	
	UnpauseTimers();
	
	LeaveServerLock();
}
Esempio n. 3
0
PeTable :: ~PeTable() {
  int i;
  for (i=0;i<NumPes;i++) CmiFree(PeList[i]);
  CmiFree(PeList);
  delete msgnum;
  delete MaxSize;
  GarbageCollect();
  //CmiFree(ptrlist);
  PTinfo *tmp;
  while (PTFreeChunks) {
    tmp=PTFreeChunks;
    PTFreeChunks=PTNEXTCHUNK(tmp);
    CmiFree(tmp);
  }
  // delete FreeList;

}
Esempio n. 4
0
void InterfaceSave()
{
	EnterServerLock();
	
	lprintf("InterfaceSave saving\n");
	
	PauseTimers();
	SendBlakodBeginSystemEvent(SYSEVENT_SAVE);
	/* ResetRoomData(); */
	GarbageCollect();
	SaveAll();
	AllocateParseClientListNodes(); /* it needs a list to send to users */
	SendBlakodEndSystemEvent(SYSEVENT_SAVE);
	UnpauseTimers();
	
	LeaveServerLock();
}
Esempio n. 5
0
void Registry::Clear()
{
	root = Object();
	try
	{
		while (!instances.empty())
		{
			GarbageCollect();
		}
		foreach (Classes::value_type &val, classes)
		{
			delete val.second;
		}
	}
	catch (ExceptionBase &e)
	{
		OM_TRACE(3) << e;
	}

	instances.clear();
	classes.clear();
}
Esempio n. 6
0
void CGrassDrawer::Draw()
{
	if (grassOff || !readMap->GetGrassShadingTexture())
		return;

	glPushAttrib(GL_CURRENT_BIT);
	glColor4f(0.62f, 0.62f, 0.62f, 1.0f);

	SetupGlStateNear();
		static CGrassBlockDrawer drawer;
			drawer.cx = int(camera->GetPos().x / bMSsq);
			drawer.cy = int(camera->GetPos().z / bMSsq);
			drawer.inviewGrass.clear();
			drawer.inviewNearGrass.clear();
			drawer.gd = this;

		readMap->GridVisibility(camera, blockMapSize, maxGrassDist, &drawer);
	ResetGlStateNear();

	if (
		globalRendering->haveGLSL
		&& (!shadowHandler->shadowsLoaded || !globalRendering->atiHacks) // Ati crashes w/o an error when shadows are enabled!?
	) {
		SetupGlStateFar();
			std::sort(drawer.inviewGrass.begin(), drawer.inviewGrass.end(), GrassSort);
			std::sort(drawer.inviewNearGrass.begin(), drawer.inviewNearGrass.end(), GrassSortNear);

			glColor4f(0.62f, 0.62f, 0.62f, 1.0f);
			DrawFarBillboards(drawer.inviewGrass);

			glColor4f(0.62f, 0.62f, 0.62f, 1.0f);
			DrawNearBillboards(drawer.inviewNearGrass);
		ResetGlStateFar();
	}

	glPopAttrib();
	GarbageCollect();
}
Esempio n. 7
0
void Dlg_OnCommand(HWND hWnd, int id, HWND hWndCtl, UINT codeNotify) {

   UINT uIndex = 0;

   switch (id) {
      case IDCANCEL:
         EndDialog(hWnd, id);
         break;

      case IDC_RESERVE:
         // Reserve enough address space to hold the array of structures.
         g_pSomeData = (PSOMEDATA) VirtualAlloc(NULL, 
            MAX_SOMEDATA * sizeof(SOMEDATA), MEM_RESERVE, PAGE_READWRITE);

         // Disable the Reserve button and enable all the other controls.
         EnableWindow(GetDlgItem(hWnd, IDC_RESERVE),        FALSE);
         EnableWindow(GetDlgItem(hWnd, IDC_INDEXTEXT),      TRUE);
         EnableWindow(GetDlgItem(hWnd, IDC_INDEX),          TRUE);
         EnableWindow(GetDlgItem(hWnd, IDC_USE),            TRUE);
         EnableWindow(GetDlgItem(hWnd, IDC_GARBAGECOLLECT), TRUE);

         // Force the index edit control to have the focus.
         SetFocus(GetDlgItem(hWnd, IDC_INDEX));
         
         // Force the memory map to update
         InvalidateRect(hWnd, &g_rcMemMap, FALSE);
         break;

      case IDC_INDEX:
         if (codeNotify != EN_CHANGE)
            break;

         uIndex = GetDlgItemInt(hWnd, id, NULL, FALSE);

         if ((g_pSomeData != NULL) && chINRANGE(0, uIndex, MAX_SOMEDATA - 1)) 
		 {
            MEMORY_BASIC_INFORMATION mbi;
			/* Retrieves information about a range of pages 
			 * in the virtual address space of the calling process.
             * To retrieve information about a range of pages 
			 * in the address space of another process, use the VirtualQueryEx function.
			 *
			 * lpAddress [in, optional]
             *    A pointer to the base address of the region of pages to be queried. 
			 *    This value is rounded down to the next page boundary. 
			 *    To determine the size of a page on the host computer, use the GetSystemInfo function.
             *    If lpAddress specifies an address above the highest memory address accessible to the process, 
			 *    the function fails with ERROR_INVALID_PARAMETER.
			 * 
			 * lpBuffer [out]
             *    A pointer to a MEMORY_BASIC_INFORMATION structure 
			 *    in which information about the specified page range is returned. 
			 */
            VirtualQuery(&g_pSomeData[uIndex], &mbi, sizeof(mbi));
			/* State
             *    The state of the pages in the region. 
			 *    This member can be one of the following values.
			 * MEM_COMMIT
             *    0x1000
             *    Indicates committed pages for which physical storage has been allocated, 
			 *    either in memory or in the paging file on disk.
			 * 
			 */
            BOOL bOk = (mbi.State == MEM_COMMIT);
            if (bOk)
               bOk = g_pSomeData[uIndex].bInUse;

            EnableWindow(GetDlgItem(hWnd, IDC_USE),  !bOk);
            EnableWindow(GetDlgItem(hWnd, IDC_CLEAR), bOk);

         } 
		 else 
		 {
            EnableWindow(GetDlgItem(hWnd, IDC_USE),   FALSE);
            EnableWindow(GetDlgItem(hWnd, IDC_CLEAR), FALSE);
         }

         break;
         

      case IDC_USE:
         uIndex = GetDlgItemInt(hWnd, IDC_INDEX, NULL, FALSE);
         // NOTE: New pages are always zeroed by the system
		 /* Commit memory allocated for g_pSomeData[uIndex] */
         VirtualAlloc(
			 &g_pSomeData[uIndex], 
			 sizeof(SOMEDATA), 
             MEM_COMMIT, 
			 PAGE_READWRITE);

		 /* Mark this part of array as used */
         g_pSomeData[uIndex].bInUse = TRUE;

         EnableWindow(GetDlgItem(hWnd, IDC_USE),   FALSE);
         EnableWindow(GetDlgItem(hWnd, IDC_CLEAR), TRUE);

         // Force the Clear button control to have the focus.
         SetFocus(GetDlgItem(hWnd, IDC_CLEAR));
      
         // Force the memory map to update
         InvalidateRect(hWnd, &g_rcMemMap, FALSE);
         break;

      case IDC_CLEAR:
         uIndex = GetDlgItemInt(hWnd, IDC_INDEX, NULL, FALSE);
         g_pSomeData[uIndex].bInUse = FALSE;
         EnableWindow(GetDlgItem(hWnd, IDC_USE),   TRUE);
         EnableWindow(GetDlgItem(hWnd, IDC_CLEAR), FALSE);

         // Force the Use button control to have the focus.
         SetFocus(GetDlgItem(hWnd, IDC_USE));
         break;

      case IDC_GARBAGECOLLECT:
         GarbageCollect(g_pSomeData, MAX_SOMEDATA, sizeof(SOMEDATA));

         // Force the memory map to update
         InvalidateRect(hWnd, &g_rcMemMap, FALSE);
         break;
   }
}
void DX11SceneRepHashSDF::Integrate( ID3D11DeviceContext* context, ID3D11ShaderResourceView* inputDepth, ID3D11ShaderResourceView* inputColor, ID3D11ShaderResourceView* bitMask, const mat4f* rigidTransform)
{
	m_LastRigidTransform = *rigidTransform;		
	if (m_JustHashAndNoSDFBlocks)	return;	//in this case we cannot integrate and we just updated rigid transform

	//////////////////
	// Alloc Phase
	//////////////////
	MapConstantBuffer(context);
	Alloc(context, inputDepth, inputColor, bitMask);


	//////////////////
	// Compactify
	//////////////////

	// Start query for timing
	if(GlobalAppState::getInstance().s_timingsDetailledEnabled)
	{
		GlobalAppState::getInstance().WaitForGPU();
		s_Timer.start();
	}
	CompactifyHashEntries(context);
	if(GlobalAppState::getInstance().s_timingsDetailledEnabled)
	{
		GlobalAppState::getInstance().WaitForGPU();
		TimingLog::totalTimeCompactifyHash+=s_Timer.getElapsedTimeMS();
		TimingLog::countCompactifyHash++;
	}

	////////////////////////
	// Integrate
	////////////////////////
	MapConstantBuffer(context);	//we need to remap the buffer since numOccupiedEntries was re-computed by 'Compacitfy'
	IntegrateDepthMap(context, inputDepth, inputColor);


	if (false)
	{
		std::cout << "occupied hash entries: " << m_NumOccupiedHashEntries << std::endl;
		std::cout << "free blocks (before free)\t: " << GetHeapFreeCount(context) << " ( " << m_SDFNumBlocks << " ) " << std::endl;
		std::cout << "free + occupied blocks: " << m_NumOccupiedHashEntries + GetHeapFreeCount(context) << std::endl;
	}

	//////////////////////
	// Garbage Collect
	//////////////////////
	if (m_bEnableGarbageCollect) {
		if (GetNumIntegratedImages() > 1 && GetNumIntegratedImages() % 15 == 0) {	//reduce one weight every 15 frames
			StarveVoxelWeights(context);	
		}
		GarbageCollect(context);
	}


	if (false)
	{
		//std::cout << "occupied hash entries: " << m_NumOccupiedHashEntries << std::endl;
		std::cout << "free blocks (after free)\t: " << GetHeapFreeCount(context) << " ( " << m_SDFNumBlocks << " ) " << std::endl;
		//std::cout << "free + occupied blocks: " << m_NumOccupiedHashEntries + GetHeapFreeCount(context) << std::endl;
	}

	//CreateAndCopyToDebugBuf(DXUTGetD3D11Device(), DXUTGetD3D11DeviceContext(), m_HashCompactified);
	//DebugHash();
	//CreateAndCopyToDebugBuf(DXUTGetD3D11Device(), DXUTGetD3D11DeviceContext(), m_SDFBlocks);

	m_NumIntegratedImages++;
}
Esempio n. 9
0
void Registry::GarbageCollect()
{
	if (!tree)
		return;
	GarbageCollect(tree->GetRoot());
}
Esempio n. 10
0
//-------------------------------------------------------------------------------------------------
void sdResourceSystem::Destroy()
{
	// 垃圾收集
	GarbageCollect();
	m_bDisposing = true;

	// 提交所有资源释放请求到ProcessList
	m_kProcessListLocker.Lock();

	if (!m_kRequestList.empty())
	{
		sdRequestInfoListItr itr = m_kRequestList.begin();
		sdRequestInfoListItr itr_end = m_kRequestList.end();
		for (; itr != itr_end; ++itr)
		{
			sdRequestInfo& kRequestInfo = *itr;
			if (kRequestInfo.m_eRequest == sdRequestInfo::E_REQ_FREE)
				m_kProcessList.push_back(kRequestInfo);
		}
		m_kRequestList.clear();
	}

	m_kProcessListLocker.Unlock();

	// 销毁资源加载线程
	m_bActive = false;

	if (m_spProcessThread)
	{
		m_spProcessThread->WaitForCompletion();

		NiDelete m_spProcessThread;
		m_spProcessThread = NULL;
	}

	// 释放ProcessList中的资源
	if (!m_kProcessList.empty())
	{
		sdRequestInfoListItr itr = m_kProcessList.begin();
		sdRequestInfoListItr itr_end = m_kProcessList.end();
		for (; itr != itr_end; ++itr)
		{
			sdRequestInfo& kRequestInfo = *itr;
			kRequestInfo.m_spResource->FreeResource(false);
			kRequestInfo.m_spResource = 0;
		}

		m_kProcessList.clear();
	}	

	// 释放FinishedList中的资源
	if (!m_kFinishedList.empty())
	{
		sdRequestInfoListItr itr = m_kFinishedList.begin();
		sdRequestInfoListItr itr_end = m_kFinishedList.end();
		for (; itr != itr_end; ++itr)
		{
			sdRequestInfo& kRequestInfo = *itr;
			kRequestInfo.m_spResource->FreeResource(false);
			kRequestInfo.m_spResource = 0;
		}

		m_kFinishedList.clear();
	}	

	// 释放CachedList中的资源
	if (!m_kCachedList.empty())
	{
		sdRequestInfoListItr itr = m_kCachedList.begin();
		sdRequestInfoListItr itr_end = m_kCachedList.end();
		for (; itr != itr_end; ++itr)
		{
			sdRequestInfo& kRequestInfo = *itr;
			kRequestInfo.m_spResource->FreeResource(false);
			kRequestInfo.m_spResource = 0;
		}

		m_kFinishedList.clear();
	}	

	// 销毁资源缓存池
	m_pkNifResourcePool = 0;
	m_pkKfmResourcePool = 0;
	m_pkKfResourcePool = 0;
}
Esempio n. 11
0
void Dlg_OnCommand(HWND hWnd, int id, HWND hWndCtl, UINT codeNotify) {

   UINT uIndex = 0;

   switch (id) {
      case IDCANCEL:
         EndDialog(hWnd, id);
         break;

      case IDC_RESERVE:
         // Reserve enough address space to hold the array of structures.
         g_pSomeData = (PSOMEDATA) VirtualAlloc(NULL, 
            MAX_SOMEDATA * sizeof(SOMEDATA), MEM_RESERVE, PAGE_READWRITE);

         // Disable the Reserve button and enable all the other controls.
         EnableWindow(GetDlgItem(hWnd, IDC_RESERVE),        FALSE);
         EnableWindow(GetDlgItem(hWnd, IDC_INDEXTEXT),      TRUE);
         EnableWindow(GetDlgItem(hWnd, IDC_INDEX),          TRUE);
         EnableWindow(GetDlgItem(hWnd, IDC_USE),            TRUE);
         EnableWindow(GetDlgItem(hWnd, IDC_GARBAGECOLLECT), TRUE);

         // Force the index edit control to have the focus.
         SetFocus(GetDlgItem(hWnd, IDC_INDEX));
         
         // Force the memory map to update
         InvalidateRect(hWnd, &g_rcMemMap, FALSE);
         break;

      case IDC_INDEX:
         if (codeNotify != EN_CHANGE)
            break;

        uIndex = GetDlgItemInt(hWnd, id, NULL, FALSE);
         if ((g_pSomeData != NULL) && chINRANGE(0, uIndex, MAX_SOMEDATA - 1)) {
            MEMORY_BASIC_INFORMATION mbi;
            VirtualQuery(&g_pSomeData[uIndex], &mbi, sizeof(mbi));
            BOOL bOk = (mbi.State == MEM_COMMIT);
            if (bOk)
               bOk = g_pSomeData[uIndex].bInUse;

            EnableWindow(GetDlgItem(hWnd, IDC_USE),  !bOk);
            EnableWindow(GetDlgItem(hWnd, IDC_CLEAR), bOk);

         } else {
            EnableWindow(GetDlgItem(hWnd, IDC_USE),   FALSE);
            EnableWindow(GetDlgItem(hWnd, IDC_CLEAR), FALSE);
         }
         break;
         

      case IDC_USE:
         uIndex = GetDlgItemInt(hWnd, IDC_INDEX, NULL, FALSE);
         // NOTE: New pages are always zeroed by the system
         VirtualAlloc(&g_pSomeData[uIndex], sizeof(SOMEDATA), 
            MEM_COMMIT, PAGE_READWRITE);

         g_pSomeData[uIndex].bInUse = TRUE;

         EnableWindow(GetDlgItem(hWnd, IDC_USE),   FALSE);
         EnableWindow(GetDlgItem(hWnd, IDC_CLEAR), TRUE);

         // Force the Clear button control to have the focus.
         SetFocus(GetDlgItem(hWnd, IDC_CLEAR));
      
         // Force the memory map to update
         InvalidateRect(hWnd, &g_rcMemMap, FALSE);
         break;

      case IDC_CLEAR:
         uIndex = GetDlgItemInt(hWnd, IDC_INDEX, NULL, FALSE);
         g_pSomeData[uIndex].bInUse = FALSE;
         EnableWindow(GetDlgItem(hWnd, IDC_USE),   TRUE);
         EnableWindow(GetDlgItem(hWnd, IDC_CLEAR), FALSE);

         // Force the Use button control to have the focus.
         SetFocus(GetDlgItem(hWnd, IDC_USE));
         break;

      case IDC_GARBAGECOLLECT:
         GarbageCollect(g_pSomeData, MAX_SOMEDATA, sizeof(SOMEDATA));

         // Force the memory map to update
         InvalidateRect(hWnd, &g_rcMemMap, FALSE);
         break;
   }
}
Esempio n. 12
0
void DoEvents(photon_instance &instance){
    SDL_Event event;
    while(SDL_PollEvent(&event)){
        switch (event.type) {
        case SDL_TEXTINPUT:
            if(instance.gui.load_save_menu.loading || instance.gui.load_save_menu.saving){

                instance.gui.load_save_menu.filename.insert(instance.gui.load_save_menu.cursor, event.text.text);

                for(char* c = event.text.text; *c != '\0'; c++){
                    instance.gui.load_save_menu.cursor++;
                }
                instance.gui.load_save_menu.current_file_index = -1;
            }else{
                // if we don't need text input anymore...
                SDL_StopTextInput();
            }
            break;
        case SDL_TEXTEDITING:
            if(instance.gui.load_save_menu.loading || instance.gui.load_save_menu.saving){
                instance.gui.load_save_menu.filename.insert(event.edit.start, event.edit.text);
            }else{
                // if we don't need text input anymore...
                SDL_StopTextInput();
            }
            break;
        case SDL_KEYDOWN:
            if(!instance.input.is_valid){
                input::LoadConfig("/config/keyboard.xml", instance.input);

                PrintToLog("INFO: Using keyboard input.");
            }
            if(event.key.keysym.sym == SDLK_f && event.key.keysym.mod & KMOD_CTRL){
                window_managment::ToggleFullscreen(instance.window);
            }else if(event.key.keysym.sym == SDLK_i && event.key.keysym.mod & KMOD_CTRL){
                // re-detect input. by doing a garbage collect and an init over again it will detect newly connected controllers.
                PrintToLog("INFO: Reinitilizing input system to redetect available devices...");
                GarbageCollect(instance.input);
                instance.input = InitInput();
            }else if((instance.gui.load_save_menu.loading || instance.gui.load_save_menu.saving)){
                photon_gui_load_save_menu &load_save_menu = instance.gui.load_save_menu;
                if(event.key.keysym.sym == SDLK_BACKSPACE){
                    if(load_save_menu.cursor > 0 && load_save_menu.cursor <= load_save_menu.filename.length()){
                        load_save_menu.filename.erase(--load_save_menu.cursor, 1);
                        load_save_menu.current_file_index = -1;
                    }
                }else if(event.key.keysym.sym == SDLK_DELETE){
                    if(load_save_menu.cursor >= 0 && load_save_menu.cursor < load_save_menu.filename.length()){
                        load_save_menu.filename.erase(load_save_menu.cursor, 1);
                        load_save_menu.current_file_index = -1;
                    }
                }else if(event.key.keysym.sym == SDLK_LEFT && instance.input.left.type != photon_input_state::keyboard){
                    if(--load_save_menu.cursor < 0){
                        load_save_menu.cursor = 0;
                    }
                }else if(event.key.keysym.sym == SDLK_RIGHT && instance.input.right.type != photon_input_state::keyboard){
                    if(++load_save_menu.cursor > load_save_menu.filename.length()){
                        load_save_menu.cursor = load_save_menu.filename.length();
                    }
                }else if(event.key.keysym.sym == SDLK_HOME){
                    if(load_save_menu.current_file_index == -1){
                        load_save_menu.cursor = 0;
                    }else{
                        load_save_menu.current_file_index = 0;
                        load_save_menu.filename = load_save_menu.file_list[load_save_menu.current_file_index];
                    }
                }else if(event.key.keysym.sym == SDLK_END){
                    if(load_save_menu.current_file_index == -1){
                        load_save_menu.cursor = load_save_menu.filename.length();
                    }else{
                        load_save_menu.current_file_index = load_save_menu.file_list.size() - 1;
                        load_save_menu.filename = load_save_menu.file_list[load_save_menu.current_file_index];
                    }
                }else if(event.key.keysym.sym == SDLK_ESCAPE){
                    gui::CancelLoadSave(instance);
                }
            }else if(event.key.keysym.sym == SDLK_ESCAPE){
                instance.paused = !instance.paused;
            }else if(event.key.keysym.sym == SDLK_s && event.key.keysym.mod & KMOD_CTRL){
                instance.paused = true;
                gui::StartSavingGUI(instance);
            }
            break;
        case SDL_QUIT:
            Close(instance);
            break;
        case SDL_WINDOWEVENT:
            switch(event.window.event){
            case SDL_WINDOWEVENT_RESIZED:
//            case SDL_WINDOWEVENT_SIZE_CHANGED:
                if(event.window.data1 < 1){
                    // prevent window dissapearing if some weirdo decides to resize the window to a width of 0...
                    SDL_SetWindowSize(instance.window.window_SDL, 1, event.window.data2);
                    break;
                }
                if(event.window.data2 < 1){
                    // prevent window dissapearing if some weirdo decides to resize the window to a height of 0...
                    SDL_SetWindowSize(instance.window.window_SDL, event.window.data1, 1);
                    break;
                }
                opengl::OnResize(event.window.data1,event.window.data2, instance.window);
                break;
            }
            break;
        case SDL_MOUSEWHEEL:
            if(!instance.paused){
                instance.camera_offset.z -= event.wheel.y * instance.camera_offset.z * 0.02f;
            }
            break;
        case SDL_MOUSEBUTTONUP:
            if(!instance.input.is_valid){
                input::LoadConfig("/config/keyboard.xml", instance.input);

                PrintToLog("INFO: Using mouse & keyboard input.");
            }else if(event.button.button == SDL_BUTTON_LEFT){
                if(!gui::HandleMouseClick(instance, event.button.x, event.button.y)){
                    if(glm::length(instance.player.location - WindowToWorldCoord(instance, event.button.x, event.button.y)) < 0.5f){
                        blocks::OnPhotonInteract(glm::uvec2(instance.player.location + 0.5f), instance.level, instance.player);
                    }
                }
            }
            break;
        case SDL_CONTROLLERBUTTONUP:
            if(!instance.input.is_valid){
                SDL_GameController *controller = SDL_GameControllerOpen(event.cbutton.which);

                if(controller != nullptr){
                    input::LoadConfig("/config/controller.xml", instance.input);
                    instance.input.controller = controller;

                    PrintToLog("INFO: Using Game Controller (device index %i)", event.cbutton.which);
                }
            }
            break;
        case SDL_CONTROLLERAXISMOTION:
            if(!instance.input.is_valid){
                SDL_GameController *controller = SDL_GameControllerOpen(event.caxis.which);

                if(controller != nullptr){
                    input::LoadConfig("/config/controller.xml", instance.input);
                    instance.input.controller = controller;

                    PrintToLog("INFO: Using Game Controller (device index %i)", event.caxis.which);
                }
            }
            break;
        }
    }
}