/* This function configure the initial state of the player
 * MPD keep its own internal state, so we have to reset it
 */
void Player::configureInitial()
{
    stop();
    setRepeat(false);
    setRandom(false);
    removeAllTracks();
}
SMActionVideoVLC::SMActionVideoVLC(QWidget *parent):
    SMAction(parent)
{
    poller = new QTimer(0);
    connect(poller, SIGNAL(timeout()), SLOT(slotTimeout()));

    //preparation of the vlc command
    const char * const vlc_args[] = {
              "--verbose=2", //be much more verbose then normal for debugging purpose
    };
    _vlcinstance=libvlc_new(sizeof(vlc_args) / sizeof(vlc_args[0]), vlc_args);

    // Create a media player playing environement
    _mp = libvlc_media_player_new (_vlcinstance);
    _m = NULL;

    setRepeat(0);
    setVolume(1.0);

    getContextMenu()->addSeparator();
    QAction* setRepeatAction = getContextMenu()->addAction("set repeat");
    connect(setRepeatAction, SIGNAL(triggered(bool)), SLOT(slotSetRepeat()));

    QAction* setVolumeAction = getContextMenu()->addAction("set volume");
    connect(setVolumeAction, SIGNAL(triggered(bool)), SLOT(slotSetVolume()));
}
Beispiel #3
0
HttpRequestHandler::HandleStatus StatusApi::handle(HttpRequest *request, HttpResponse *response)
{
    if (HttpRequest::Method_Get==request->method()) {
        if (request->path()=="/api/v1/status/socket") {
            response->write("{\"port\":"+QByteArray::number(serverPort())+"}");
            return Status_Handled;
        } else if (request->path()=="/api/v1/status") {
            response->write(statusMessage());
            return Status_Handled;
        } else if (request->path()=="/api/v1/status/current") {
            response->write(currentSongMessage());
            return Status_Handled;
        }
    } else if(HttpRequest::Method_Post==request->method() && request->path()=="/api/v1/status") {
        QString repeat=request->parameter("repeat");
        QString random=request->parameter("random");
        QString single=request->parameter("single");
        QString consume=request->parameter("consume");
        DBUG << repeat << random << single << consume;
        if (!repeat.isEmpty()) {
            emit setRepeat(isSet(repeat));
        }
        if (!random.isEmpty()) {
            emit setRandom(isSet(random));
        }
        if (!single.isEmpty()) {
            emit setSingle(isSet(single));
        }
        if (!consume.isEmpty()) {
            emit setConsume(isSet(consume));
        }
        return Status_Handled;
    }
    return Status_BadRequest;
}
Beispiel #4
0
void KCMiscKeyboardWidget::load()
{
    KConfigGroup config(KSharedConfig::openConfig(QStringLiteral("kcminputrc"), KConfig::NoGlobals), "Keyboard");

    ui.delay->blockSignals(true);
    ui.rate->blockSignals(true);

    // need to read as string to support old "true/false" parameter
    QString key = config.readEntry("KeyboardRepeating", TriStateHelper::getString(STATE_ON));
    if( key == QLatin1String("true") || key == TriStateHelper::getString(STATE_ON)) {
        keyboardRepeat = STATE_ON;
    }
    else if( key == QLatin1String("false") || key == TriStateHelper::getString(STATE_OFF)) {
        keyboardRepeat = STATE_OFF;
    }
    else {
        keyboardRepeat = STATE_UNCHANGED;
    }

//  keyboardRepeat = (key ? AutoRepeatModeOn : AutoRepeatModeOff);
    int delay = config.readEntry("RepeatDelay", DEFAULT_REPEAT_DELAY);
    double rate = config.readEntry("RepeatRate", DEFAULT_REPEAT_RATE);
    setRepeat(keyboardRepeat, delay, rate);

    //  setRepeat(kbd.global_auto_repeat, ui.delay->value(), ui.rate->value());

    numlockState = TriStateHelper::getTriState(config.readEntry( "NumLock", TriStateHelper::getInt(STATE_UNCHANGED) ));
    TriStateHelper::setTriState( _numlockButtonGroup, numlockState );

    ui.delay->blockSignals(false);
    ui.rate->blockSignals(false);
}
Beispiel #5
0
Timer::Timer(base::lambda<void()> callback) : QObject(nullptr)
, _callback(std::move(callback))
, _type(Qt::PreciseTimer)
, _adjusted(false) {
	setRepeat(Repeat::Interval);
	connect(TimersAdjuster(), &QObject::destroyed, this, [this] { adjust(); }, Qt::QueuedConnection);
}
void IOHIKeyboard::keyboardEvent(unsigned eventType,
	/* flags */              unsigned flags,
	/* keyCode */            unsigned keyCode,
	/* charCode */           unsigned charCode,
	/* charSet */            unsigned charSet,
	/* originalCharCode */   unsigned origCharCode,
	/* originalCharSet */    unsigned origCharSet)
