コード例 #1
0
/*
 * Class:     org_gamepad4j_desktop_GamepadJniWrapper
 * Method:    natDetectPads
 * Signature: ()V
 */
JNIEXPORT void JNICALL Java_org_gamepad4j_desktop_GamepadJniWrapper_natDetectPads
(JNIEnv *env, jobject obj) {
	Gamepad_detectDevices();
	// The following call is required on Windows
	Gamepad_processEvents();
	return;
}
コード例 #2
0
ファイル: Gamepad_linux.cpp プロジェクト: Algomorph/HAL
void Gamepad_init() {
    if (!inited) {
        pthread_mutex_init(&devicesMutex, NULL);
        pthread_mutex_init(&eventQueueMutex, NULL);
        inited = true;
        Gamepad_detectDevices();
    }
}
コード例 #3
0
void GHID::onEnterFrame(int type, void *event, void *udata)
{
    if(type == GEVENT_PRE_TICK_EVENT)
    {
        Gamepad_detectDevices();
        Gamepad_processEvents();
    }
}
コード例 #4
0
// -- ControllerGamepadEnumerator -----
ControllerGamepadEnumerator::ControllerGamepadEnumerator()
	: DeviceEnumerator()
	, m_controllerIndex(-1)
{
	m_deviceType= CommonDeviceState::PSMove;
	assert(m_deviceType >= 0 && GET_DEVICE_TYPE_INDEX(m_deviceType) < MAX_CONTROLLER_TYPE_INDEX);

	Gamepad_detectDevices();
	next();
}
コード例 #5
0
ファイル: Gamepad_linux.c プロジェクト: BluShine/linc_stempad
void Gamepad_init() {
	if (!inited) {
		pthread_mutexattr_t recursiveLock;
		pthread_mutexattr_init(&recursiveLock);
		pthread_mutexattr_settype(&recursiveLock, PTHREAD_MUTEX_RECURSIVE);
		pthread_mutex_init(&devicesMutex, &recursiveLock);
		pthread_mutex_init(&eventQueueMutex, &recursiveLock);
		inited = true;
		Gamepad_detectDevices();
	}
}
コード例 #6
0
ControllerGamepadEnumerator::ControllerGamepadEnumerator(
	CommonDeviceState::eDeviceType deviceTypeFilter)
	: DeviceEnumerator(deviceTypeFilter)
	, m_controllerIndex(-1)
{
	m_deviceType= deviceTypeFilter;
	m_deviceTypeFilter= deviceTypeFilter;
	assert(m_deviceType >= 0 && GET_DEVICE_TYPE_INDEX(m_deviceType) < MAX_CONTROLLER_TYPE_INDEX);

	Gamepad_detectDevices();
	next();
}
コード例 #7
0
ファイル: Gamepad_windows.c プロジェクト: svn2github/libstem
void Gamepad_init() {
	if (!inited) {
		inited = true;
		Gamepad_detectDevices();
	}
}
コード例 #8
0
void JoystickHandler::UpdateJoystick()
{
    Gamepad_detectDevices();
    Gamepad_processEvents();
}
コード例 #9
0
ファイル: main.cpp プロジェクト: Jlaird/AutoFlight_v1
int main(int argc, char *argv[])
{
#ifdef __MINGW32__
	SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX);

	// Set the timer resolution on Windows
    TIMECAPS tc;
    UINT     wTimerRes;

    if(timeGetDevCaps(&tc, sizeof(TIMECAPS)) != TIMERR_NOERROR)
    {
        std::cerr << "FATAL ERROR: Could not determine supported timer resolutions." << std::endl;
        return 1;
    }

    wTimerRes = std::min(std::max((UINT) tc.wPeriodMin, (UINT) TARGET_RESOLUTION), (UINT) tc.wPeriodMax);
    timeBeginPeriod(wTimerRes);
#endif

	// Parse command line options with boost::program_options
	boost::program_options::options_description desc("Available options");
	desc.add_options()
			("help", "show help message")
			("drone", boost::program_options::value<std::string>(), "set which drone to use (ARDrone2 or Bebop, default is ARDrone2)")
            ("script", boost::program_options::value<std::string>(), "load a python script")
            ("script-args", boost::program_options::value<std::vector<std::string>>()->multitoken(), "arguments for the python script")
			("ip-address", boost::program_options::value<std::string>(), "an alternative IP address for the drone (default is 192.168.1.1 for AR.Drone 2.0 and 192.168.42.1 for Bebop)")
			("stream-resolution", boost::program_options::value<std::string>(), "resolution for the live video stream (360P default, can be set to 720P)")
	;

	boost::program_options::variables_map vm;
	boost::program_options::store(boost::program_options::parse_command_line(argc, argv, desc), vm);
	boost::program_options::notify(vm);

	if(vm.count("help"))
	{
	    std::cout << desc << std::endl;
	    return 1;
	}

	drone_type drone_type = BEBOP;
	std::string ip_address = bebop::DEFAULT_IP;
	std::string stream_res = "360P";

	// Detect which drone to use
	if(vm.count("drone"))
	{
		std::string drone_name = vm["drone"].as<std::string>();
		std::transform(drone_name.begin(), drone_name.end(), drone_name.begin(), ::tolower);
		if(drone_name == "ardrone2")
		{
			std::cout << "Using AR.Drone 2.0" << std::endl;
			ip_address = ardrone2::DEFAULT_IP;
			drone_type = ARDRONE2;
		}
		else if(drone_name == "bebop")
		{
			std::cout << "Using Bebop Drone" << std::endl;
			ip_address = bebop::DEFAULT_IP;
			drone_type = BEBOP;
		}
		else
		{
			std::cout << "Drone not supported. Currently only Parrot's AR.Drone 2.0 and Bebop are supported." << std::endl;
		}
	}

	if(vm.count("ip-address"))
	{
		ip_address = vm["ip-address"].as<std::string>();
		std::cout << "Drone IP address manually set to " << ip_address << std::endl;
	}
	else
	{
		std::cout << "Using default Drone IP address ("<< ip_address <<"). Use the --ip-address option to choose a different address." << std::endl;
	}

	if(vm.count("stream-resolution"))
	{
		stream_res = vm["stream-resolution"].as<std::string>();
	}

	std::cout << "Starting AutoFlight...\n";

	Gamepad_init();
	Gamepad_detectDevices();

	AutoFlight af(drone_type, ip_address);

	// TODO: Allow setting stream resolution
	/*
	if(stream_res == "720P")
	{
		af.ardrone2()->setDefaultLiveStreamCodec(ardrone2::config::codec::H264_720P);
		std::cout << "AR.Drone 2.0 live video stream resolution manually set to " << stream_res << std::endl;
	}
	*/

	QApplication gui(argc, argv);

	AFMainWindow w(&af);
	w.show();

    if(vm.count("script"))
    {
        std::string script = vm["script"].as<std::string>();
        std::vector<std::string> args;
        if(vm.count("script-args"))
        {
            args = vm["script-args"].as<std::vector<std::string>>();
        }
        w.launchAutoScriptIDE(script, args);
    }

	gui.exec();

	Gamepad_shutdown();

	//Py_Finalize();

#ifdef __MINGW32__
    timeEndPeriod(wTimerRes);
#endif

	std::cout << "Closing...\n";

	return 0;
}