Beispiel #1
0
  void System::onRawArrival( HANDLE handle )
  {
    UINT pathLength = 0;

    if ( GetRawInputDeviceInfoW( handle, RIDI_DEVICENAME, NULL, &pathLength ) )
      NIL_EXCEPT_WINAPI( "GetRawInputDeviceInfoW failed" );

    wideString rawPath( pathLength, '\0' );

    GetRawInputDeviceInfoW( handle, RIDI_DEVICENAME, &rawPath[0], &pathLength );
    rawPath.resize( rawPath.length() - 1 );

    for ( auto device : mDevices )
    {
      if ( device->getHandler() != Device::Handler_RawInput )
        continue;

      auto rawDevice = static_cast<RawInputDevice*>( device );

      if ( !_wcsicmp( rawDevice->getRawPath().c_str(), rawPath.c_str() ) )
      {
        deviceConnect( rawDevice );
        return;
      }
    }

    auto device = new RawInputDevice( this, getNextID(), handle, rawPath );

    if ( isInitializing() )
      device->setStatus( Device::Status_Connected );
    else
      deviceConnect( device );

    mDevices.push_back( device );
  }
Beispiel #2
0
WaterTowerWidget::WaterTowerWidget(int id, QWidget *parent) :
    QGroupBox(parent),
    ui(new Ui::WaterTowerWidget),
    uuid(NotifyPanel::instance()->uuid())
{
    ui->setupUi(this);

    setTitle(readableName(id));
    waterTower = WaterTower::instance(id);
    connect(waterTower, SIGNAL(waterLevelChanged(int)), this, SLOT(waterLevelChanged(int)));
    connect(waterTower, SIGNAL(deviceConnected()), this, SLOT(deviceConnect()));
    connect(waterTower, SIGNAL(deviceDisconnected()), this, SLOT(deviceDisconnect()));
    connect(waterTower, SIGNAL(highWaterLevelAlarm()), this, SLOT(highWaterLevelAlarm()));

    waterTower->getWaterLevel();
    ui->avatarWidget->setAvatar(QPixmap(QString(qApp->applicationDirPath() + "/images/watertower-%1.png").arg(id)));
    ui->progressBar->setRange(0, waterTower->getHeight());
    ui->progressBar->setFormat("%v");
    deviceDisconnect();
    connect(waterTower, SIGNAL(waterLevelRangeChanged(int,int)), ui->progressBar, SLOT(setRange(int,int)));

    enableWidget = new QCheckBox();
    enableWidget->setChecked(waterTower->isEnabled());

    enableAlarmWidget = new QCheckBox();
    enableAlarmWidget->setChecked(waterTower->isAlarmEnabled());

    addressWidget = new QSpinBox();
    addressWidget->setRange(0, 15);
    addressWidget->setValue(waterTower->getAddress());
    connect(addressWidget, SIGNAL(valueChanged(int)), this, SLOT(addressChanged(int)));

    radiusWidget = new QSpinBox();
    radiusWidget->setRange(20, 300);
    radiusWidget->setValue(waterTower->getRadius());
    connect(radiusWidget, SIGNAL(valueChanged(int)), this, SLOT(radiusChanged(int)));

    levelSensorHeightWidget = new QSpinBox();
    levelSensorHeightWidget->setRange(20, 100);
    levelSensorHeightWidget->setValue(waterTower->getLevelSensorHeight());
    connect(levelSensorHeightWidget, SIGNAL(valueChanged(int)), this, SLOT(levelSensorHeightChanged(int)));

    levelSensorNumberWidget = new QSpinBox();
    levelSensorNumberWidget->setRange(1, 8);
    levelSensorNumberWidget->setValue(waterTower->getSensorNumber());
    connect(levelSensorNumberWidget, SIGNAL(valueChanged(int)), this, SLOT(levelSensorNumberChanged(int)));

    getSampleIntervalWidget();
    connect(sampleIntervalWidget, SIGNAL(valueChanged(int)), this, SLOT(sampleIntervalChanged(int)));
    connect(enableWidget, SIGNAL(clicked(bool)), this, SLOT(readyForUse(bool)));
    connect(enableAlarmWidget, SIGNAL(clicked(bool)), this, SLOT(enableAlarm(bool)));
}
Beispiel #3
0
  BOOL CALLBACK System::diDeviceEnumCallback( LPCDIDEVICEINSTANCEW instance,
  LPVOID referer )
  {
    auto system = reinterpret_cast<System*>( referer );

    for ( auto identifier : system->mXInputDeviceIDs )
      if ( instance->guidProduct.Data1 == identifier )
        return DIENUM_CONTINUE;

    for ( auto device : system->mDevices )
    {
      if ( device->getHandler() != Device::Handler_DirectInput )
        continue;

      auto diDevice = static_cast<DirectInputDevice*>( device );

      if ( diDevice->getInstanceID() == instance->guidInstance )
      {
        if ( device->getSavedStatus() == Device::Status_Disconnected )
          system->deviceConnect( device );
        else
          device->setStatus( Device::Status_Connected );

        return DIENUM_CONTINUE;
      }
    }

    Device* device = new DirectInputDevice( system, system->getNextID(), instance );

    if ( system->isInitializing() )
      device->setStatus( Device::Status_Connected );
    else
      system->deviceConnect( device );

    system->mDevices.push_back( device );

    return DIENUM_CONTINUE;
  }