// Description: We use this notification to set up our _keyRepeat timer
//		and to pass along the event to our owner. This method
//		will be called while the KeyMap object is processing
//		the key code we've sent it using deliverKey.
{
    KeyboardReserved *tempReservedStruct = GetKeyboardReservedStructEventForService(this); 
    
    if (tempReservedStruct && tempReservedStruct->dispatchEventCalled) 
    {
        IOLockUnlock(_deviceLock);
    }

    _keyboardEvent(	   this,
                           eventType,
    /* flags */            flags,
    /* keyCode */          keyCode,
    /* charCode */         charCode,
    /* charSet */          charSet,
    /* originalCharCode */ origCharCode,
    /* originalCharSet */  origCharSet,
    /* keyboardType */     _deviceType,
    /* repeat */           _isRepeat,
    /* atTime */           _lastEventTime);

    if (tempReservedStruct && tempReservedStruct->dispatchEventCalled) 
    {
        IOLockLock(_deviceLock);
    }


    if( keyCode == _keyMap->getParsedSpecialKey(NX_KEYTYPE_CAPS_LOCK) ||
        keyCode == _keyMap->getParsedSpecialKey(NX_KEYTYPE_NUM_LOCK) ||
        keyCode == _keyMap->getParsedSpecialKey(NX_POWER_KEY) ||
        keyCode == _keyMap->getParsedSpecialKey(NX_KEYTYPE_MUTE) ||
        keyCode == _keyMap->getParsedSpecialKey(NX_KEYTYPE_PLAY) ||
        keyCode == _keyMap->getParsedSpecialKey(NX_KEYTYPE_EJECT) ||
        keyCode == _keyMap->getParsedSpecialKey(NX_KEYTYPE_VIDMIRROR) ||
        keyCode == _keyMap->getParsedSpecialKey(NX_KEYTYPE_ILLUMINATION_TOGGLE))  
    {		
		//Don't repeat caps lock on ADB/USB.  0x39 is default ADB code.
		//    We are here because KeyCaps needs to see 0x39 as a real key,
		//    not just another modifier bit.

		if (_interfaceType == NX_EVS_DEVICE_INTERFACE_ADB)
		{
			return;
		}
    }

    // Set up key repeat operations here.
    setRepeat(eventType, keyCode);
}
void SMActionVideoNative::slotSetRepeat(void)
{
    bool ok;
    int r = QInputDialog::getInt(this, tr("Repeat Action"), tr("repeat count:"),
                                        repeat(), -1, 1000, 1, &ok);
    if (ok)
        setRepeat(r);
}
Beispiel #8
0
AdvButton::AdvButton(uint8_t pin,void (*OnKeyPress)(AdvButton*) , unsigned long repeat, unsigned long startDelay, buttonMode mode)
{
	init(pin,OnKeyPress,NULL,NULL,mode);
	
	setRepeat(repeat);
	setStartDelay(startDelay);
	

}
Animation* GameCritterObject::setActionAnimation(std::string action)
{
    Animation* animation = new Animation("art/critters/" + _generateArmorFrmString() + action + ".frm", orientation());
    animation->play();
    auto queue = new AnimationQueue();
    queue->setRepeat(true);
    queue->animations()->push_back(animation);
    queue->start();
    setUI(queue);
    return animation;
}
Beispiel #10
0
void Timer::start(TimeMs timeout, Qt::TimerType type, Repeat repeat) {
	cancel();

	_type = type;
	setRepeat(repeat);
	_adjusted = false;
	setTimeout(timeout);
	_timerId = startTimer(_timeout, _type);
	if (_timerId) {
		_next = getms(true) + _timeout;
	} else {
		_next = 0;
	}
}
Beispiel #11
0
void JoypadClass::begin()
{

  pinMode(6, INPUT);

  pinA      = 8;
  pinB      = 9;
  pinStart  = 10;
  pinSelect = 11;
  pinRight  = 12;
  pinDown   = 13;
  pinUp     = 14;
  pinLeft   = 15;
  
  mcp.begin();
  mcp.pinMode(0, INPUT);
  mcp.pullUp(0, HIGH);
  mcp.setupInterrupts(true,false,LOW);

  mcp.pinMode(pinUp, INPUT);
  mcp.pullUp(pinUp, HIGH);
  mcp.pinMode(pinDown, INPUT);
  mcp.pullUp(pinDown, HIGH);
  mcp.pinMode(pinLeft, INPUT);
  mcp.pullUp(pinLeft, HIGH);
  mcp.pinMode(pinRight, INPUT);
  mcp.pullUp(pinRight, HIGH);
  mcp.pinMode(pinSelect, INPUT);
  mcp.pullUp(pinSelect, HIGH);
  mcp.pinMode(pinStart, INPUT);
  mcp.pullUp(pinStart, HIGH);
  mcp.pinMode(pinA, INPUT);
  mcp.pullUp(pinA, HIGH);
  mcp.pinMode(pinB, INPUT);
  mcp.pullUp(pinB, HIGH);

  bufferPosition = readPosition = 0;
  callback();
  bufferPosition--;

  attachInterrupt(6,inputCallback,FALLING);

  delay(10); //Delay to ensure internal pull-ups are activated
  setRepeat(300,30);
}
void IOHIKeyboard::keyboardSpecialEvent(unsigned eventType,
	/* flags */                     unsigned flags,
	/* keyCode */                   unsigned keyCode,
	/* specialty */                 unsigned flavor)
