Пример #1
0
char sfw::getInput(bool onlyNum)
{
	char press = '#';

	if (!onlyNum)
	{
		for (int a = 0; bindings[a] != '\0'; a++)
		{
			if (getKey(bindings[a]) && !bindPress[a])
			{
				press = bindings[a];
				bindPress[a] = true;
			}
		}
	}
	else
	{
		for (int a = 27; bindings[a] != '`'; a++)
		{
			if (getKey(bindings[a]) && !bindPress[a])
			{
				press = bindings[a];
				bindPress[a] = false;
			}
		}
	}

	resetKeys();
	return press;
}
Пример #2
0
Window::Window( const Parameters &parameters ) :
_parameters( parameters )
{
	//set all the keys as not pressed
	resetKeys();

	//instatiate a new scene
	_scene = new Scene( *this );
}
void QSoftKeyDesignToolWidget::on_BtnReset_clicked()
{
    CSoftkeyArray& Keys = T3kCommonData::instance()->getKeys();

    if ( QMessageBox::warning( this, "Warning", "Would you like to erase all softkey?", QMessageBox::Yes|QMessageBox::No ) == QMessageBox::No )
        return;

    Keys.load( DEFAULT_SOFTKEY, NULL, NULL );

    emit resetKeys();
}
Пример #4
0
int sfw::getControls()
{
	for (int a = 0; a < 4; a++)
	{
		if (getKey(key[a]) && !keyPress[a])
		{
			keyPress[a] = true;
			return a;
		}
	}

	resetKeys();
	return -1;
}
Пример #5
0
void InputManager::init()
{
    for (int i = 0; i < Input::KEY_TOTAL; i++)
    {
        for (int f = 0; f < KeyFunctionSize; f ++)
        {
            mKey[i].values[f].type = INPUT_UNKNOWN;
            mKey[i].values[f].value = -1;
        }
    }

    mNewKeyIndex = Input::KEY_NO_VALUE;

    resetKeys();
    retrieve();
    update();
}
Пример #6
0
void InputManager::init()
{
    for (unsigned int i = 0; i < InputAction::TOTAL; i++)
    {
        InputFunction &kf = mKey[i];
        for (unsigned int f = 0; f < inputFunctionSize; f ++)
        {
            InputItem &ki = kf.values[f];
            ki.type = InputType::UNKNOWN;
            ki.value = -1;
        }
    }

    mNewKeyIndex = InputAction::NO_VALUE;

    resetKeys();
    retrieve();
    update();
}
Пример #7
0
void BerconGradient::Reset() {
	TimeValue t = GetCOREInterface()->GetTime();
		
	//if (xyzGen) xyzGen->Reset();
	//else ReplaceReference( COORD_REF, GetNewDefaultXYZGen());	
	if (texout) texout->Reset();
	else ReplaceReference( OUTPUT_REF, GetNewDefaultTextureOutput());
	
	if (curve) curve->DeleteMe();
	curve = (ICurveCtl *) CreateInstance(REF_MAKER_CLASS_ID,CURVE_CONTROL_CLASS_ID);
	curve->RegisterResourceMaker(static_cast<ReferenceMaker*>(this));
	CurveCtrl::init(curve);
	pbCurve->SetValue( pb_curve_on, t, FALSE);	

	pblock->SetValue( pb_type,				t, 0);
	pblock->SetValue( pb_interpolation,		t, 0);
	pblock->SetValue( pb_seed,				t, 12345);
	pblock->SetValue( pb_rand_mat,			t, 1);
	pblock->SetValue( pb_rand_obj,			t, 1);
	pblock->SetValue( pb_rand_par,			t, 1);
	pblock->SetValue( pb_rand_tile,			t, 1);
	pblock->SetValue( pb_range_min,			t, 0.f);
	pblock->SetValue( pb_range_max,			t, 1.f);
	pblock->SetValue( p_rangeLoop,			t, 0);
	pblock->SetValue( p_reverse,			t, 0);
	pblock->SetValue( pb_dison,				t, 0);
	pblock->SetValue( pb_disstr,			t, 0.05f);
	pblock->SetValue( pb_gradient_uvw,		t, 0);	
	pblock->SetValue( pb_gradient_normal,	t, 0);	
	pblock->SetValue( pb_gradient_normal2,	t, 0);	
	pblock->SetValue( pb_ior,				t, 1.6f);		

	p_maptex = NULL;
	p_distex = NULL;
	p_node = NULL;

	gradient->reset();
	resetKeys();

	berconXYZ.reset(pbXYZ, ivalid, 0, 1, 1, 1);

	ivalid.SetEmpty();
}
Пример #8
0
bool sfw::checkSel()
{
	if (getKey(key[4]) && !keyPress[4])
	{
		keyPress[4] = true;
		if (key[4] == ' ') { bindPress[26] = true; }
		else
		{
			for (int a = 0; bindings[a] != '\0'; a++)
			{
				if (key[4] == bindings[a]) { bindPress[a] = true; }
			}
		}
		return true;
	}
	else
	{
		resetKeys();
		return false;
	}
}
Пример #9
0
int sfw::menuChoice(int opts, bool isVertical)
{
	opts -= 1;

	if (isVertical)
	{
		/********************************************************\
		* This isn't one switch becasue that would allow the   *
		* "sideways" keys to function in vertical menus, which *
		* I find undesireable.                                 *
		\*******************************************************/
		switch (getControls())
		{
		case 0:
			sel--;
			break;
		case 1:
			sel++;
			break;
		}
	}
	else if (!isVertical)
	{
		switch (getControls())
		{
		case 2:
			sel--;
			break;
		case 3:
			sel++;
			break;
		}
	}

	if (sel > opts) { sel = 0; }
	else if (sel < 0) { sel = opts; }

	resetKeys();
	return sel;
}
Пример #10
0
void Samurai::IO::Net::TlsFactory::freeKeys()
{
    delete pem_key;
    delete pem_cert;
    resetKeys();
}
Пример #11
0
void Samurai::IO::Net::TlsFactory::priv_init()
{
    resetKeys();
}
Пример #12
0
KeyInput::KeyInput() :
    mutex()
{
    resetKeys();
}
Пример #13
0
void ALEState::setActionJoysticks(Event* event, int player_a_action, int player_b_action) {
  // Reset keys
  resetKeys(event);

  switch(player_a_action) {
      case PLAYER_A_NOOP: 
          break; 
          
      case PLAYER_A_FIRE: 
          event->set(Event::JoystickZeroFire, 1);
          break; 
          
      case PLAYER_A_UP: 
          event->set(Event::JoystickZeroUp, 1);
          break; 
          
      case PLAYER_A_RIGHT: 
          event->set(Event::JoystickZeroRight, 1);
          break; 
          
      case PLAYER_A_LEFT: 
          event->set(Event::JoystickZeroLeft, 1);
          break; 
          
      case PLAYER_A_DOWN: 
          event->set(Event::JoystickZeroDown, 1);
          break; 
          
      case PLAYER_A_UPRIGHT: 
          event->set(Event::JoystickZeroUp, 1);
          event->set(Event::JoystickZeroRight, 1);
          break; 
          
      case PLAYER_A_UPLEFT: 
          event->set(Event::JoystickZeroUp, 1);
          event->set(Event::JoystickZeroLeft, 1);
          break; 
          
      case PLAYER_A_DOWNRIGHT: 
          event->set(Event::JoystickZeroDown, 1);
          event->set(Event::JoystickZeroRight, 1);
          break; 
          
      case PLAYER_A_DOWNLEFT: 
          event->set(Event::JoystickZeroDown, 1);
          event->set(Event::JoystickZeroLeft, 1);
          break; 
          
      case PLAYER_A_UPFIRE: 
          event->set(Event::JoystickZeroUp, 1);
          event->set(Event::JoystickZeroFire, 1);
          break; 
          
      case PLAYER_A_RIGHTFIRE: 
          event->set(Event::JoystickZeroRight, 1);
          event->set(Event::JoystickZeroFire, 1); 
          break; 
          
      case PLAYER_A_LEFTFIRE: 
          event->set(Event::JoystickZeroLeft, 1);
          event->set(Event::JoystickZeroFire, 1); 
          break; 
          
      case PLAYER_A_DOWNFIRE: 
          event->set(Event::JoystickZeroDown, 1);
          event->set(Event::JoystickZeroFire, 1);
          break; 
          
      case PLAYER_A_UPRIGHTFIRE: 
          event->set(Event::JoystickZeroUp, 1);
          event->set(Event::JoystickZeroRight, 1);
          event->set(Event::JoystickZeroFire, 1);
          break; 
          
      case PLAYER_A_UPLEFTFIRE: 
          event->set(Event::JoystickZeroUp, 1);
          event->set(Event::JoystickZeroLeft, 1);
          event->set(Event::JoystickZeroFire, 1); 
          break; 
          
      case PLAYER_A_DOWNRIGHTFIRE: 
          event->set(Event::JoystickZeroDown, 1);
          event->set(Event::JoystickZeroRight, 1);
          event->set(Event::JoystickZeroFire, 1); 
          break; 
          
      case PLAYER_A_DOWNLEFTFIRE: 
          event->set(Event::JoystickZeroDown, 1);
          event->set(Event::JoystickZeroLeft, 1);
          event->set(Event::JoystickZeroFire, 1);
          break; 
      case RESET:
          event->set(Event::ConsoleReset, 1);
          break;
      default: 
          cerr << "Invalid Player A Action: " << player_a_action;
          exit(-1); 
      
  }

  switch(player_b_action) {
  case PLAYER_B_NOOP: 
          break; 
          
      case PLAYER_B_FIRE: 
          event->set(Event::JoystickOneFire, 1);
          break; 
          
      case PLAYER_B_UP: 
          event->set(Event::JoystickOneUp, 1);
          break; 
          
      case PLAYER_B_RIGHT: 
          event->set(Event::JoystickOneRight, 1);
          break; 
          
      case PLAYER_B_LEFT: 
          event->set(Event::JoystickOneLeft, 1);
          break; 
          
      case PLAYER_B_DOWN: 
          event->set(Event::JoystickOneDown, 1);
          break; 
          
      case PLAYER_B_UPRIGHT: 
          event->set(Event::JoystickOneUp, 1);
          event->set(Event::JoystickOneRight, 1);
          break; 
          
      case PLAYER_B_UPLEFT: 
          event->set(Event::JoystickOneUp, 1);
          event->set(Event::JoystickOneLeft, 1);
          break; 
          
      case PLAYER_B_DOWNRIGHT: 
          event->set(Event::JoystickOneDown, 1);
          event->set(Event::JoystickOneRight, 1);
          break; 
          
      case PLAYER_B_DOWNLEFT: 
          event->set(Event::JoystickOneDown, 1);
          event->set(Event::JoystickOneLeft, 1);
          break; 
          
      case PLAYER_B_UPFIRE: 
          event->set(Event::JoystickOneUp, 1);
          event->set(Event::JoystickOneFire, 1);
          break; 
          
      case PLAYER_B_RIGHTFIRE: 
          event->set(Event::JoystickOneRight, 1);
          event->set(Event::JoystickOneFire, 1); 
          break; 
          
      case PLAYER_B_LEFTFIRE: 
          event->set(Event::JoystickOneLeft, 1);
          event->set(Event::JoystickOneFire, 1); 
          break; 
          
      case PLAYER_B_DOWNFIRE: 
          event->set(Event::JoystickOneDown, 1);
          event->set(Event::JoystickOneFire, 1);
          break; 
          
      case PLAYER_B_UPRIGHTFIRE: 
          event->set(Event::JoystickOneUp, 1);
          event->set(Event::JoystickOneRight, 1);
          event->set(Event::JoystickOneFire, 1);
          break; 
          
      case PLAYER_B_UPLEFTFIRE: 
          event->set(Event::JoystickOneUp, 1);
          event->set(Event::JoystickOneLeft, 1);
          event->set(Event::JoystickOneFire, 1); 
          break; 
          
      case PLAYER_B_DOWNRIGHTFIRE: 
          event->set(Event::JoystickOneDown, 1);
          event->set(Event::JoystickOneRight, 1);
          event->set(Event::JoystickOneFire, 1); 
          break; 
          
      case PLAYER_B_DOWNLEFTFIRE: 
          event->set(Event::JoystickOneDown, 1);
          event->set(Event::JoystickOneLeft, 1);
          event->set(Event::JoystickOneFire, 1);
          break; 
      case RESET:
          event->set(Event::ConsoleReset, 1);
          cerr << "Sending Reset..." << endl;
          break;
      default: 
          cerr << "Invalid Player B Action: " << player_b_action << endl;
          exit(-1); 
  }
}
Пример #14
0
void ALEState::applyActionPaddles(Event* event, int player_a_action, int player_b_action) {
  // Reset keys
  resetKeys(event);

  // First compute whether we should increase or decrease the paddle position
  //  (for both left and right players)
  int delta_left;
  int delta_right;

    switch(player_a_action) {
        case PLAYER_A_RIGHT: 
        case PLAYER_A_RIGHTFIRE: 
        case PLAYER_A_UPRIGHT: 
        case PLAYER_A_DOWNRIGHT: 
        case PLAYER_A_UPRIGHTFIRE: 
        case PLAYER_A_DOWNRIGHTFIRE: 
          delta_left = -PADDLE_DELTA;   
            break; 
            
        case PLAYER_A_LEFT:
        case PLAYER_A_LEFTFIRE: 
        case PLAYER_A_UPLEFT: 
        case PLAYER_A_DOWNLEFT: 
        case PLAYER_A_UPLEFTFIRE: 
        case PLAYER_A_DOWNLEFTFIRE: 
      delta_left = PADDLE_DELTA;
            break;
    default:
      delta_left = 0;
      break;
    }

    switch(player_b_action) {
        case PLAYER_B_RIGHT: 
        case PLAYER_B_RIGHTFIRE: 
        case PLAYER_B_UPRIGHT: 
        case PLAYER_B_DOWNRIGHT: 
        case PLAYER_B_UPRIGHTFIRE: 
        case PLAYER_B_DOWNRIGHTFIRE: 
          delta_right = -PADDLE_DELTA;
            break; 
            
        case PLAYER_B_LEFT:
        case PLAYER_B_LEFTFIRE: 
        case PLAYER_B_UPLEFT: 
        case PLAYER_B_DOWNLEFT: 
        case PLAYER_B_UPLEFTFIRE: 
        case PLAYER_B_DOWNLEFTFIRE: 
      delta_right = PADDLE_DELTA;
            break;
    default:
      delta_right = 0;
      break;
    }

  // Now update the paddle positions
  updatePaddlePositions(event, delta_left, delta_right);

  // Handle reset
  if (player_a_action == RESET || player_b_action == RESET) 
    event->set(Event::ConsoleReset, 1);

  // Now add the fire event 
  switch (player_a_action) {
        case PLAYER_A_FIRE: 
        case PLAYER_A_UPFIRE: 
        case PLAYER_A_RIGHTFIRE: 
        case PLAYER_A_LEFTFIRE: 
        case PLAYER_A_DOWNFIRE: 
        case PLAYER_A_UPRIGHTFIRE: 
        case PLAYER_A_UPLEFTFIRE: 
        case PLAYER_A_DOWNRIGHTFIRE: 
        case PLAYER_A_DOWNLEFTFIRE: 
            event->set(Event::PaddleZeroFire, 1);
            break;
    default:
      // Nothing
      break;
  }
  
  switch (player_b_action) {
        case PLAYER_B_FIRE: 
        case PLAYER_B_UPFIRE: 
        case PLAYER_B_RIGHTFIRE: 
        case PLAYER_B_LEFTFIRE: 
        case PLAYER_B_DOWNFIRE: 
        case PLAYER_B_UPRIGHTFIRE: 
        case PLAYER_B_UPLEFTFIRE: 
        case PLAYER_B_DOWNRIGHTFIRE: 
        case PLAYER_B_DOWNLEFTFIRE: 
            event->set(Event::PaddleOneFire, 1);
            break;
    default:
      // Nothing
      break;
  }
}
void
InputService::update()
{

	if(_infoSlot == NULL)
	{
		_isTerminationPending = true;
		_terminationMessage = "Missing InfoHandle";
	}
	else
	{
		int mousePositionX, mousePositionY;
		glfwGetMousePos(&mousePositionX, &mousePositionY);
		_inputHandle->setMousePosition(mousePositionX, mousePositionY);
		

		_inputHandle->resetKeys();
		
		if(glfwGetKey(GLFW_KEY_ESC) == GLFW_PRESS) {
			//std::cout << "Pressed ESC" << std::endl;
			_inputHandle->toggleKey(InputHandle::KEY_ESC);
		}

	  if(glfwGetKey(167) == GLFW_PRESS && glfwGetKey(167) == GLFW_RELEASE)
		{
				//std::cout << "PRESSED 167" << std::endl;
				_audio->play(3);	
				
				if (_state == INGAME)
				{
					setState(CONSOLE);
					_inputHandle->setState(_state);
				}
				else if (_state == CONSOLE)
				{
					setState(INGAME);
					_inputHandle->setState(_state);
				}
			
				_console->clearCommand();
				_console->updateText();
				resetKeys();
		}
		
		// Legacy :) Still needed though
		if(_state == INGAME)
		{	
			if(glfwGetKey('A') == GLFW_PRESS) {
				//std::cout << "Pressed A" << std::endl;
				if(!_infoSlot->getIsJumping())
					_audio->play(0);

				_inputHandle->toggleKey(InputHandle::KEY_A);
			}
			
			if(glfwGetKey('S') == GLFW_PRESS) {
				//std::cout << "Pressed S" << std::endl;
			if(!_infoSlot->getIsJumping())
				_audio->play(0);

				_inputHandle->toggleKey(InputHandle::KEY_S);
			}

			if(glfwGetKey('D') == GLFW_PRESS) {
				//std::cout << "Pressed D" << std::endl;
			if(!_infoSlot->getIsJumping())
				_audio->play(0);

				_inputHandle->toggleKey(InputHandle::KEY_D);
			}

			if(glfwGetKey('W') == GLFW_PRESS) {
				//std::cout << "Pressed W" << std::endl;	
			if(!_infoSlot->getIsJumping())
				_audio->play(0);

				_inputHandle->toggleKey(InputHandle::KEY_W);
			}

			if(glfwGetKey(GLFW_KEY_SPACE) == GLFW_PRESS)
			{
				_audio->play(4);
				_inputHandle->toggleKey(InputHandle::KEY_SPACE);
			}

			if(glfwGetMouseButton(GLFW_MOUSE_BUTTON_1) == GLFW_PRESS) {
				//std::cout << "Mouse 1" << std::endl;		
				_audio->play(1);
			}

			if(glfwGetMouseButton(GLFW_MOUSE_BUTTON_2) == GLFW_PRESS) {
				//std::cout << "Mouse 1" << std::endl;		
				_audio->play(2);
			}
		}

		/*if(glfwGetKey(GLFW_KEY_ESC) == GLFW_PRESS || !glfwGetWindowParam(GLFW_OPENED))
		{
				_isTerminationPending = true;
				_terminationMessage = "Termination by user input";
		}*/
	}

}
Пример #16
0
InputHandle::InputHandle()
{
	resetKeys();
}