示例#1
0
/* 
 * Get a pointer to the base of physical video memory. This can be used for DMA transfer.
 * In DOS, the physical and the logical address most likely are the same.
 * Return: A pointer to base of physical video memory.
 *         NULL pointer if fail.
 */
void *getPhysicalMemoryBase(
    unsigned short vendorId, /* PCI vendor ID */
    unsigned short deviceId, /* PCI device ID */
    unsigned short deviceNum /* If more than one device in system, device number are ordered as 0, 1, 2,... */
)
{
    uint32_t physicalAddr;

    if (enableDevice(vendorId, deviceId, deviceNum) == -1)
        return (void *)0;
    
#ifdef USE_A0000
    /*
     * Access frame buffer through the 0xA0000 address.
     */
    physicalAddr = 0xA0000;
    
    /* Set to Write Mode 0 */
    pokeIO(GRAPHICS_REGISTER, 0x05, 0x00);
        
    /* Enable address 0xA0000 to 0xAFFFF */
#ifdef BANK_SIZE_128K
    pokeIO(GRAPHICS_REGISTER, 0x06, 0x00);
    setBankSize(128*1024);
#else
    pokeIO(GRAPHICS_REGISTER, 0x06, 0x04);
    setBankSize(64*1024);
#endif
    
    /* Enable writing to corresponding plane. Set it ot 0x0f or 0x04. BIOS set this IO
       port to 0x04 during font loading */
    pokeIO(SEQUENCER_REGISTER, 0x04, 0x04);

#else
    /*
     * Access frame buffer through the PCI linear address.  
     */
     
    /* Get frame buffer physical address */
    physicalAddr = readPCIDword(vendorId, deviceId, deviceNum, 0x10);

    /*
     * In a memory bar (Frame buffer), bit 3 to bit 0 are used as the base
     * address information, therefore, we should mask this out and set them
     * to zero.
     */
    physicalAddr &= ~0x0000000F;
#endif

    DDKDEBUGPRINT((INIT_LEVEL, "Memory Physical Addr: %08x\n", physicalAddr));
    if (physicalAddr == (-1))
       return (void *)0;

    return ((void *)physicalAddr);
}
示例#2
0
void DlgPrefController::slotApply() {
    if (m_bDirty) {
        // Apply the presets and load the resulting preset.
        if (m_pInputTableModel != NULL) {
            m_pInputTableModel->apply();
        }

        if (m_pOutputTableModel != NULL) {
            m_pOutputTableModel->apply();
        }

        // Load script info from the script table.
        m_pPreset->scripts.clear();
        for (int i = 0; i < m_ui.m_pScriptsTableWidget->rowCount(); ++i) {
            QString scriptFile = m_ui.m_pScriptsTableWidget->item(i, 0)->text();

            // Skip empty rows.
            if (scriptFile.isEmpty()) {
                continue;
            }

            QString scriptPrefix = m_ui.m_pScriptsTableWidget->item(i, 1)->text();

            bool builtin = m_ui.m_pScriptsTableWidget->item(i, 2)
                    ->checkState() == Qt::Checked;

            ControllerPreset::ScriptFileInfo info;
            info.name = scriptFile;
            info.functionPrefix = scriptPrefix;
            info.builtin = builtin;
            m_pPreset->scripts.append(info);
        }

        // Load the resulting preset (which has been mutated by the input/output
        // table models). The controller clones the preset so we aren't touching
        // the same preset.
        emit(loadPreset(m_pController, m_pPreset));

        //Select the "..." item again in the combobox.
        m_ui.comboBoxPreset->setCurrentIndex(0);

        bool wantEnabled = m_ui.chkEnabledDevice->isChecked();
        bool enabled = m_pController->isOpen();
        if (wantEnabled && !enabled) {
            enableDevice();
        } else if (!wantEnabled && enabled) {
            disableDevice();
        }

        m_bDirty = false;
    }
}
示例#3
0
文件: driver.cpp 项目: BayronP/clam
void
Driver::init()
{ 
    try {
        enableDevice();
        //TODO Need to check here that we have been successful.
    }
    catch ( const gbxserialacfr::SerialException &e )
    {
        stringstream ss;
        ss << "Driver: Caught SerialException: " << e.what();
        tracer_.error( ss.str() );
        throw gbxutilacfr::Exception( ERROR_INFO, ss.str() );
    }
}
void ccGamepadManager::setupMenu()
{
	if (!m_menu)
	{
		m_menu = new QMenu("Gamepad");
		m_menu->setIcon(QIcon(":/CC/images/gamepad.png"));
	}
	
	if (!m_actionEnable)
	{
		m_actionEnable = new QAction(tr("Enable"), this);
		m_actionEnable->setCheckable(true);

		connect(m_actionEnable, &QAction::toggled, [this](bool state) {
			enableDevice(state, false);
		});

		m_menu->addAction(m_actionEnable);
	}
}
示例#5
0
/*
 * Get a pointer to the base of Memory Mapped IO space.
 *
 * Return: A pointer to base of MMIO.
 *         NULL pointer if fail.
 */