// Description: See the description for keyboardEvent.
{
    KeyboardReserved *tempReservedStruct = GetKeyboardReservedStructEventForService(this); 

    if (tempReservedStruct && tempReservedStruct->dispatchEventCalled) 
    {
        IOLockUnlock(_deviceLock);
    }

    _keyboardSpecialEvent(this,
                        eventType,
        /* flags */	flags,
        /* keyCode */	keyCode,
        /* specialty */	flavor,
        /* guid */ 	_guid,
        /* repeat */	_isRepeat,
        /* atTime */	_lastEventTime);
                    
    if (tempReservedStruct && tempReservedStruct->dispatchEventCalled) 
    {
        IOLockLock(_deviceLock);
    }

    // Set up key repeat operations here.
    // Don't repeat capslock, numlock, power key, mute key, play key, 
    // eject key, vidmirror key, illumination toggle key.
    if( keyCode == _keyMap->getParsedSpecialKey(NX_KEYTYPE_CAPS_LOCK) ||
        keyCode == _keyMap->getParsedSpecialKey(NX_KEYTYPE_NUM_LOCK) ||
        keyCode == _keyMap->getParsedSpecialKey(NX_POWER_KEY) ||
        keyCode == _keyMap->getParsedSpecialKey(NX_KEYTYPE_MUTE) ||
        keyCode == _keyMap->getParsedSpecialKey(NX_KEYTYPE_PLAY) ||
        keyCode == _keyMap->getParsedSpecialKey(NX_KEYTYPE_EJECT) ||
        keyCode == _keyMap->getParsedSpecialKey(NX_KEYTYPE_VIDMIRROR) ||
        keyCode == _keyMap->getParsedSpecialKey(NX_KEYTYPE_ILLUMINATION_TOGGLE))  
    {
        return;
    }

    // Set up key repeat operations here.
    setRepeat(eventType, keyCode);
}
Beispiel #13
0
void AdvButton::init(uint8_t pin,void (*OnKeyPress)(AdvButton*) , void (*OnKeyDown)(AdvButton*),void (*OnKeyUp)(AdvButton*), buttonMode mode){
	setPin(pin);
	setRepeat(300);
	setStartDelay(500);
	setOnKeyPress( (*OnKeyPress));
	setOnKeyDown( (*OnKeyDown));
	setOnKeyUp( (*OnKeyUp));

	debounceTime = 100;
	ButtonManager::instance()->addButton(this);
	if (mode == btn_Digital){
		pinMode(pin, INPUT_PULLUP);
		digitalWrite(pin,HIGH);
	}
	this->mode = mode;
	lastChange = millis();
	lastState = HIGH;
}
Beispiel #14
0
void KeyboardConfig::load()
{
  KConfig config("kcminputrc");

  XKeyboardState kbd;

  XGetKeyboardControl(kapp->getDisplay(), &kbd);

  config.setGroup("Keyboard");
  bool key = config.readBoolEntry("KeyboardRepeating", true);
  keyboardRepeat = (key ? AutoRepeatModeOn : AutoRepeatModeOff);
  ui->delay->setValue(config.readNumEntry( "RepeatDelay", 660 ));
  ui->rate->setValue(config.readDoubleNumEntry( "RepeatRate", 25 ));
  clickVolume = config.readNumEntry("ClickVolume", kbd.key_click_percent);
  numlockState = config.readNumEntry( "NumLock", 2 );

  setClick(kbd.key_click_percent);
  setRepeat(kbd.global_auto_repeat, ui->delay->value(), ui->rate->value());
  setNumLockState( numlockState );
}
void SMActionVideoNative::readSettingsFromNode(QDomNode node)
{
    SMAction::readSettingsFromNode(node);
    node = node.firstChild();
    while(!node.isNull())
    {
        if(!node.isElement())
        {
            node = node.nextSibling();
            continue;
        }
        QDomElement element = node.toElement();
        QString name = element.tagName();
        if (name.toLower() == "repeat")
            setRepeat(element.text().toInt());
        if (name.toLower() == "volume")
            setVolume(element.text().toDouble());

        node = node.nextSibling();
    }
}
SMActionVideoNative::SMActionVideoNative(QWidget *parent):
    SMAction(parent)
{
    mediaDuration = 0;
    _repeated     = 0;

    mediaPlayer = new QMediaPlayer(0, QMediaPlayer::VideoSurface);
    videoItem = new QGraphicsVideoItem;
    mediaPlayer->setVideoOutput(videoItem);
    mediaPlayer->setNotifyInterval(250); //interval 250 ms

    setRepeat(0);
    setVolume(1.0);

    getContextMenu()->addSeparator();
    QAction* setRepeatAction = getContextMenu()->addAction("set repeat");
    connect(setRepeatAction, SIGNAL(triggered(bool)), SLOT(slotSetRepeat()));

    QAction* setVolumeAction = getContextMenu()->addAction("set volume");
    connect(setVolumeAction, SIGNAL(triggered(bool)), SLOT(slotSetVolume()));
}
Beispiel #17
0
bool TextureSprite::init(std::string &texFileName, CCPointVector  &vertices)
{
    /// Load the texture from file
    if (texFileName.length() == 0) {
        CCLOGERROR("Invalid texture filename (empty string)");
        return false;
    }

    CCTexture2D *texture = CCTextureCache::sharedTextureCache()->addImage(texFileName.c_str());
    if (!texture) {
        CCLOGERROR("ERROR: Can't load texture: '%s'", texFileName.c_str());
        return false;
    }
    setTexture(texture);
    /// Enable texture repeat. Horizontal and vertical repeat enabled by default.
    setRepeat(true, true);

    /// Create the shader program
    CCGLProgram *shader = CCShaderCache::sharedShaderCache()->programForKey(settings::kShader_PositionTexture_uColor_uTime);
    mColorLocation = glGetUniformLocation(shader->getProgram(), "u_color");
    mTimeLocation = glGetUniformLocation(shader->getProgram(), "u_time");

    setShaderProgram(shader);

    addPolygon(vertices);

    /* Seems that there's no need to call the init method again when the app is back to foreground (like CCDrawNode.cpp).
     * Only reload shaders is mandatory (see proj.android/jni/hellolua/main.cpp).
     */
    /*
#if CC_ENABLE_CACHE_TEXTURE_DATA > 0
     CCNotificationCenter::sharedNotificationCenter()->addObserver(this,
                                callfuncO_selector(TextureSprite::listenBackToForeground),
                                EVENT_COME_TO_FOREGROUND,
                                NULL);
#endif
     */

    return true;
}
Beispiel #18
0
    void AbstractParam::readParameters(const YAML::Node &yamlNode)
    {
        for ( YAML::const_iterator it = yamlNode.begin(); it != yamlNode.end(); ++it )
        {
            std::string key = READ_NODE_AS_STRING(it->first);

            if (key == Keys::Description)
                setDescription(READ_NODE_AS_STRING(it->second));
            else if (key == Keys::Default)
                setDefaultValue(READ_NODE_AS_STRING(it->second));
            else if (key == Keys::DisplayName)
                setDisplayName(READ_NODE_AS_STRING(it->second));

            else if (key == Keys::Example)
                setExample(READ_NODE_AS_STRING(it->second));
            else if (key == Keys::Maximum)
                setMaximum(READ_NODE_AS_LONG(it->second));
            else if (key == Keys::Minimum)
                setMinimum(READ_NODE_AS_LONG(it->second));
            else if (key == Keys::MaxLength)
                setMaxLength(READ_NODE_AS_INT(it->second));
            else if (key == Keys::MinLength)
                setMinLength(READ_NODE_AS_INT(it->second));

            else if (key == Keys::Pattern)
                setPattern(READ_NODE_AS_STRING(it->second));
            else if (key == Keys::Repeat)
                setRepeat(READ_NODE_AS_BOOL(it->second));
            else if (key == Keys::Required)
                setRequired(READ_NODE_AS_BOOL(it->second));
            else if (key == Keys::Type)
                setType(READ_NODE_AS_STRING(it->second));
            else if (key == Keys::Enum)
            {
                YAML::Node enumNode = it->second;
                for ( YAML::const_iterator tt = enumNode.begin(); tt != enumNode.end(); ++tt )
                    setEnumeration(READ_NODE_AS_STRING(*tt));
            }
        }
    }
