Camera::Camera(Field* field) { m_field = field; m_coloredWorld = ColoredWorld::getInstance(); setTrigger(Message::MSG_CAMERA_INITIALIZED); setTrigger(Message::MSG_COL_PLAYER_FLY); initValues(); }
AudioMixerSettings::AudioMixerSettings() : TriggeredConfigurationGroup(false, true, false, false) { setLabel(QObject::tr("Audio Mixer")); setUseLabel(false); Setting *volumeControl = MythControlsVolume(); addChild(volumeControl); // Mixer settings ConfigurationGroup *settings = new VerticalConfigurationGroup(false, true, false, false); settings->addChild(MixerDevice()); settings->addChild(MixerControl()); settings->addChild(MixerVolume()); settings->addChild(PCMVolume()); ConfigurationGroup *dummy = new VerticalConfigurationGroup(false, true, false, false); // Show Mixer config only if internal volume controls enabled setTrigger(volumeControl); addTarget("0", dummy); addTarget("1", settings); }
GalleryConfigurationGroup() : TriggeredConfigurationGroup(false, true, false, false) { setLabel(QObject::tr("MythGallery Settings (Slideshow)")); setUseLabel(false); #ifdef USING_OPENGL HostCheckBox* useOpenGL = SlideshowUseOpenGL(); addChild(useOpenGL); setTrigger(useOpenGL); ConfigurationGroup* openGLConfig = new VerticalConfigurationGroup(false); openGLConfig->addChild(SlideshowOpenGLTransition()); openGLConfig->addChild(SlideshowOpenGLTransitionLength()); addTarget("1", openGLConfig); #endif ConfigurationGroup* regularConfig = new VerticalConfigurationGroup(false); regularConfig->addChild(MythGalleryOverlayCaption()); regularConfig->addChild(SlideshowTransition()); regularConfig->addChild(SlideshowBackground()); addTarget("0", regularConfig); addChild(SlideshowDelay()); addChild(SlideshowRecursive()); }
TriggeredItem(Setting *checkbox, Setting *setting) : TriggeredConfigurationGroup(false, false, false, false) { setTrigger(checkbox); addTarget("1", setting); addTarget("0", new VerticalConfigurationGroup(false, false)); }
LocalHostNameSettings(Setting *checkbox, ConfigurationGroup *group) : TriggeredConfigurationGroup(false, false, false, false) { setLabel(QObject::tr("Use custom identifier for frontend preferences")); addChild(checkbox); setTrigger(checkbox); addTarget("1", group); addTarget("0", new VerticalConfigurationGroup(true)); }
///////////////////////////////////////////////////////////////////////////// // initializes the scope ///////////////////////////////////////////////////////////////////////////// void MbCvScope::init(u8 _displayNum) { displayNum = _displayNum; oversamplingFactor = 8; updatePeriod = 3000; // 3 seconds setTrigger(10); // P10% setSource(_displayNum + 1); // CV1..4 clear(); }
WOLsqlSettings::WOLsqlSettings(Setting *checkbox, ConfigurationGroup *group) : TriggeredConfigurationGroup(false, false, false, false) { setLabel(DatabaseSettings::tr("Backend Server Wakeup settings")); addChild(checkbox); setTrigger(checkbox); addTarget("1", group); addTarget("0", new VerticalConfigurationGroup(true)); };
ScanOptionalConfig::ScanOptionalConfig(ScanTypeSetting *_scan_type) : TriggeredConfigurationGroup(false, false, true, true, false, false, true, true), scanType(_scan_type), country(new ScanCountry()), network(new ScanNetwork()), paneDVBT(new PaneDVBT()), paneDVBS(new PaneDVBS()), paneDVBS2(new PaneDVBS2()), paneATSC(new PaneATSC()), paneDVBC(new PaneDVBC()), paneAnalog(new PaneAnalog()), paneSingle(new PaneSingle()), paneAll(new PaneAll()), paneDVBUtilsImport(new PaneDVBUtilsImport()), paneExistingScanImport(new PaneExistingScanImport()) { setTrigger(scanType); // only save settings for the selected pane setSaveAll(false); addTarget(QString::number(ScanTypeSetting::Error_Open), new PaneError(tr("Failed to open the card"))); addTarget(QString::number(ScanTypeSetting::Error_Probe), new PaneError(tr("Failed to probe the card"))); addTarget(QString::number(ScanTypeSetting::NITAddScan_DVBC), paneDVBC); addTarget(QString::number(ScanTypeSetting::NITAddScan_DVBS), paneDVBS); addTarget(QString::number(ScanTypeSetting::NITAddScan_DVBS2), paneDVBS2); addTarget(QString::number(ScanTypeSetting::NITAddScan_DVBT), paneDVBT); addTarget(QString::number(ScanTypeSetting::FullScan_ATSC), paneATSC); addTarget(QString::number(ScanTypeSetting::FullScan_DVBC), network); addTarget(QString::number(ScanTypeSetting::FullScan_DVBT), country); addTarget(QString::number(ScanTypeSetting::FullScan_Analog), paneAnalog); addTarget(QString::number(ScanTypeSetting::TransportScan), paneSingle); addTarget(QString::number(ScanTypeSetting::FullTransportScan), paneAll); addTarget(QString::number(ScanTypeSetting::CurrentTransportScan), new BlankSetting()); addTarget(QString::number(ScanTypeSetting::IPTVImport), new BlankSetting()); addTarget(QString::number(ScanTypeSetting::VBoxImport), new BlankSetting()); // addTarget(QString::number(ScanTypeSetting::DVBUtilsImport), // paneDVBUtilsImport); addTarget(QString::number(ScanTypeSetting::ExistingScanImport), paneExistingScanImport); }
void MousePluginWidget::clearTrigger() { QString oldTrigger = m_triggerButton->trigger(); setTrigger(QString()); emit triggerChanged(oldTrigger, QString()); //byebye! m_pluginList->deleteLater(); m_aboutButton->deleteLater(); m_clearButton->deleteLater(); m_triggerButton->deleteLater(); m_configButton->deleteLater(); deleteLater(); }
bool Physics3DCollider::init(Physics3DColliderDes *info) { _physics3DShape = info->shape; _physics3DShape->retain(); _btGhostObject = new btCollider(this); _btGhostObject->setCollisionShape(_physics3DShape->getbtShape()); setTrigger(info->isTrigger); setFriction(info->friction); setRollingFriction(info->rollingFriction); setRestitution(info->restitution); setHitFraction(info->hitFraction); setCcdSweptSphereRadius(info->ccdSweptSphereRadius); setCcdMotionThreshold(info->ccdMotionThreshold); _type = Physics3DObject::PhysicsObjType::COLLIDER; return true; }
SpeechSynch::SpeechSynch() { festival_initialize(1,210000); // This must be called before any other festival functions may be called. It sets up the //synthesizer system. The first argument if true, causes the system set up files to be loaded //(which is normallly what is necessary), the second argument is the initial size of the Scheme heap, //this should normally be 210000 unless you envisage processing very large Lisp structures. festival_eval_command("(voice_el_diphone)"); festival_say_text("Welcome to Flying Object Madness"); // // festival_wait_for_spooler(); setTrigger(Message::MSG_COL_PLAYER_LETTER); // Say some text; // festival_say_text("hello world"); }
MythFillSettings() : TriggeredConfigurationGroup(false, true, false, false) { setLabel(QObject::tr("Program Schedule Downloading Options")); setUseLabel(false); Setting* fillEnabled = MythFillEnabled(); addChild(fillEnabled); setTrigger(fillEnabled); ConfigurationGroup* settings = new VerticalConfigurationGroup(false); settings->addChild(MythFillDatabasePath()); settings->addChild(MythFillDatabaseArgs()); settings->addChild(MythFillMinHour()); settings->addChild(MythFillMaxHour()); settings->addChild(MythFillGrabberSuggestsTime()); addTarget("1", settings); // show nothing if fillEnabled is off addTarget("0", new VerticalConfigurationGroup(true)); };
Window::Window(QWidget* parent) : QWidget(parent) { QGridLayout* grid = new QGridLayout; grid->addWidget(createAccelerometerGroup(), 0, 0); grid->addWidget(createGyroscopeGroup(), 0, 1); grid->addWidget(createMagnetometerGroup(), 1, 0); grid->addWidget(createButtonsGroup(), 1, 1); setLayout(grid); setWindowTitle(tr("psmoveosc")); resize(480, 320); psm = new PSMoveQt(0); psm->setColor(Qt::red); psm->setEnabled(true); connect(psm, SIGNAL(accelerometerChanged()), this, SLOT(readAccelerometer())); connect(psm, SIGNAL(gyroChanged()), this, SLOT(readGyro())); connect(psm, SIGNAL(magnetometerChanged()), this, SLOT(readMagnetometer())); connect(psm, SIGNAL(triggerChanged()), this, SLOT(setTrigger())); connect(psm, SIGNAL(buttonPressed(int)), this, SLOT(onButton(int))); connect(psm, SIGNAL(buttonReleased(int)), this, SLOT(onButton(int))); }
static int GPIO_set_trigger(GPIO *self, PyObject *val, void *closure) { char * trigger; char cdir; if (val == NULL) { PyErr_SetString(PyExc_TypeError, "Cannot delete attribute"); return -1; } if ( setTrigger(self, val) == NULL ) return -1; if ( PyObject_Compare(val, getTrigger( self ) ) != 0 ) { PyErr_SetString(PyExc_IOError, "setting trigger failed"); return -1; } self->trigger = val; return 0; }
void GuiTune::setTriggerPercent(int trig) { setTrigger((double)trig/100.0); }
int PhysicObject::methodsBridge(lua_State* luaVM) { if (isCurrentMethod("applyImpulse")) { applyImpulse(CVector(lua_tonumber(luaVM, 1), lua_tonumber(luaVM, 2), lua_tonumber(luaVM, 3)), CVector(lua_tonumber(luaVM, 4), lua_tonumber(luaVM, 5), lua_tonumber(luaVM, 6))); return 0; } if (isCurrentMethod("applyForce")) { applyForce(CVector(lua_tonumber(luaVM, 1), lua_tonumber(luaVM, 2), lua_tonumber(luaVM, 3)), CVector(lua_tonumber(luaVM, 4), lua_tonumber(luaVM, 5), lua_tonumber(luaVM, 6))); return 0; } if (isCurrentMethod("setLinearVelocity")) { setLinearVelocity(CVector(lua_tonumber(luaVM, 1), lua_tonumber(luaVM, 2), lua_tonumber(luaVM, 3))); return 0; } if (isCurrentMethod("getLinearVelocity")) { luaPushVector(luaVM, getLinearVelocity().x, getLinearVelocity().y, getLinearVelocity().z); return 1; } if (isCurrentMethod("setMass")) { setMass(lua_tonumber(luaVM, 1)); return 0; } if (isCurrentMethod("getMass")) { lua_pushnumber(luaVM, getMass()); return 1; } if (isCurrentMethod("setCollisionShapeType")) { setCollisionShapeType((CollisionShapeType)lua_tointeger(luaVM, 1)); return 0; } if (isCurrentMethod("getCollisionShapeType")) { lua_pushinteger(luaVM, getCollisionShapeType()); return 1; } if (isCurrentMethod("enablePhysics")) { enablePhysics(lua_toboolean(luaVM, 1)); return 0; } if (isCurrentMethod("isEnabledPhysics")) { lua_pushboolean(luaVM, isEnabledPhysics()); return 1; } if (isCurrentMethod("setAngularFactor")) { setAngularFactor(CVector(lua_tonumber(luaVM, 1), lua_tonumber(luaVM, 2), lua_tonumber(luaVM, 3))); return 0; } if (isCurrentMethod("getAngularFactor")) { luaPushVector(luaVM, getAngularFactor().x, getAngularFactor().y, getAngularFactor().z); return 1; } if (isCurrentMethod("setLinearFactor")) { setLinearFactor(CVector(lua_tonumber(luaVM, 1), lua_tonumber(luaVM, 2), lua_tonumber(luaVM, 3))); return 0; } if (isCurrentMethod("getLinearFactor")) { luaPushVector(luaVM, getLinearFactor().x, getLinearFactor().y, getLinearFactor().z); return 1; } if (isCurrentMethod("setTrigger")) { setTrigger(lua_toboolean(luaVM, 1)); return 0; } if (isCurrentMethod("isTrigger")) { lua_pushboolean(luaVM, isTrigger()); return 1; } if (isCurrentMethod("getCollisionShape")) { if (getCollisionShape() == NULL) { lua_pushnil(luaVM); } else { lua_getglobal(luaVM, getCollisionShape()->getGOID().c_str()); } return 1; } if (isCurrentMethod("setCollisionShape")) { if (lua_isnil(luaVM, 1)) { setCollisionShape(NULL); return 0; } lua_pushstring(luaVM, "cpointer"); lua_gettable(luaVM, -2); GOCollisionShape* o = (GOCollisionShape*)lua_tointeger(luaVM, -1); setCollisionShape(o); lua_pop(luaVM, -1); return 0; } if (isCurrentMethod("setEnableDeactivation")) { setEnableDeactivation(lua_toboolean(luaVM, 1)); return 0; } if (isCurrentMethod("isEnableDeactivation")) { lua_pushboolean(luaVM, isEnableDeactivation()); return 1; } if (isCurrentMethod("setFriction")) { setFriction(lua_tonumber(luaVM, 1)); return 0; } if (isCurrentMethod("getFriction")) { lua_pushnumber(luaVM, getFriction()); return 1; } if (isCurrentMethod("setRestitution")) { setRestitution(lua_tonumber(luaVM, 1)); return 0; } if (isCurrentMethod("getRestitution")) { lua_pushnumber(luaVM, getRestitution()); return 1; } if (isCurrentMethod("setLinearDumping")) { setLinearDumping(lua_tonumber(luaVM, 1)); return 0; } if (isCurrentMethod("getLinearDumping")) { lua_pushnumber(luaVM, getLinearDumping()); return 1; } if (isCurrentMethod("setAngularDumping")) { setAngularDumping(lua_tonumber(luaVM, 1)); return 0; } if (isCurrentMethod("getAngularDumping")) { lua_pushnumber(luaVM, getAngularDumping()); return 1; } if (isCurrentMethod("setAngularVelocity")) { setAngularVelocity(CVector(lua_tonumber(luaVM, 1), lua_tonumber(luaVM, 2), lua_tonumber(luaVM, 3))); return 0; } if (isCurrentMethod("getAngularVelocity")) { CVector av = getAngularVelocity(); luaPushVector(luaVM, av.x, av.y, av.z); return 1; } if (isCurrentMethod("addConstraint")) { if (lua_isnil(luaVM, 1)) { return 0; } lua_pushstring(luaVM, "cpointer"); lua_gettable(luaVM, -2); GOConstraint* o = (GOConstraint*)lua_tointeger(luaVM, -1); addConstraint(o); lua_pop(luaVM, -1); return 0; } if (isCurrentMethod("getConstraints")) { lua_newtable(luaVM); int tableIndex = lua_gettop(luaVM); vector<GOConstraint*> objs; for (unsigned int i = 0; i < constraints.size(); ++i) { if (constraints.at(i)->id == "undefined" || constraints.at(i)->id == "") continue; objs.push_back(constraints.at(i)); } for (unsigned int i = 0; i < objs.size(); ++i) { lua_pushinteger(luaVM, i+1); lua_getglobal(luaVM, objs.at(i)->id.c_str()); lua_settable (luaVM, tableIndex); } return 1; } if (isCurrentMethod("removeConstraint")) { if (lua_isnil(luaVM, 1)) { return 0; } lua_pushstring(luaVM, "cpointer"); lua_gettable(luaVM, -2); GOConstraint* o = (GOConstraint*)lua_tointeger(luaVM, -1); removeConstraint(o); lua_pop(luaVM, -1); return 0; } if (isCurrentMethod("removeAllConstrains")) { removeAllConstraints(); return 0; } if (isCurrentMethod("secondObjectForConstraint")) { if (lua_isnil(luaVM, 1)) { return 0; } lua_pushstring(luaVM, "cpointer"); lua_gettable(luaVM, -2); GOConstraint* o = (GOConstraint*)lua_tointeger(luaVM, -1); secondObjectForConstraint(o); lua_pop(luaVM, -1); return 0; } if (isCurrentMethod("isSecondObjectForConstraints")) { lua_newtable(luaVM); int tableIndex = lua_gettop(luaVM); vector<GOConstraint*> objs; for (unsigned int i = 0; i < secondObjectForConstraints.size(); ++i) { if (secondObjectForConstraints.at(i)->id == "undefined" || secondObjectForConstraints.at(i)->id == "") continue; objs.push_back(secondObjectForConstraints.at(i)); } for (unsigned int i = 0; i < objs.size(); ++i) { lua_pushinteger(luaVM, i+1); lua_getglobal(luaVM, objs.at(i)->id.c_str()); lua_settable (luaVM, tableIndex); } return 1; } if (isCurrentMethod("notUseAsSecondObjectForConstraint")) { if (lua_isnil(luaVM, 1)) { return 0; } lua_pushstring(luaVM, "cpointer"); lua_gettable(luaVM, -2); GOConstraint* o = (GOConstraint*)lua_tointeger(luaVM, -1); notUseAsSecondObjectForConstraint(o); lua_pop(luaVM, -1); return 0; } return LuaBridge::methodsBridge(luaVM); }
void PhysicObject::loadPhysProperties(FILE* f) { enablePhysics(readChar(f)); if (!isEnabledPhysics()) return; setMass(readFloat(f)); setAngularFactor(readVector(f)); setLinearFactor(readVector(f)); //writeVector(getLinearVelocity(), f); setTrigger(readChar(f)); setCollisionShapeType((CollisionShapeType)readChar(f)); setEnableDeactivation(readChar(f)); setFriction(readFloat(f)); setRestitution(readFloat(f)); setLinearDumping(readFloat(f)); setAngularDumping(readFloat(f)); // load custom collision shape if (getCollisionShapeType() == CST_CUSTOM) { switch ((GOCollisionShapeType)readChar(f)) { case GOCST_COMPOUND_SHAPE: setCollisionShape(new GOCompoundCollisionShape(f)); break; case GOCST_BOX: setCollisionShape(new GOBoxCollisionShape(f)); break; case GOCST_SPHERE: setCollisionShape(new GOSphereCollisionShape(f)); break; case GOCST_CYLINDER: setCollisionShape(new GOCylinderCollisionShape(f)); break; case GOCST_UNDEFINED: setCollisionShape(new GOUndefinedCollisionShape(f)); break; case GOCST_CAPSULE: setCollisionShape(new GOCapsuleCollisionShape(f)); break; case GOCST_CONE: setCollisionShape(new GOConeCollisionShape(f)); break; case GOCST_MESH: setCollisionShape(new GOMeshCollisionShape(f)); break; default: Log::error("PhysicObject::loadPhysProperties(FILE* f): Undefined custom shape type."); } } // load constraints int c_count = readChar(f); for (int i = 0; i < c_count; i++) { GOConstraint* cs; unsigned char type = readChar(f); switch (type) { case GO_P2P_CONSTRAINT: cs = new GOP2PConstraint(f); break; case GO_HINGE_CONSTRAINT: cs = new GOHingeConstraint(f); break; case GO_SLIDER_CONSTRAINT: cs = new GOSliderConstraint(f); break; default: Log::error("PhysicObject::loadPhysProperties(FILE* f): Undefined constraint type."); } addConstraint(cs); } }
/** Called when asyn clients call pasynInt32->write(). * This function performs actions for some parameters, including ADAcquire, ADBinX, etc. * For all parameters it sets the value in the parameter library and calls any registered callbacks.. * \param[in] pasynUser pasynUser structure that encodes the reason and address. * \param[in] value Value to write. */ asynStatus mythen::writeInt32(asynUser *pasynUser, epicsInt32 value) { int function = pasynUser->reason; int status = asynSuccess; static const char *functionName = "writeInt32"; /* Reject any call to the detector if it is running */ if ((function != ADAcquire) && acquiring_) { asynPrint(this->pasynUserSelf, ASYN_TRACE_ERROR, "%s:%s: detector is busy\n", driverName, functionName); return asynError; } /* Set the parameter and readback in the parameter library. * This may be overwritten when we read back the * status at the end, but that's OK */ status |= setIntegerParam(function, value); if (function == ADAcquire) { getIntegerParam(SDReadMode, &readmode_); status |= setAcquire(value); } else { if (function == SDSetting) { status |= loadSettings(value); } else if (function == SDUseFlatField) { status |= setFCorrection(value); } else if (function == SDUseCountRate) { status |= setRCorrection(value); } else if (function == SDUseBadChanIntrpl) { status |= setBadChanIntrpl(value); } else if (function == SDBitDepth) { status |= setBitDepth(value); } else if (function == SDNumGates) { status = setNumGates(value); } else if (function == SDUseGates) { status = setUseGates(value); } else if (function == SDNumFrames) { status |= setFrames(value); } else if (function == SDTrigger) { status |= setTrigger(value); } else if (function == SDReset) { status |= setReset(); } else if (function == ADImageMode) { //getIntegerParam(SDNumFrames, &frames_); status |= setFrames(frames_); } else { /* If this is not a parameter we have handled call the base class */ if (function < FIRST_SD_PARAM) status = ADDriver::writeInt32(pasynUser, value); } status |= getSettings(); } /* Update any changed parameters */ status |= callParamCallbacks(); if (status) asynPrint(pasynUser, ASYN_TRACE_ERROR, "%s:%s: error, status=%d function=%d, value=%d\n", driverName, functionName, status, function, value); else asynPrint(pasynUser, ASYN_TRACEIO_DRIVER, "%s:%s: function=%d, value=%d\n", driverName, functionName, function, value); return((asynStatus)status); }
MousePluginWidget::MousePluginWidget(const QString &pluginName, const QString &trigger, QGridLayout *layoutHack, QWidget *parent) : QObject(parent), m_configDlg(0), m_containment(0), m_lastConfigLocation(trigger), m_tempConfigParent(QString(), KConfig::SimpleConfig) { KPluginInfo::List plugins = Plasma::ContainmentActions::listContainmentActionsInfo(); if (plugins.isEmpty()) { //panic!! QLabel *fail = new QLabel(i18n("No plugins found, check your installation."), parent); layoutHack->addWidget(fail, 0, 0); return; } //make us some widgets m_pluginList = new QComboBox(parent); m_aboutButton = new QToolButton(parent); m_clearButton = new QToolButton(parent); m_triggerButton = new MouseInputButton(parent); m_configButton = new QToolButton(parent); //m_ui.description->setText(plugin.comment()); //plugin list //FIXME is there some way to share this across all the entries? foreach (const KPluginInfo& plugin, plugins) { if (plugin.property("NoDisplay").toBool()) { continue; } m_pluginList->addItem(KIcon(plugin.icon()), plugin.name(), QVariant::fromValue(plugin)); if (plugin.pluginName() == pluginName) { m_pluginList->setCurrentIndex(m_pluginList->count() - 1); m_plugin = plugin; } } if (! m_plugin.isValid()) { //probably an empty string; pick the first one m_pluginList->setCurrentIndex(0); m_plugin = plugins.first(); } //I can haz config? m_tempConfig = KConfigGroup(&m_tempConfigParent, "test"); if (!m_plugin.property("X-Plasma-HasConfigurationInterface").toBool()) { m_configButton->setVisible(false); } setTrigger(trigger); //pretty icons for the buttons m_aboutButton->setIcon(KIcon("dialog-information")); m_aboutButton->setToolTip(i18nc("About mouse action", "About")); m_triggerButton->setIcon(KIcon("input-mouse")); m_configButton->setIcon(KIcon("configure")); m_configButton->setToolTip(i18nc("Configure mouse action", "Configure")); m_clearButton->setIcon(KIcon("list-remove")); m_clearButton->setToolTip(i18nc("Remove mouse action", "Remove")); //HACK //FIXME what's the Right Way to do this? int row = layoutHack->rowCount(); layoutHack->addWidget(m_triggerButton, row, 0); layoutHack->addWidget(m_pluginList, row, 1); layoutHack->addWidget(m_configButton, row, 2); layoutHack->addWidget(m_aboutButton, row, 3); layoutHack->addWidget(m_clearButton, row, 4); //connect connect(m_pluginList, SIGNAL(currentIndexChanged(int)), this, SLOT(setPlugin(int))); connect(m_triggerButton, SIGNAL(triggerChanged(QString,QString)), this, SLOT(changeTrigger(QString,QString))); connect(m_configButton, SIGNAL(clicked()), this, SLOT(configure())); connect(m_clearButton, SIGNAL(clicked()), this, SLOT(clearTrigger())); connect(m_aboutButton, SIGNAL(clicked()), this, SLOT(showAbout())); }
void PSMoveQt::onTimeout() { int ax, ay, az, gx, gy, gz, mx, my, mz, buttons, battery; while (psmove_poll(_move)) { setTrigger(psmove_get_trigger(_move)); psmove_get_gyroscope(_move, &gx, &gy, &gz); if (gx != _gx || gy != _gy || gz != _gz) { _gx = gx; _gy = gy; _gz = gz; emit gyroChanged(); } psmove_get_accelerometer(_move, &ax, &ay, &az); if (ax != _ax || ay != _ay || az != _az) { _ax = ax; _ay = ay; _az = az; emit accelerometerChanged(); } psmove_get_magnetometer(_move, &mx, &my, &mz); if (mx != _mx || my != _my || mz != _mz) { _mx = mx; _my = my; _mz = mz; emit magnetometerChanged(); } buttons = psmove_get_buttons(_move); if (buttons != _buttons) { unsigned int pressed, released; psmove_get_button_events(_move, &pressed, &released); for (int i=1; i<=PSMoveQt::T; i <<= 1) { if (pressed & i) { emit buttonPressed(i); } else if (released & i) { emit buttonReleased(i); } } _buttons = buttons; } battery = psmove_get_battery(_move); if (battery != _battery) { bool charging = (battery == Batt_CHARGING || _battery == Batt_CHARGING); _battery = battery; if (charging) { emit chargingChanged(); } else if (_battery != Batt_CHARGING) { emit batteryChanged(_battery); } } } }
void IMuseDigital::playComiMusic(const char *songName, const imuseComiTable *table, int attribPos, bool sequence) { int hookId = 0; if ((songName != NULL) && (attribPos != 0)) { if (table->attribPos != 0) attribPos = table->attribPos; hookId = _attributes[COMI_STATE_OFFSET + attribPos]; if (table->hookId != 0) { if ((hookId != 0) && (table->hookId > 1)) { _attributes[COMI_STATE_OFFSET + attribPos] = 2; } else { _attributes[COMI_STATE_OFFSET + attribPos] = hookId + 1; if (table->hookId < hookId + 1) _attributes[COMI_STATE_OFFSET + attribPos] = 1; } } } if (!songName) { fadeOutMusic(120); return; } switch (table->transitionType) { case 0: break; case 8: setHookIdForMusic(table->hookId); break; case 9: _stopingSequence = 1; setHookIdForMusic(table->hookId); break; case 2: case 3: case 4: case 12: if (table->filename[0] == 0) { fadeOutMusic(60); return; } if (getCurMusicSoundId() == table->soundId) return; if (table->transitionType == 4) _stopingSequence = 1; if (table->transitionType == 2) { fadeOutMusic(table->fadeOutDelay); startMusic(table->filename, table->soundId, table->hookId, 127); return; } if ((!sequence) && (table->attribPos != 0) && (table->attribPos == _comiStateMusicTable[_curMusicState].attribPos)) { fadeOutMusicAndStartNew(table->fadeOutDelay, table->filename, table->soundId); } else if (table->transitionType == 12) { TriggerParams trigger; strcpy(trigger.marker, "exit"); trigger.fadeOutDelay = table->fadeOutDelay; strcpy(trigger.filename, table->filename); trigger.soundId = table->soundId; trigger.hookId = table->hookId; trigger.volume = 127; setTrigger(&trigger); } else { fadeOutMusic(table->fadeOutDelay); startMusic(table->filename, table->soundId, hookId, 127); } break; } }
static int GPIO_init(GPIO *self, PyObject *args, PyObject *kwds) { int fd = -1; int gpio = -1; PyObject * direction = NULL; PyObject * trigger = NULL; PyObject * tmp = NULL; static char *kwlist[] = { "gpio", "direction", "trigger", NULL }; if ( !PyArg_ParseTupleAndKeywords(args, kwds, "i|OO:__init__", kwlist, &gpio, &direction, &trigger ) ) return -1; if (gpio < 0) return -1; self->gpio = gpio; GPIO_VALUE( gpio, self->v_path ); if ( ( fd = open( self->v_path, O_RDWR, 0 ) ) == -1 ) { // try to get gpio exported: if ( exportGpio( gpio ) == 0 ) { // check if export was (really) successful if ( ( fd = open( self->v_path, O_RDWR ) ) == -1) { // export failed PyErr_SetFromErrno( PyExc_IOError ); return -1; } } else { PyErr_SetString( PyExc_StandardError, "Export failed." ); return -1; } } GPIO_EDGE(gpio, self->e_path); GPIO_DIREC(gpio, self->d_path); self->fd_val = fd; if ( ( self->fd_dir = open( self->d_path, O_RDWR ) ) == -1 ) { return -1; } if ( ( self->fd_edge = open( self->e_path, O_RDWR ) ) == -1 ) { return -1; } if (direction) { setDirection( self, direction ); tmp = self->direction; Py_INCREF(direction); self->direction = direction; Py_XDECREF(tmp); } else { // no direction requested, use current Py_XDECREF(self->direction); self->direction = getDirection( self ); Py_INCREF(self->direction); } if (trigger) { setTrigger( self, trigger ); tmp = self->trigger; Py_INCREF(trigger); self->trigger = trigger; Py_XDECREF(tmp); } else { // no trigger requested, use current Py_XDECREF(self->trigger); self->trigger = getTrigger( self ); Py_INCREF(self->trigger); } return 0; }