示例#1
0
void Scene1000::Action1::signal() {
	Scene1000 *scene = (Scene1000 *)_globals->_sceneManager._scene;

	switch (_actionIndex++) {
	case 0:
		_globals->_player.disableControl();
		setDelay(10);
		break;
	case 1:
		scene->_object4.postInit();
		scene->_object4.setVisage(1001);
		scene->_object4._frame = 1;
		scene->_object4.setStrip2(5);
		scene->_object4.changeZoom(100);
		scene->_object4.animate(ANIM_MODE_2, NULL);
		scene->_object4.setPosition(Common::Point(403, 163));
		setDelay(90);
		break;
	case 2: {
		SceneItem::display(0, 0);
		scene->_object4.remove();
		scene->_object1.changeZoom(-1);
		NpcMover *mover = new NpcMover();
		Common::Point pt(180, 100);
		scene->_object1.addMover(mover, &pt, this);
		break;
	}
	case 3:
		_globals->_sceneManager.changeScene(1400);
		break;
	}

}
int AkmSensor::setEnable(int32_t handle, int enabled)
{
	int id = handle2id(handle);
	int err = 0;
	char buffer[2];

	switch (id) {
	case Accelerometer:
		strcpy(&input_sysfs_path[input_sysfs_path_len], "enable_acc");
		break;
	case MagneticField:
		strcpy(&input_sysfs_path[input_sysfs_path_len], "enable_mag");
		break;
	case Orientation:
		strcpy(&input_sysfs_path[input_sysfs_path_len], "enable_ori");
		break;
	default:
		ALOGE("AkmSensor: unknown handle (%d)", handle);
		return -EINVAL;
	}

	buffer[0] = '\0';
	buffer[1] = '\0';

	if (mEnabled[id] <= 0) {
		if(enabled) buffer[0] = '1';
	} else if (mEnabled[id] == 1) {
		if(!enabled) buffer[0] = '0';
	}

    if (buffer[0] != '\0') {
		err = write_sys_attribute(input_sysfs_path, buffer, 1);
		if (err != 0) {
			return err;
		}
		ALOGD("AkmSensor: set %s to %s",
			&input_sysfs_path[input_sysfs_path_len], buffer);

		/* for AKMD specification */
		if (buffer[0] == '1') {
			setDelay(handle, AKMD_DEFAULT_INTERVAL);
		} else {
			setDelay(handle, -1);
		}
    }

	if (enabled) {
		(mEnabled[id])++;
		if (mEnabled[id] > 32767) mEnabled[id] = 32767;
	} else {
		(mEnabled[id])--;
		if (mEnabled[id] < 0) mEnabled[id] = 0;
	}
	ALOGD("AkmSensor: mEnabled[%d] = %d", id, mEnabled[id]);

    return err;
}
示例#3
0
void Board::getHint() {
  int x1, y1, x2, y2;
  History h[4];

  if(getHint_I(x1, y1, x2, y2, h)) {
    undrawArrow();
    for(int i = 0; i < 4; i++)
      history[i] = h[i];

    int old_delay = getDelay();
    setDelay(1000);
    drawArrow(x1, y1, x2, y2);
    setDelay(old_delay);
  }
}
int Kxtf9Sensor::enable(int32_t handle, int en)
{
    int err = 0;

    int newState = en ? 1 : 0;

    // don't set enable state if it's already valid
    if(mEnabled == newState) {
        return err;
    }

    // ok we need to set our enabled state
    int fd = open(KXTF9_ENABLE_FILE, O_WRONLY);
    if(fd >= 0) {
        char buffer[20];
        int bytes = sprintf(buffer, "%d\n", newState);
        err = write(fd, buffer, bytes);
        err = err < 0 ? -errno : 0;
    } else {
        err = -errno;
    }

    LOGE_IF(err < 0, "Error setting enable of kxtf9 accelerometer (%s)", strerror(-err));

    if (!err) {
        mEnabled = newState;
        setDelay(0, 100000000); // 100ms by default for faster re-orienting
    }

    return err;
}
int SensorKXTF9::enable(int32_t handle, int en)
{
    int err = 0;
    int newState = en ? 1 : 0;

    if(mEnabled == (unsigned)newState)
        return err;

    if (!mEnabled)
        open_device();

    err = ioctl(dev_fd, KXTF9_IOCTL_SET_ENABLE, &newState);
    err = err < 0 ? -errno : 0;
    LOGE_IF(err, "SensorKXTF9: KXTF9_IOCTL_SET_ENABLE failed (%s)", strerror(-err));

    if (!err)
    {
        mEnabled = newState;
        err = setDelay(handle, KXTF9_DEFAULT_DELAY);
    }

    if (!mEnabled)
        close_device();

    return err;
}
示例#6
0
void SpeakerPOR::SpeakerAction1::signal(){
	switch (_actionIndex++) {
	case 0:
		setDelay(_globals->_randomSource.getRandomNumber(60) + 60);
		break;
	case 1:
		static_cast<SceneObject *>(_owner)->animate(ANIM_MODE_5, this, NULL);
		break;
	case 2:
		setDelay(_globals->_randomSource.getRandomNumber(10));
		_actionIndex = 0;
		break;
	default:
		break;
	}
}
示例#7
0
// set default values
void Config::setDefaultSettings()
{
    setSaveDir(getDirNameDefault());
    setSaveFileName(DEF_SAVE_NAME);
    setSaveFormat(DEF_SAVE_FORMAT);
    setDefDelay(DEF_DELAY);
    setImageQuality(DEF_IMG_QUALITY);
    setDateTimeInFilename(DEF_DATETIME_FILENAME);
    setDateTimeTpl(DEF_DATETIME_TPL);
    setAutoCopyFilenameOnSaving(DEF_FILENAME_TO_CLB);
    setAutoSave(DEF_AUTO_SAVE);
    setAutoSaveFirst(DEF_AUTO_SAVE_FIRST);
    setTrayMessages(DEF_TRAY_MESS_TYPE);
    setIncludeCursor(DEF_INCLUDE_CURSOR);
    setZoomAroundMouse(DEF_ZOOM_AROUND_MOUSE);
    setCloseInTray(DEF_CLOSE_IN_TRAY);
    setTimeTrayMess(DEF_TIME_TRAY_MESS);
    setAllowMultipleInstance(DEF_ALLOW_COPIES);
    // TODO - make set windows size without hardcode values
    // setRestoredWndSize(DEF_WND_WIDTH, DEF_WND_HEIGHT);
    setShowTrayIcon(DEF_SHOW_TRAY);
    setEnableExtView(DEF_ENABLE_EXT_VIEWER);

    _shortcuts->setDefaultSettings();

    setNoDecoration(DEF_X11_NODECOR);
    setDelay(DEF_DELAY);

    quint8 countModules = Core::instance()->modules()->count();
    for (int i = 0; i < countModules; ++i)
        Core::instance()->modules()->getModule(i)->defaultSettings();
}
示例#8
0
/**
 * @param p the priority of this event
 * @param str the structure which repair
 */
