Exemplo n.º 1
0
int Joystick::getNumDevices() {
#ifndef DUMMY_JOYSTICK
	return joyGetNumDevs();
#else
	return 1;
#endif
}
Exemplo n.º 2
0
/* Function to scan the system for joysticks.
 * This function should set SDL_numjoysticks to the number of available
 * joysticks.  Joystick 0 should be the system default joystick.
 * It should return 0, or -1 on an unrecoverable fatal error.
 */
int SDL_SYS_JoystickInit(void)
{
	int	i;
	int maxdevs;
	int numdevs;
	JOYINFOEX joyinfo;
	JOYCAPS	joycaps;
	MMRESULT result;

	/* Reset the joystick ID & name mapping tables */
	for ( i = 0; i < MAX_JOYSTICKS; ++i ) {
		SYS_JoystickID[i] = 0;
		SYS_JoystickName[i] = NULL;
	}

	/* Loop over all potential joystick devices */
	numdevs = 0;
	maxdevs = joyGetNumDevs();
	for ( i = JOYSTICKID1; i < maxdevs && numdevs < MAX_JOYSTICKS; ++i ) {
		
		joyinfo.dwSize = sizeof(joyinfo);
		joyinfo.dwFlags = JOY_RETURNALL;
		result = joyGetPosEx(i, &joyinfo);
		if ( result == JOYERR_NOERROR ) {
			result = joyGetDevCaps(i, &joycaps, sizeof(joycaps));
			if ( result == JOYERR_NOERROR ) {
				SYS_JoystickID[numdevs] = i;
				SYS_Joystick[numdevs] = joycaps;
				SYS_JoystickName[numdevs] = GetJoystickName(i, joycaps.szRegKey);
				numdevs++;
			}
		}
	}
	return(numdevs);
}
Exemplo n.º 3
0
/* 
=============== 
IN_StartupJoystick 
=============== 
*/  
void IN_StartupJoystick (void) 
{ 
	int			numdevs;
	JOYCAPS		jc;
	MMRESULT	mmr;
 
 	// assume no joystick
	joy_avail = 0; 

	// abort startup if user requests no joystick
	if ( gEngfuncs.CheckParm ("-nojoy", NULL ) ) 
		return; 
 
	// verify joystick driver is present
	if ((numdevs = joyGetNumDevs ()) == 0)
	{
		gEngfuncs.Con_DPrintf ("joystick not found -- driver not present\n\n");
		return;
	}

	// cycle through the joystick ids for the first valid one
	for (joy_id=0 ; joy_id<numdevs ; joy_id++)
	{
		memset (&ji, 0, sizeof(ji));
		ji.dwSize = sizeof(ji);
		ji.dwFlags = JOY_RETURNCENTERED;

		if ((mmr = joyGetPosEx (joy_id, &ji)) == JOYERR_NOERROR)
			break;
	} 

	// abort startup if we didn't find a valid joystick
	if (mmr != JOYERR_NOERROR)
	{
		gEngfuncs.Con_DPrintf ("joystick not found -- no valid joysticks (%x)\n\n", mmr);
		return;
	}

	// get the capabilities of the selected joystick
	// abort startup if command fails
	memset (&jc, 0, sizeof(jc));
	if ((mmr = joyGetDevCaps (joy_id, &jc, sizeof(jc))) != JOYERR_NOERROR)
	{
		gEngfuncs.Con_DPrintf ("joystick not found -- invalid joystick capabilities (%x)\n\n", mmr); 
		return;
	}

	// save the joystick's number of buttons and POV status
	joy_numbuttons = jc.wNumButtons;
	joy_haspov = jc.wCaps & JOYCAPS_HASPOV;

	// old button and POV states default to no buttons pressed
	joy_oldbuttonstate = joy_oldpovstate = 0;

	// mark the joystick as available and advanced initialization not completed
	// this is needed as cvars are not available during initialization
	gEngfuncs.Con_Printf ("joystick found\n\n", mmr); 
	joy_avail = 1; 
	joy_advancedinit = 0;
}
Exemplo n.º 4
0
VOID AL5_AnimRender( VOID )
{
  INT i;
  static FLT dx = 0, dy = 0;
  LARGE_INTEGER t;
  POINT pt;

  /* Mouse wheel */
  AL5_Anim.Mdz = AL5_MOUSEWHEEL;
  AL5_Anim.Mz += AL5_MOUSEWHEEL;
  AL5_MOUSEWHEEL = 0;

  /* Mouse */
  GetCursorPos(&pt);
  ScreenToClient(AL5_Anim.hWnd, &pt);
  AL5_Anim.Mdx = pt.x - AL5_Anim.Mx;
  AL5_Anim.Mdy = pt.y - AL5_Anim.My;
  AL5_Anim.Mx = pt.x;
  AL5_Anim.My = pt.y;

  /*Keyboard*/
  GetKeyboardState(AL5_Anim.Keys);
  for ( i = 0; i < 256; i++ )
  {
    AL5_Anim.Keys[i] >>= 7;
    if (!AL5_Anim.OldKeys[i] && AL5_Anim.Keys[i])
      AL5_Anim.KeysClick[i] = 1;
    else
      AL5_Anim.KeysClick[i] = 0;
  }
  memcpy(AL5_Anim.OldKeys, AL5_Anim.Keys, 256);

  /* joystick */
  if (joyGetNumDevs() > 0)
  {
    JOYCAPS jc;

    /* Get joystick info */
    if (joyGetDevCaps(JOYSTICKID1, &jc, sizeof(jc)) == JOYERR_NOERROR)
    {
      JOYINFOEX ji;

      ji.dwSize = sizeof(JOYINFOEX);
      ji.dwFlags = JOY_RETURNALL;
      if (joyGetPosEx(JOYSTICKID1, &ji) == JOYERR_NOERROR)
      {
        /* Buttons */
        for (i = 0; i < 32; i++)
          AL5_Anim.JBut[i] = (ji.dwButtons >> i) & 1;

        /* Axes */
        AL5_Anim.JX = AL5_GET_JOYSTIC_AXIS(X);
        AL5_Anim.JY = AL5_GET_JOYSTIC_AXIS(Y);
        AL5_Anim.JZ = AL5_GET_JOYSTIC_AXIS(Z);
        AL5_Anim.JR = AL5_GET_JOYSTIC_AXIS(R);

        /* Point of view */
        AL5_Anim.JPov = ji.dwPOV == 0xFFFF ? 0 : ji.dwPOV / 4500 + 1;
      }
    }
Exemplo n.º 5
0
bool CheckForJoystick(HWND hWnd)
{
	//Creamos variables temporales
	JOYINFO joyinfo; 
	UINT wNumDevs; 
	BOOL bDev1Attached, bDev2Attached; 
 
	//Obtenemos el número de joysticks configurados
	if((wNumDevs = joyGetNumDevs()) == 0)
	{
		return false;
	}
	
	//Revisamos si hay uno o dos joysticks conectados
	bDev1Attached = joyGetPos(JOYSTICKID1, &joyinfo) != JOYERR_UNPLUGGED; 
	bDev2Attached = joyGetPos(JOYSTICKID2, &joyinfo) != JOYERR_UNPLUGGED; 
	
	//Si hay un primer dispositivo conectado
	if( bDev1Attached )
	{//Establecemos la velocidad de captura de datos para este joystick
		joySetCapture(hWnd, JOYSTICKID1, 1000/30, true);
	}

	//Si hay un segundo dispositivo conectado
	if( bDev2Attached )
	{//Establecemos la velocidad de captura de datos para este joystick
		joySetCapture(hWnd, JOYSTICKID2, 1000/30, true);
	}

	return true;	//Indicamos que si hay joysticks conectados
}
Exemplo n.º 6
0
bool InitInput(HWND window, SPHERECONFIG* config)
{

    unsigned int i;

    // build mapping from Windows to Sphere keys
    for (i = 0; i < MAX_KEY; ++i)
    {
        int k = SphereToWindows[i];
        if (k >= 0 && k < MAX_KEY)
        {
            WindowsToSphere[k] = i;
        }
    }
    
    SphereWindow = window;
    Config = config;

    // try to initialize joysticks (only the plugged in and valid ones will be initialized)
    UINT num = joyGetNumDevs();

    for (i = 0; i < num; ++i)
    {
        TryJoystick(i);
    }
    
    return true;
}
Exemplo n.º 7
0
int
ui_joystick_init( void )
{
  int retval;
  JOYINFO joyinfo;

  retval = joyGetNumDevs();

  if( retval >= 2 ) {

    retval = 2;

    if( joyGetPos( JOYSTICKID2, &joyinfo ) == JOYERR_UNPLUGGED ) {
      ui_error( UI_ERROR_ERROR, "failed to initialise joystick 2" );
      return 0;
    }
  }

  if( retval > 0 ) {

    if( joyGetPos( JOYSTICKID1, &joyinfo ) == JOYERR_UNPLUGGED ) {
      ui_error( UI_ERROR_ERROR, "failed to initialise joystick 1" );
      return 0;
    }
  }

  return retval;
}
Exemplo n.º 8
0
bool joystick_exists(int id) {
	JOYINFO joyinfo; 
	UINT wNumDevs; 
	BOOL bDevAttached; 
 
    if((wNumDevs = joyGetNumDevs()) == 0) 
        return false; 
    bDevAttached = joyGetPos(JOYSTICKID1 + id, &joyinfo) == JOYERR_NOERROR; 
	return bDevAttached;
}
int joystickInit(void)		
{
	int i;

	numJoySticks = joyGetNumDevs();
	if(numJoySticks)
		joySticks = calloc(numJoySticks,sizeof(JOYCAPS));
	for(i=0;i<numJoySticks; i++)
		joyGetDevCaps(i,&(joySticks[i]),sizeof(JOYCAPS));
	return 1;
}
Exemplo n.º 10
0
void joymng_initialize(void) {

	JOYINFO		ji;
	int			i;

	if ((!joyGetNumDevs()) ||
		(joyGetPos(JOYSTICKID1, &ji) == JOYERR_UNPLUGGED)) {
		np2oscfg.JOYPAD1 |= 2;
	}
	for (i=0; i<4; i++) {
		joypad1btn[i] = 0xff ^
			((np2oscfg.JOY1BTN[i] & 3) << ((np2oscfg.JOY1BTN[i] & 4)?4:6));
	}
}
Exemplo n.º 11
0
void joy_init(void) {

	JOYINFO		ji;
	int			i;

	if ((!joyGetNumDevs()) ||
		(joyGetPos(JOYSTICKID1, &ji) == JOYERR_UNPLUGGED)) {
//		xmenu_setjoystick(np2cfg.JOYSTICK | 2);					// ver0.28
		np2oscfg.JOYPAD1 |= 2;
	}
	for (i=0; i<4; i++) {										// ver0.28
		joypad1btn[i] = 0xff ^
				((np2oscfg.JOY1BTN[i] & 3) << ((np2oscfg.JOY1BTN[i] & 4)?4:6));
	}
}
Exemplo n.º 12
0
/**
    [email protected] 2002-08-20:
    Now returns the number of connected, functioning
    joysticks, as intended.
*/
int wxJoystick::GetNumberJoysticks()
{
    JOYINFO joyInfo;
    int i, maxsticks, actualsticks;
    maxsticks = joyGetNumDevs();
    actualsticks = 0;
    for( i=0; i<maxsticks; i++ )
    {
        if( joyGetPos( i, & joyInfo ) == JOYERR_NOERROR )
        {
            actualsticks ++;
        }
    }
    return actualsticks;
}
Exemplo n.º 13
0
void EMU::initialize_input()
{
	// initialize status
	memset(key_status, 0, sizeof(key_status));
	memset(joy_status, 0, sizeof(joy_status));
	memset(mouse_status, 0, sizeof(mouse_status));
	
	// initialize joysticks
	joy_num = joyGetNumDevs();
	for(int i = 0; i < joy_num && i < 2; i++) {
		JOYCAPS joycaps;
		if(joyGetDevCaps(i, &joycaps, sizeof(joycaps)) == JOYERR_NOERROR) {
			joy_mask[i] = (1 << joycaps.wNumButtons) - 1;
		} else {
			joy_mask[i] = 0x0f; // 4buttons
		}
	}
	
	// mouse emulation is disenabled
	mouse_enabled = false;
	
	// initialize keycode convert table
	FILEIO* fio = new FILEIO();
	if(fio->Fopen(bios_path(_T("keycode.cfg")), FILEIO_READ_BINARY)) {
		fio->Fread(keycode_conv, sizeof(keycode_conv), 1);
		fio->Fclose();
	}
	else {
		for(int i = 0; i < 256; i++) {
			keycode_conv[i] = i;
		}
	}
	delete fio;
	
#ifdef USE_SHIFT_NUMPAD_KEY
	// initialize shift+numpad conversion
	memset(key_converted, 0, sizeof(key_converted));
	key_shift_pressed = key_shift_released = false;
#endif
#ifdef USE_AUTO_KEY
	// initialize autokey
	autokey_buffer = new FIFO(65536);
	autokey_buffer->clear();
	autokey_phase = autokey_shift = 0;
#endif
	lost_focus = false;
}
Exemplo n.º 14
0
bool joystick_load(int id)
{
	JOYINFO joyinfo;
	UINT wNumDevs;

    if((wNumDevs = joyGetNumDevs()) == 0)
        return false;

    if (joySetCapture(enigma::hWnd, JOYSTICKID1 + id, 0, FALSE))
    {
        MessageBeep(MB_ICONEXCLAMATION);
        MessageBox(enigma::hWnd, "Couldn't capture the joystick.", NULL,
            MB_OK | MB_ICONEXCLAMATION);
        return false;
    }

	return (joyGetPos(JOYSTICKID1 + id, &joyinfo) == JOYERR_NOERROR);
}
Exemplo n.º 15
0
int CJoystick::Init()
{
	m_Cant=joyGetNumDevs();
	joySetCapture(m_hWnd,JOYSTICKID1,0,FALSE);
	if (m_Cant==0)
		return false;

	for (m_ID=JOYSTICKID1; m_ID<m_Cant; m_ID++)
	{
		if (joyGetPos(m_ID, &m_JI)==JOYERR_NOERROR)
		{ 
			break;
		}
		if (m_ID == m_Cant-1)
			return false;
	}
	return true;
}
Exemplo n.º 16
0
int joy_NumSticks()
{
	JOYINFO joyinfo;
	int NumDevs = joyGetNumDevs();
	if (NumDevs > MAX_DEVS) NumDevs = MAX_DEVS;
	joy_numsticks = 0;
	memset(joy_present, 0, sizeof joy_present);

	/* joyGetNumDevs() simply returns the number of joystick slots, not actual
	   number of devices attached. On my win2k system, it always returns 16. So we
	   have to poll each joystick slot to see if a device is actually attached. */

	for (int i = 0; i < NumDevs; i++)
	{
		joy_present[i] = (joyGetPos(i, &joyinfo) == JOYERR_NOERROR);
		if (joy_present[i]) joy_numsticks++;
	}
	return joy_numsticks;
}
Exemplo n.º 17
0
bool Joystick::InitJoystick()
{
	if(init)
		return true;
	// Make sure joystick driver is present
	UINT uiNumJoysticks;
	if ((uiNumJoysticks = joyGetNumDevs()) == 0)
		return false;

	// Make sure the joystick is attached
	JOYINFO jiInfo;
	unsigned i;
	for(i = m_uiJoystickID; i < uiNumJoysticks; i++){
		MMRESULT mr = joyGetPos(i, &jiInfo);
		if (mr == JOYERR_NOERROR){
			m_uiJoystickID = i;
			break;
		}
	}
	if(i == uiNumJoysticks){
		return false;
	}

	// Calculate the trip values
	JOYCAPS jcCaps;
	joyGetDevCaps(m_uiJoystickID, &jcCaps, sizeof(JOYCAPS));
	DWORD dwXCenter = ((DWORD)jcCaps.wXmin + jcCaps.wXmax) / 2;
	DWORD dwYCenter = ((DWORD)jcCaps.wYmin + jcCaps.wYmax) / 2;
	DWORD dwZCenter = ((DWORD)jcCaps.wZmin + jcCaps.wZmax) / 2;
	DWORD dwRCenter = ((DWORD)jcCaps.wRmin + jcCaps.wRmax) / 2;
	m_rcJoystickTrip.left = (jcCaps.wXmin + (WORD)dwXCenter) / 2;
	m_rcJoystickTrip.right = (jcCaps.wXmax + (WORD)dwXCenter) / 2;
	m_rcJoystickTrip.top = (jcCaps.wYmin + (WORD)dwYCenter) / 2;
	m_rcJoystickTrip.bottom = (jcCaps.wYmax + (WORD)dwYCenter) / 2;
	m_rcJoystickTrip2.left = (jcCaps.wZmin + (WORD)dwZCenter) / 2;
	m_rcJoystickTrip2.right = (jcCaps.wZmax + (WORD)dwZCenter) / 2;
	m_rcJoystickTrip2.top = (jcCaps.wRmin + (WORD)dwRCenter) / 2;
	m_rcJoystickTrip2.bottom = (jcCaps.wRmax + (WORD)dwRCenter) / 2;

	init = true;
	return true;
}
Exemplo n.º 18
0
/* Function to scan the system for joysticks.
 * This function should set SDL_numjoysticks to the number of available
 * joysticks.  Joystick 0 should be the system default joystick.
 * It should return 0, or -1 on an unrecoverable fatal error.
 */
int SDL_SYS_JoystickInit(void)
{
	int	i;
	int maxdevs;
	int numdevs;
	JOYINFOEX joyinfo;
	JOYCAPS	joycaps;
	MMRESULT result;

	numdevs = 0;
	maxdevs = joyGetNumDevs();

	if ( maxdevs > MAX_JOYSTICKS ) {
		maxdevs = MAX_JOYSTICKS;
	}


	for ( i = 0; i < MAX_JOYSTICKS; i++ ) {
		SYS_JoystickID[i] = JOYSTICKID1 + i;
	}


	for ( i = 0; (i < maxdevs); ++i ) {
		
		/* added 8/31/2001 By Vitaliy Mikitchenko */
		joyinfo.dwSize = sizeof(joyinfo);
		joyinfo.dwFlags = JOY_RETURNALL;
		/* end addition */

		result = joyGetPosEx(SYS_JoystickID[i], &joyinfo);
		if ( result == JOYERR_NOERROR ) {
			result = joyGetDevCaps(SYS_JoystickID[i], &joycaps, sizeof(joycaps));
			if ( result == JOYERR_NOERROR ) {
				SYS_JoystickID[numdevs] = SYS_JoystickID[i];
				SYS_Joystick[numdevs] = joycaps;
				numdevs++;
			}
		}
	}
	return(numdevs);
}
Exemplo n.º 19
0
	void PXL_joystick_init() {
		JOYINFOEX joy_info;
		JOYCAPS joy_caps;
		uint32 num_devices = joyGetNumDevs();
		uint32 device_id;

		for (size_t n = 0; n < num_devices; ++n) {
			if (joyGetPosEx(n, &joy_info) == JOYERR_NOERROR) {
				device_id = n;

				joyGetDevCaps(device_id, &joy_caps, sizeof(joy_caps));

				PXL_Joystick* joystick = new PXL_Joystick();

				joystick->name = get_joystick_name(device_id, joy_caps);
				joystick->device_id = device_id;
				joystick->num_buttons = joy_caps.wNumButtons;
				joystick->num_axes = joy_caps.wNumAxes;

				joysticks.push_back(joystick);
			}
		}
	}
Exemplo n.º 20
0
bool joystick_load(int id)
{
	JOYINFO joyinfo; 
	UINT wNumDevs; 
	BOOL bDevAttached; 
 
    if((wNumDevs = joyGetNumDevs()) == 0) 
        return false; 
		
    if (joySetCapture(enigma::hWnd, JOYSTICKID1 + id, NULL, FALSE)) 
    { 
        MessageBeep(MB_ICONEXCLAMATION); 
        MessageBox(enigma::hWnd, "Couldn't capture the joystick.", NULL, 
            MB_OK | MB_ICONEXCLAMATION); 
        return false;
    } 
	
	bDevAttached = joyGetPos(JOYSTICKID1 + id, &joyinfo) != JOYERR_UNPLUGGED; 
    if (!bDevAttached) 
        return false;
		
	return true;
}
Exemplo n.º 21
0
    UInt32 Joystick::NumJoysticks()
    {
        UInt32 numPossibleJoysticks = joyGetNumDevs();

        JOYINFOEX info;
        UInt32 numActualJoysticks = 0;
        for (UInt32 i = JOYSTICKID1; i < numPossibleJoysticks; ++i)
        {
            info.dwSize = sizeof(info);
            info.dwFlags = JOY_RETURNALL;

            if (joyGetPosEx(i, &info) == JOYERR_NOERROR)
            {
                ++numActualJoysticks;
            }
            else
            {
                break;
            }
        }

        return numActualJoysticks;
    }
Exemplo n.º 22
0
VOID IK1_AnimRender( VOID )
{
  INT i;

  if (!IK1_IsInit)
    return;


  if ((i = joyGetNumDevs()) > 1)
  {
    JOYCAPS jc;

    if (joyGetDevCaps(JOYSTICKID1, &jc, sizeof(jc)) == JOYERR_NOERROR)
    {
      JOYINFOEX ji;

      ji.dwSize = sizeof(ji);
      ji.dwFlags = JOY_RETURNALL;

      if (joyGetPosEx(JOYSTICKID1, &ji) == JOYERR_NOERROR)
      {
        /* кнопки */
        memcpy(IK1_Anim.JButOld, IK1_Anim.JBut, 32);
        for (i = 0; i < 32; i++)
          IK1_Anim.JBut[i] = (ji.dwButtons >> i) & 1;

        /* оси переводим в диапазон -1..1 */
        IK1_Anim.Jx = 2.0 * (ji.dwXpos - jc.wXmin) / (jc.wXmax - jc.wXmin) - 1;
        IK1_Anim.Jy = 2.0 * (ji.dwYpos - jc.wYmin) / (jc.wYmax - jc.wYmin) - 1;
        IK1_Anim.Jz = 2.0 * (ji.dwZpos - jc.wZmin) / (jc.wZmax - jc.wZmin) - 1;
        IK1_Anim.Jr = 2.0 * (ji.dwRpos - jc.wRmin) / (jc.wRmax - jc.wRmin) - 1;

        if (ji.dwPOV == 0xFFFF)
          IK1_Anim.Jpov = 0;
        else
          IK1_Anim.Jpov = ji.dwPOV / 4500 + 1;
      }
Exemplo n.º 23
0
/**
    [email protected] 2002-08-20:
    Now returns only valid, functioning
    joysticks, counting from the first
    available and upwards.
*/
wxJoystick::wxJoystick(int joystick)
{
    JOYINFO joyInfo;
    int i, maxsticks;

    maxsticks = joyGetNumDevs();
    for( i=0; i<maxsticks; i++ )
    {
        if( joyGetPos(i, & joyInfo) == JOYERR_NOERROR )
        {
            if( !joystick )
            {
                /* Found the one we want, store actual OS id and return */
                m_joystick = i;
                return;
            }
            joystick --;
        }
    }

    /* No such joystick, return ID 0 */
    m_joystick = 0;
    return;
}
Exemplo n.º 24
0
/* Функция построения кадра анимации.
 * АРГУМЕНТЫ: Нет.
 * ВОЗВРАЩАЕМОЕ ЗНАЧЕНИЕ: Нет.
 */
VOID OK2_AnimRender( VOID )
{
  INT i;
  LARGE_INTEGER li;
  POINT pt;

  /* Обновление ввода */
  GetKeyboardState(OK2_Anim.Keys);
  for (i = 0; i < 256; i++)
    OK2_Anim.KeyClick[i] = OK2_Anim.Keys[i] && !OK2_Anim.KeysOld[i];
  memcpy(OK2_Anim.KeysOld, OK2_Anim.Keys, sizeof(OK2_Anim.Keys));


  /* Обновление таймера */
  OK2_Anim.Time = (DBL)clock() / CLOCKS_PER_SEC;

  /* Обновление кадра */
  QueryPerformanceCounter(&li);

  /* глобальное время */
  OK2_Anim.GlobalTime = (DBL)(li.QuadPart - TimeStart) / TimeFreq;
  OK2_Anim.GlobalDeltaTime = (DBL)(li.QuadPart - TimeOld) / TimeFreq;

  /* локальное время */
  if (OK2_Anim.IsPause)
  {
    TimePause += li.QuadPart - TimeOld;
    OK2_Anim.DeltaTime = 0;
  }
  else
    OK2_Anim.DeltaTime = OK2_Anim.GlobalDeltaTime;

  OK2_Anim.Time = (DBL)(li.QuadPart - TimeStart - TimePause) / TimeFreq;

  /* вычисляем FPS */
  if (li.QuadPart - TimeFPS > TimeFreq)
  {
    OK2_Anim.FPS = FrameCounter / ((DBL)(li.QuadPart - TimeFPS) / TimeFreq);
    TimeFPS = li.QuadPart;
    FrameCounter = 0;
  }

  /* время "прошлого" кадра */
  TimeOld = li.QuadPart;

  /* очистка фона */
  SelectObject(OK2_Anim.hDC, GetStockObject(DC_BRUSH));
  SelectObject(OK2_Anim.hDC, GetStockObject(NULL_PEN));
  SetDCBrushColor(OK2_Anim.hDC, RGB(0, 110, 0));
  Rectangle(OK2_Anim.hDC, 0, 0, OK2_Anim.W, OK2_Anim.H);

  /* опрос на изменение состояний объектов */
  for (i = 0; i < OK2_Anim.NumOfUnits; i++)
    OK2_Anim.Units[i]->Response(OK2_Anim.Units[i], &OK2_Anim);

  /* рисование объектов */
  for (i = 0; i < OK2_Anim.NumOfUnits; i++)
  {
    SelectObject(OK2_Anim.hDC, GetStockObject(DC_BRUSH));
    SelectObject(OK2_Anim.hDC, GetStockObject(DC_PEN));
    SetDCBrushColor(OK2_Anim.hDC, RGB(0, 0, 0));
    SetDCPenColor(OK2_Anim.hDC, RGB(55, 155, 255));
    OK2_Anim.Units[i]->Render(OK2_Anim.Units[i], &OK2_Anim);
  }

  /* Мышь */
  /*  колесо */
  OK2_Anim.MsWheel = OK2_MouseGlobalWheel;
  OK2_MouseGlobalWheel = 0;
  /* абсолютная позиция */
  pt.x = OK2_MouseGlobalX;
  pt.y = OK2_MouseGlobalY;
  ScreenToClient(OK2_Anim.hWnd, &pt);
  OK2_Anim.MsX = pt.x;
  OK2_Anim.MsY = pt.y;
  /* относительное перемещение */
  OK2_Anim.MsDeltaX = OK2_MouseGlobalX - OK2_MouseXOld;
  OK2_Anim.MsDeltaY = OK2_MouseGlobalY - OK2_MouseYOld;
  OK2_MouseXOld = OK2_MouseGlobalX;
  OK2_MouseYOld = OK2_MouseGlobalY;

    /* Джойстик */
  if ((i = joyGetNumDevs()) > 0)
  {
    JOYCAPS jc;

    /* получение общей информации о джостике */
    if (joyGetDevCaps(JOYSTICKID1, &jc, sizeof(jc)) == JOYERR_NOERROR)
    {
      JOYINFOEX ji;

      /* получение текущего состояния */
      ji.dwSize = sizeof(JOYCAPS);
      ji.dwFlags = JOY_RETURNALL;
      if (joyGetPosEx(JOYSTICKID1, &ji) == JOYERR_NOERROR)
      {
        /* Кнопки */
        memcpy(OK2_Anim.JButsOld, OK2_Anim.JButs, sizeof(OK2_Anim.JButs));
        for (i = 0; i < 32; i++)
          OK2_Anim.JButs[i] = (ji.dwButtons >> i) & 1;
        for (i = 0; i < 32; i++)
          OK2_Anim.JButsClick[i] = OK2_Anim.JButs[i] && !OK2_Anim.JButsOld[i];

        /* Оси */
        OK2_Anim.JX = 2.0 * (ji.dwXpos - jc.wXmin) / (jc.wXmax - jc.wXmin - 1) - 1;
        OK2_Anim.JY = 2.0 * (ji.dwYpos - jc.wYmin) / (jc.wYmax - jc.wYmin - 1) - 1;
        if (jc.wCaps & JOYCAPS_HASZ)
          OK2_Anim.JZ = 2.0 * (ji.dwZpos - jc.wZmin) / (jc.wZmax - jc.wZmin - 1) - 1;
        if (jc.wCaps & JOYCAPS_HASR)
          OK2_Anim.JR = 2.0 * (ji.dwRpos - jc.wRmin) / (jc.wRmax - jc.wRmin - 1) - 1;
        if (jc.wCaps & JOYCAPS_HASU)
          OK2_Anim.JU = 2.0 * (ji.dwUpos - jc.wUmin) / (jc.wUmax - jc.wUmin - 1) - 1;

        /* Point-Of-View */
        if (jc.wCaps & JOYCAPS_HASPOV)
        {
          if (ji.dwPOV == 0xFFFF)
            OK2_Anim.JPOV = 0;
          else
            OK2_Anim.JPOV = ji.dwPOV / 4500 + 1;
        }
      }
Exemplo n.º 25
0
Arquivo: ANIM.C Projeto: CGSG/SPR2013
/* Функция построения кадра.
 * АРГУМЕНТЫ: Нет.
 * ВОЗВРАЩАЕМОЕ ЗНАЧЕНИЕ: Нет.
 */
VOID VG4_AnimRender( VOID )
{
  INT i;
  LARGE_INTEGER li;
  POINT pt;

  if (!VG4_IsInit)
    return;

  /*** Опрос таймера ***/

  /* обновляем информацию: */
  QueryPerformanceCounter(&li);

  /* глобальное время */
  VG4_Anim.GlobalTime = (DBL)(li.QuadPart - VG4_TimeStart) / VG4_TimeFreq;
  VG4_Anim.GlobalDeltaTime = (DBL)(li.QuadPart - VG4_TimeOld) / VG4_TimeFreq;

  /* локальное время */
  if (VG4_Anim.IsPause)
    VG4_Anim.DeltaTime = 0, VG4_TimePause += li.QuadPart - VG4_TimeOld;
  else
    VG4_Anim.DeltaTime = VG4_Anim.GlobalDeltaTime;

  VG4_Anim.Time = (DBL)(li.QuadPart - VG4_TimeStart - VG4_TimePause - VG4_TimeShift) /
    VG4_TimeFreq;

  /* вычисляем производительность */
  if (li.QuadPart - VG4_TimeFPS > VG4_TimeFreq * 3.0)
  {
    VG4_Anim.FPS = VG4_FrameCounter / ((DBL)(li.QuadPart - VG4_TimeFPS) / VG4_TimeFreq);
    VG4_TimeFPS = li.QuadPart;
    VG4_FrameCounter = 0;
  }
  /* обновляем время "старого" кадра */
  VG4_TimeOld = li.QuadPart;

  /*** Опрос устройств ввода ***/

  /* клавиатура */
  /* копируем старое состояние */
  memcpy(VG4_Anim.KeysOld, VG4_Anim.Keys, 256);
  /* Считываем новое */
  GetKeyboardState(VG4_Anim.Keys);
  /* конвертироем в Да,Нет */
  for (i = 0; i < 256; i++)
    VG4_Anim.Keys[i] >>= 7;

  /* мышь */
  GetCursorPos(&pt);
  ScreenToClient(VG4_Anim.hWnd, &pt);
  VG4_Anim.MouseX = pt.x;
  VG4_Anim.MouseY = pt.y;
  VG4_Anim.MouseBut[0] = VG4_Anim.Keys[VK_LBUTTON];
  VG4_Anim.MouseBut[1] = VG4_Anim.Keys[VK_RBUTTON];
  VG4_Anim.MouseBut[2] = VG4_Anim.Keys[VK_MBUTTON];
  VG4_Anim.MouseDeltaX = pt.x - VG4_MousePosOld.x;
  VG4_Anim.MouseDeltaY = pt.y - VG4_MousePosOld.y;
  VG4_Anim.MouseWheel = VG4_MouseWheel;
  VG4_MouseWheel = 0;
  VG4_MousePosOld = pt;

  /* джойстик */
  if ((i = joyGetNumDevs()) > 1)
  {
    JOYCAPS jc;

    if (joyGetDevCaps(JOYSTICKID1, &jc, sizeof(jc)) == JOYERR_NOERROR)
    {
      JOYINFOEX ji;

      ji.dwSize = sizeof(ji);
      ji.dwFlags = JOY_RETURNALL;

      if (joyGetPosEx(JOYSTICKID1, &ji) == JOYERR_NOERROR)
      {
        /* кнопки */
        memcpy(VG4_Anim.JButOld, VG4_Anim.JBut, 32);
        for (i = 0; i < 32; i++)
          VG4_Anim.JBut[i] = (ji.dwButtons >> i) & 1;

        /* оси переводим в диапазон -1..1 */
        VG4_Anim.Jx = 2.0 * (ji.dwXpos - jc.wXmin) / (jc.wXmax - jc.wXmin) - 1;
        VG4_Anim.Jy = 2.0 * (ji.dwYpos - jc.wYmin) / (jc.wYmax - jc.wYmin) - 1;
        VG4_Anim.Jz = 2.0 * (ji.dwZpos - jc.wZmin) / (jc.wZmax - jc.wZmin) - 1;
        VG4_Anim.Jr = 2.0 * (ji.dwRpos - jc.wRmin) / (jc.wRmax - jc.wRmin) - 1;

        if (ji.dwPOV == 0xFFFF)
          VG4_Anim.JPov = 0;
        else
          VG4_Anim.JPov = ji.dwPOV / 4500 + 1;
      }
Exemplo n.º 26
0
//-----------------------------------------------------------------------------
// Function: IN_StartupJoystick
// Parameters: Nothing
// Returns:     Nothing
// Notes: Pause CD audio
//-----------------------------------------------------------------------------
void IN_StartupJoystick( void )
{
        int                     numdevs;
        JOYCAPS         jc;
        MMRESULT        mmr;
        cvar_t          *cv;

        // joystick variables
        in_joystick				= Cvar_Get( "in_joystick",                              "0",            CVAR_ARCHIVE);
        joy_name				= Cvar_Get( "joy_name",                                 "joystick",     0                       );
        joy_advanced			= Cvar_Get( "joy_advanced",                             "0",            0                       );
        joy_advaxisx			= Cvar_Get( "joy_advaxisx",                             "0",            0                       );
        joy_advaxisy			= Cvar_Get( "joy_advaxisy",                             "0",            0                       );
        joy_advaxisz			= Cvar_Get( "joy_advaxisz",                             "0",            0                       );
        joy_advaxisr			= Cvar_Get( "joy_advaxisr",                             "0",            0                       );
        joy_advaxisu			= Cvar_Get( "joy_advaxisu",                             "0",            0                       );
        joy_advaxisv			= Cvar_Get( "joy_advaxisv",                             "0",            0                       );
        joy_forwardthreshold	= Cvar_Get( "joy_forwardthreshold",             "0.15",         0                       );
        joy_sidethreshold		= Cvar_Get( "joy_sidethreshold",                "0.15",         0                       );
        joy_upthreshold			= Cvar_Get( "joy_upthreshold",                  "0.15",         0                       );
        joy_pitchthreshold		= Cvar_Get( "joy_pitchthreshold",               "0.15",         0                       );
        joy_yawthreshold		= Cvar_Get( "joy_yawthreshold",                 "0.15",         0                       );
        joy_forwardsensitivity	= Cvar_Get( "joy_forwardsensitivity",   "-1",           0                       );
        joy_sidesensitivity		= Cvar_Get( "joy_sidesensitivity",              "-1",           0                       );
        joy_upsensitivity		= Cvar_Get( "joy_upsensitivity",                "-1",           0                       );
        joy_pitchsensitivity	= Cvar_Get( "joy_pitchsensitivity",             "1",            0                       );
        joy_yawsensitivity		= Cvar_Get( "joy_yawsensitivity",               "-1",           0                       );


        Cmd_AddCommand( "joy_advancedupdate", Joy_AdvancedUpdate_f );

        // assume no joystick
        joy_avail = false;

        // abort startup if user requests no joystick
        cv = Cvar_Get( "in_initjoy", "1", CVAR_ROM );
        if( ! cv->value )
                return;

        // verify joystick driver is present
        if( ( numdevs = joyGetNumDevs() ) == 0 )
        {
                return;
        }

        // cycle through the joystick ids for the first valid one
        for( joy_id = 0; joy_id < numdevs; ++joy_id )
        {
                memset( &ji, 0, sizeof( ji ) );
                ji.dwSize = sizeof( ji );
                ji.dwFlags = JOY_RETURNCENTERED;

                if( ( mmr = joyGetPosEx( joy_id, &ji ) ) == JOYERR_NOERROR )
                        break;
        }

        // abort startup if we didn't find a valid joystick
        if( mmr != JOYERR_NOERROR )
        {
                Com_Printf( "\njoystick not found -- no valid joysticks (%x)\n\n", mmr );
                return;
        }

        // get the capabilities of the selected joystick
        // abort startup if command fails
        memset( &jc, 0, sizeof( jc ) );
        if( ( mmr = joyGetDevCaps( joy_id, &jc, sizeof( jc ) ) ) != JOYERR_NOERROR )
        {
                Com_Printf( "\njoystick not found -- invalid joystick capabilities (%x)\n\n", mmr );
                return;
        }

        // save the joystick's number of buttons and POV status
        joy_numbuttons = jc.wNumButtons;
        joy_haspov = jc.wCaps & JOYCAPS_HASPOV;

        // old button and POV states default to no buttons pressed
        joy_oldbuttonstate = joy_oldpovstate = 0;

        // mark the joystick as available and advanced initialization not completed
        // this is needed as cvars are not available during initialization

        joy_avail = true;
        joy_advancedinit = false;

        Com_Printf( "\njoystick detected\n\n" );
}
Exemplo n.º 27
0
/* joystick_win32_init:
 *  Initialises the Win32 joystick driver.
 */
static int joystick_win32_init(void)
{
   JOYCAPS caps;
   JOYINFOEX js;
   int n_joyat, n_joy, n_axis;

   win32_joy_num = joyGetNumDevs();

   if (win32_joy_num > MAX_JOYSTICKS)
      _TRACE(PREFIX_W "The system supports more than %d joysticks\n", MAX_JOYSTICKS);

   /* retrieve joystick infos */
   n_joy = 0;
   for (n_joyat = 0; n_joyat < win32_joy_num; n_joyat++) {
      if (n_joy == MAX_JOYSTICKS)
         break;

      if (joyGetDevCaps(n_joyat, &caps, sizeof(caps)) == JOYERR_NOERROR) {
         /* is the joystick physically attached? */
         js.dwSize = sizeof(js);
         js.dwFlags = JOY_RETURNALL;
         if (joyGetPosEx(n_joyat, &js) == JOYERR_UNPLUGGED)
            continue;

         memset(&win32_joystick[n_joy], 0, sizeof(struct WIN32_JOYSTICK_INFO));

         /* set global properties */
	 win32_joystick[n_joy].device = n_joyat;
	 win32_joystick[n_joy].caps = caps.wCaps;
	 win32_joystick[n_joy].num_buttons = MIN(caps.wNumButtons, MAX_JOYSTICK_BUTTONS);
	 win32_joystick[n_joy].num_axes = MIN(caps.wNumAxes, WINDOWS_MAX_AXES);

	 /* fill in ranges of axes */
	 win32_joystick[n_joy].axis_min[0] = caps.wXmin;
	 win32_joystick[n_joy].axis_max[0] = caps.wXmax;
	 win32_joystick[n_joy].axis_min[1] = caps.wYmin;
	 win32_joystick[n_joy].axis_max[1] = caps.wYmax;
	 n_axis = 2;

	 if (caps.wCaps & JOYCAPS_HASZ)	{
	    win32_joystick[n_joy].axis_min[2] = caps.wZmin;
	    win32_joystick[n_joy].axis_max[2] = caps.wZmax;
	    n_axis++;
	 }

	 if (caps.wCaps & JOYCAPS_HASR)	{
	    win32_joystick[n_joy].axis_min[n_axis] = caps.wRmin;
	    win32_joystick[n_joy].axis_max[n_axis] = caps.wRmax;
	    n_axis++;
	 }

	 if (caps.wCaps & JOYCAPS_HASU)	{
	    win32_joystick[n_joy].axis_min[n_axis] = caps.wUmin;
	    win32_joystick[n_joy].axis_max[n_axis] = caps.wUmax;
	    n_axis++;
	 }

	 if (caps.wCaps & JOYCAPS_HASV)	{
	    win32_joystick[n_joy].axis_min[n_axis] = caps.wVmin;
	    win32_joystick[n_joy].axis_max[n_axis] = caps.wVmax;
	    n_axis++;
	 }

         /* register this joystick */
         if (win_add_joystick((WINDOWS_JOYSTICK_INFO *)&win32_joystick[n_joy]) != 0)
            break;

         n_joy++;
      }
   }

   win32_joy_num = n_joy;

   return (win32_joy_num == 0);
}
Exemplo n.º 28
0
Arquivo: ANIM.C Projeto: CGSG/SUM2014
/* Функция построения кадра анимации.
 * АРГУМЕНТЫ: Нет.
 * ВОЗВРАЩАЕМОЕ ЗНАЧЕНИЕ: Нет.
 */
VOID VG4_AnimRender( VOID )
{
  INT i;
  LARGE_INTEGER li;
  POINT pt;

  /*** Обновление ввода ***/
  /* Клавиатура */
  GetKeyboardState(VG4_Anim.Keys);
  for (i = 0; i < 256; i++)
    VG4_Anim.Keys[i] >>= 7;
  for (i = 0; i < 256; i++)
    VG4_Anim.KeysClick[i] = VG4_Anim.Keys[i] && !VG4_Anim.KeysOld[i];
  memcpy(VG4_Anim.KeysOld, VG4_Anim.Keys, 256);

  /* Мышь */
  /*  колесо */
  VG4_Anim.MsWheel = VG4_MouseGlobalWheel;
  VG4_MouseGlobalWheel = 0;
  /* абсолютная позиция */
  pt.x = VG4_MouseGlobalX;
  pt.y = VG4_MouseGlobalY;
  ScreenToClient(VG4_Anim.hWnd, &pt);
  VG4_Anim.MsX = pt.x;
  VG4_Anim.MsY = pt.y;
  /* относительное перемещение */
  VG4_Anim.MsDeltaX = VG4_MouseGlobalX - VG4_MouseXOld;
  VG4_Anim.MsDeltaY = VG4_MouseGlobalY - VG4_MouseYOld;
  VG4_MouseXOld = VG4_MouseGlobalX;
  VG4_MouseYOld = VG4_MouseGlobalY;

  /* Джойстик */
  if ((i = joyGetNumDevs()) > 0)
  {
    JOYCAPS jc;

    /* получение общей информации о джостике */
    if (joyGetDevCaps(JOYSTICKID1, &jc, sizeof(jc)) == JOYERR_NOERROR)
    {
      JOYINFOEX ji;

      /* получение текущего состояния */
      ji.dwSize = sizeof(JOYCAPS);
      ji.dwFlags = JOY_RETURNALL;
      if (joyGetPosEx(JOYSTICKID1, &ji) == JOYERR_NOERROR)
      {
        /* Кнопки */
        memcpy(VG4_Anim.JButsOld, VG4_Anim.JButs, sizeof(VG4_Anim.JButs));
        for (i = 0; i < 32; i++)
          VG4_Anim.JButs[i] = (ji.dwButtons >> i) & 1;
        for (i = 0; i < 32; i++)
          VG4_Anim.JButsClick[i] = VG4_Anim.JButs[i] && !VG4_Anim.JButsOld[i];

        /* Оси */
        VG4_Anim.JX = VG4_GET_AXIS_VALUE(X);
        VG4_Anim.JY = VG4_GET_AXIS_VALUE(Y);
        if (jc.wCaps & JOYCAPS_HASZ)
          VG4_Anim.JZ = VG4_GET_AXIS_VALUE(Z);
        if (jc.wCaps & JOYCAPS_HASR)
          VG4_Anim.JR = VG4_GET_AXIS_VALUE(R);
        if (jc.wCaps & JOYCAPS_HASU)
          VG4_Anim.JU = 2.0 * (ji.dwUpos - jc.wUmin) / (jc.wUmax - jc.wUmin - 1) - 1;

        /* Point-Of-View */
        if (jc.wCaps & JOYCAPS_HASPOV)
        {
          if (ji.dwPOV == 0xFFFF)
            VG4_Anim.JPOV = 0;
          else
            VG4_Anim.JPOV = ji.dwPOV / 4500 + 1;
        }
      }
Exemplo n.º 29
0
VOID IK3_AnimRender( VOID )
{
  int i;
  POINT pt;
  LARGE_INTEGER t;

  IK3_FrameCounter++;
  QueryPerformanceCounter(&t);

  IK3_Anim.GlobalTime =(DBL)(t.QuadPart - IK3_StartTime) / IK3_TimePerSec;
  IK3_Anim.GlobalDeltaTime =(DBL)(t.QuadPart - IK3_OldTime) / IK3_TimePerSec;
  if (IK3_Anim.IsPause)
  {
    IK3_Anim.DeltaTime = 0;
    IK3_PauseTime += t.QuadPart - IK3_OldTime;
  }
  else 
  {
    IK3_Anim.DeltaTime = IK3_Anim.GlobalDeltaTime;
    IK3_Anim.Time = (DBL)(t.QuadPart - IK3_PauseTime - IK3_OldTime) / IK3_TimePerSec;
  }

  if (t.QuadPart - IK3_OldTimeFPS > IK3_TimePerSec);
  {
    CHAR str[100];

    IK3_Anim.FPS = IK3_FrameCounter * IK3_TimePerSec / (DBL)(t.QuadPart - IK3_OldTimeFPS);
    IK3_OldTimeFPS = t.QuadPart;
    sprintf(str, "FPS: %.5f", IK3_Anim.FPS);
    SetWindowText(IK3_Anim.hWnd, str);
    IK3_FrameCounter = 0;
  }

  GetKeyboardState(IK3_Anim.Keys);
  for (i = 0; i < 256; i++)
  {
    IK3_Anim.Keys[i] >>= 7;
    if (!IK3_Anim.OldKeys[i] && IK3_Anim.Keys[i])
      IK3_Anim.KeysClick[i] = TRUE;
    else
      IK3_Anim.KeysClick[i] = FALSE;
  }
  memcpy(IK3_Anim.OldKeys, IK3_Anim.Keys, 256);

  GetCursorPos(&pt);
  ScreenToClient(IK3_Anim.hWnd, &pt);
  IK3_Anim.Mdx = pt.x - IK3_Anim.Mx;
  IK3_Anim.Mdy = pt.y - IK3_Anim.My;
  IK3_Anim.Mdx = pt.x;
  IK3_Anim.Mdy = pt.y;

  /* Joystick */

  if (joyGetNumDevs() > 0)
  {
    JOYCAPS jc;

    /* Get joystick info */
    if (joyGetDevCaps(JOYSTICKID1, &jc, sizeof(jc)) == JOYERR_NOERROR)
    {
      JOYINFOEX ji;

      ji.dwSize = sizeof(JOYINFOEX);
      ji.dwFlags = JOY_RETURNALL;
      if (joyGetPosEx(JOYSTICKID1, &ji) == JOYERR_NOERROR)
      {
        /* Buttons */
        for (i = 0; i < 32; i++)
          IK3_Anim.JBut[i] = (ji.dwButtons >> i) & 1;

        /* Axes */
        IK3_Anim.JX = IK3_GET_JOYSTIC_AXIS(X);
        IK3_Anim.JY = IK3_GET_JOYSTIC_AXIS(Y);
        IK3_Anim.JZ = IK3_GET_JOYSTIC_AXIS(Z);
        IK3_Anim.JR = IK3_GET_JOYSTIC_AXIS(R);

        /* Point of view */
        IK3_Anim.JPov = ji.dwPOV == 0xFFFF ? 0 : ji.dwPOV / 4500 + 1;
      }
    }
Exemplo n.º 30
0
int WINAPI WinMain(HINSTANCE hInstance, // instance
                   HINSTANCE hPrevInstance, // previous instance
                   LPSTR lpCmdLine, // command line parameters
                   int nCmdShow) // window show state
{
    MSG msg; // windows message structure
    BOOL done = FALSE; // bool variable to exit loop
    fullscreen = true;
    DecimalSeparator = '.';
    /* //Ra: tutaj to nie dzia³a - zwraca NULL
     //najpierw ustalmy wersjê OpenGL
     AnsiString glver=((char*)glGetString(GL_VERSION));
     while (glver.LastDelimiter(".")>glver.Pos("."))
      glver=glver.SubString(1,glver.LastDelimiter(".")-1); //obciêcie od drugiej kropki
     try {Global::fOpenGL=glver.ToDouble();} catch (...) {Global::fOpenGL=0.0;}
     Global::bOpenGL_1_5=(Global::fOpenGL>=1.5);
    */
    DeleteFile("errors.txt"); // usuniêcie starego
    Global::LoadIniFile("eu07.ini"); // teraz dopiero mo¿na przejrzeæ plik z ustawieniami
    Global::InitKeys("keys.ini"); // wczytanie mapowania klawiszy - jest na sta³e

    // hunter-271211: ukrywanie konsoli
    if (Global::iWriteLogEnabled & 2)
    {
        AllocConsole();
        SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), FOREGROUND_GREEN);
    }
    AnsiString str = lpCmdLine; // parametry uruchomienia
    if (!str.IsEmpty())
    { // analizowanie parametrów
        TQueryParserComp *Parser;
        Parser = new TQueryParserComp(NULL);
        Parser->TextToParse = lpCmdLine;
        Parser->First();
        while (!Parser->EndOfFile)
        {
            str = Parser->GetNextSymbol().LowerCase();
            if (str == AnsiString("-s"))
            { // nazwa scenerii
                str = Parser->GetNextSymbol().LowerCase();
                strcpy(Global::szSceneryFile, str.c_str());
            }
            else if (str == AnsiString("-v"))
            { // nazwa wybranego pojazdu
                str = Parser->GetNextSymbol().LowerCase();
                Global::asHumanCtrlVehicle = str;
            }
            else if (str == AnsiString("-modifytga"))
            { // wykonanie modyfikacji wszystkich plików TGA
                Global::iModifyTGA = -1; // specjalny tryb wykonania totalnej modyfikacji
            }
            else if (str == AnsiString("-e3d"))
            { // wygenerowanie wszystkich plików E3D
                if (Global::iConvertModels > 0)
                    Global::iConvertModels = -Global::iConvertModels; // specjalny tryb
                else
                    Global::iConvertModels = -7; // z optymalizacj¹, bananami i prawid³owym Opacity
            }
            else
                Error(
                    "Program usage: EU07 [-s sceneryfilepath] [-v vehiclename] [-modifytga] [-e3d]",
                    !Global::iWriteLogEnabled);
        }
        delete Parser; // ABu 050205: tego wczesniej nie bylo
    }
    /* MC: usunalem tymczasowo bo sie gryzlo z nowym parserem - 8.6.2003
        AnsiString csp=AnsiString(Global::szSceneryFile);
        csp=csp.Delete(csp.Pos(AnsiString(strrchr(Global::szSceneryFile,'/')))+1,csp.Length());
        Global::asCurrentSceneryPath=csp;
    */

    fullscreen = Global::bFullScreen;
    WindowWidth = Global::iWindowWidth;
    WindowHeight = Global::iWindowHeight;
    Bpp = Global::iBpp;
    if (Bpp != 32)
        Bpp = 16;
    // create our OpenGL window
    if (!CreateGLWindow(Global::asHumanCtrlVehicle.c_str(), WindowWidth, WindowHeight, Bpp,
                        fullscreen))
        return 0; // quit if window was not created
    SetForegroundWindow(hWnd);
    // McZapkie: proba przeplukania klawiatury
    Console *pConsole = new Console(); // Ra: nie wiem, czy ma to sens, ale jakoœ zainicjowac trzeba
    while (Console::Pressed(VK_F10))
        Error("Keyboard buffer problem - press F10"); // na Windows 98 lubi siê to pojawiaæ
    int iOldSpeed, iOldDelay;
    SystemParametersInfo(SPI_GETKEYBOARDSPEED, 0, &iOldSpeed, 0);
    SystemParametersInfo(SPI_GETKEYBOARDDELAY, 0, &iOldDelay, 0);
    SystemParametersInfo(SPI_SETKEYBOARDSPEED, 20, NULL, 0);
    // SystemParametersInfo(SPI_SETKEYBOARDDELAY,10,NULL,0);
    if (!joyGetNumDevs())
        WriteLog("No joystick");
    if (Global::iModifyTGA < 0)
    { // tylko modyfikacja TGA, bez uruchamiania symulacji
        Global::iMaxTextureSize = 64; //¿eby nie zamulaæ pamiêci
        World.ModifyTGA(); // rekurencyjne przegl¹danie katalogów
    }
    else
    {
        if (Global::iConvertModels < 0)
        {
            Global::iConvertModels = -Global::iConvertModels;
            World.CreateE3D("models\\"); // rekurencyjne przegl¹danie katalogów
            World.CreateE3D("dynamic\\", true);
        } // po zrobieniu E3D odpalamy normalnie sceneriê, by j¹ zobaczyæ
        // else
        //{//g³ówna pêtla programu
        Console::On(); // w³¹czenie konsoli
        while (!done) // loop that runs while done=FALSE
        {
            if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) // is there a message waiting?
            {
                if (msg.message == WM_QUIT) // have we received a quit message?
                    done = TRUE; // if so
                else // if not, deal with window messages
                {
                    // if (msg.message==WM_CHAR)
                    // World.OnKeyDown(msg.wParam);
                    TranslateMessage(&msg); // translate the message
                    DispatchMessage(&msg); // dispatch the message
                }
            }
            else // if there are no messages
            {
                // draw the scene, watch for quit messages
                // DrawGLScene()
                // if (!pause)
                // if (Global::bInactivePause?Global::bActive:true) //tak nie, bo spada z góry
                if (World.Update()) // Was There A Quit Received?
                    SwapBuffers(hDC); // Swap Buffers (Double Buffering)
                else
                    done = true; //[F10] or DrawGLScene signalled a quit
            }
        }
        Console::Off(); // wy³¹czenie konsoli (komunikacji zwrotnej)
    }
    SystemParametersInfo(SPI_SETKEYBOARDSPEED, iOldSpeed, NULL, 0);
    SystemParametersInfo(SPI_SETKEYBOARDDELAY, iOldDelay, NULL, 0);
    delete pConsole; // deaktywania sterownika
    // shutdown
    KillGLWindow(); // kill the window
    return (msg.wParam); // exit the program
}