Exemple #1
0
GKey GKey::fromString(const std::string& _s) {
    std::string s = trimWhitespace(toLower(_s));    

    for (int i = 0; i < LAST; ++i) {
        std::string t = GKey(i).toString();
        if ((t.size() == s.size()) &&
            (toLower(t) == s)) {
            return GKey(i);
        }
    }

    return UNKNOWN;
}
// call this routine to quit the application
void g19daemon::quit()
{
	// you can do some cleanup here
    // then do emit finished to signal CoreApplication to quit

	disconnect(device, SIGNAL(GKey()), this, SLOT(GKeys()));
	disconnect(device, SIGNAL(LKey()), this, SLOT(LKeys()));

	emit finished();
}
g19daemon::g19daemon(QWidget *parent):
    QMainWindow(parent),
	ui(new Ui::g19daemon)
{
	QImage micon;
	QColor BackLight;
    
	ui->setupUi(this);

	qRegisterMetaType<gAction>("gAction");
	
	device = new G19Device;
	device->initializeDevice();
	device->openDevice();

	settings =  new QSettings("Dynamite", "G19Daemon");
	
	activePlugin = -1;
	isActive = true;
	
	connect(device, SIGNAL(GKey()), SLOT(GKeys()));
	connect(device, SIGNAL(LKey()), SLOT(LKeys()));

	micon = QImage(":/menu_icon.png");
	menuScreen = new gScreen(micon, tr("Logitech G19s Linux"));
	menuSelect = 0;
	
	loadPlugins();
	
	if (activePlugin != -1)
		menuActive = false;
	else
		menuActive = true;
	
	BackLight.setRed(settings->value("KeyBacklight_Red", "255").toInt());
	BackLight.setGreen(settings->value("KeyBacklight_Green", "255").toInt());
	BackLight.setBlue(settings->value("KeyBacklight_Blue", "255").toInt());
	
	device->setKeysBacklight(BackLight);
	device->setDisplayBrightness(settings->value("Backlight", "255").toInt());
	device->setMKeys(true, false, false, false);

	trayIconMenu = new QMenu(this);
	trayIconMenu->addAction(tr("Show"), this, SLOT(Show()));
	trayIconMenu->addAction(tr("Reset LCD Backlight"), this, SLOT(ResetLcdBacklight()));
	trayIconMenu->addAction(QIcon(":/off.png"), "&Quit", this, SLOT(quit()));
	

	trayIcon = new QSystemTrayIcon(this);
	trayIcon->setContextMenu(trayIconMenu);
    trayIcon->setToolTip("Logitech G19 Daemon");
	trayIcon->setIcon(QIcon(":/tray_icon.png"));
	trayIcon->show();
}
Exemple #4
0
bool App::onEvent(const GEvent& event) {
    // Handle super-class events
    if ((event.type == GEventType::KEY_DOWN) && (event.key.keysym.sym == GKey::F5)) { loadGrid(); }  

    if ((event.type == GEventType::KEY_DOWN) && (event.key.keysym.sym == GKey::SPACE)) { 
        m_automata.setPaused(!m_automata.paused());
    }
    if ((event.type == GEventType::KEY_DOWN) && (event.key.keysym.sym == GKey::LEFT)) {
        m_automata.m_bpm = max(m_automata.m_bpm-1, 1);
    }
    if ((event.type == GEventType::KEY_DOWN) && (event.key.keysym.sym == GKey::RIGHT)) {
        m_automata.m_bpm = min(m_automata.m_bpm+1, 10000);
    }
    if ((event.type == GEventType::KEY_DOWN) && (event.key.keysym.sym == GKey('h'))) {
        m_showHelp = !m_showHelp;
    }
    if ((event.type == GEventType::KEY_DOWN) && (event.key.keysym.sym == GKey('t'))) {
        m_automata.m_displayMode = CellularAutomata::DisplayMode(1 - m_automata.m_displayMode);
    }

    if ((event.type == GEventType::KEY_DOWN) && (event.key.keysym.sym == GKey('r'))) {
        m_rainbowMode = !m_rainbowMode;
    }
    if (GApp::onEvent(event)) { return true; }


    // If you need to track individual UI events, manage them here.
    // Return true if you want to prevent other parts of the system
    // from observing this specific event.
    //
    // For example,
    // if ((event.type == GEventType::GUI_ACTION) && (event.gui.control == m_button)) { ... return true; }
    

    return false;
}
Exemple #5
0
void App::onUserInput(UserInput* ui) {
    GApp::onUserInput(ui);
    if (ui->keyDown(GKey::SPACE)) {
        m_appMode = AppMode::MAKING_SCULPTURE;
    } else {
        m_appMode = AppMode::DEFAULT;
    }

    if (ui->keyDown(GKey::LCTRL) || ui->keyDown(GKey::RCTRL)) {
        if (ui->keyPressed(GKey('s'))) {
            saveSoundscape();
        }
        if (ui->keyPressed(GKey('l'))) {
            loadSoundscape();
        }
    }

	if (ui->keyPressed(GKey::RETURN)) {


        Point3 origin = Point3(0.0, 0.0, 0.0);
        Vector3 direction = activeCamera()->frame().rightVector();
        Ray playRay(origin, -direction);
        float minValue = finf();
        for (auto& sculpture : m_sonicSculpturePieces) {
            minValue = min(minValue, sculpture->minValueAlongRay(playRay));
        }
        
        playRay.set(origin + direction*minValue, direction);
		playSculpture(playRay);
	}

    if (ui->keyPressed(GKey('f'))) {
        m_freezeEverything = !m_freezeEverything;
        for (shared_ptr<SonicSculpturePiece>& piece : m_sonicSculpturePieces) {
            piece->setFrozen(m_freezeEverything);
        }
    }

    if (ui->keyDown(GKey(','))) {
        cameraAdjustment -= 0.01f;
    }

    if (ui->keyDown(GKey('.'))) {
        cameraAdjustment += 0.01f;
    }

    // Hack for playing pieces
    for (int i = 0; i < 8; ++i) {
        if (m_sonicSculpturePieces.size() > i) {
            if (ui->keyPressed(GKey('1' + char(i)))) {
                generatePlayPulse(m_sonicSculpturePieces[i]);
                m_lastInterestingEventTime = System::time();
            }
        }
    }


    // Add key handling here based on the keys currently held or
    // ones that changed in the last frame.
}