00001
00002
00003
00004
00005
00006
00007
00008 #include <jsw.h>
00009 #include <iostream>
00010 #include <uvsim/utilities/utilities.h>
00011 #include <cstdlib>
00012
00013 using namespace uvsim;
00014
00015 const char * joystickCalibration = "/usr/share/.joystick";
00016
00017 int main()
00018 {
00019 js_data_struct joystick;
00020
00021 if (!fileExists(joystickCalibration))
00022 {
00023 std::cout << "Error: " << joystickCalibration
00024 << " not found. Please run jscalibrator program and save to "
00025 << joystickCalibration << "." << std::endl;
00026 exit(1);
00027 }
00028 JSInit(&joystick, JSDefaultDevice, joystickCalibration, JSFlagNonBlocking);
00029 joystick.axis[3]->correction_level = 1;
00030 joystick.axis[0]->correction_level = 1;
00031
00032 while (1)
00033 {
00034 JSUpdate(&joystick);
00035 std::cout << "throttle: " << JSGetAxisCoeffNZ(&joystick, 3)
00036 << std::endl;
00037 std::cout << "steering: " << JSGetAxisCoeffNZ(&joystick, 0)
00038 << std::endl;
00039 std::cout << "autoMode: " << JSGetButtonState(&joystick, 0)
00040 << std::endl;
00041 usleep(16000);
00042 }
00043 JSClose(&joystick);
00044 return 0;
00045 }