BRepairUnitAnimEvent::BRepairUnitAnimEvent(uint32_t p, Structure *str) : BuildingAnimEvent(p,str,8)
{
    int		un_cost;
    Sint16	health;
    Unit	*UnitToFix = NULL;

    // The Anim is not finished
	done		= false;
    // Structure to Apply
    this->strct = str;

    StartFrame	= 0;
    frame		= 0;

	UnitToFix = p::uspool->getUnitAt(strct->UnitToRepairPos);

	if (UnitToFix == 0)
	{
		logger->error ("%s line %i: Structure anim unit not found\n", __FILE__, __LINE__);
		stop();
		return;
	}

	health = UnitToFix->getHealth();
	un_cost = UnitToFix->getType()->getCost();
	if (health > 0) {
		dmg_cost = (Uint16)(((double)un_cost/(double)UnitToFix->getType()->getMaxHealth()) * ((double)UnitToFix->getType()->getMaxHealth() - (double)health));
	} else {
		dmg_cost = (Uint16)un_cost;
    }

    setDelay(1);
}
示例#9
0
Board::Board(QWidget *parent) : QWidget(parent) {
  trying = FALSE;
  _solvable_flag = TRUE;

  // randomze
  setShuffle(DEFAULTSHUFFLE);
  clock_t t;
  struct tms dummy;
  t = times(&dummy); 
  srandom((int)t);

  starttime = time((time_t *)0);

  for(int i = 0; i < 45; i++)
    pm_tile[i] = 0;

  setDelay(DEFAULTDELAY);
  _redo.setAutoDelete(TRUE);
  _undo.setAutoDelete(TRUE);

  loadTiles(1);
  field = 0;
  QPixmap bg((PICDIR + "/kshisen_bgnd.xpm").data());
  setBackgroundPixmap(bg);
  connect(this, SIGNAL(fieldClicked(int, int)),
	  this, SLOT(marked(int, int)));
  connect(this, SIGNAL(madeMove(int, int, int, int)),
	  this, SLOT(slotMadeMove(int, int, int, int)));  

  setShuffle(0);
  setSize(18, 8);

  highlighted_tile = -1;
}
示例#10
0
void Scene1250::Action2::signal() {
	Scene1250 *scene = (Scene1250 *)_globals->_sceneManager._scene;

	switch (_actionIndex++) {
	case 0:
		switch (_globals->_randomSource.getRandomNumber(2)) {
		case 0:
			scene->_object2.setPosition(Common::Point(163, 75));
			break;
		case 1:
			scene->_object2.setPosition(Common::Point(109, 65));
			break;
		case 2:
			scene->_object2.setPosition(Common::Point(267, 20));
			break;
		}

		setDelay(30);
		break;
	case 1:
		scene->_object2.animate(ANIM_MODE_5, this);
		_actionIndex = 0;
		break;
	}
}
示例#11
0
bool CircuitElement::updateState(GameScripting* m_script, Map* map, INodeDefManager* ndef) {
	MapNode node = map->getNodeNoEx(m_pos);
	// Map not yet loaded
	if(!node) {
		dstream << "Circuit simulator: Waiting for map blocks loading..." << std::endl;
		return false;
	}
	const ContentFeatures& node_features = ndef->get(node);
	// Update delay (may be not synchronized)
	u32 delay = node_features.circuit_element_delay;
	if(delay != m_states_queue.size()) {
		setDelay(delay);
	}
	m_states_queue.push_back(m_next_input_state);
	m_next_input_state = m_states_queue.front();
	m_states_queue.pop_front();
	m_current_output_state = node_features.circuit_element_func[m_next_input_state];
	if(m_next_input_state && !m_current_input_state && node_features.has_on_activate) {
		m_script->node_on_activate(m_pos, node);
	}
	if(!m_next_input_state && m_current_input_state && node_features.has_on_deactivate) {
		m_script->node_on_deactivate(m_pos, node);
	}
	m_prev_input_state = m_current_input_state;
	m_current_input_state = m_next_input_state;
	m_next_input_state = 0;
	return true;
}
示例#12
0
void initQuickSwap(void){
		
	quickSwapMode = eeprom_read_byte((uint8_t *)EEPROM_QUICK_SWAP); 
	if(quickSwapMode == 0xFF) quickSwapMode = 0;
		
	quickSwapCountMax = setDelay(QUICKSWAP_COUNT_MAX);
}
示例#13
0
void AbstractCommand::readProperties(boost::property_tree::wptree& pt)
{
    if (pt.count(L"channel") > 0) setChannel(pt.get<int>(L"channel"));
    if (pt.count(L"videolayer") > 0) setVideolayer(pt.get<int>(L"videolayer"));
    if (pt.count(L"delay") > 0) setDelay(pt.get<int>(L"delay"));
    if (pt.count(L"allowgpi") > 0) setAllowGpi(pt.get<bool>(L"allowgpi"));
    if (pt.count(L"allowremotetriggering") > 0) setAllowRemoteTriggering(pt.get<bool>(L"allowremotetriggering"));
}
示例#14
0
文件: ktimer.cpp 项目: KDE/ktimer
void KTimerJob::load( KConfig *cfg, const QString& grp )
{
	KConfigGroup groupcfg = cfg->group(grp);
    setDelay( groupcfg.readEntry( "Delay", 100 ) );
    setCommand( groupcfg.readPathEntry( "Command", QString() ) );
    setLoop( groupcfg.readEntry( "Loop", false ) );
    setOneInstance( groupcfg.readEntry( "OneInstance", d->oneInstance ) );
    setState( (States)groupcfg.readEntry( "State", (int)Stopped ) );
}
示例#15
0
void Scene1250::Action4::signal() {
	Scene1250 *scene = (Scene1250 *)_globals->_sceneManager._scene;

	switch (_actionIndex++) {
	case 0:
		setDelay(3);
		break;
	case 1:
		scene->_stripManager.start(1250, this);
		break;
	case 2:
		setDelay(6);
		break;
	case 3:
		_globals->_sceneManager.changeScene(2000);
		break;
	}
}
示例#16
0
void Board::loadSettings(){
	int index = Prefs::size();
	setSize(size_x[index], size_y[index]);

	setShuffle(Prefs::level() * 4 + 1);
	setGravityFlag(Prefs::gravity());
	setSolvableFlag(Prefs::solvable());
	setDelay(DELAY[Prefs::speed()]);
}
int SensorBase::batch(int handle, int flags, int64_t period_ns, int64_t timeout){
	/*default , not support batch mode or SENSORS_BATCH_WAKE_UPON_FIFO_FULL */
	if(timeout > 0 || flags & SENSORS_BATCH_WAKE_UPON_FIFO_FULL)
		return -EINVAL;
	if(!(flags & SENSORS_BATCH_DRY_RUN)){
		setDelay(handle,period_ns);
	}
	return 0;
}
示例#18
0
void Scene3500::Action2::signal() {
	Scene3500 *scene = (Scene3500 *)_globals->_sceneManager._scene;

	switch (_actionIndex++) {
	case 0:
		setDelay(10);
		break;
	case 1:
		scene->_stripManager.start(3501, this);
		break;
	case 2:
		setDelay(3);
		break;
	case 3:
		_globals->_sceneManager.changeScene(2012);
		break;
	}
}
int PSHCommonSensor::batch(int handle, int flags, int64_t period_ns, int64_t timeout) {
        int delay = period_ns / NS_TO_MS;
        int ret = -EINVAL;
        static int oldDataRate = -1;
        static int oldBufferDelay = -1;
        static streaming_flag oldFlag;

        if (handle != device.getHandle()) {
                ALOGE("%s: line: %d: %s handle not match! handle: %d required handle: %d",
                     __FUNCTION__, __LINE__, device.getName(), device.getHandle(), handle);
                return -EINVAL;
        }

        if (period_ns < 0 || timeout < 0)
                return -EINVAL;

        if (timeout == 0) {
                ret = setDelay(handle, period_ns);
                bufferDelay = 0;
                oldBufferDelay = 0;
                return ret;
        }

        bufferDelay = timeout / NS_TO_MS;

        ret = setDelay(handle, period_ns);

        if (oldDataRate == -1) {
                oldDataRate = state.getDataRate();
                oldBufferDelay = bufferDelay;
                oldFlag = flag;
                return ret;
        }

        if (oldDataRate != state.getDataRate() || oldBufferDelay != bufferDelay || oldFlag != flag) {
                oldDataRate = state.getDataRate();
                oldBufferDelay = bufferDelay;
                oldFlag = flag;
                if (state.getActivated())
                        ret = hardwareSet(true);
        }

        return ret;
}
示例#20
0
void Scene1000::Action2::signal() {
	switch (_actionIndex++) {
	case 0:
		_globals->_player.disableControl();
		setDelay(10);
		break;
	case 1:
		SceneItem::display(1000, 0, SET_Y, 20, SET_FONT, 2, SET_BG_COLOR, -1,
				SET_EXT_BGCOLOR, 35, SET_WIDTH, 200, SET_KEEP_ONSCREEN, 1, LIST_END);
		setDelay(180);
		break;
	case 2:
		SceneItem::display(0, 0);
		_globals->_sceneManager.changeScene(2000);
		break;
	default:
		break;
	}
}
示例#21
0
文件: timer.cpp 项目: RAttab/slick
Timer::
Timer(double delay, double init)
{
    int clockid = delay < 0.01 ? CLOCK_MONOTONIC : CLOCK_REALTIME;

    fd_ = timerfd_create(clockid, TFD_NONBLOCK);
    SLICK_CHECK_ERRNO(fd_ != -1, "timer.create");

    setDelay(delay, init);
}
示例#22
0
文件: actors.c 项目: witheld9/Torch
void moveActor(character *actor, int vx, int vy) {
	if (actor->delay) {
		return;
	}
	
	actor->vx = vx;
	actor->vy = vy;
	
	setDelay(actor, getMovementCost(actor));
}
示例#23
0
boolean JTimerObj::updateProperty(JProperty& prop) {
  if (JANDObj::updateProperty(prop)) return true;
  if (prop.getName() == JString("delay")) {
    setDelay(((JIntegerProperty*)&prop)->value);
    return true;
  } else if (prop.getName() == JString("priority")) {
    priority = ((JIntegerListProperty*)&prop)->value;
    return true;
  }
  return false;
}
示例#24
0
void Scene666::Action1::signal() {
	switch (_actionIndex++) {
	case 0:
		BF_GLOBALS._player.hide();
		setDelay(6);
		break;
	case 1:
		BF_GLOBALS._game->restartGame();
		break;
	}
}
示例#25
0
//------------------------------------------------------------------------
void ADelay::setParameter (VstInt32 index, float value)
{
	ADelayProgram* ap = &programs[curProgram];

	switch (index)
	{
		case kDelay :    setDelay (value);					break;
		case kFeedBack : fFeedBack = ap->fFeedBack = value; break;
		case kOut :      fOut = ap->fOut = value;			break;
	}
}
示例#26
0
void PitchedDelay::updateLatency(int latency)
{
	latencyCompensation.setLength(latency);
	unpitchedDelay.setLength(latency);

	const double minDelay = (latency + 10) / sampleRate;
	const double maxDelay = (delayL.getDataLength() + latency - 10) / sampleRate;
	delayRange = Range<double> (minDelay, maxDelay);

	setDelay(currentTime, preDelayPitch);
}
示例#27
0
void SequenceManager::process(Event &event) {
	if (((event.eventType == EVENT_BUTTON_DOWN) || (event.eventType == EVENT_KEYPRESS)) &&
		!event.handled && g_globals->_sceneObjects->contains(&_sceneText)) {
		// Remove the text item
		_sceneText.remove();
		setDelay(2);
		event.handled = true;
	} else {
		Action::process(event);
	}
}
/**
 * @param p  of the anim
 * @param pos Position of the animation in the map
 */
