コード例 #1
0
TEST_F(MidiControllerTest, ReceiveMessage_PushButtonCO_ToggleOnOff_ButtonMidiOption) {
    // Using the button MIDI option allows you to use a MIDI toggle button as a
    // push button.
    ConfigKey key("[Channel1]", "hotcue_1_activate");
    ControlPushButton cpb(key);

    unsigned char channel = 0x01;
    unsigned char control = 0x10;

    MidiOptions options;
    options.button = true;

    addMapping(MidiInputMapping(MidiKey(MIDI_NOTE_ON | channel, control),
                                options, key));
    addMapping(MidiInputMapping(MidiKey(MIDI_NOTE_OFF | channel, control),
                                options, key));
    loadPreset(m_preset);

    // NOTE(rryan): This behavior is broken!

    // Toggle the switch on, sets the push button on.
    receive(MIDI_NOTE_ON | channel, control, 0x7F);
    EXPECT_LT(0.0, cpb.get());

    // The push button is stuck down here!

    // Toggle the switch off, sets the push button off.
    receive(MIDI_NOTE_OFF | channel, control, 0x00);
    EXPECT_DOUBLE_EQ(0.0, cpb.get());
}
コード例 #2
0
TEST_F(MidiControllerTest, ReceiveMessage_ToggleCO_PushOnOff) {
    // Most MIDI controller send push-buttons as (NOTE_ON, 0x7F) for press and
    // (NOTE_OFF, 0x00) for release.
    ConfigKey key("[Channel1]", "keylock");
    ControlPushButton cpb(key);
    cpb.setButtonMode(ControlPushButton::TOGGLE);

    unsigned char channel = 0x01;
    unsigned char control = 0x10;

    addMapping(MidiInputMapping(MidiKey(MIDI_NOTE_ON | channel, control),
                                MidiOptions(), key));
    addMapping(MidiInputMapping(MidiKey(MIDI_NOTE_OFF | channel, control),
                                MidiOptions(), key));
    loadPreset(m_preset);

    // Receive an on/off, toggles the control.
    receive(MIDI_NOTE_ON | channel, control, 0x7F);
    receive(MIDI_NOTE_OFF | channel, control, 0x00);

    EXPECT_LT(0.0, cpb.get());

    // Receive an on/off, toggles the control.
    receive(MIDI_NOTE_ON | channel, control, 0x7F);
    receive(MIDI_NOTE_OFF | channel, control, 0x00);

    EXPECT_DOUBLE_EQ(0.0, cpb.get());
}
コード例 #3
0
TEST_F(MidiControllerTest, ReceiveMessage_ToggleCO_ToggleOnOff_ButtonMidiOption) {
    // Using the button MIDI option allows you to use a MIDI toggle button as a
    // push button.
    ConfigKey key("[Channel1]", "keylock");
    ControlPushButton cpb(key);
    cpb.setButtonMode(ControlPushButton::TOGGLE);

    unsigned char channel = 0x01;
    unsigned char control = 0x10;

    MidiOptions options;
    options.button = true;

    addMapping(MidiInputMapping(MidiKey(MIDI_NOTE_ON | channel, control),
                                options, key));
    addMapping(MidiInputMapping(MidiKey(MIDI_NOTE_OFF | channel, control),
                                options, key));
    loadPreset(m_preset);

    // NOTE(rryan): If the intended behavior of the button MIDI option is to
    // make a toggle MIDI button act like a push button then this isn't
    // working. The toggle on toggles the CO but the toggle off does nothing.

    // Toggle the switch on, since it is interpreted as a button press it
    // toggles the button on.
    receive(MIDI_NOTE_ON | channel, control, 0x7F);
    EXPECT_LT(0.0, cpb.get());

    // Toggle the switch off, since it is interpreted as a button release it
    // does nothing to the toggle button.
    receive(MIDI_NOTE_OFF | channel, control, 0x00);
    EXPECT_LT(0.0, cpb.get());
}
コード例 #4
0
TEST_F(MidiControllerTest, ReceiveMessage_PushButtonCO_PushOnOff) {
    // Most MIDI controller send push-buttons as (NOTE_ON, 0x7F) for press and
    // (NOTE_OFF, 0x00) for release.
    ConfigKey key("[Channel1]", "hotcue_1_activate");
    ControlPushButton cpb(key);

    unsigned char channel = 0x01;
    unsigned char control = 0x10;

    addMapping(MidiInputMapping(MidiKey(MIDI_NOTE_ON | channel, control),
                                MidiOptions(), key));
    addMapping(MidiInputMapping(MidiKey(MIDI_NOTE_OFF | channel, control),
                                MidiOptions(), key));
    loadPreset(m_preset);

    // Receive an on/off, sets the control on/off with each press.
    receive(MIDI_NOTE_ON | channel, control, 0x7F);
    EXPECT_LT(0.0, cpb.get());
    receive(MIDI_NOTE_OFF | channel, control, 0x00);
    EXPECT_DOUBLE_EQ(0.0, cpb.get());

    // Receive an on/off, sets the control on/off with each press.
    receive(MIDI_NOTE_ON | channel, control, 0x7F);
    EXPECT_LT(0.0, cpb.get());
    receive(MIDI_NOTE_OFF | channel, control, 0x00);
    EXPECT_DOUBLE_EQ(0.0, cpb.get());
}
コード例 #5
0
hkvPlatformToTextureDataFormatMapping::hkvPlatformToTextureDataFormatMapping()
: hkReferencedObject(), hkSingleton(), hkvPlatformToTextureDataFormatMappingBase()
{
  hkvTextureDataFormat rawFormats[] = {
    HKV_TEXTURE_DATA_FORMAT_A4R4G4B4,
    HKV_TEXTURE_DATA_FORMAT_A1R5G5B5,
    HKV_TEXTURE_DATA_FORMAT_R5G6B5,
    HKV_TEXTURE_DATA_FORMAT_A8R8G8B8,
    HKV_TEXTURE_DATA_FORMAT_X8R8G8B8,
    HKV_TEXTURE_DATA_FORMAT_R8G8B8
  };
  addMappings(HKV_TARGET_PLATFORM_DX9, rawFormats);
  addMappings(HKV_TARGET_PLATFORM_DX11, rawFormats);
  addMappings(HKV_TARGET_PLATFORM_XBOX360, rawFormats);
  addMappings(HKV_TARGET_PLATFORM_PS3, rawFormats);
  addMappings(HKV_TARGET_PLATFORM_PSVITA, rawFormats);
  addMappings(HKV_TARGET_PLATFORM_IOS, rawFormats);
  addMappings(HKV_TARGET_PLATFORM_ANDROID, rawFormats);
  addMappings(HKV_TARGET_PLATFORM_TIZEN, rawFormats);
  addMappings(HKV_TARGET_PLATFORM_WIIU, rawFormats);

  addMapping(HKV_TARGET_PLATFORM_ANDROID, HKV_TEXTURE_DATA_FORMAT_R4G4B4A4_GL);
  addMapping(HKV_TARGET_PLATFORM_IOS, HKV_TEXTURE_DATA_FORMAT_R4G4B4A4_GL);
  addMapping(HKV_TARGET_PLATFORM_TIZEN, HKV_TEXTURE_DATA_FORMAT_R4G4B4A4_GL);

  hkvTextureDataFormat bcFormats[] = {
    HKV_TEXTURE_DATA_FORMAT_DXT1,
    HKV_TEXTURE_DATA_FORMAT_DXT3,
    HKV_TEXTURE_DATA_FORMAT_DXT5,
  };
  addMappings(HKV_TARGET_PLATFORM_DX9, bcFormats);
  addMappings(HKV_TARGET_PLATFORM_DX11, bcFormats);
  addMappings(HKV_TARGET_PLATFORM_XBOX360, bcFormats);
  addMappings(HKV_TARGET_PLATFORM_PS3, bcFormats);
  addMappings(HKV_TARGET_PLATFORM_PSVITA, bcFormats);
  addMappings(HKV_TARGET_PLATFORM_WIIU, bcFormats);

  hkvTextureDataFormat pvrFormats[] = {
    HKV_TEXTURE_DATA_FORMAT_PVRTC2,
    HKV_TEXTURE_DATA_FORMAT_PVRTC4,
  };
  addMappings(HKV_TARGET_PLATFORM_IOS, pvrFormats);
  addMappings(HKV_TARGET_PLATFORM_ANDROID, pvrFormats);
  addMappings(HKV_TARGET_PLATFORM_TIZEN, pvrFormats);

  hkvTextureDataFormat etcFormats[] = {
    HKV_TEXTURE_DATA_FORMAT_ETC1,
  };
  addMappings(HKV_TARGET_PLATFORM_ANDROID, etcFormats);
  addMappings(HKV_TARGET_PLATFORM_TIZEN, etcFormats);
}
コード例 #6
0
void HuffmanCode::addMapping(Node* node, string code) {
    //assumption: codes only exist in leaf nodes
    if (node == NULL) {
        return;
    }
    else if (node->left == NULL && node->right == NULL) {
        //code
        codeMapping[node->probability.value] = code;
    }
    else {
        addMapping(node->left, code + "1");
        addMapping(node->right, code + "0");
    }
}
コード例 #7
0
TEST_F(MidiControllerTest, ReceiveMessage_ToggleCO_ToggleOnOff_SwitchMidiOption) {
    // Using the switch MIDI option interprets a MIDI toggle button as a toggle
    // button rather than a momentary push button.
    ConfigKey key("[Channel1]", "keylock");
    ControlPushButton cpb(key);
    cpb.setButtonMode(ControlPushButton::TOGGLE);

    unsigned char channel = 0x01;
    unsigned char control = 0x10;

    MidiOptions options;
    options.sw = true;

    addMapping(MidiInputMapping(MidiKey(MIDI_NOTE_ON | channel, control),
                                options, key));
    addMapping(MidiInputMapping(MidiKey(MIDI_NOTE_OFF | channel, control),
                                options, key));
    loadPreset(m_preset);

    // NOTE(rryan): If the intended behavior of switch MIDI option is to make a
    // toggle MIDI button act like a toggle button then this isn't working. The
    // toggle on presses the CO and the toggle off presses the CO. This toggles
    // the control but allows it to get out of sync.

    // Toggle the switch on, since it is interpreted as a button press it
    // toggles the control on.
    receive(MIDI_NOTE_ON | channel, control, 0x7F);
    EXPECT_LT(0.0, cpb.get());

    // Toggle the switch off, since it is interpreted as a button press it
    // toggles the control off.
    receive(MIDI_NOTE_OFF | channel, control, 0x00);
    EXPECT_DOUBLE_EQ(0.0, cpb.get());

    // Meanwhile, the GUI toggles the control on again.
    // NOTE(rryan): Now the MIDI toggle button is out of sync with the toggle
    // CO.
    cpb.set(1.0);

    // Toggle the switch on, since it is interpreted as a button press it
    // toggles the control off (since it was on).
    receive(MIDI_NOTE_ON | channel, control, 0x7F);
    EXPECT_DOUBLE_EQ(0.0, cpb.get());

    // Toggle the switch off, since it is interpreted as a button press it
    // toggles the control on (since it was off).
    receive(MIDI_NOTE_OFF | channel, control, 0x00);
    EXPECT_LT(0.0, cpb.get());
}
コード例 #8
0
TEST_F(MidiControllerTest, ReceiveMessage_PushButtonCO_ToggleOnOff_SwitchMidiOption) {
    // Using the switch MIDI option interprets a MIDI toggle button as a toggle
    // button rather than a momentary push button.
    ConfigKey key("[Channel1]", "hotcue_1_activate");
    ControlPushButton cpb(key);

    unsigned char channel = 0x01;
    unsigned char control = 0x10;

    MidiOptions options;
    options.sw = true;

    addMapping(MidiInputMapping(MidiKey(MIDI_NOTE_ON | channel, control),
                                options, key));
    addMapping(MidiInputMapping(MidiKey(MIDI_NOTE_OFF | channel, control),
                                options, key));
    loadPreset(m_preset);

    // NOTE(rryan): This behavior is broken!

    // Toggle the switch on, sets the push button on.
    receive(MIDI_NOTE_ON | channel, control, 0x7F);
    EXPECT_LT(0.0, cpb.get());

    // The push button is stuck down here!

    // Toggle the switch off, sets the push button on again.
    receive(MIDI_NOTE_OFF | channel, control, 0x00);
    EXPECT_LT(0.0, cpb.get());

    // NOTE(rryan): What is supposed to happen in this case? It's an open
    // question I think. I think if you want to connect a switch MIDI control to
    // a push button CO then the switch should directly set the CO. After all,
    // the preset author asked for the switch to be interpreted as a switch. If
    // they want the switch to act like a push button, they should use the
    // button MIDI option.
    //
    // Most of our push buttons trigger behavior on press and do nothing on
    // release, and most don't care about being "stuck down" except for hotcue
    // and cue controls that have preview behavior.

    // "reverse" is an example of a push button that is a push button because we
    // want the default behavior to be momentary press and not toggle. If I
    // mapped a switch to it, I would expect the switch to enable it (set it to
    // 1) when the switch was enabled and set it to 0 when the switch was
    // disabled. So I think we should change the switch option to behave like
    // this.
}
コード例 #9
0
hkvTextureFileToDataFormatMapping::hkvTextureFileToDataFormatMapping()
{
  hkvTextureDataFormat rawFormats[] = {
    HKV_TEXTURE_DATA_FORMAT_A4R4G4B4,
    HKV_TEXTURE_DATA_FORMAT_A1R5G5B5,
    HKV_TEXTURE_DATA_FORMAT_R5G6B5,
    HKV_TEXTURE_DATA_FORMAT_A8R8G8B8,
    HKV_TEXTURE_DATA_FORMAT_X8R8G8B8,
    HKV_TEXTURE_DATA_FORMAT_R8G8B8
  };
  addMappings(HKV_TEXTURE_FILE_FORMAT_DDS, rawFormats);
  addMappings(HKV_TEXTURE_FILE_FORMAT_RGBA, rawFormats);
  addMappings(HKV_TEXTURE_FILE_FORMAT_GTX, rawFormats);

  addMapping(HKV_TEXTURE_FILE_FORMAT_RGBA, HKV_TEXTURE_DATA_FORMAT_R4G4B4A4_GL);

  hkvTextureDataFormat bcFormats[] = {
    HKV_TEXTURE_DATA_FORMAT_DXT1,
    HKV_TEXTURE_DATA_FORMAT_DXT3,
    HKV_TEXTURE_DATA_FORMAT_DXT5,
  };
  addMappings(HKV_TEXTURE_FILE_FORMAT_DDS, bcFormats);
  addMappings(HKV_TEXTURE_FILE_FORMAT_GTX, bcFormats);

  hkvTextureDataFormat pvrFormats[] = {
    HKV_TEXTURE_DATA_FORMAT_PVRTC2,
    HKV_TEXTURE_DATA_FORMAT_PVRTC4,
  };
  addMappings(HKV_TEXTURE_FILE_FORMAT_PVR, pvrFormats);

  hkvTextureDataFormat etcFormats[] = {
    HKV_TEXTURE_DATA_FORMAT_ETC1,
  };
  addMappings(HKV_TEXTURE_FILE_FORMAT_ETC, etcFormats);
}
コード例 #10
0
TEST_F(MidiControllerTest, ReceiveMessage_ToggleCO_PushCC) {
    // Some MIDI controllers (e.g. Korg nanoKONTROL) send momentary push-buttons
    // as (CC, 0x7f) for press and (CC, 0x00) for release.
    ConfigKey key("[Channel1]", "keylock");
    ControlPushButton cpb(key);
    cpb.setButtonMode(ControlPushButton::TOGGLE);

    unsigned char channel = 0x01;
    unsigned char control = 0x10;

    addMapping(MidiInputMapping(MidiKey(MIDI_CC | channel, control),
                                MidiOptions(), key));
    loadPreset(m_preset);

    // Receive an on/off, toggles the control.
    receive(MIDI_CC | channel, control, 0x7F);
    receive(MIDI_CC | channel, control, 0x00);

    EXPECT_LT(0.0, cpb.get());

    // Receive an on/off, toggles the control.
    receive(MIDI_CC | channel, control, 0x7F);
    receive(MIDI_CC | channel, control, 0x00);

    EXPECT_DOUBLE_EQ(0.0, cpb.get());
}
コード例 #11
0
void SqlContactsMapping::loadMappingsFromDatabase()
{
	QMutexLocker locker(&Mutex);

	QSqlQuery query(Database);
	query.prepare("SELECT id, account_id, contact FROM kadu_contacts");

	query.setForwardOnly(true);
	query.exec();

	while (query.next())
	{
		int id = query.value(0).toInt();
		Account account = AccountsMapping->accountById(query.value(1).toInt());
		QString contactId = query.value(2).toString();

		if (id <= 0)
			continue;

		// This contact needs to be known to the manager even if it's not on our roster,
		// in case we want to add him later or even talk to her without adding.
		Contact contact = m_contactManager->byId(account, contactId, ActionCreateAndAdd);
		if (contact)
			addMapping(id, contact);
	}
}
コード例 #12
0
ファイル: Dialogs.cpp プロジェクト: PyroOS/Pyro
GotoLineDialog::GotoLineDialog() : DialogBase("GotoLineDialog", "Go to line")
{
    okButton=new os::Button(os::Rect(), "okButton", "GoTo", new os::Message(ID_OK));
    cancelButton=new os::Button(os::Rect(), "cancelButton", "Cancel", new os::Message(os::M_QUIT));

    text=new os::TextView(os::Rect(), "TextView", "");
    text->SetMultiLine(false);
    text->SetNumeric(true);
    text->SetMinPreferredSize(10, 1);

    os::Point p0=cancelButton->GetPreferredSize(false);
    os::Point p1=text->GetPreferredSize(false);

    const int border=5;

    float h=2*p0.y+3*border;
    float w=p1.x+p0.x+3*border;
    ResizeTo(w, h);
    okButton->SetFrame(os::Rect(p1.x+2*border, border, p1.x+p0.x+2*border, border+p0.y));
    cancelButton->SetFrame(os::Rect(p1.x+2*border, 2*border+p0.y, p1.x+p0.x+2*border, 2*border+2*p0.y));
    text->SetFrame(os::Rect(border, (h-p1.y)/2, border+p1.x, (h+p1.y)/2));

    AddChild(text);
    AddChild(okButton);
    AddChild(cancelButton);

    addMapping("0\n", ID_OK);
    addMapping("0\e", os::M_QUIT);
}
コード例 #13
0
TEST_F(MidiControllerTest, ReceiveMessage_PotMeterCO_7BitCC) {
    ConfigKey key("[Channel1]", "playposition");

    const double kMinValue = -1234.5;
    const double kMaxValue = 678.9;
    const double kMiddleValue = (kMinValue + kMaxValue) * 0.5;
    ControlPotmeter potmeter(key, kMinValue, kMaxValue);

    unsigned char channel = 0x01;
    unsigned char control = 0x10;

    addMapping(MidiInputMapping(MidiKey(MIDI_CC | channel, control),
                                MidiOptions(), key));
    loadPreset(m_preset);

    // Receive a 0, MIDI parameter should map to the min value.
    receive(MIDI_CC | channel, control, 0x00);
    EXPECT_DOUBLE_EQ(kMinValue, potmeter.get());

    // Receive a 0x7F, MIDI parameter should map to the potmeter max value.
    receive(MIDI_CC | channel, control, 0x7F);
    EXPECT_DOUBLE_EQ(kMaxValue, potmeter.get());

    // Receive a 0x40, MIDI parameter should map to the potmeter middle value.
    receive(MIDI_CC | channel, control, 0x40);
    EXPECT_DOUBLE_EQ(kMiddleValue, potmeter.get());
}
コード例 #14
0
TEST_F(MidiControllerTest, ReceiveMessage_PotMeterCO_14BitPitchBend) {
    ConfigKey key("[Channel1]", "rate");

    const double kMinValue = -1234.5;
    const double kMaxValue = 678.9;
    const double kMiddleValue = (kMinValue + kMaxValue) * 0.5;
    ControlPotmeter potmeter(key, kMinValue, kMaxValue);
    unsigned char channel = 0x01;

    // The control is ignored in mappings for messages where the control is part
    // of the payload.
    addMapping(MidiInputMapping(MidiKey(MIDI_PITCH_BEND | channel, 0xFF),
                                MidiOptions(), key));
    loadPreset(m_preset);

    // Receive a 0x0000, MIDI parameter should map to the min value.
    receive(MIDI_PITCH_BEND | channel, 0x00, 0x00);
    EXPECT_DOUBLE_EQ(kMinValue, potmeter.get());

    // Receive a 0x3FFF, MIDI parameter should map to the potmeter max value.
    receive(MIDI_PITCH_BEND | channel, 0x7F, 0x7F);
    EXPECT_DOUBLE_EQ(kMaxValue, potmeter.get());

    // Receive a 0x2000, MIDI parameter should map to the potmeter middle value.
    receive(MIDI_PITCH_BEND | channel, 0x00, 0x40);
    EXPECT_DOUBLE_EQ(kMiddleValue, potmeter.get());

    // Check the 14-bit resolution is actually present. Receive a 0x2001, MIDI
    // parameter should map to the middle value plus a tiny amount. Scaling is
    // not quite linear for MIDI parameters so just check that incrementing the
    // LSB by 1 is greater than the middle value.
    receive(MIDI_PITCH_BEND | channel, 0x01, 0x40);
    EXPECT_LT(kMiddleValue, potmeter.get());
}
コード例 #15
0
void DirMappingWidget::setMappings(const QMap<QString,QString>& mappings)
{
  QMap<QString, QString>::const_iterator it;
  for(it = mappings.begin(); it != mappings.end(); ++it) 
  {
    addMapping(it.key(), it.data());
  }
}
コード例 #16
0
ファイル: Dialogs.cpp プロジェクト: PyroOS/Pyro
FileReq::FileReq(os::FileRequester::file_req_mode_t p0,
                 os::Messenger* p1, const char* p2, uint32 p3,
                 bool p4, os::Message* p5, os::FileFilter* p6, bool p7,
                 bool p8, String p9, String p10)
        : os::FileRequester(p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10)
{
    addMapping("0\e", ID_CANCEL);
    addMapping("o\n", ID_OK);
		 m_pcTarget = ( p1 != NULL ) ? p1 : new Messenger( Application::GetInstance() );
}
コード例 #17
0
ファイル: ControlMap.cpp プロジェクト: Ezio47/flightgear
void ControlMap::addMapping(int input, int type, void* object, int options,
			    float src0, float src1, float dst0, float dst1)
{
    addMapping(input, type, object, options);

    // The one we just added is last in the list (ugly, awful hack!)
    Vector* maps = (Vector*)_inputs.get(input);
    MapRec* m = (MapRec*)maps->get(maps->size() - 1);

    m->src0 = src0;
    m->src1 = src1;
    m->dst0 = dst0;
    m->dst1 = dst1;
}
コード例 #18
0
bool QmcTypeUnitComponentAndAliasResolver::resolve()
{
    // TBD: component related stuff
    // foreach (component) -> addAliases
    foreach (const QmcUnitObjectIndexToIdComponent &mapping, qmcTypeUnit->qmcUnit()->objectIndexToIdComponent) {
       QHash<int,int> &map = qmcTypeUnit->compiledData->objectIndexToIdPerComponent[mapping.componentIndex];
       foreach (const QmcUnitObjectIndexToId &componentMapping, mapping.mappings) {
            if (!addMapping(componentMapping, map))
                return false;
       }
    }

    // add mappings for root object
    foreach (const QmcUnitObjectIndexToId &mapping, qmcTypeUnit->qmcUnit()->objectIndexToIdRoot) {
        if (!addMapping(mapping, qmcTypeUnit->compiledData->objectIndexToIdForRoot))
            return false;
    }

    // add aliases
    if (!addAliases())
        return false;

    return true;
}
コード例 #19
0
ファイル: cppprojectfile.cpp プロジェクト: 55171514/qtcreator
ProjectFileAdder::ProjectFileAdder(QList<ProjectFile> &files)
    : m_files(files)
{
    addMapping(CppTools::Constants::C_SOURCE_MIMETYPE, ProjectFile::CSource);
    addMapping(CppTools::Constants::C_HEADER_MIMETYPE, ProjectFile::CHeader);
    addMapping(CppTools::Constants::CPP_SOURCE_MIMETYPE, ProjectFile::CXXSource);
    addMapping(CppTools::Constants::CPP_HEADER_MIMETYPE, ProjectFile::CXXHeader);
    addMapping(CppTools::Constants::OBJECTIVE_C_SOURCE_MIMETYPE, ProjectFile::ObjCSource);
    addMapping(CppTools::Constants::OBJECTIVE_CPP_SOURCE_MIMETYPE, ProjectFile::ObjCXXSource);
}
コード例 #20
0
int SqlContactsMapping::idByContact(const Contact &contact, bool create)
{
	QMutexLocker locker(&Mutex);

	int id = contact.property("sql_history:id", 0).toInt();
	if (!create || id > 0)
		return id;

	QSqlQuery query(Database);
	query.prepare("INSERT INTO kadu_contacts (account_id, contact) VALUES (:account_id, :contact)");
	query.bindValue(":account_id", SqlAccountsMapping::idByAccount(contact.contactAccount()));
	query.bindValue(":contact", contact.id());
	query.exec();

	id = query.lastInsertId().toInt();
	addMapping(id, contact);

	return id;
}
コード例 #21
0
void DirMappingWidget::slotAdd()
{
  KURL local;
  local.setDirectory(m_edLocalDir->url()); 

  KURL remote;
  remote.setDirectory(m_edRemoteDir->text());

  if(m_edLocalDir->url().isEmpty() || !local.isValid())
  {
    KMessageBox::sorry(this, i18n("\"Local dir\" is not valid."));
    return;
  }

  if(m_edRemoteDir->text().isEmpty() || !remote.isValid())
  {
    KMessageBox::sorry(this, i18n("\"Remote dir\" is not valid."));
    return;
  }

  QString l = m_edLocalDir->url();
  if(!l.endsWith("/"))
  {
    l += "/";
  }

  if(itemExists(l))
  {
    KMessageBox::sorry(this, i18n("\"Local dir\" already exists."));
    return;
  }

  addMapping(m_edLocalDir->url(), m_edRemoteDir->text());

  m_listView->clearSelection();

  m_edLocalDir->clear();
  m_edRemoteDir->clear();
}
コード例 #22
0
// Construct mappings from an input string.
UtlBoolean
SipRedirectorGateway::addMappings(const char* value,
                                  int length,
                                  UtlString*& user,
                                  const char*& error_msg,
                                  int& location)
{
   // Process the input string one character at a time.
   // Buffer into which to edit the input string.
   char buffer[FORM_SIZE];
   // Pointer for filling the edit buffer.
   char* p = buffer;
   char c;
   int count = length;
   while (count-- > 0)
   {
      c = *value++;
      switch (c)
      {
      case '\n':
         // Trim trailing whitespace on the line.
         while (p > buffer && p[-1] != '\n' && isspace(p[-1]))
         {
            p--;
         }
         // Fall through to insert if not at the beginning of a line.
      case ' ':
      case '\t':
         // If at the beginning of a line, ignore it.
         if (p > buffer && p[-1] != '\n' && p[-1] != '{')
         {
            *p++ = c;
         }
         break;
      case '}':
      {
         // Process component redirection.
         // Trim trailing whitespace.
         while (p > buffer && isspace(p[-1]))
         {
            p--;
         }
         // Find the matching '{'.
         *p = '\0';             // End scope of strrchr.
         char* open = strrchr(buffer, '{');
         if (open == NULL)
         {
            error_msg = "Unmatched '}'";
            location = length - count;
            return FALSE;
         }
         if (open+1 == p)
         {
            error_msg = "No contacts given";
            location = length - count;
            return FALSE;
         }
         // Insert the addresses into the map and get the assigned user name.
         UtlString* user = addMapping(open+1, p - (open+1));
         // Truncate off the sub-redirection.
         p = open;
         // Append the resulting user name.
         strcpy(p, user->data());
         p += strlen(user->data());
      }
         break;
      case '{':
         // '{' is copied into the buffer like other characters.
      default:
         // Ordinary characters are just copied.
         *p++ = c;
         break;
      }
   }
   // Trim trailing whitespace.
   while (p > buffer && isspace(p[-1]))
   {
      p--;
   }
   // Check that there are no unclosed '{'.
   *p = '\0';                   // To limit strchr's search.
   if (strchr(buffer, '{') != NULL)
   {
      error_msg = "Unmatched '{'";
      // Report at end of string because we have no better choice.
      location = length;
      return FALSE;
   }
   // Check that the contacts are not empty.
   if (p == buffer)
   {
      error_msg = "No contacts given";
      location = 0;
      return FALSE;
   }
   // Insert the addresses into the map and return the assigned user name.
   user = addMapping(buffer, p - buffer);
   return TRUE;
}
コード例 #23
0
hkvPlatformToTextureFileFormatMapping::hkvPlatformToTextureFileFormatMapping()
{
  //DDS
  addMapping(HKV_TARGET_PLATFORM_DX9, HKV_TEXTURE_FILE_FORMAT_DDS);
  addMapping(HKV_TARGET_PLATFORM_DX11, HKV_TEXTURE_FILE_FORMAT_DDS);
  addMapping(HKV_TARGET_PLATFORM_XBOX360, HKV_TEXTURE_FILE_FORMAT_DDS);
  addMapping(HKV_TARGET_PLATFORM_PS3, HKV_TEXTURE_FILE_FORMAT_DDS);
  addMapping(HKV_TARGET_PLATFORM_PSVITA, HKV_TEXTURE_FILE_FORMAT_DDS);
  addMapping(HKV_TARGET_PLATFORM_ANDROID, HKV_TEXTURE_FILE_FORMAT_DDS);
  addMapping(HKV_TARGET_PLATFORM_IOS, HKV_TEXTURE_FILE_FORMAT_DDS);
  addMapping(HKV_TARGET_PLATFORM_TIZEN, HKV_TEXTURE_FILE_FORMAT_DDS);

  //RGBA
  addMapping(HKV_TARGET_PLATFORM_ANDROID, HKV_TEXTURE_FILE_FORMAT_RGBA);
  addMapping(HKV_TARGET_PLATFORM_IOS, HKV_TEXTURE_FILE_FORMAT_RGBA);
  addMapping(HKV_TARGET_PLATFORM_TIZEN, HKV_TEXTURE_FILE_FORMAT_RGBA);

  //PVR
  addMapping(HKV_TARGET_PLATFORM_IOS, HKV_TEXTURE_FILE_FORMAT_PVR);
  addMapping(HKV_TARGET_PLATFORM_ANDROID, HKV_TEXTURE_FILE_FORMAT_PVR);
  addMapping(HKV_TARGET_PLATFORM_TIZEN, HKV_TEXTURE_FILE_FORMAT_PVR);

  //ETC
  addMapping(HKV_TARGET_PLATFORM_ANDROID, HKV_TEXTURE_FILE_FORMAT_ETC);
  addMapping(HKV_TARGET_PLATFORM_TIZEN, HKV_TEXTURE_FILE_FORMAT_ETC);

  //GTX
  addMapping(HKV_TARGET_PLATFORM_WIIU, HKV_TEXTURE_FILE_FORMAT_GTX);
}
コード例 #24
0
TEST_F(MidiControllerTest, ReceiveMessage_PotMeterCO_14BitCC) {
    ConfigKey key("[Channel1]", "playposition");

    const double kMinValue = -1234.5;
    const double kMaxValue = 678.9;
    const double kMiddleValue = (kMinValue + kMaxValue) * 0.5;
    ControlPotmeter potmeter(key, kMinValue, kMaxValue);
    potmeter.set(0);

    unsigned char channel = 0x01;
    unsigned char lsb_control = 0x10;
    unsigned char msb_control = 0x11;

    MidiOptions lsb;
    lsb.fourteen_bit_lsb = true;

    MidiOptions msb;
    msb.fourteen_bit_msb = true;

    addMapping(MidiInputMapping(MidiKey(MIDI_CC | channel, lsb_control),
                                lsb, key));
    addMapping(MidiInputMapping(MidiKey(MIDI_CC | channel, msb_control),
                                msb, key));
    loadPreset(m_preset);

    // If kMinValue or kMaxValue are such that the middle value is 0 then the
    // set(0) commands below allow us to hide failures.
    ASSERT_NE(0.0, kMiddleValue);

    // Receive a 0x0000 (lsb-first), MIDI parameter should map to the min value.
    potmeter.set(0);
    receive(MIDI_CC | channel, lsb_control, 0x00);
    receive(MIDI_CC | channel, msb_control, 0x00);
    EXPECT_DOUBLE_EQ(kMinValue, potmeter.get());

    // Receive a 0x0000 (msb-first), MIDI parameter should map to the min value.
    potmeter.set(0);
    receive(MIDI_CC | channel, msb_control, 0x00);
    receive(MIDI_CC | channel, lsb_control, 0x00);
    EXPECT_DOUBLE_EQ(kMinValue, potmeter.get());

    // Receive a 0x3FFF (lsb-first), MIDI parameter should map to the max value.
    potmeter.set(0);
    receive(MIDI_CC | channel, lsb_control, 0x7F);
    receive(MIDI_CC | channel, msb_control, 0x7F);
    EXPECT_DOUBLE_EQ(kMaxValue, potmeter.get());

    // Receive a 0x3FFF (msb-first), MIDI parameter should map to the max value.
    potmeter.set(0);
    receive(MIDI_CC | channel, msb_control, 0x7F);
    receive(MIDI_CC | channel, lsb_control, 0x7F);
    EXPECT_DOUBLE_EQ(kMaxValue, potmeter.get());

    // Receive a 0x2000 (lsb-first), MIDI parameter should map to the middle
    // value.
    potmeter.set(0);
    receive(MIDI_CC | channel, lsb_control, 0x00);
    receive(MIDI_CC | channel, msb_control, 0x40);
    EXPECT_DOUBLE_EQ(kMiddleValue, potmeter.get());

    // Receive a 0x2000 (msb-first), MIDI parameter should map to the middle
    // value.
    potmeter.set(0);
    receive(MIDI_CC | channel, msb_control, 0x40);
    receive(MIDI_CC | channel, lsb_control, 0x00);
    EXPECT_DOUBLE_EQ(kMiddleValue, potmeter.get());

    // Check the 14-bit resolution is actually present. Receive a 0x2001
    // (msb-first), MIDI parameter should map to the middle value plus a tiny
    // amount. Scaling is not quite linear for MIDI parameters so just check
    // that incrementing the LSB by 1 is greater than the middle value.
    potmeter.set(0);
    receive(MIDI_CC | channel, msb_control, 0x40);
    receive(MIDI_CC | channel, lsb_control, 0x01);
    EXPECT_LT(kMiddleValue, potmeter.get());

    // Check the 14-bit resolution is actually present. Receive a 0x2001
    // (lsb-first), MIDI parameter should map to the middle value plus a tiny
    // amount. Scaling is not quite linear for MIDI parameters so just check
    // that incrementing the LSB by 1 is greater than the middle value.
    potmeter.set(0);
    receive(MIDI_CC | channel, lsb_control, 0x01);
    receive(MIDI_CC | channel, msb_control, 0x40);
    EXPECT_LT(kMiddleValue, potmeter.get());
}
コード例 #25
0
ファイル: Dialogs.cpp プロジェクト: PyroOS/Pyro
FindDialog::FindDialog(const string& str, bool down, bool caseS, bool extended)
        : DialogBase("FindDialog", "Find text")
{
    findButton=new os::Button(os::Rect(), "findButton", "Find", new os::Message(ID_FIND));
    closeButton=new os::Button(os::Rect(), "closeButton", "Close", new os::Message(os::M_QUIT));

    rUp=new os::RadioButton(os::Rect(), "rUp", "Up", NULL);
    rDown=new os::RadioButton(os::Rect(), "rDown", "Down", NULL);
    rCase=new os::RadioButton(os::Rect(), "rCase", "Sensitive", NULL);
    rNoCase=new os::RadioButton(os::Rect(), "rNoCase", "Insensitive", NULL);
    rBasic=new os::RadioButton(os::Rect(), "rBasic", "Basic", NULL);
    rExtended=new os::RadioButton(os::Rect(), "rExtended", "Extended", NULL);

    text=new os::TextView(os::Rect(), "TextView", "");
    text->SetMultiLine(false);
    text->SetMinPreferredSize(30, 1);

    os::FrameView *dirFrame=new os::FrameView(os::Rect(), "dirFrame", "Direction");
    os::FrameView *caseFrame=new os::FrameView(os::Rect(), "caseFrame", "Case");
    os::FrameView *syntaxFrame=new os::FrameView(os::Rect(), "syntaxFrame", "Syntax");

    os::LayoutView *rootView=new os::LayoutView(os::Rect(), "");

    os::HLayoutNode *root=new os::HLayoutNode("root");
    root->SetBorders(os::Rect(3, 3, 3, 0));
    os::VLayoutNode *l1=new os::VLayoutNode("l1", 1.0f, root);
    l1->SetBorders(os::Rect(3, 3, 3, 3));
    l1->AddChild(text);
    os::HLayoutNode *l2=new os::HLayoutNode("l2", 1.0f, l1);
    os::VLayoutNode *l2a=new os::VLayoutNode("l2a");
    l2a->SetHAlignment(os::ALIGN_LEFT);
    l2a->AddChild(rUp);
    l2a->AddChild(rDown);
    l2a->SetBorders(os::Rect(3, 3, 3, 3), "rUp", "rDown", NULL);
    dirFrame->SetRoot(l2a);
    l2->AddChild(dirFrame);
    os::VLayoutNode *l2b=new os::VLayoutNode("l2b");
    l2b->SetHAlignment(os::ALIGN_LEFT);
    l2b->AddChild(rCase);
    l2b->AddChild(rNoCase);
    l2b->SetBorders(os::Rect(3, 3, 3, 3), "rCase", "rNoCase", NULL);
    caseFrame->SetRoot(l2b);
    l2->AddChild(caseFrame);
    os::VLayoutNode *l2c=new os::VLayoutNode("l2c");
    l2c->SetHAlignment(os::ALIGN_LEFT);
    l2c->AddChild(rBasic);
    l2c->AddChild(rExtended);
    l2c->SetBorders(os::Rect(3, 3, 3, 3), "rBasic", "rExtended", NULL);
    syntaxFrame->SetRoot(l2c);
    l2->AddChild(syntaxFrame);
    os::VLayoutNode *l3=new os::VLayoutNode("l3", 1.0f, root);
    l3->SetBorders(os::Rect(3, 3, 3, 3));
    l3->AddChild(findButton);
    l3->AddChild(closeButton);
    new os::VLayoutSpacer("", 0, 1000, l3);
    l3->SameWidth("findButton", "closeButton", NULL);
    l3->SetBorders(os::Rect(0, 0, 0, 3), "findButton", NULL);
    root->SameWidth("TextView", "l2", NULL);
    root->SetBorders(os::Rect(0, 0, 0, 3), "TextView", NULL);

    rootView->SetRoot(root);
    root->Layout();

    os::Point p=rootView->GetPreferredSize(false);
    rootView->SetFrame(os::Rect(0, 0, p.x, p.y));
    ResizeTo(p.x, p.y);

    AddChild(rootView);

    //set keyboard shorcuts
    addMapping("0\n", ID_FIND);
    addMapping("0\e", os::M_QUIT);
    addMapping("2u", ID_UP);
    addMapping("2d", ID_DOWN);
    addMapping("2s", ID_CASE);
    addMapping("2i", ID_NOCASE);
    addMapping("2b", ID_BASIC);
    addMapping("2e", ID_EXTENDED);

    //set initial config
    text->Set(str.c_str());
    text->SelectAll();
    if(down)
        rDown->SetValue(true);
    else
        rUp->SetValue(true);
    if(caseS)
        rCase->SetValue(true);
    else
        rNoCase->SetValue(true);
    if(extended)
        rExtended->SetValue(true);
    else
        rBasic->SetValue(true);
}
コード例 #26
0
void HuffmanCode::createMapping() {
    addMapping(root, "");
}
コード例 #27
0
ファイル: EditMode.cpp プロジェクト: jpetrie/quip
 EditMode::EditMode () {
   addMapping(Key::Escape, &EditMode::commitInsert);
 }
