Esempio n. 1
0
KeyID
OSXKeyState::CUCHRKeyResource::getKey(UInt32 table, UInt32 button) const
{
	assert(table < getNumTables());
	assert(button < getNumButtons());

	const UInt8* base   = reinterpret_cast<const UInt8*>(m_resource);
	const UCKeyOutput* cPtr = reinterpret_cast<const UCKeyOutput*>(base +
								m_cti->keyToCharTableOffsets[table]);

  const UCKeyOutput c = cPtr[button];

	KeySequence keys;
	switch (c & kUCKeyOutputTestForIndexMask) {
	case kUCKeyOutputStateIndexMask:
		if (!getDeadKey(keys, c & kUCKeyOutputGetIndexMask)) {
			return kKeyNone;
		}
		break;

	case kUCKeyOutputSequenceIndexMask:
	default:
		if (!addSequence(keys, c)) {
			return kKeyNone;
		}
		break;
	}

	// XXX -- no support for multiple characters
	if (keys.size() != 1) {
		return kKeyNone;
	}

	return keys.front();
}
Esempio n. 2
0
bool
OSXKeyState::CUCHRKeyResource::getDeadKey(
				KeySequence& keys, UInt16 index) const
{
	if (m_sri == NULL || index >= m_sri->keyStateRecordCount) {
		// XXX -- should we be using some other fallback?
		return false;
	}

	UInt16 state = 0;
	if (!getKeyRecord(keys, index, state)) {
		return false;
	}
	if (state == 0) {
		// not a dead key
		return true;
	}

	// no dead keys if we couldn't find the space key
	if (m_spaceOutput == 0xffffu) {
		return false;
	}

	// the dead key should not have put anything in the key list
	if (!keys.empty()) {
		return false;
	}

	// get the character generated by pressing the space key after the
	// dead key.  if we're still in a compose state afterwards then we're
	// confused so we bail.
	if (!getKeyRecord(keys, m_spaceOutput, state) || state != 0) {
		return false;
	}

	// convert keys to their dead counterparts
	for (KeySequence::iterator i = keys.begin(); i != keys.end(); ++i) {
		*i = synergy::KeyMap::getDeadKey(*i);
	}

	return true;
}
Esempio n. 3
0
InputResponder::InputResponder(RenderingWindow* window, Character* character,
                               Camera* camera, BloomFilterEffect* bloom, LuminanceFilterEffect* luminance) : inputProc(window) {

    //Wire up the event to close window
    CloseWindowEvent* cWindow = new CloseWindowEvent(window);
    inputProc.bind(KeySequence(InputEvent::WinClosed), cWindow);

    //Wire up the event to move the character along the axis
    KeyMovement* movement = new KeyMovement(character, camera);
    KeySequence movementKeys;
    movementKeys.add(InputEvent::KeyW);
    movementKeys.add(InputEvent::KeyA);
    movementKeys.add(InputEvent::KeyS);
    movementKeys.add(InputEvent::KeyD);
    inputProc.bind(movementKeys, movement);

    //Wire up the mouse to rotate view
    MouseLookEvent* mouseLook = new MouseLookEvent(character, window, camera);
    inputProc.bind(KeySequence(InputEvent::MouseMove), mouseLook);

    //Wire up the postprocesseffects controller
    PostprocessParameterInputEvent* pprocessInputs = new PostprocessParameterInputEvent(bloom, luminance);
    KeySequence paramKeys;
    paramKeys.add(InputEvent::Key1);
    paramKeys.add(InputEvent::Key2);
    paramKeys.add(InputEvent::Key3);
    paramKeys.add(InputEvent::Key4);
    inputProc.bind(paramKeys, pprocessInputs);
}
void galera::WriteSet::get_keys(KeySequence& s) const
{
    size_t offset(0);
    while (offset < keys_.size())
    {
        KeyOS key(version_);
        if ((offset = key.unserialize(&keys_[0], keys_.size(), offset)) == 0)
        {
            gu_throw_fatal << "failed to unserialize key";
        }
        s.push_back(key);
    }
    assert(offset == keys_.size());
}
size_t galera::WriteSet::keys(const gu::byte_t* buf,
                              size_t buf_len, size_t offset, int version,
                              KeySequence& ks)
{
    std::pair<size_t, size_t> seg(segment(buf, buf_len, offset));
    offset = seg.first;
    const size_t seg_end(seg.first + seg.second);
    assert(seg_end <= buf_len);

    while (offset < seg_end)
    {
        KeyOS key(version);
        if ((offset = key.unserialize(buf, buf_len, offset)) == 0)
        {
            gu_throw_fatal << "failed to unserialize key";
        }
        ks.push_back(key);
    }
    assert(offset == seg_end);
    return offset;
}
Esempio n. 6
0
bool
OSXKeyState::CUCHRKeyResource::addSequence(
				KeySequence& keys, UCKeyCharSeq c) const
{
	if ((c & kUCKeyOutputTestForIndexMask) == kUCKeyOutputSequenceIndexMask) {
		UInt16 index = (c & kUCKeyOutputGetIndexMask);
		if (index < m_sdi->charSequenceCount &&
			m_sdi->charSequenceOffsets[index] !=
				m_sdi->charSequenceOffsets[index + 1]) {
			// XXX -- sequences not supported yet
			return false;
		}
	}

	if (c != 0xfffe && c != 0xffff) {
		KeyID id = unicharToKeyID(c);
		if (id != kKeyNone) {
			keys.push_back(id);
		}
	}

	return true;
}
Esempio n. 7
0
bool KeySequence::operator ==(const KeySequence& b) const{
	return sequence == b.getSequence();
}
Esempio n. 8
0
bool KeySequence::operator <(const KeySequence& b) const{
	return sequence < b.getSequence();
}