Beispiel #19
0
void Player::setupUi()
{
    //	QTextStream out(stderr,QIODevice::WriteOnly);


    QToolBar *bar = new QToolBar;
    bar->setStyleSheet("QToolBar { border: 0px }");
    bar->addAction(previousAction);
    bar->addAction(playAction);

    bar->addAction(pauseAction);
    bar->addAction(stopAction);
    bar->addAction(nextAction);
    bar->setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum);

    m_seekSlider = new QSlider(this);

    m_pictureLabel = new QLabel();
    m_pictureLabel->setMaximumHeight(150);
    m_pictureLabel->setMaximumWidth(150);
    m_pictureLabel->setScaledContents(true);
    QHBoxLayout* m_horizonLayout = new QHBoxLayout();


    m_horizonLayout->addWidget(m_pictureLabel);


    m_seekSlider->setOrientation(Qt::Horizontal);
    connect(this,SIGNAL(positionTime(int)),m_seekSlider,SLOT(setValue(int)));
    connect(m_mediaPlayer,SIGNAL(positionChanged(qint64)),this,SLOT(tick(qint64)));
    connect(m_seekSlider,SIGNAL(sliderMoved(int)),this,SLOT(setTime(int)));
    connect(m_mediaPlayer,SIGNAL(durationChanged(qint64)),this,SLOT(setDuration(qint64)));



    QToolBar *bar2 = new QToolBar;
    bar2->addWidget(randomly);
    bar2->setStyleSheet("QToolBar { border: 0px }");
    m_volumeSlider = new QSlider(this);
    m_volumeSlider->setOrientation(Qt::Horizontal);
    m_volumeSlider->setRange(0,100);
    connect(m_volumeSlider,SIGNAL(valueChanged(int)),m_mediaPlayer,SLOT(setVolume(int)));
    m_volumeSlider->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);

    QPalette palette;
    palette.setBrush(QPalette::Light, Qt::darkGray);

    m_timeLcd = new QLCDNumber;
    m_timeLcd->setPalette(palette);
    m_timeLcd->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
    
    title = new QLineEdit;
    title->setReadOnly(true);
#ifdef REPEAT
    m_repeatCheck = new QCheckBox(tr("Repeat:"),this);
    connect(m_repeatCheck,SIGNAL(clicked()),this,SLOT(setRepeat()));
    m_repeatCheck->setChecked(m_repeatState);
#endif
    QHBoxLayout *seekerLayout = new QHBoxLayout;
    seekerLayout->setMargin(0);
    //seekerLayout->setPadding(0);
    seekerLayout->addWidget(m_seekSlider);
    seekerLayout->addWidget(m_timeLcd);

    QHBoxLayout *playbackLayout = new QHBoxLayout;
    playbackLayout->setMargin(0);
    // playbackLayout->setPadding(0);
    playbackLayout->addWidget(bar);
    playbackLayout->addWidget(title);
    playbackLayout->addWidget(bar2);
#ifdef REPEAT
    playbackLayout->addWidget(m_repeatCheck);
