void ServerDriver::openvr_axisEvent(uint32_t unWhichDevice, uint32_t unWhichAxis, const vr::VRControllerAxis_t & axisState) {
	auto devicePtr = this->m_openvrIdToVirtualDeviceMap[unWhichDevice];
	if (devicePtr && devicePtr->deviceType() == VirtualDeviceType::TrackedController) {
		devicePtr->axisEvent(unWhichAxis, axisState);
	} else {
		if (_openvrIdToDeviceManipulationHandleMap[unWhichDevice] && _openvrIdToDeviceManipulationHandleMap[unWhichDevice]->isValid()) {
			_openvrIdToDeviceManipulationHandleMap[unWhichDevice]->ll_sendAxisEvent(unWhichAxis, axisState);
		}
	}
}
void ServerDriver::openvr_buttonEvent(uint32_t unWhichDevice, ButtonEventType eventType, vr::EVRButtonId eButtonId, double eventTimeOffset) {
	auto devicePtr = this->m_openvrIdToVirtualDeviceMap[unWhichDevice];
	if (devicePtr && devicePtr->deviceType() == VirtualDeviceType::TrackedController) {
		devicePtr->buttonEvent(eventType, eButtonId, eventTimeOffset);
	} else {
		if (_openvrIdToDeviceManipulationHandleMap[unWhichDevice] && _openvrIdToDeviceManipulationHandleMap[unWhichDevice]->isValid()) {
			_openvrIdToDeviceManipulationHandleMap[unWhichDevice]->ll_sendButtonEvent(eventType, eButtonId, eventTimeOffset);
		}
	}
}
bool IOHIDevice::updateProperties( void )
{
    bool ok;

    ok = setProperty( kIOHIDKindKey, hidKind(), 32 )
    &    setProperty( kIOHIDInterfaceIDKey, interfaceID(), 32 )
    &    setProperty( kIOHIDDeviceEventIDKey, IOHIDevice::GenerateKey(this), 32 )
    &    setProperty( kIOHIDSubinterfaceIDKey, deviceType(), 32 );

    return( ok );
}
// Initializes I2C and verifies communication with the BQ27441.
bool BQ27441::begin(void)
{
	uint16_t deviceID = 0;
	
	Wire.begin(); // Initialize I2C master
	
	deviceID = deviceType(); // Read deviceType from BQ27441
	
	if (deviceID == BQ27441_DEVICE_ID)
	{
		return true; // If device ID is valid, return true
	}
	
	return false; // Otherwise return false
}
bool IOHIKeyboard::resetKeyboard()
// Description:	Reset the keymapping to the default value and reconfigure
//		the keyboards.
{
    const unsigned char *defaultKeymap;
    UInt32	defaultKeymapLength;

    IOLockLock( _deviceLock);

    if ( _keyMap )
		_keyMap->release();

    // Set up default keymapping.
    defaultKeymap = defaultKeymapOfLength(&defaultKeymapLength);

    _keyMap = IOHIKeyboardMapper::keyboardMapper( this,
                                                  defaultKeymap,
                                                  defaultKeymapLength,
                                                  false );

    if (_keyMap)
    {
		// point the new keymap to the IOHIDSystem, so it can set properties in it
		_keyMap->setKeyboardTarget((IOService *) _keyboardEventTarget);

        clock_interval_to_absolutetime_interval( EV_DEFAULTKEYREPEAT,
                                                 kNanosecondScale, &_keyRepeat);
        clock_interval_to_absolutetime_interval( EV_DEFAULTINITIALREPEAT,
                                                 kNanosecondScale, &_initialKeyRepeat);
    }

    updateProperties();
    
    _interfaceType = interfaceID();
    _deviceType    = deviceType();
    _guid	   = getGUID();

    if (getProperty("HIDKeyboardKeysDefined"))
    {
        KeyboardReserved * reservedStruct = GetKeyboardReservedStructEventForService(this);
        
        if ( reservedStruct && !reservedStruct->keyboardNub)
            reservedStruct->keyboardNub = IOHIDKeyboardDevice::newKeyboardDeviceAndStart(this);
    }

    IOLockUnlock( _deviceLock);
    return (_keyMap) ? true : false;
}
Exemple #6
0
void MidiDevice::saveSettings() const
{
    QSettings settings;
    QString devType = deviceTypeToString(deviceType());

    QString key = QString(SETTINGS_MIDICHANNEL).arg(devType, name());
    settings.setValue(key, midiChannel());

    key = QString(SETTINGS_MODE).arg(devType, name());
    settings.setValue(key, MidiDevice::modeToString(mode()));

    key = QString(SETTINGS_INITMESSAGE).arg(devType, name());
    settings.setValue(key, midiTemplateName());

    qDebug() << "[MIDI] Saving mididevice with template name: " << midiTemplateName();
}
Exemple #7
0
QString MidiDevice::deviceTypeString() const
{
  switch(deviceType())
  {
    case ALSA_MIDI:
        return "ALSA";
    case JACK_MIDI:
        return "JACK";
    case SYNTH_MIDI:
    {
      const SynthI* s = dynamic_cast<const SynthI*>(this);
      if(s && s->synth())
        return MusECore::synthType2String(s->synth()->synthType());
      else
        return "SYNTH";
    }
  }
  return "UNKNOWN";
}
Exemple #8
0
void MidiDevice::loadSettings()
{
    QSettings settings;
    QString devType = deviceTypeToString(deviceType());

    QString key = QString(SETTINGS_MIDICHANNEL).arg(devType, name());
    QVariant value = settings.value(key);
    if (value.isValid() == false)
    {   // no value, try loading old-style setting
        key = QString(SETTINGS_MIDICHANNEL_OLD).arg(uid().toString());
        value = settings.value(key);
    }
    if (value.isValid() == true)
        setMidiChannel(value.toInt());
    else
        setMidiChannel(0);

    key = QString(SETTINGS_MODE).arg(devType, name());
    value = settings.value(key);
    if (value.isValid() == false)
    {   // no value, try loading old-style setting
        key = QString(SETTINGS_MODE_OLD).arg(uid().toString());
        value = settings.value(key);
    }
    if (value.isValid() == true)
        setMode(stringToMode(value.toString()));
    else
        setMode(ControlChange);

    key = QString(SETTINGS_INITMESSAGE).arg(devType, name());
    value = settings.value(key);
    if (value.isValid() == false)
    {   // no value, try loading old-style setting
        key = QString(SETTINGS_INITMESSAGE_OLD).arg(uid().toString());
        value = settings.value(key);
    }
    if (value.isValid() == true)
        setMidiTemplateName(value.toString());
    else
        setMidiTemplateName("");
}