コード例 #28
0
ファイル: Stage.cpp プロジェクト: etherealvisage/kriti
void Stage::addMapping(int previousIndex, Framebuffer::Attachment attachment,
    boost::shared_ptr<Render::Material> material, std::string uniformName) {

    auto prev = m_previous[previousIndex];
    addMapping(prev, attachment, material, uniformName);
}
コード例 #29
0
ファイル: Stage.cpp プロジェクト: etherealvisage/kriti
bool Stage::loadFrom(std::string identifier) {
    auto node = ResourceRegistry::get<XMLResource>(
            "data"
        )->doc().first_element_by_path(
            "/kriti/render/"
        ).find_child_by_attribute(
            "stage", "name", identifier.c_str());

    if(!node) return false;

    m_name = identifier;

    int outputs = node.child("outputs").text().as_int(1);
    int width = -1, height = -1;
    // TODO: support loading width/height from XML resource

    initialize(outputs, width, height);

    // add previous
    for(auto &child : node.children()) {
        if(std::strcmp(child.name(), "previous")) continue;

        std::string pname = child.text().as_string("");
        auto prev = ResourceRegistry::get<Stage>(pname);
        if(!prev) {
            Message3(Render, Error, "Couldn't find previous stage " << pname);
            continue;
        }

        addPrevious(prev);
    }

    for(auto &child : node.children()) {
        if(std::strcmp(child.name(), "map")) continue;

        std::string fromString = child.attribute("from").as_string();
        int from = 0;
        for(; from < m_previous.size(); from ++)
            if(m_previous[from]->name() == fromString) break;
        if(from == m_previous.size()) {
            Message3(Render, Error, "No previous stage " << fromString);
            continue;
        }

        std::string whichString = child.attribute("which").as_string();
        const std::map<std::string, Framebuffer::Attachment> whichMap = {
            {"colour0", Framebuffer::ColourBuffer0},
            {"colour1", Framebuffer::ColourBuffer1},
            {"colour2", Framebuffer::ColourBuffer2},
            {"colour3", Framebuffer::ColourBuffer3},
            {"depth", Framebuffer::DepthBuffer}
        };
        if(whichMap.count(whichString) == 0) {
            Message3(Render, Warning, "Unknown attachment: " << whichString);
            continue;
        }

        std::string materialString = child.attribute("material").as_string();
        std::string uniform = child.attribute("to").as_string();

        auto mat = ResourceRegistry::get<Render::Material>(materialString);
        addMapping(from, whichMap.at(whichString), mat, uniform);
    }

    return true;
}