#endif
    playbackLayout->addStretch();
    playbackLayout->addWidget(m_volumeSlider);

    QVBoxLayout *mainLayout = new QVBoxLayout;
    mainLayout->setMargin(0);
    //  mainLayout->setPadding(0);
    mainLayout->addLayout(seekerLayout);
    mainLayout->addLayout(playbackLayout);


    m_horizonLayout->addLayout(mainLayout);
    setLayout(m_horizonLayout);


    
}
Beispiel #20
0
void PlistsGroup::toggleRepeat()
{
    setRepeat(repeatMode() > 1 ? 1 : 2);
}
Beispiel #21
0
void KeyboardConfig::defaults()
{
    setClick(50);
    setRepeat(true, 660, 25);
    setNumLockState( 2 );
}
Beispiel #22
0
void KCMiscKeyboardWidget::defaults()
{
    setRepeat(STATE_ON, DEFAULT_REPEAT_DELAY, DEFAULT_REPEAT_RATE);
    TriStateHelper::setTriState( _numlockButtonGroup, STATE_UNCHANGED );
    emit changed(true);
}
Beispiel #23
0
//---------------------------------------------------------------------------------
// Program entry point
//---------------------------------------------------------------------------------
int main(void) {
//---------------------------------------------------------------------------------


	// the vblank interrupt must be enabled for VBlankIntrWait() to work
	// since the default dispatcher handles the bios flags no vblank handler
	// is required
	irqInit();
	irqEnable(IRQ_VBLANK);

	// set mode 0, 1D mapping
	REG_DISPCNT = MODE_0 | OBJ_1D_MAP;

    init_oam(obj_buffer, 128);

	// copy sprites to appropriate memory spots
	u16 *palette_end = SPRITE_PALETTE;
	u16 *tiles_end =SPRITE_GFX;
	// blue slime
	memcpy(palette_end, blueslimePal, blueslimePalLen);
	memcpy(tiles_end, blueslimeTiles, blueslimeTilesLen);
	palette_end += blueslimePalLen/2;
	tiles_end += blueslimeTilesLen/2;
	// drakee
	memcpy(palette_end, drakeePal, drakeePalLen);
	memcpy(tiles_end, drakeeTiles, drakeeTilesLen);
	palette_end += drakeePalLen/2;
	tiles_end += drakeeTilesLen/2;
	// orange slime
	memcpy(palette_end, orangeslimePal, orangeslimePalLen);
	memcpy(tiles_end, orangeslimeTiles, orangeslimeTilesLen);
	palette_end += orangeslimePalLen/2;
	tiles_end += orangeslimeTilesLen/2;

	// enable sprites
	REG_DISPCNT |= OBJ_ON | OBJ_WIN_ENABLE;

	u16 x = 0;
	u16 y = 0;
	s8 sprite = 1;
	u16 status = ATTR0_NORMAL;


	obj_buffer[0].attr0 = (y & 0x00ff) | ATTR0_NORMAL | ATTR0_COLOR_16 | ATTR0_SQUARE;
	obj_buffer[0].attr1 = (x & 0x01ff) | ATTR1_SIZE_32;
    obj_buffer[0].attr2 = OBJ_CHAR(0);
	
	oam_copy(OAM, obj_buffer, 1);

	setRepeat(1,1);

	while (1)
	{
		// check keypad
		scanKeys();
		u16 keystate = keysDownRepeat();
		u16 keydown = keysDown();
		// directional pad
		// move sprite
		if (keystate & KEY_LEFT)
			x -= 1;
		else if (keystate & KEY_RIGHT)
			x += 1;
		if (keystate & KEY_UP)
			y -= 1;
		else if (keystate & KEY_DOWN)
			y += 1;
		// A
		// enable/disable sprite
		if (keydown & KEY_A)
		{
			if (status == ATTR0_NORMAL)
				status = ATTR0_DISABLED;
			else
				status = ATTR0_NORMAL;
		}
		// L + R
		// rotate sprites
        if (keydown & KEY_R)
		{
			sprite++;
			if (sprite > 2) sprite = 0;
		}
        else if (keydown & KEY_L)
		{
            sprite--;
			if (sprite < 0) sprite = 2;
		}
			
		// set current sprite attributes
        obj_buffer[0].attr0 = (y & 0x00ff) | status | ATTR0_COLOR_16 | ATTR0_SQUARE;
        obj_buffer[0].attr1 = (x & 0x01ff) | ATTR1_SIZE_32;
        obj_buffer[0].attr2 = OBJ_CHAR(sprite*16) | OBJ_PALETTE(sprite);

        oam_copy(OAM, obj_buffer, 1);

		VBlankIntrWait();
	}

	return 0;
}
Beispiel #24
0
/***************************************************
 キー初期化
 ***************************************************/