void *getMmioBase( 
    unsigned short vendorId, /* PCI vendor ID */
    unsigned short deviceId, /* PCI device ID */
    unsigned short deviceNum /* If more than one device in system, device number are ordered as 0, 1, 2,... */
)
{
    uint32_t physicalAddr;

    if (enableDevice(vendorId, deviceId, deviceNum) == -1)
        return (void *)0;

    /* Get MMIO physical address */
    physicalAddr = readPCIDword(vendorId, deviceId, deviceNum, 0x14);
        
    DDKDEBUGPRINT((INIT_LEVEL, "Mmio Physical Addr: %08x\n", physicalAddr));
    if (physicalAddr == (-1))
       return (void *)0;
    
    /* Map it into the address space. */
    return (mapPhysicalAddress((void*)physicalAddr, SM750_PCI_ALLOC_MMIO_SIZE));
}
void ccGamepadManager::setupGamepadInput()
{
	if (m_gamepadInput)
	{
		assert(false);
		return;
	}

	m_gamepadInput = new GamepadInput(this);

	connect(m_gamepadInput, &GamepadInput::updated, this, &ccGamepadManager::onGamepadInput, Qt::DirectConnection);

	connect(m_gamepadInput, &GamepadInput::buttonL1Changed, this, [=]() {
		m_appInterface->decreasePointSize();
	});
	connect(m_gamepadInput, &GamepadInput::buttonR1Changed, this, [=]() {
		m_appInterface->increasePointSize();
	});

	connect(m_gamepadInput, &GamepadInput::buttonStartChanged, this, [=](bool state) {
		if (state)
		{
			m_appInterface->setGlobalZoom();
		}
	});
	connect(m_gamepadInput, &GamepadInput::buttonAChanged, this, [=](bool state)
	{
		if (state)
		{
			m_appInterface->toggleActiveWindowViewerBasedPerspective();
		}
	});
	connect(m_gamepadInput, &GamepadInput::buttonBChanged, this, [=](bool state)
	{
		if (state)
		{
			m_appInterface->toggleActiveWindowCenteredPerspective();
		}
	});

	QGamepadManager* manager = QGamepadManager::instance();
	if (manager)
	{
		connect(manager, &QGamepadManager::gamepadConnected, this, [&](int deviceId)
		{
			ccLog::Print(QString("gamepad device %1 has been connected").arg(deviceId));
			//auto-enable the device (if none is enabled yet)
			if (m_actionEnable && !m_actionEnable->isChecked())
			{
				enableDevice(true, true, deviceId);
			}
		});

		connect(manager, &QGamepadManager::gamepadDisconnected, this, [&](int deviceId)
		{
			ccLog::Print(QString("gamepad device %1 has been disconnected").arg(deviceId));
			//auto-disable the device (if this device is the one currently enabled)
			if (m_actionEnable && m_actionEnable->isChecked() && m_gamepadInput && m_gamepadInput->deviceId() == deviceId)
			{
				enableDevice(false, true, deviceId);
			}
		});
	}
	else
	{
		assert(false);
		showMessage("[Gamepad] Manager is not accessible?!", true);
	}
}