GHOST_NDOFManagerX11::GHOST_NDOFManagerX11(GHOST_System& sys)
    : GHOST_NDOFManager(sys),
      m_available(false)
{
	setDeadZone(0.1f); /* how to calibrate on Linux? throw away slight motion! */

	if (spnav_open() != -1) {
		m_available = true;

		/* determine exactly which device (if any) is plugged in */

#define MAX_LINE_LENGTH 100

		/* look for USB devices with Logitech or 3Dconnexion's vendor ID */
		FILE *command_output = popen("lsusb | grep '046d:\\|256f:'", "r");
		if (command_output) {
			char line[MAX_LINE_LENGTH] = {0};
			while (fgets(line, MAX_LINE_LENGTH, command_output)) {
				unsigned short vendor_id = 0, product_id = 0;
				if (sscanf(line, "Bus %*d Device %*d: ID %hx:%hx", &vendor_id, &product_id) == 2)
					if (setDevice(vendor_id, product_id)) {
						break; /* stop looking once the first 3D mouse is found */
					}
			}
			pclose(command_output);
		}
	}
	else {
#ifdef DEBUG
		/* annoying for official builds, just adds noise and most people don't own these */
		puts("ndof: spacenavd not found");
		/* This isn't a hard error, just means the user doesn't have a 3D mouse. */
#endif
	}
}
GHOST_NDOFManagerWin32::GHOST_NDOFManagerWin32(GHOST_System& sys)
	: GHOST_NDOFManager(sys)
{
	setDeadZone(0.1f);
}
示例#3
0
static int lSetDeadZone(lua_State *L)
{
	lua_Number dz=luaL_checknumber(L,1);
	setDeadZone(dz);
    return 0;
}