Beispiel #4
0
bool cSystem_Commodore_64::prepare() {

	if(!mBasic->loadFile( systemDataPath( "BASIC.ROM" ) ))
		return false;

	if(!mKernal->loadFile( systemDataPath( "KERNAL.ROM" ) ))
		return false;

	if(!mChar->loadFile( systemDataPath( "CHAR.ROM") ))
		return false;

	deviceConnect( mBasic,		0xA000, 0x2000 );
	deviceConnect( mChar,		0xD000, 0x1000 );
	deviceConnect( mKernal,		0xE000, 0x2000 );

	deviceConnect( mCpu,		0x0000, 0x0002 );
	deviceConnect( mRam,		0x0000, 0x10000 );
	deviceConnect( mRamColor,	0xD800, 0x400 );

	deviceConnect( mVideo,		0xD000, 0x0400 );
	deviceConnect( mCia1,		0xDC00, 0x100 );
	deviceConnect( mCia2,		0xDD00, 0x100 );

	mCpu->reset();
	//mCpu->threadStart();

	mVideo->reset();
	//mVideo->threadStart();

	mCia1->reset();
	mCia2->reset();

	mDisk->prepare();
	mDisk->reset();
	// Force debug mode if compiled as debug build
#ifdef _DEBUG
	mCpu->mDebugSet(false, eDebug_End );
	mDisk->mDebugSet(false, eDebug_Message );
#endif

    this->mAnalyseSet(true);
	return true;
}
Beispiel #5
0
  void System::refreshDevices()
  {
    identifyXInputDevices();

    for ( Device* device : mDevices )
      if ( device->getHandler() == Device::Handler_DirectInput )
      {
        device->saveStatus();
        device->setStatus( Device::Status_Pending );
      }

    auto hr = mDirectInput->EnumDevices( DI8DEVCLASS_GAMECTRL,
      diDeviceEnumCallback, this, DIEDFL_ATTACHEDONLY );
    if ( FAILED( hr ) )
      NIL_EXCEPT_DINPUT( hr, "Could not enumerate DirectInput devices!" );

    for ( Device* device : mDevices )
      if ( device->getHandler() == Device::Handler_DirectInput
        && device->getSavedStatus() == Device::Status_Connected
        && device->getStatus() == Device::Status_Pending )
        deviceDisconnect( device );

    XINPUT_STATE state;
    for ( Device* device : mDevices )
    {
      if ( device->getHandler() == Device::Handler_XInput )
      {
        auto xDevice = static_cast<XInputDevice*>( device );
        auto status = mXInput->mFunctions.pfnXInputGetState( xDevice->getXInputID(), &state );
        if ( status == ERROR_DEVICE_NOT_CONNECTED )
        {
          if ( xDevice->getStatus() == Device::Status_Connected )
            deviceDisconnect( xDevice );
          else if ( xDevice->getStatus() == Device::Status_Pending )
            xDevice->setStatus( Device::Status_Disconnected );
        }
        else if ( status == ERROR_SUCCESS )
        {
          if ( xDevice->getStatus() == Device::Status_Disconnected )
            deviceConnect( xDevice );
          else if ( xDevice->getStatus() == Device::Status_Pending )
            xDevice->setStatus( Device::Status_Connected );
        }
        else
          NIL_EXCEPT( "XInputGetState failed" );
      }
    }
  }