void
init_key ()
{
  setRepeat ( DEF_KEY_DELAY, DEF_KEY_REPEAT);
}
Beispiel #25
0
 void Mouse::_setType(Cursor state)
 {
     if (this->state() == state) return;
     _ui.reset(nullptr);
     switch (state)
     {
         case Cursor::BIG_ARROW:
             _ui = std::make_unique<UI::Image>("art/intrface/stdarrow.frm");
             break;
         case Cursor::SCROLL_W:
             _ui = std::make_unique<UI::Image>("art/intrface/scrwest.frm");
             _ui->setOffset(0, -_ui->size().height() / 2);
             break;
         case Cursor::SCROLL_W_X:
             _ui = std::make_unique<UI::Image>("art/intrface/scrwx.frm");
             _ui->setOffset(0, -_ui->size().height() / 2);
             break;
         case Cursor::SCROLL_N:
             _ui = std::make_unique<UI::Image>("art/intrface/scrnorth.frm");
             _ui->setOffset( -_ui->size().width() / 2, 0);
             break;
         case Cursor::SCROLL_N_X:
             _ui = std::make_unique<UI::Image>("art/intrface/scrnx.frm");
             _ui->setOffset( -_ui->size().width() / 2, 0);
             break;
         case Cursor::SCROLL_S:
             _ui = std::make_unique<UI::Image>("art/intrface/scrsouth.frm");
             _ui->setOffset( -_ui->size().width() / 2, -_ui->size().height());
             break;
         case Cursor::SCROLL_S_X:
             _ui = std::make_unique<UI::Image>("art/intrface/scrsx.frm");
             _ui->setOffset(-_ui->size().width() / 2, -_ui->size().height());
             break;
         case Cursor::SCROLL_E:
             _ui = std::make_unique<UI::Image>("art/intrface/screast.frm");
             _ui->setOffset( -_ui->size().width(), -_ui->size().height() / 2);
             break;
         case Cursor::SCROLL_E_X:
             _ui = std::make_unique<UI::Image>("art/intrface/screx.frm");
             _ui->setOffset(-_ui->size().width(), -_ui->size().height() / 2);
             break;
         case Cursor::SCROLL_NW:
             _ui = std::make_unique<UI::Image>("art/intrface/scrnwest.frm");
             break;
         case Cursor::SCROLL_NW_X:
             _ui = std::make_unique<UI::Image>("art/intrface/scrnwx.frm");
             break;
         case Cursor::SCROLL_SW:
             _ui = std::make_unique<UI::Image>("art/intrface/scrswest.frm");
             _ui->setOffset(0, -_ui->size().height());
             break;
         case Cursor::SCROLL_SW_X:
             _ui = std::make_unique<UI::Image>("art/intrface/scrswx.frm");
             _ui->setOffset(0, -_ui->size().height());
             break;
         case Cursor::SCROLL_NE:
             _ui = std::make_unique<UI::Image>("art/intrface/scrneast.frm");
             _ui->setOffset(-_ui->size().width(), 0);
             break;
         case Cursor::SCROLL_NE_X:
             _ui = std::make_unique<UI::Image>("art/intrface/scrnex.frm");
             _ui->setOffset(-_ui->size().width(), 0);
             break;
         case Cursor::SCROLL_SE:
             _ui = std::make_unique<UI::Image>("art/intrface/scrseast.frm");
             _ui->setOffset(-_ui->size().width(), -_ui->size().height());
             break;
         case Cursor::SCROLL_SE_X:
             _ui = std::make_unique<UI::Image>("art/intrface/scrsex.frm");
             _ui->setOffset(-_ui->size().width(), -_ui->size().height());
             break;
         case Cursor::HEXAGON_RED:
             _ui = std::make_unique<UI::Image>("art/intrface/msef000.frm");
             _ui->setOffset(- _ui->size().width() / 2, - _ui->size().height() / 2);
             break;
         case Cursor::ACTION:
             _ui = std::make_unique<UI::Image>("art/intrface/actarrow.frm");
             break;
         case Cursor::HAND:
             _ui = std::make_unique<UI::Image>("art/intrface/hand.frm");
             break;
         case Cursor::SMALL_DOWN_ARROW:
             _ui = std::make_unique<UI::Image>("art/intrface/sdnarrow.frm");
             _ui->setOffset(-5, -10);
             break;
         case Cursor::SMALL_UP_ARROW:
             _ui = std::make_unique<UI::Image>("art/intrface/suparrow.frm");
             _ui->setOffset(-5, 0);
             break;
         case Cursor::WAIT:
         {
             auto queue = std::make_unique<UI::AnimationQueue>();
             queue->animations().push_back(std::make_unique<UI::Animation>("art/intrface/wait.frm"));
             queue->setRepeat(true);
             queue->start();
             _ui = std::move(queue);
             _ui->setOffset(Point() - _ui->size() / 2);
             break;
         }
         case Cursor::USE:
         {
             _ui = std::make_unique<UI::Image>("art/intrface/crossuse.frm");
             _ui->setOffset(-10, -10);
             break;
         }
         case Cursor::NONE:
             break;
         default:
             break;
     }
 }