BarrelExplosionActionEvent::BarrelExplosionActionEvent(unsigned int p, unsigned int pos) :
ActionEvent(p)
{
    // Set a delay (0.512 sec)
    setDelay(6);

    // Save the position
    position = pos;

    // Reschedule this anim
    p::aequeue->scheduleEvent(this);
}
示例#29
0
float myProcess(float AudioIn)
{
	float sample;
  float envGain[2];
	int m = 0;
	scalar[0] =( powf( 0.5f, (1.0f/(((float)ADC_values[4]) * INV_TWO_TO_12 * (float)SAMPLE_RATE))));
	scalar[1] =( powf( 0.5f, (1.0f/(((float)ADC_values[5]) * INV_TWO_TO_12 * (float)SAMPLE_RATE))));
	
	//set frequency of sine and delay
	phaseInc = (MtoF((currParamValue[ADC_FREQ]) * 109.0f + 25.f)) * INV_SAMPLE_RATE;
	setDelay(currParamValue[ADC_DELAY]);
	
	AudioGateVal = ((float)ADC_values[3]) * INV_TWO_TO_12 * 0.2f;
	env_detector_thresh = AudioGateVal;
	if (AudioIn < AudioGateVal)
	{
		AudioIn = 0;
	}
	envGain[0] = adc_env_detector(AudioIn, 0);
  envGain[1] = adc_env_detector(AudioIn, 1);
	
	sample = ((KSprocess(AudioIn) * 0.7f) + AudioIn * 0.8f);
	sample += (0.8f * ((wavetableSynth() * envGain[0] * 0.8f) + (whiteNoise() * envGain[1] * 0.18f)));
  sample = highpass(FastTanh2Like4Term(sample * gainBoost));

	//update Parameters
	for (m = 0; m < NUM_PARAMS; m++)
	{
		
		if ((currParamValue[m] >= destParamValue[m]) && (dirParamInc[m] == 1)) 
		{
			mParamInc[m] = 0.0f;
			currParamValue[m] = destParamValue[m];
		}
		else if ((currParamValue[m] <= destParamValue[m]) && (dirParamInc[m] == -1))
		{
			mParamInc[m] = 0.0f;
			currParamValue[m] = destParamValue[m];
		}
		else if (dirParamInc[m] == 0)
		{
			mParamInc[m] = 0.0f;
			currParamValue[m] = destParamValue[m];
		}
		else 
		{
			currParamValue[m] += mParamInc[m];
		}

	}
		
  return sample;
}
示例#30
0
void BRepairUnitAnimEvent::run()
{
	Unit* UnitToFix = 0;
	Sint16 health;
	uint16_t cost;

//	updateDamaged();

	if( !strct->isAlive() || done ) {
		delete this;
		return;
	}

	UnitToFix = p::uspool->getUnitAt(strct->UnitToRepairPos);

	if (UnitToFix == NULL){
		delete this;
		return;
	}

	health = UnitToFix->getHealth();

	if (health < UnitToFix->getType()->getMaxHealth()){
		cost = (Uint16)((double)dmg_cost/((double)UnitToFix->getType()->getMaxHealth() - (double)health));
		Player* Owner = p::ppool->getPlayer(UnitToFix->getOwner());
		if (Owner->getMoney() > cost){
			Owner->changeMoney(-1 * cost);
			dmg_cost -= cost;
			UnitToFix->ChangeHealth (1);
			UnitToFix->updateDamaged();
		}
	}else{
		//printf ("%s line %i: Unit repaired\n", __FILE__, __LINE__);
		// @todo ADD "Unit repaired" sound
		//pc::sfxeng->PlaySound(pc::Config.UnitRepaired);
		stop();
	}

	if (frame < 6){
		frame++;
	}else{
		frame = 0;
	}

	if (strct->getNumbImages (0) > frame){
		strct->setImageNum(frame,0);
	}else{
		logger->error ("%s line %i: Failed to set frame %i\n", __FILE__, __LINE__, frame);
	}

	setDelay(3);
	p::aequeue->scheduleEvent(this);
}