Beispiel #6
0
void MainWidget::createTrayIcon()
{    
    trayIcon = createTrayObject(this);
    trayIcon->init();

#ifndef Q_OS_WIN32
    trayIcon->setIcon("qcma_off");
#else
    trayIcon->setIcon("tray/qcma_off_16");
#endif
    trayIcon->show();

    connect(trayIcon, SIGNAL(openConfig()), this, SLOT(openConfig()));
    connect(trayIcon, SIGNAL(openManager()), this, SLOT(openManager()));
    connect(trayIcon, SIGNAL(refreshDatabase()), this, SLOT(refreshDatabase()));
    connect(trayIcon, SIGNAL(showAboutDialog()), this, SLOT(showAboutDialog()));
    connect(trayIcon, SIGNAL(showAboutQt()), this, SLOT(showAboutQt()));
    connect(trayIcon, SIGNAL(stopServer()), this, SLOT(stopServer()));

    connect(managerForm, SIGNAL(deviceConnected(QString)), this, SLOT(deviceConnect(QString)));
    connect(managerForm, SIGNAL(deviceDisconnected()), this, SLOT(deviceDisconnect()));
    connect(managerForm, SIGNAL(messageSent(QString)), this, SLOT(receiveMessage(QString)));
}
Beispiel #7
0
int main(int argc, char *argv[]) {
	
	printf(" exVasi0n, tihmstar will pwn you :O\n");
    
    
	printf(" waiting for device\n");
	while (deviceConnect() != 0) {
		sleep(1);
	}
	printf(" device found!\n");
	
	// start lockdownd client.
	if (startLockdownd() != 0) {
		return -1;
	}
	
	// start AFC service on lockdownd.
	if (startAFC() != 0) {
		return -1;
	}
	
	// create an AFC client and connect to AFC service.
	if (connectAFC() != 0) {
		return -1;
	}
	
	afcerr = afc_make_directory(gAfc, "/evasi0n-install");
	if (afcerr != AFC_E_SUCCESS) {
		printf("%s Error creating dir %s\n\n", KRED, KNRM);
		afc_client_free(gAfc);
		idevice_free(gDevice);
		return -1;
	}
	
	afcerr = afc_send_file(gAfc, "mylittlesecret.tar", "evasi0n-install/Cydia.tar");
	if (afcerr != AFC_E_SUCCESS) {
		printf("%s Error putting file.%s\n\n", KRED, KNRM);
		return -1;
	}
	
	//reboot

	// start lockdownd client.
	printf(" lockdownd...\n");
	lderr = lockdownd_client_new_with_handshake(gDevice, &gLockdown, "exVasi0n");
	if (lderr != LOCKDOWN_E_SUCCESS) {
		printf("%s [*] Unable to connect to lockdownd. Please reboot your device and try again.%s\n", KRED, KNRM);
		return -1;
	}
	
	printf(" gonna reboot\n");
	lderr = lockdownd_start_service(gLockdown, "com.apple.mobile.diagnostics_relay", &port);
	if (lderr != LOCKDOWN_E_SUCCESS) {
		printf("%s diag service error%s\n", KRED, KNRM);
		return -1;
	}
	
	diagerr = diagnostics_relay_client_new(gDevice, port, &gDiag);
	if (diagerr != DIAGNOSTICS_RELAY_E_SUCCESS) {
		printf("%s diag client error %s %d\n", KRED, KNRM,diagerr);
		lockdownd_client_free(gLockdown);
		idevice_free(gDevice);
		return -1;
	}
	
	diagerr = diagnostics_relay_restart(gDiag, DIAGNOSTICS_RELAY_ACTION_FLAG_DISPLAY_PASS);
	if (diagerr != DIAGNOSTICS_RELAY_E_SUCCESS && diagerr != -2) {
        printf("%s reboot error, reboot manually %d %s\n", KNRM,diagerr, KNRM);
		lockdownd_client_free(gLockdown);
		idevice_free(gDevice);
		return -1;
	}
    
	
	printf(" done :P \n");
    // thanks a lot to DarkMalloc allowing me to use parts of his breakout JB code <3
	return 0;
	
	
}