Beispiel #26
0
void PlayerControls::settingsUpdated()
{
    setLastfmState(Settings::instance()->getValue("lastfm/scrobbling").toBool());
    setShuffle(Settings::instance()->getValue("player/shuffle").toInt());
    setRepeat(Settings::instance()->getValue("player/repeat").toInt());
}
Beispiel #27
0
void PlayerControls::setRepeat()
{
    setRepeat(0);
}
Beispiel #28
0
void PlayerControls::setupButtons(QMenu *appMenu)
{
    QHBoxLayout *layout = new QHBoxLayout();

    QHBoxLayout *leftLayout = new QHBoxLayout();
    leftLayout->setAlignment(Qt::AlignLeft);

    QHBoxLayout *centerLayout = new QHBoxLayout();
    centerLayout->setAlignment(Qt::AlignCenter);

    QHBoxLayout *rightLayout = new QHBoxLayout();
    rightLayout->setAlignment(Qt::AlignRight);

    // Menu button
    m_wbAppMenu = new StyledButton(QIcon(QPixmap(":icons/menu")), tr("Menu"));
    m_wbAppMenu->setFixedHeight(28);
    m_wbAppMenu->setIconSize(QSize(16, 16));
    m_wbAppMenu->setMenu(appMenu);

    // Prev
    m_wbPrev = new StyledButton(QIcon(QPixmap(":icons/prev")), "Prev");
    m_wbPrev->setFixedHeight(28);
    m_wbPrev->setIconSize(QSize(16, 16));
    connect(m_wbPrev, SIGNAL(clicked()), SIGNAL(prev()));

    // Play
    m_wbPlay = new StyledButton(QIcon(QPixmap(":icons/play")), "Play");
    m_wbPlay->setFixedHeight(28);
    m_wbPlay->setIconSize(QSize(16, 16));
    m_wbPlay->setCheckable(true);
    connect(m_wbPlay, SIGNAL(clicked()), SIGNAL(play()));

    // Next
    m_wbNext = new StyledButton(QIcon(QPixmap(":icons/next")), "Next");
    m_wbNext->setFixedHeight(28);
    m_wbNext->setIconSize(QSize(16, 16));
    m_wbNext->setLayoutDirection(Qt::RightToLeft);
    connect(m_wbNext, SIGNAL(clicked()), SIGNAL(next()));

    // Shuffle
    m_wbShuffle = new StyledButton(QIcon(QPixmap(":icons/circle_empty")), "Shuffle");
    m_wbShuffle->setCheckable(true);
    m_wbShuffle->setFixedHeight(28);
    m_wbShuffle->setIconSize(QSize(16, 16));
    setShuffle(Settings::instance()->getValue("player/shuffle").toInt());
    connect(m_wbShuffle, SIGNAL(clicked()), SLOT(setShuffle()));

    // Repeat
    m_wbRepeat = new StyledButton(QIcon(QPixmap(":icons/circle_empty")), "Repeat");
    m_wbRepeat->setCheckable(true);
    m_wbRepeat->setFixedHeight(28);
    m_wbRepeat->setIconSize(QSize(16, 16));
    setRepeat(Settings::instance()->getValue("player/repeat").toInt());
    connect(m_wbRepeat, SIGNAL(clicked()), SLOT(setRepeat()));

    // Status
    m_wbStatus = new StyledButton(QIcon(QPixmap(":icons/vk")), "");
    m_wbStatus->setCheckable(true);
    m_wbStatus->setFixedSize(28,28);
    m_wbStatus->setIconSize(QSize(20, 20));
    m_wbStatus->setTransparent(true);
    connect(m_wbStatus, SIGNAL(clicked(bool)), SLOT(setStatusState(bool)));
    setStatusState(Settings::instance()->getValue("player/status").toBool());

    m_wbLastfm = new StyledButton(QIcon(QPixmap(":icons/lf")), "");
    m_wbLastfm->setCheckable(true);
    m_wbLastfm->setFixedSize(28,28);
    m_wbLastfm->setIconSize(QSize(20, 20));
    m_wbLastfm->setTransparent(true);
    connect(m_wbLastfm, SIGNAL(clicked(bool)), SLOT(setLastfmState(bool)));
    setLastfmState(Settings::instance()->getValue("lastfm/scrobbling").toBool());

    layout->addLayout(leftLayout);
    layout->addLayout(centerLayout);
    layout->addLayout(rightLayout);

    leftLayout->addWidget(m_wbAppMenu);

    centerLayout->addWidget(m_wbShuffle);
    centerLayout->addSpacing(20);
    centerLayout->addWidget(m_wbPrev);
    centerLayout->addWidget(m_wbPlay);
    centerLayout->addWidget(m_wbNext);
    centerLayout->addSpacing(20);
    centerLayout->addWidget(m_wbRepeat);

    rightLayout->addWidget(m_wbStatus);
    rightLayout->addWidget(m_wbLastfm);

    m_mainLayout->addLayout(layout, 2, 1);
    m_mainLayout->setAlignment(layout, Qt::AlignTop);

    bool isAcc = Settings::instance()->getValue("general/account_use").toBool();

    if(!isAcc) {
        m_wbStatus->setDisabled(true);
    }
}
Beispiel #29
0
void QSpotifySession::init()
{
    memset(&m_sp_callbacks, 0, sizeof(m_sp_callbacks));
    m_sp_callbacks.logged_in = callback_logged_in;
    m_sp_callbacks.logged_out = callback_logged_out;
    m_sp_callbacks.metadata_updated = callback_metadata_updated;
    m_sp_callbacks.connection_error = callback_connection_error;
    m_sp_callbacks.notify_main_thread = callback_notify_main_thread;
    m_sp_callbacks.music_delivery = callback_music_delivery;
    m_sp_callbacks.play_token_lost = callback_play_token_lost;
    m_sp_callbacks.log_message = callback_log_message;
    m_sp_callbacks.end_of_track = callback_end_of_track;
    m_sp_callbacks.userinfo_updated = callback_userinfo_updated;
    m_sp_callbacks.offline_error = callback_offline_error;
    m_sp_callbacks.connectionstate_updated = callback_connectionstate_updated;
    m_sp_callbacks.scrobble_error = callback_scrobble_error;

    QString dpString = settings.value("dataPath").toString();
    dataPath = (char *) calloc(strlen(dpString.toLatin1()) + 1, sizeof(char));
    strcpy(dataPath, dpString.toLatin1());

    memset(&m_sp_config, 0, sizeof(m_sp_config));
    m_sp_config.api_version = SPOTIFY_API_VERSION;
    m_sp_config.cache_location = dataPath;
    m_sp_config.settings_location = dataPath;
    m_sp_config.application_key = g_appkey;
    m_sp_config.application_key_size = g_appkey_size;
    m_sp_config.user_agent = "CuteSpot";
    m_sp_config.callbacks = &m_sp_callbacks;
    sp_error error = sp_session_create(&m_sp_config, &m_sp_session);

    if (error != SP_ERROR_OK)
    {
        fprintf(stderr, "failed to create session: %s\n",
                sp_error_message(error));

        m_sp_session = nullptr;
        return;
    }
    Q_ASSERT(m_sp_session);

    sp_session_set_cache_size(m_sp_session, 0);

    // Remove stored login information from older version of MeeSpot
    if (settings.contains("username")) {
        settings.remove("username");
        settings.remove("password");
    }
    // Remove old volume information
    if (settings.contains("volume")) {
        settings.remove("volume");
    }

    m_offlineMode = settings.value("offlineMode", false).toBool();

    checkNetworkAccess();

    StreamingQuality quality = StreamingQuality(settings.value("streamingQuality", int(LowQuality)).toInt());
    setStreamingQuality(quality);

    StreamingQuality syncQuality = StreamingQuality(settings.value("syncQuality", int(HighQuality)).toInt());
    setSyncQuality(syncQuality);

    bool syncMobile = settings.value("syncOverMobile", false).toBool();
    setSyncOverMobile(syncMobile);

    QString storedLogin = getStoredLoginInformation();
    if (!storedLogin.isEmpty()) {
        login(storedLogin);
    }

    bool shuffle = settings.value("shuffle", false).toBool();
    setShuffle(shuffle);

    bool repeat = settings.value("repeat", false).toBool();
    setRepeat(repeat);

    bool repeatOne = settings.value("repeatOne", false).toBool();
    setRepeatOne(repeatOne);

    bool volumeNormalizeSet = settings.value("volumeNormalize", true).toBool();
    setVolumeNormalize(volumeNormalizeSet);

    m_lfmLoggedIn = false;

    // Flush cache regularly as we might get killed by life cycle manager / OOM killer
    QTimer *timer = new QTimer(this);
    connect(timer, SIGNAL(timeout()), this, SLOT(flush()));
    timer->start(60000);

    connect(this, SIGNAL(offlineModeChanged()), m_playQueue, SLOT(onOfflineModeChanged()));

    new MPRISMediaPlayer(this);
    new MPRISMediaPlayerPlayer(this);

    QDBusConnection::sessionBus().registerObject(QString("/org/mpris/MediaPlayer2"), this, QDBusConnection::ExportAdaptors);
    QDBusConnection::sessionBus().registerService("org.mpris.MediaPlayer2.CuteSpot");
}
Beispiel #30
0
void Mouse::_setType(unsigned int state)
{
    if (this->state() == state) return;
    delete _ui; _ui = 0;
    switch(state)
    {
        case BIG_ARROW:
            _ui = new Image("art/intrface/stdarrow.frm");
            break;
        case SCROLL_W:
            _ui = new Image("art/intrface/scrwest.frm");
            _ui->setYOffset( -_ui->height()*0.5);
            break;
        case SCROLL_W_X:
            _ui = new Image("art/intrface/scrwx.frm");
            _ui->setYOffset( -_ui->height()*0.5);
            break;
        case SCROLL_N:
            _ui = new Image("art/intrface/scrnorth.frm");
            _ui->setXOffset( -_ui->width()*0.5);
            break;
        case SCROLL_N_X:
            _ui = new Image("art/intrface/scrnx.frm");
            _ui->setXOffset( -_ui->width()*0.5);
            break;
        case SCROLL_S:
            _ui = new Image("art/intrface/scrsouth.frm");
            _ui->setXOffset( -_ui->width()*0.5);
            _ui->setYOffset( -_ui->height());
            break;
        case SCROLL_S_X:
            _ui = new Image("art/intrface/scrsx.frm");
            _ui->setXOffset(-_ui->width()*0.5);
            _ui->setYOffset(-_ui->height());
            break;
        case SCROLL_E:
            _ui = new Image("art/intrface/screast.frm");
            _ui->setXOffset( -_ui->width());
            _ui->setYOffset( -_ui->height()*0.5);
            break;
        case SCROLL_E_X:
            _ui = new Image("art/intrface/screx.frm");
            _ui->setXOffset(-_ui->width());
            _ui->setYOffset(-_ui->height()*0.5);
            break;
        case SCROLL_NW:
            _ui = new Image("art/intrface/scrnwest.frm");
            break;
        case SCROLL_NW_X:
            _ui = new Image("art/intrface/scrnwx.frm");
            break;
        case SCROLL_SW:
            _ui = new Image("art/intrface/scrswest.frm");
            _ui->setYOffset(-_ui->height());
            break;
        case SCROLL_SW_X:
            _ui = new Image("art/intrface/scrswx.frm");
            _ui->setYOffset(-_ui->height());
            break;
        case SCROLL_NE:
            _ui = new Image("art/intrface/scrneast.frm");
            _ui->setXOffset(-_ui->width());
            break;
        case SCROLL_NE_X:
            _ui = new Image("art/intrface/scrnex.frm");
            _ui->setXOffset(-_ui->width());
            break;
        case SCROLL_SE:
            _ui = new Image("art/intrface/scrseast.frm");
            _ui->setXOffset(-_ui->width());
            _ui->setYOffset(-_ui->height());
            break;
        case SCROLL_SE_X:
            _ui = new Image("art/intrface/scrsex.frm");
            _ui->setXOffset(-_ui->width());
            _ui->setYOffset(-_ui->height());
            break;
        case HEXAGON_RED:
            _ui = new Image("art/intrface/msef000.frm");
            _ui->setXOffset(- _ui->width()/2);
            _ui->setYOffset(- _ui->height()/2);
            break;
        case ACTION:
            _ui = new Image("art/intrface/actarrow.frm");
            break;
        case HAND:
            _ui = new Image("art/intrface/hand.frm");
            break;
        case WAIT:
        {
            auto queue = new AnimationQueue();
            queue->animations()->push_back(new Animation("art/intrface/wait.frm"));
            queue->setRepeat(true);
            queue->start();
            _ui = queue;
            _ui->setXOffset(-_ui->width()*0.5);
            _ui->setYOffset(-_ui->height()*0.5);
            break;
        }
        case NONE:
            break;
    }
}