示例#1
0
bool KeyboardDevice::finalize()
{
	SURGSIM_ASSERT(isInitialized());
	SURGSIM_LOG_INFO(m_scaffold->getLogger()) << "Device " << getName() << ": " << "Finalizing.";
	m_scaffold.reset();
	return true;
}
std::vector<std::string> InputDeviceHandle::enumeratePaths(SurgSim::Framework::Logger* logger)
{
	std::vector<std::string> results;

	for (int i = 0;  i < 100;  ++i)
	{
		char devicePath[128];
		snprintf(devicePath, sizeof(devicePath), "/dev/input/event%d", i);

		FileDescriptor handle;
		if (! handle.openForReadingAndMaybeWriting(devicePath))
		{
			int error = errno;
			if (error != ENOENT)
			{
				SURGSIM_LOG_INFO(logger) << "InputDeviceHandle::enumeratePaths: Could not open device " << devicePath <<
					": error " << error << ", " << getSystemErrorText(error);
			}
			continue;
		}

		results.push_back(devicePath);
	}

	return results;
}
示例#3
0
bool KeyboardDevice::initialize()
{
	SURGSIM_ASSERT(!isInitialized());

	m_scaffold = KeyboardScaffold::getOrCreateSharedInstance();
	SURGSIM_ASSERT(m_scaffold);

	m_scaffold->registerDevice(this);
	SURGSIM_LOG_INFO(m_scaffold->getLogger()) << "Device " << getName() << ": " << "Initialized.";

	return true;
}
示例#4
0
bool OsgManager::addRepresentation(std::shared_ptr<SurgSim::Graphics::Representation> representation)
{
	std::shared_ptr<OsgRepresentation> osgRepresentation = std::dynamic_pointer_cast<OsgRepresentation>(representation);
	bool result;
	if (osgRepresentation)
	{
		result = Manager::addRepresentation(osgRepresentation);
	}
	else
	{
		SURGSIM_LOG_INFO(getLogger())
				<< __FUNCTION__ << " Representation is not a subclass of OsgRepresentation "
				<< representation->getName();
		result = false;
	}
	return result;
}
bool InputDeviceHandle::hasAbsoluteTranslationAndRotationAxes() const
{
	BitSetBuffer<ABS_CNT> buffer;
	if (ioctl(m_state->handle.get(), EVIOCGBIT(EV_ABS, buffer.sizeBytes()), buffer.getPointer()) == -1)
	{
		int error = errno;
		SURGSIM_LOG_DEBUG(m_state->logger) << "InputDeviceHandle: ioctl(EVIOCGBIT(EV_ABS)): error " <<
			error << ", " << getSystemErrorText(error);
		return false;
	}

	if (! buffer.test(ABS_X) || ! buffer.test(ABS_Y) || ! buffer.test(ABS_Z) ||
		! buffer.test(ABS_RX) || ! buffer.test(ABS_RY) || ! buffer.test(ABS_RZ))
	{
		SURGSIM_LOG_DEBUG(m_state->logger) << "InputDeviceHandle: does not have the 6 absolute axes.";
		return false;
	}

	int numIgnoredAxes = 0;
	for (size_t i = 0;  i < ABS_CNT;  ++i)
	{
		if (buffer.test(i))
		{
			if ((i != ABS_X) && (i != ABS_Y) && (i != ABS_Z) && (i != ABS_RX) && (i != ABS_RY) && (i != ABS_RZ))
			{
				++numIgnoredAxes;
			}
		}
	}


	if (numIgnoredAxes)
	{
		SURGSIM_LOG_INFO(m_state->logger) << "InputDeviceHandle: has absolute translation and rotation axes;" <<
			" ignoring " << numIgnoredAxes << " additional axes.";
	}

	return true;
}