Esempio n. 1
0
void timer_init()
{
	if ( !Timer_inited )	{
		INITIALIZE_CRITICAL_SECTION( Timer_lock );

#ifdef _WIN32
		timeBeginPeriod(precision);
		Timer_base = Timer_last_value = timeGetTime();
#endif

		Timer_inited = 1;

		atexit(timer_close);
	}
}
Esempio n. 2
0
void key_init()
{
	// Initialize queue
	if (key_inited)
		return;
	key_inited = 1;

	INITIALIZE_CRITICAL_SECTION(key_lock);

	ENTER_CRITICAL_SECTION(key_lock);

#ifdef SCP_UNIX
	FillSDLArray();
#endif

	keyd_time_when_last_pressed = timer_get_milliseconds();
	keyd_buffer_type = 1;
	keyd_repeat = 1;

	// Clear the keyboard array
	key_flush();

	// Clear key filter
	key_clear_filter();

	LEAVE_CRITICAL_SECTION(key_lock);

#ifdef _WIN32
	#ifdef USE_DIRECTINPUT
		di_init();
	#endif

	OSVERSIONINFO ver;
	ver.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
	GetVersionEx(&ver);
	if ( ver.dwPlatformId == VER_PLATFORM_WIN32_NT ) {
		Key_running_NT = 1;
	} else {
		Key_running_NT = 0;
		if ( key_numlock_is_on() ) {
			Key_numlock_was_on = 1;
			key_turn_off_numlock();
		}
	}
#endif

	atexit(key_close);
}
Esempio n. 3
0
void mouse_init()
{
	// Initialize queue
	if ( mouse_inited ) return;
	mouse_inited = 1;

	INITIALIZE_CRITICAL_SECTION( mouse_lock );

	ENTER_CRITICAL_SECTION( mouse_lock );

	mouse_flags = 0;
	Mouse_x = gr_screen.max_w / 2;
	Mouse_y = gr_screen.max_h / 2;

	#ifdef WIN32
		if (Cmdline_no_di_mouse) {
			Mouse_mode = MOUSE_MODE_WIN;
		} else {
			if (!di_init() || Cmdline_window || Cmdline_fullscreen_window)
				Mouse_mode = MOUSE_MODE_WIN;
			else
				Mouse_mode = MOUSE_MODE_DI;
		} 
	#else
		Mouse_mode = MOUSE_MODE_WIN;
	#endif


#ifdef SCP_UNIX
	// we poll for mouse motion events so be sure to skip those in normal event polling
	SDL_EventState( SDL_MOUSEMOTION, SDL_IGNORE );

	// we do want to make sure that button presses go through event polling though
	// (should be on by default already, just here as a reminder)
	SDL_EventState( SDL_MOUSEBUTTONDOWN, SDL_ENABLE );
	SDL_EventState( SDL_MOUSEBUTTONUP, SDL_ENABLE );
#endif

	LEAVE_CRITICAL_SECTION( mouse_lock );	

	atexit( mouse_close );
}
// If app_name is NULL or ommited, then TITLE is used
// for the app name, which is where registry keys are stored.
void os_init(const char * wclass, const char * title, const char *app_name, const char *version_string )
{
	// create default ini entries for the user
	if (os_config_read_string(NULL, NOX("VideocardFs2open"), NULL) == NULL)
		os_config_write_string(NULL, NOX("VideocardFs2open"), NOX("OGL -(640x480)x16 bit"));

	os_init_registry_stuff(Osreg_company_name, title, version_string);
	
	strcpy_s( szWinTitle, title );
	strcpy_s( szWinClass, wclass );	

	INITIALIZE_CRITICAL_SECTION( Os_lock );

	unix_process(0);

	// initialized
	Os_inited = 1;

	atexit(os_deinit);
}
Esempio n. 5
0
// Constructor
AudioStream::AudioStream(void)
{
	INITIALIZE_CRITICAL_SECTION(write_lock);
}
Esempio n. 6
0
void audiostream_init()
{
	int i;

	if (Audiostream_inited == 1)
		return;

	if (!ACM_is_inited())
	{
		return;
	}

	// Create and initialize AudioStreamServices object.
	// This must be done once and only once for each window that uses
	// streaming services.
	m_pass = (AudioStreamServices*)vm_malloc(sizeof(AudioStreamServices));

	if (m_pass)
	{
		m_pass->Constructor();
		m_pass->Initialize();

		if (!pDirectSound)
		{
			return;
		}
	}

	// Allocate memory for the buffer which holds the uncompressed wave data that is streamed from the
	// disk during a load/cue
	if (Wavedata_load_buffer == NULL)
	{
		Wavedata_load_buffer = (unsigned char*)vm_malloc(BIGBUF_SIZE);
		Assert(Wavedata_load_buffer != NULL);
	}

	// Allocate memory for the buffer which holds the uncompressed wave data that is streamed from the
	// disk during a service interval
	if (Wavedata_service_buffer == NULL)
	{
		Wavedata_service_buffer = (unsigned char*)vm_malloc(BIGBUF_SIZE);
		Assert(Wavedata_service_buffer != NULL);
	}

	// Allocate memory for the buffer which holds the compressed wave data that is read from the hard disk
	if (Compressed_buffer == NULL)
	{
		Compressed_buffer = (unsigned char*)vm_malloc(COMPRESSED_BUFFER_SIZE);
		Assert(Compressed_buffer != NULL);
	}

	if (Compressed_service_buffer == NULL)
	{
		Compressed_service_buffer = (unsigned char*)vm_malloc(COMPRESSED_BUFFER_SIZE);
		Assert(Compressed_service_buffer != NULL);
	}

	for (i = 0; i < MAX_AUDIO_STREAMS; i++)
	{
		Audio_streams[i].Init_Data();
		Audio_streams[i].status = ASF_FREE;
		Audio_streams[i].type = ASF_NONE;
	}

	INITIALIZE_CRITICAL_SECTION(Global_service_lock);

	Audiostream_inited = 1;
}