jstest-gtk-0.1.1~git20090722/0002755000175000017500000000000011531037716014404 5ustar stevestevejstest-gtk-0.1.1~git20090722/TODO0000644000175000017500000001243011531037643015071 0ustar stevestevePre Release Testing: ==================== * check the version number VERSION="0.1.0" TAG="v${VERSION}" git tag -s "${TAG}" -m "jstest-gtk ${TAG}" git archive --format=tar --prefix="jstest-gtk-${VERSION}/" ${TAG} | bzip2 -c > /tmp/jstest-gtk-${VERSION}.tar.bz2 git push --tags ========== [[ TODO ]] ========== * display "No joystick found" when no joystick is available * [ Save Profile ] |-----------------------| | Name: ............... | | [*] save calibration | | [*] save calibration | | [Cancel] [Ok] | Give Overwrite warning when name matches existing one. * implement command line profile load * use while loop in Joystick::update * don't pop up new dialogs when old ones are still present * [FEATURE] Load and save presets in devices, and to load them automatically when you connect the device. * [CLEANUP] sync evtest_helper.?pp, make sure no boost dependency is present * [CLEANUP] center font in ButtonWidget (current way is a dirty hack) * [FEATURE] axis names (ABS_X, ...) should be used instead of raw axis numbers to guess which layout is correct, also the layout should be properly labeled * [BUG] add some more checks to catch invalid button/axis mappings supplied to the joydev interface * [FEATURE] provide additional support for SDL and evdev devices ================================= [[ Possible Future Improvments ]] ================================= * [FEATURE] Possibility of activate noise reduction in joystick axis (read only field, but can't hurd to have it, in case any app wants to play with it) * Joystick Database, base it on evdev, not joydev: * [FEATURE] Watch the system, maybe being in systray, to protect the device from accidental reconfiguration by another application. (unlikely, as that would mean polling and other then jscalibrator there isn't much to mess up joystick calibration) * draw calibration icon * draw mapping icon * Joystick name of a joydev is taken from USB and build up of (iManufacturer + iProduct), but thats ugly, (idVendor + idProduct) or just idProduct would give much prettier name: idVendor 0x045e Microsoft Corp. idProduct 0x0007 SideWinder Game Pad bcdDevice 1.05 iManufacturer 1 Microsoft iProduct 2 Microsoft SideWinder Game Pad USB * the joystick name seems to be the only way to link from a joydev to a evdev, hack some code together to accomplish that as it would allow proper reset of calibration data * axis names very buggy: - ABS_RZ instead of ABS_RUDDER (Sidewinder2) - ABS_RZ,ABS_THROTTLE instead of ABS_RX,ABS_RY (Thrustmaster gamepad) - BTN_TL2,BTN_TR2 instead of BTN_START, BTN_MODE (Sidewinder gamepad) - ... * create a small database with most common joysticks, maybe add a way how a user can automatically submit his joystick profile, to ease the database generation ================== [[ Random Notes ]] ================== * jscal: # Remove any calibration and report raw USB data jsscal -s 6,0,0,0,0,0,0,0,0,0,0,0,0 /dev/input/js0 jscal -s 6, // number of axes .--- type (0: raw, 1: "broken line") | .--- prec (seems to be read only, taken for evdev's absfuzz) | | .---.- coef[0], coef[1], ... v v v v 1, 0, -15, 15, 5534751, 5534751, ??? 1, 0, -15, 15, 5534751, 5534751, 1, 0, -15, 15, 5534751, 5534751, 1, 0, 112, 142, 5534751, 5534751, 1, 0, 0, 0, 536870912, 536870912, (1<<29) 1, 0, 0, 0, 536870912, 536870912 type == 0 -> none of coef used type == 1 -> coef[0:4] used type == 0 -> "none (raw)" type == 1 -> "broken line" # Original jscal -s 6,1,0,-15,15,5534751,5534751,1,0,-15,15,5534751,5534751,1,0,-15,15,5534751,5534751,1,0,112,142,5534751,5534751,1,0,0,0,536870912,536870912,1,0,0,0,536870912,536870912 /dev/input/js0 # No Dead jscal -s 6,1,0,0,0,5534751,5534751,1,0,0,0,5534751,5534751,1,0,0,0,5534751,5534751,1,0,112,142,5534751,5534751,1,0,0,0,536870912,536870912,1,0,0,0,536870912,536870912 /dev/input/js0 int solve_broken(int *results /* coef[4] */, struct correction_data inputs) { results[0] = inputs.cmin[CENTER]; results[1] = inputs.cmax[CENTER]; results[2] = (32767.0 / (inputs.cmin[CENTER] - inputs.cmax[MINIMUM])) * 16384.0; results[3] = (32767.0 / (inputs.cmin[MAXIMUM] - inputs.cmax[CENTER])) * 16384.0; results[2] = (32767 * 16384) / left_range results[3] = (32767 * 16384) / left_range // in float terms: // [2] = 1.0f / left_range; // [3] = 1.0f / right_range; return 1; } Apply coef: =========== if (value > corr->coef[0]) { if (value < corr->coef[1]) { value = 0; } else { value = (corr->coef[3] * (value - corr->coef[1])) / 16384; } } else { value = (corr->coef[2] * (value - corr->coef[0])) / 16384; } return value < -32767 ? -32767 : (value > 32767 ? 32767 : value); Set coef: ========= joydev->corr[i].type = JS_CORR_BROKEN; joydev->corr[i].prec = dev->absfuzz[j]; joydev->corr[i].coef[0] = (dev->absmax[j] + dev->absmin[j]) / 2 - dev->absflat[j]; joydev->corr[i].coef[1] = (dev->absmax[j] + dev->absmin[j]) / 2 + dev->absflat[j]; t = (dev->absmax[j] - dev->absmin[j]) / 2 - 2 * dev->absflat[j]; if (t) { joydev->corr[i].coef[2] = (1 << 29) / t; joydev->corr[i].coef[3] = (1 << 29) / t; } # EOF # jstest-gtk-0.1.1~git20090722/src/0002755000175000017500000000000011531037643015172 5ustar stevestevejstest-gtk-0.1.1~git20090722/src/joystick_test_widget.cpp0000644000175000017500000003136611531037643022146 0ustar stevesteve/* ** jstest-gtk - A graphical joystick tester ** Copyright (C) 2009 Ingo Ruhnke ** ** This program is free software: you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation, either version 3 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program. If not, see . */ #include #include #include #include #include #include #include "xml_writer.hpp" #include "main.hpp" #include "joystick.hpp" #include "button_widget.hpp" #include "joystick_map_widget.hpp" #include "joystick_calibration_widget.hpp" #include "joystick_test_widget.hpp" JoystickTestWidget::JoystickTestWidget(Joystick& joystick_) : Gtk::Dialog(joystick_.get_name()), joystick(joystick_), label("" + joystick.get_name() + "\nDevice: " + joystick.get_filename() , Gtk::ALIGN_LEFT, Gtk::ALIGN_CENTER), profile_save_button(Gtk::Stock::SAVE_AS), profile_delete_button(Gtk::Stock::DELETE), axis_frame("Axes"), button_frame("Buttons"), button_table((joystick.get_button_count()-1) / 8 + 1, std::min(joystick.get_button_count(), 8)), mapping_button("Mapping"), calibration_button("Calibration"), buttonbox(Gtk::BUTTONBOX_SPREAD), stick1_widget(128, 128), stick2_widget(128, 128), stick3_widget(128, 128), rudder_widget(128, 32), throttle_widget(32, 128), left_trigger_widget(32, 128, true), right_trigger_widget(32, 128, true) { label.set_use_markup(true); label.set_selectable(); profile_delete_button.set_tooltip_text("Delete the current profile"); profile_save_button.set_tooltip_text("Save the current configuration into a profile"); profile_hbox.pack_start(profile_delete_button, Gtk::PACK_SHRINK); profile_hbox.pack_start(profile_save_button, Gtk::PACK_SHRINK); profile_hbox.add(profile_entry); profile_delete_button.signal_clicked().connect(sigc::mem_fun(this, &JoystickTestWidget::on_delete_profile)); profile_save_button.signal_clicked().connect(sigc::mem_fun(this, &JoystickTestWidget::on_save_profile)); axis_frame.set_border_width(5); axis_table.set_border_width(5); axis_table.set_spacings(5); button_frame.set_border_width(5); button_table.set_border_width(5); button_table.set_spacings(8); buttonbox.set_border_width(5); // Use two columns for large number of axes if (joystick.get_axis_count() > 15) axis_table.resize((joystick.get_axis_count()+1)/2, 4); else axis_table.resize(joystick.get_axis_count(), 2); for(int i = 0; i < joystick.get_axis_count(); ++i) { std::ostringstream str; str << "Axis " << i << ": "; Gtk::Label& label = *Gtk::manage(new Gtk::Label(str.str())); Gtk::ProgressBar& progressbar = *Gtk::manage(new Gtk::ProgressBar()); progressbar.set_fraction(0.5); if (i >= (int)axis_table.property_n_rows()) { axis_table.attach(label, 2, 3, i - axis_table.property_n_rows(), i+1 - axis_table.property_n_rows(), Gtk::SHRINK, Gtk::FILL); axis_table.attach(progressbar, 3, 4, i - axis_table.property_n_rows(), i+1 - axis_table.property_n_rows(), Gtk::FILL|Gtk::EXPAND, Gtk::EXPAND); } else { axis_table.attach(label, 0, 1, i, i+1, Gtk::SHRINK, Gtk::FILL); axis_table.attach(progressbar, 1, 2, i, i+1, Gtk::FILL|Gtk::EXPAND, Gtk::EXPAND); } axes.push_back(&progressbar); } for(int i = 0; i < joystick.get_button_count(); ++i) { int x = i % 8; int y = i / 8; std::ostringstream str; str << i; ButtonWidget& button = *Gtk::manage(new ButtonWidget(32, 32, str.str())); button_table.attach(button, x, x+1, y, y+1, Gtk::EXPAND, Gtk::EXPAND); buttons.push_back(&button); } alignment.set_padding(8, 8, 8, 8); alignment.add(label); get_vbox()->pack_start(alignment, Gtk::PACK_SHRINK); buttonbox.add(mapping_button); buttonbox.add(calibration_button); get_vbox()->pack_start(profile_hbox, Gtk::PACK_SHRINK); get_vbox()->pack_start(axis_frame, Gtk::PACK_EXPAND_WIDGET); get_vbox()->pack_start(button_frame, Gtk::PACK_EXPAND_WIDGET); get_vbox()->pack_start(buttonbox, Gtk::PACK_SHRINK); stick_hbox.set_border_width(5); axis_callbacks.clear(); // Using manual loop instead of resize, as else all the signals // would be clones of each other, instead of individual signals for(int i = 0; i < (int)joystick.get_axis_count(); ++i) axis_callbacks.push_back(sigc::signal()); if (joystick.get_axis_count() == 2) // Simple stick { stick_hbox.pack_start(stick1_widget, Gtk::PACK_EXPAND_PADDING); axis_callbacks[0].connect(sigc::mem_fun(stick1_widget, &AxisWidget::set_x_axis)); axis_callbacks[1].connect(sigc::mem_fun(stick1_widget, &AxisWidget::set_y_axis)); } else if (joystick.get_axis_count() == 6) // Flightstick { Gtk::Table& table = *Gtk::manage(new Gtk::Table(2, 2)); table.attach(stick1_widget, 0, 1, 0, 1, Gtk::SHRINK, Gtk::SHRINK); table.attach(rudder_widget, 0, 1, 1, 2, Gtk::SHRINK, Gtk::SHRINK); table.attach(throttle_widget, 1, 2, 0, 1, Gtk::SHRINK, Gtk::SHRINK); stick_hbox.pack_start(table, Gtk::PACK_EXPAND_PADDING); stick_hbox.pack_start(stick3_widget, Gtk::PACK_EXPAND_PADDING); axis_callbacks[0].connect(sigc::mem_fun(stick1_widget, &AxisWidget::set_x_axis)); axis_callbacks[1].connect(sigc::mem_fun(stick1_widget, &AxisWidget::set_y_axis)); axis_callbacks[2].connect(sigc::mem_fun(rudder_widget, &RudderWidget::set_pos)); axis_callbacks[3].connect(sigc::mem_fun(throttle_widget, &ThrottleWidget::set_pos)); axis_callbacks[4].connect(sigc::mem_fun(stick3_widget, &AxisWidget::set_x_axis)); axis_callbacks[5].connect(sigc::mem_fun(stick3_widget, &AxisWidget::set_y_axis)); } else if (joystick.get_axis_count() == 6) // Dual Analog Gamepad { // FIXME: never reached as this is the same as Flightstick, no // way to tell them apart from simple axis count stick_hbox.pack_start(stick1_widget, Gtk::PACK_EXPAND_PADDING); stick_hbox.pack_start(stick2_widget, Gtk::PACK_EXPAND_PADDING); stick_hbox.pack_start(stick3_widget, Gtk::PACK_EXPAND_PADDING); axis_callbacks[0].connect(sigc::mem_fun(stick1_widget, &AxisWidget::set_x_axis)); axis_callbacks[1].connect(sigc::mem_fun(stick1_widget, &AxisWidget::set_y_axis)); axis_callbacks[2].connect(sigc::mem_fun(stick2_widget, &AxisWidget::set_x_axis)); axis_callbacks[3].connect(sigc::mem_fun(stick2_widget, &AxisWidget::set_y_axis)); axis_callbacks[4].connect(sigc::mem_fun(stick3_widget, &AxisWidget::set_x_axis)); axis_callbacks[5].connect(sigc::mem_fun(stick3_widget, &AxisWidget::set_y_axis)); } else if (joystick.get_axis_count() == 8) // Dual Analog Gamepad + Analog Trigger { stick_hbox.pack_start(stick1_widget, Gtk::PACK_EXPAND_PADDING); stick_hbox.pack_start(stick2_widget, Gtk::PACK_EXPAND_PADDING); stick_hbox.pack_start(stick3_widget, Gtk::PACK_EXPAND_PADDING); stick_hbox.pack_start(left_trigger_widget, Gtk::PACK_EXPAND_PADDING); stick_hbox.pack_start(right_trigger_widget, Gtk::PACK_EXPAND_PADDING); axis_callbacks[0].connect(sigc::mem_fun(stick1_widget, &AxisWidget::set_x_axis)); axis_callbacks[1].connect(sigc::mem_fun(stick1_widget, &AxisWidget::set_y_axis)); axis_callbacks[2].connect(sigc::mem_fun(stick2_widget, &AxisWidget::set_x_axis)); axis_callbacks[3].connect(sigc::mem_fun(stick2_widget, &AxisWidget::set_y_axis)); axis_callbacks[6].connect(sigc::mem_fun(stick3_widget, &AxisWidget::set_x_axis)); axis_callbacks[7].connect(sigc::mem_fun(stick3_widget, &AxisWidget::set_y_axis)); axis_callbacks[4].connect(sigc::mem_fun(left_trigger_widget, &ThrottleWidget::set_pos)); axis_callbacks[5].connect(sigc::mem_fun(right_trigger_widget, &ThrottleWidget::set_pos)); } else if (joystick.get_axis_count() == 7) // Dual Analog Gamepad DragonRise Inc. Generic USB Joystick { stick_hbox.pack_start(stick1_widget, Gtk::PACK_EXPAND_PADDING); stick_hbox.pack_start(stick2_widget, Gtk::PACK_EXPAND_PADDING); stick_hbox.pack_start(stick3_widget, Gtk::PACK_EXPAND_PADDING); axis_callbacks[0].connect(sigc::mem_fun(stick1_widget, &AxisWidget::set_x_axis)); axis_callbacks[1].connect(sigc::mem_fun(stick1_widget, &AxisWidget::set_y_axis)); axis_callbacks[3].connect(sigc::mem_fun(stick2_widget, &AxisWidget::set_x_axis)); axis_callbacks[4].connect(sigc::mem_fun(stick2_widget, &AxisWidget::set_y_axis)); axis_callbacks[5].connect(sigc::mem_fun(stick3_widget, &AxisWidget::set_x_axis)); axis_callbacks[6].connect(sigc::mem_fun(stick3_widget, &AxisWidget::set_y_axis)); } else if (joystick.get_axis_count() == 28) // Playstation 3 Controller { stick_hbox.pack_start(stick1_widget, Gtk::PACK_EXPAND_PADDING); stick_hbox.pack_start(stick2_widget, Gtk::PACK_EXPAND_PADDING); // Not using stick3 for now, as the dpad is 4 axis on the PS3, not 2 (one for each direction) //stick_hbox.pack_start(stick3_widget, Gtk::PACK_EXPAND_PADDING); stick_hbox.pack_start(left_trigger_widget, Gtk::PACK_EXPAND_PADDING); stick_hbox.pack_start(right_trigger_widget, Gtk::PACK_EXPAND_PADDING); axis_callbacks[0].connect(sigc::mem_fun(stick1_widget, &AxisWidget::set_x_axis)); axis_callbacks[1].connect(sigc::mem_fun(stick1_widget, &AxisWidget::set_y_axis)); axis_callbacks[2].connect(sigc::mem_fun(stick2_widget, &AxisWidget::set_x_axis)); axis_callbacks[3].connect(sigc::mem_fun(stick2_widget, &AxisWidget::set_y_axis)); //axis_callbacks[6].connect(sigc::mem_fun(stick3_widget, &AxisWidget::set_x_axis)); //axis_callbacks[7].connect(sigc::mem_fun(stick3_widget, &AxisWidget::set_y_axis)); axis_callbacks[12].connect(sigc::mem_fun(left_trigger_widget, &ThrottleWidget::set_pos)); axis_callbacks[13].connect(sigc::mem_fun(right_trigger_widget, &ThrottleWidget::set_pos)); } else { std::cout << "Warning: unknown joystick, not displaying graphical representation." << std::endl; } axis_vbox.pack_start(stick_hbox, Gtk::PACK_SHRINK); axis_vbox.add(axis_table); axis_frame.add(axis_vbox); button_frame.add(button_table); add_button(Gtk::Stock::CLOSE, 0); signal_response().connect(sigc::mem_fun(this, &JoystickTestWidget::on_response)); joystick.axis_move.connect(sigc::mem_fun(this, &JoystickTestWidget::axis_move)); joystick.button_move.connect(sigc::mem_fun(this, &JoystickTestWidget::button_move)); calibration_button.signal_clicked().connect(sigc::mem_fun(this, &JoystickTestWidget::on_calibrate)); mapping_button.signal_clicked().connect(sigc::mem_fun(this, &JoystickTestWidget::on_mapping)); } void JoystickTestWidget::axis_move(int number, int value) { axes.at(number)->set_fraction((value + 32767) / (double)(2*32767)); std::ostringstream str; str << value; axes.at(number)->set_text(str.str()); axis_callbacks[number](value / 32767.0); } void JoystickTestWidget::button_move(int number, bool value) { if (value) buttons.at(number)->set_down(true); else buttons.at(number)->set_down(false); } void JoystickTestWidget::on_calibrate() { Main::current()->show_calibration_dialog(joystick); } void JoystickTestWidget::on_mapping() { Main::current()->show_mapping_dialog(joystick); } void JoystickTestWidget::on_response(int v) { hide(); } void JoystickTestWidget::on_save_profile() { on_save_profile_as("Hello World"); } void JoystickTestWidget::on_save_profile_as(const std::string& name) { std::ostringstream profile_name; profile_name << "Profile " << profile_entry.get_model()->children().size(); profile_entry.append_text(profile_name.str()); profile_entry.set_active_text(profile_name.str()); std::ostringstream filename; filename << Main::current()->get_cfg_directory() << "/" << "profile" << profile_entry.get_model()->children().size() << ".xml"; XMLWriter out(filename.str()); out.start_section("joysticks"); joystick.write(out); out.end_section("joysticks"); } void JoystickTestWidget::on_delete_profile() { // FIXME: Bad idea, could lead to deletion of the wrong entry when text is the same profile_entry.remove_text(profile_entry.get_active_text()); } /* EOF */ jstest-gtk-0.1.1~git20090722/src/calibrate_maximum_dialog.cpp0000644000175000017500000000656211531037643022707 0ustar stevesteve/* ** jstest-gtk - A graphical joystick tester ** Copyright (C) 2009 Ingo Ruhnke ** ** This program is free software: you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation, either version 3 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program. If not, see . */ #include #include #include "joystick.hpp" #include "calibrate_maximum_dialog.hpp" CalibrateMaximumDialog::CalibrateMaximumDialog(Joystick& joystick_) : Gtk::Dialog("CalibrationWizard: " + joystick_.get_name()), joystick(joystick_), orig_data(joystick.get_calibration()), label("1) Rotate your joystick around to move all axis into their extreme positions at least once\n" "2) Move all axis back to the center\n" "3) Press ok\n") { joystick.clear_calibration(); set_border_width(5); set_has_separator(false); label.set_line_wrap(); get_vbox()->add(label); add_button(Gtk::Stock::CANCEL, 1); add_button(Gtk::Stock::OK, 0); connection = joystick.axis_move.connect(sigc::mem_fun(this, &CalibrateMaximumDialog::on_axis_move)); is_init_axis_state.resize(joystick.get_axis_count(), false); min_axis_state.resize(joystick.get_axis_count()); max_axis_state.resize(joystick.get_axis_count()); for(int i = 0; i < joystick.get_axis_count(); ++i) { min_axis_state[i] = joystick.get_axis_state(i); max_axis_state[i] = joystick.get_axis_state(i); } } void CalibrateMaximumDialog::on_response(int v) { if (v == 0) { // Calculate CalibrationData std::vector data; for(int i = 0; i < joystick.get_axis_count(); ++i) { Joystick::CalibrationData axis; axis.calibrate = true; axis.invert = false; axis.center_min = axis.center_max = joystick.get_axis_state(i); axis.range_min = min_axis_state[i]; axis.range_max = max_axis_state[i]; // When the center is the same as the outer edge of an axis, // we assume its a throttle control or analog button and // calculate the center on our own if (axis.center_min == axis.range_min || axis.center_max == axis.range_max) { axis.center_min = axis.center_max = (axis.range_min + axis.range_max)/2; } data.push_back(axis); } joystick.set_calibration(data); hide(); } else { joystick.set_calibration(orig_data); } } void CalibrateMaximumDialog::on_axis_move(int id, int value) { // std::cout << "AxisMove: " << id << " " << value << std::endl; if (!is_init_axis_state[id]) { min_axis_state[id] = value; max_axis_state[id] = value; is_init_axis_state[id] = true; } else { min_axis_state[id] = std::min(value, min_axis_state[id]); max_axis_state[id] = std::max(value, max_axis_state[id]); } } /* EOF */ jstest-gtk-0.1.1~git20090722/src/throttle_widget.hpp0000644000175000017500000000234311531037643021113 0ustar stevesteve/* ** jstest-gtk - A graphical joystick tester ** Copyright (C) 2009 Ingo Ruhnke ** ** This program is free software: you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation, either version 3 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program. If not, see . */ #ifndef HEADER_JSTEST_GTK_THROTTLE_WIDGET_HPP #define HEADER_JSTEST_GTK_THROTTLE_WIDGET_HPP #include class ThrottleWidget : public Gtk::DrawingArea { private: bool invert; double pos; public: ThrottleWidget(int width, int height, bool invert = false); bool on_expose_event(GdkEventExpose* event); void set_pos(double p); private: ThrottleWidget(const ThrottleWidget&); ThrottleWidget& operator=(const ThrottleWidget&); }; #endif /* EOF */ jstest-gtk-0.1.1~git20090722/src/joystick_list_widget.hpp0000644000175000017500000000327111531037643022141 0ustar stevesteve/* ** jstest-gtk - A graphical joystick tester ** Copyright (C) 2009 Ingo Ruhnke ** ** This program is free software: you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation, either version 3 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program. If not, see . */ #ifndef HEADER_JSTEST_GTK_JOYSTICK_LIST_WIDGET_HPP #define HEADER_JSTEST_GTK_JOYSTICK_LIST_WIDGET_HPP #include #include #include #include #include #include #include #include class JoystickListWidget : public Gtk::Dialog { private: Gtk::Label label; Gtk::Frame frame; Gtk::ScrolledWindow scrolled; Gtk::TreeView treeview; Gtk::HButtonBox buttonbox; Gtk::Button refresh_button; Gtk::Button properties_button; Glib::RefPtr device_list; public: JoystickListWidget(); void on_refresh(); void on_properties(); void on_response(int v); void on_row_activated(const Gtk::TreeModel::Path& path, Gtk::TreeViewColumn* column); private: JoystickListWidget(const JoystickListWidget&); JoystickListWidget& operator=(const JoystickListWidget&); }; #endif /* EOF */ jstest-gtk-0.1.1~git20090722/src/main.cpp0000644000175000017500000001405511531037643016625 0ustar stevesteve/* ** jstest-gtk - A graphical joystick tester ** Copyright (C) 2009 Ingo Ruhnke ** ** This program is free software: you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation, either version 3 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program. If not, see . */ #include #include #include #include #include #include #include #include "joystick_test_widget.hpp" #include "joystick_list_widget.hpp" #include "joystick_map_widget.hpp" #include "joystick_calibration_widget.hpp" #include "joystick.hpp" #include "main.hpp" #include "xml_writer.hpp" Main* Main::current_ = 0; Main::Main() : list_dialog(0) { current_ = this; } Main::~Main() { } void Main::show_device_list_dialog() { if (list_dialog) { list_dialog->show(); } else { list_dialog = new JoystickListWidget(); list_dialog->show_all(); } } void Main::show_device_property_dialog(const std::string& filename) { Joystick* joystick = new Joystick(filename); JoystickTestWidget* dialog = new JoystickTestWidget(*joystick); dialog->signal_hide().connect(sigc::bind(sigc::mem_fun(this, &Main::on_dialog_hide), dialog)); dialog->show_all(); joysticks.push_back(joystick); dialogs.push_back(dialog); } void Main::show_calibration_dialog(Joystick& joystick) { JoystickCalibrationWidget* dialog = new JoystickCalibrationWidget(joystick); dialog->signal_hide().connect(sigc::bind(sigc::mem_fun(this, &Main::on_dialog_hide), dialog)); dialog->show_all(); dialogs.push_back(dialog); } void Main::show_mapping_dialog(Joystick& joystick) { JoystickMapWidget* dialog = new JoystickMapWidget(joystick); dialog->signal_hide().connect(sigc::bind(sigc::mem_fun(this, &Main::on_dialog_hide), dialog)); dialog->show_all(); dialogs.push_back(dialog); } void Main::on_dialog_hide(Gtk::Dialog* dialog) { dialogs.erase(std::remove(dialogs.begin(), dialogs.end(), dialog), dialogs.end()); delete dialog; if (dialogs.empty()) { Gtk::Main::quit(); } } int Main::main(int argc, char** argv) { typedef std::vector DeviceFiles; DeviceFiles device_files; std::string config_save_file; for(int i = 1; i < argc; ++i) { if (strcmp("--help", argv[i]) == 0 || strcmp("-h", argv[i]) == 0) { std::cout << "Usage: " << argv[0] << " [OPTIONS]... [DEVICE]...\n" << "A graphical joystick tester.\n" << "\n" << "Options:\n" << " -h, --help Display this help and exit\n" << " -v, --version Display version information and exit\n" << " -l, --load CFG Load load configuration from file and apply them\n" << " -s, --save CFG Save current device configuration to file CFG\n" << "\n" << "Report bugs to Ingo Ruhnke .\n"; return 0; } else if (strcmp("--load", argv[i]) == 0 || strcmp("-l", argv[i]) == 0) { ++i; if (i < argc) { std::cout << "Configuration file load is not yet implemented" << std::endl; return 0; } else { std::cout << "Error: " << argv[i-1] << " expected an argument" << std::endl; exit(EXIT_FAILURE); } } else if (strcmp("--save", argv[i]) == 0 || strcmp("-s", argv[i]) == 0) { ++i; if (i < argc) { config_save_file = argv[i]; } else { std::cout << "Error: " << argv[i-1] << " expected an argument" << std::endl; exit(EXIT_FAILURE); } } else if (strcmp("--version", argv[i]) == 0 || strcmp("-v", argv[i]) == 0) { std::cout << "jstest-gtk 0.1.0" << std::endl; return 0; } else if (argv[i][0] == '-') { std::cout << "Error: " << argv[0] << ": unrecognized option '" << argv[i] << "'" << std::endl; return EXIT_FAILURE; } else { device_files.push_back(argv[i]); } } if (!config_save_file.empty()) { XMLWriter out(config_save_file); out.start_section("joysticks"); for(DeviceFiles::iterator i = device_files.begin(); i != device_files.end(); ++i) { Joystick joystick(*i); joystick.write(out); } out.end_section("joysticks"); } else { Glib::set_application_name("Joystick Test"); Glib::set_prgname("jstest-gtk"); cfg_directory = Glib::build_filename(Glib::get_user_config_dir(), Glib::get_prgname()); if (access(cfg_directory.c_str(), R_OK | W_OK) != 0 && mkdir(cfg_directory.c_str(), 0770) != 0) { throw std::runtime_error(cfg_directory + ": " + strerror(errno)); } Gtk::Main kit(&argc, &argv); if (device_files.empty()) { show_device_list_dialog(); } else { for(DeviceFiles::iterator i = device_files.begin(); i != device_files.end(); ++i) { show_device_property_dialog(*i); } } Gtk::Main::run(); } return 0; } int main(int argc, char** argv) { try { Main app; return app.main(argc, argv); } catch(std::exception& err) { std::cout << "Error: " << err.what() << std::endl; return EXIT_FAILURE; } } /* EOF */ jstest-gtk-0.1.1~git20090722/src/axis_widget.hpp0000644000175000017500000000241011531037643020205 0ustar stevesteve/* ** jstest-gtk - A graphical joystick tester ** Copyright (C) 2009 Ingo Ruhnke ** ** This program is free software: you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation, either version 3 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program. If not, see . */ #ifndef HEADER_JSTEST_GTK_AXIS_WIDGET_HPP #define HEADER_JSTEST_GTK_AXIS_WIDGET_HPP #include #include class AxisWidget : public Gtk::Alignment { private: Gtk::DrawingArea drawingarea; double x; double y; public: AxisWidget(int width, int height); bool on_my_expose_event(GdkEventExpose* event); void set_x_axis(double x); void set_y_axis(double x); private: AxisWidget(const AxisWidget&); AxisWidget& operator=(const AxisWidget&); }; #endif /* EOF */ jstest-gtk-0.1.1~git20090722/src/rudder_widget.cpp0000644000175000017500000000406311531037643020527 0ustar stevesteve/* ** jstest-gtk - A simple joystick test and calibration utility ** Copyright (C) 2009 Ingo Ruhnke ** ** This program is free software: you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation, either version 3 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program. If not, see . */ #include "rudder_widget.hpp" RudderWidget::RudderWidget(int width, int height) : pos(0.0) { set_size_request(width, height); } bool RudderWidget::on_expose_event(GdkEventExpose* event) { double p = (pos + 1.0)/2.0; if (0) { get_window()->draw_rectangle(get_style()->get_fg_gc(get_state()), true, (get_allocation().get_width() * p) - 4, 0, 9, get_allocation().get_height()-1); } Glib::RefPtr window = get_window(); if(window) { Cairo::RefPtr cr = window->create_cairo_context(); int w = get_allocation().get_width()-10; int h = get_allocation().get_height()-10; cr->translate(5, 5); // Outer Rectangle cr->set_source_rgb(0.0, 0.0, 0.0); cr->set_line_width(1.0); cr->rectangle(0, 0, w, h); cr->stroke(); cr->set_source_rgba(0.0, 0.0, 0.0, 0.5); cr->move_to(w/2, 0); cr->line_to(w/2, h); cr->stroke(); cr->set_line_width(2.0); cr->set_source_rgb(0.0, 0.0, 0.0); cr->move_to(w * p, 0); cr->line_to(w * p, h); cr->stroke(); } return true; } void RudderWidget::set_pos(double p) { pos = p; queue_draw(); } /* EOF */ jstest-gtk-0.1.1~git20090722/src/button_widget.cpp0000644000175000017500000000346111531037643020556 0ustar stevesteve/* ** jstest-gtk - A graphical joystick tester ** Copyright (C) 2009 Ingo Ruhnke ** ** This program is free software: you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation, either version 3 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program. If not, see . */ #include "button_widget.hpp" ButtonWidget::ButtonWidget(int width, int height, const std::string& name_) : name(name_) { set_size_request(width, height); } bool ButtonWidget::on_expose_event(GdkEventExpose* event) { Gtk::DrawingArea::on_expose_event(event); Glib::RefPtr window = get_window(); if(window) { Cairo::RefPtr cr = window->create_cairo_context(); int w = get_allocation().get_width() - 10; int h = get_allocation().get_height() - 10; cr->set_source_rgb(0.0, 0.0, 0.0); cr->set_line_width(1.0); cr->translate(5, 5); cr->rectangle(0, 0, w, h); if (down) cr->fill_preserve(); cr->stroke(); if (down) cr->set_source_rgb(1.0, 1.0, 1.0); // FIXME: There are better ways to center text if (name.size() == 2) cr->move_to(w/2-6, h/2+3); else cr->move_to(w/2-4, h/2+3); cr->show_text(name); } return true; } void ButtonWidget::set_down(bool t) { down = t; queue_draw(); } /* EOF */ jstest-gtk-0.1.1~git20090722/src/xml_parser.cpp0000644000175000017500000001037011531037643020051 0ustar stevesteve/* ** jstest-gtk - A graphical joystick tester ** Copyright (C) 2009 Ingo Ruhnke ** ** This program is free software: you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation, either version 3 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program. If not, see . */ #include #include #include #include #include #include "xml_parser.hpp" // static C functions that map back to the C++ member functions void XMLParser::start_element(void* userdata, const char* el, const char** attr) { static_cast(userdata)->on_start_element(el, attr); } void XMLParser::end_element(void* userdata, const char* el) { static_cast(userdata)->on_end_element(el); } void XMLParser::character_data(void* userdata, const char* s, int len) { static_cast(userdata)->on_character_data(s, len); } std::auto_ptr XMLParser::parse(const std::string& filename) { XMLParser tree(filename); return tree.get_root(); } XMLParser::XMLParser(const std::string& filename_) : filename(filename_), parser(0) { std::vector data; { // Read the file into the vector data std::ifstream in(filename.c_str(), std::ios::binary); if (!in) { throw std::runtime_error("couldn't open: " + filename); } else { in.seekg (0, std::ios::end); data.resize(in.tellg()); in.seekg (0, std::ios::beg); in.read(&*data.begin(), data.size()); } } parser = XML_ParserCreate(NULL); XML_SetUserData(parser, this); XML_SetElementHandler(parser, &start_element, &end_element); XML_SetCharacterDataHandler(parser, &character_data); if (XML_Parse(parser, &*data.begin(), data.size(), 0) == XML_STATUS_ERROR) { std::ostringstream out; out << filename << ":" << XML_GetCurrentLineNumber(parser) << ": parse error: " << XML_ErrorString(XML_GetErrorCode(parser)); throw std::runtime_error(out.str()); } } XMLParser::~XMLParser() { XML_ParserFree(parser); } void XMLParser::on_start_element(const char* name, const char** attr) { if (*attr) raise_error("attribute not allowed"); // spaces are ignored, everything else is an error for(int i = 0; i < (int)cdata.size(); ++i) if (!isspace(cdata[i])) raise_error("unexpected character data"); cdata.clear(); if (!node.empty()) { XMLListNode* new_node = new XMLListNode(node); if (!root_node.get()) { root_node.reset(new_node); } else { node_stack.back()->children.push_back(new_node); } node_stack.push_back(new_node); } node = name; } void XMLParser::on_end_element(const char* el) { if (!node.empty() && !cdata.empty()) { node_stack.back()->children.push_back(new XMLDataNode(node, cdata)); node.clear(); cdata.clear(); } else { // spaces are ignored, everything else is an error for(int i = 0; i < (int)cdata.size(); ++i) if (!isspace(cdata[i])) raise_error("unexpected character data"); node_stack.pop_back(); node.clear(); cdata.clear(); } } void XMLParser::on_character_data(const char* s, int len) { cdata += std::string(s, len); } void XMLParser::raise_error(const std::string& str) { std::ostringstream out; out << filename << ":" << XML_GetCurrentLineNumber(parser) << ": " << str; throw std::runtime_error(out.str()); } #ifdef __TEST__ int main(int argc, char** argv) { try { for(int i = 1; i < argc; ++i) { std::auto_ptr root = XMLParser::parse(argv[i]); root->print(std::cout); } } catch(std::exception& err) { std::cout << "Error: " << err.what() << std::endl; } return 0; } #endif /* EOF */ jstest-gtk-0.1.1~git20090722/src/joystick_map_widget.hpp0000644000175000017500000000255011531037643021742 0ustar stevesteve/* ** jstest-gtk - A graphical joystick tester ** Copyright (C) 2009 Ingo Ruhnke ** ** This program is free software: you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation, either version 3 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program. If not, see . */ #ifndef HEADER_JOYSTICK_MAP_WIDGET_HPP #define HEADER_JOYSTICK_MAP_WIDGET_HPP #include #include #include #include #include #include "remap_widget.hpp" class Joystick; class JoystickMapWidget : public Gtk::Dialog { private: Gtk::Label label; Gtk::HBox hbox; RemapWidget axis_map; RemapWidget button_map; public: JoystickMapWidget(Joystick& joystick); void on_response(int v); private: JoystickMapWidget(const JoystickMapWidget&); JoystickMapWidget& operator=(const JoystickMapWidget&); }; #endif /* EOF */ jstest-gtk-0.1.1~git20090722/src/jscfg.cpp0000644000175000017500000000231011531037643016764 0ustar stevesteve/* ** jstest-gtk - A graphical joystick tester ** Copyright (C) 2009 Ingo Ruhnke ** ** This program is free software: you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation, either version 3 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program. If not, see . */ #include #include "jscfg.hpp" void print_help() { std::cout << "Usage: jscfg [OPTIONS] JOYSTICKDEVICE\n" << "\n" << " --help, -h Display this help\n" << " --btnmap, -b B1,B2,... Display this help\n" << " --axismap, -a A1,A2,... Display this help\n" } int main(int argc, char** argv) { for(int i = 1; i < argc; ++i) { } return 0; } /* EOF */ jstest-gtk-0.1.1~git20090722/src/remap_widget.hpp0000644000175000017500000000341111531037643020347 0ustar stevesteve/* ** jstest-gtk - A graphical joystick tester ** Copyright (C) 2009 Ingo Ruhnke ** ** This program is free software: you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation, either version 3 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program. If not, see . */ #ifndef HEADER_JSTEST_GTK_REMAP_WIDGET_HPP #define HEADER_JSTEST_GTK_REMAP_WIDGET_HPP #include #include #include #include #include #include class Joystick; class RemapWidget : public Gtk::VBox { public: enum Mode { REMAP_AXIS, REMAP_BUTTON }; private: Joystick& joystick; Mode mode; Gtk::TreeView treeview; Glib::RefPtr map_list; public: RemapWidget(Joystick& joystick_, Mode mode); void add_entry(int id, const std::string& str); void on_clear(); void on_apply(); void on_my_row_inserted(const Gtk::TreeModel::Path& path, const Gtk::TreeModel::iterator& iter); void on_my_row_deleted(const Gtk::TreeModel::Path& path); void on_my_rows_reordered(const Gtk::TreeModel::Path& path, const Gtk::TreeModel::iterator& iter, int* new_order); private: RemapWidget(const RemapWidget&); RemapWidget& operator=(const RemapWidget&); }; #endif /* EOF */ jstest-gtk-0.1.1~git20090722/src/joystick_test_widget.hpp0000644000175000017500000000530711531037643022147 0ustar stevesteve/* ** jstest-gtk - A graphical joystick tester ** Copyright (C) 2009 Ingo Ruhnke ** ** This program is free software: you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation, either version 3 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program. If not, see . */ #ifndef HEADER_JSTEST_GTK_JOYSTICK_TEST_WIDGET_HPP #define HEADER_JSTEST_GTK_JOYSTICK_TEST_WIDGET_HPP #include #include #include #include #include #include #include #include #include #include #include #include #include "throttle_widget.hpp" #include "rudder_widget.hpp" #include "axis_widget.hpp" class Joystick; class ButtonWidget; class JoystickTestWidget : public Gtk::Dialog { private: Joystick& joystick; Gtk::Alignment alignment; Gtk::Label label; Gtk::HBox profile_hbox; Gtk::ToolButton profile_save_button; Gtk::ToolButton profile_delete_button; Gtk::ComboBoxText profile_entry; Gtk::Frame axis_frame; Gtk::VBox axis_vbox; Gtk::Frame button_frame; Gtk::Table axis_table; Gtk::Table button_table; Gtk::HBox stick_hbox; Gtk::Button mapping_button; Gtk::Button calibration_button; Gtk::HButtonBox buttonbox; AxisWidget stick1_widget; AxisWidget stick2_widget; AxisWidget stick3_widget; RudderWidget rudder_widget; ThrottleWidget throttle_widget; ThrottleWidget left_trigger_widget; ThrottleWidget right_trigger_widget; std::vector axes; std::vector buttons; Glib::RefPtr button_on; Glib::RefPtr button_off; std::vector > axis_callbacks; public: JoystickTestWidget(Joystick& joystick); void axis_move(int number, int value); void button_move(int number, bool value); void on_calibrate(); void on_mapping(); void on_response(int v); void on_save_profile(); void on_save_profile_as(const std::string& name); void on_delete_profile(); private: JoystickTestWidget(const JoystickTestWidget&); JoystickTestWidget& operator=(const JoystickTestWidget&); }; #endif /* EOF */ jstest-gtk-0.1.1~git20090722/src/joystick_configuration.cpp0000644000175000017500000000205411531037643022463 0ustar stevesteve/* ** jstest-gtk - A graphical joystick tester ** Copyright (C) 2009 Ingo Ruhnke ** ** This program is free software: you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation, either version 3 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program. If not, see . */ #include #include #include #include #include #include #include "joystick_configuration.hpp" JoystickConfiguration::JoystickConfiguration(const std::string& filename) { } JoystickConfiguration::~JoystickConfiguration() { } /* EOF */ jstest-gtk-0.1.1~git20090722/src/evdev_helper.cpp0000644000175000017500000006423611531037643020357 0ustar stevesteve/* ** Xbox360 USB Gamepad Userspace Driver ** Copyright (C) 2008 Ingo Ruhnke ** ** This program is free software: you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation, either version 3 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program. If not, see . */ #include #include #include #include #include #include #include "evdev_helper.hpp" template class EnumBox { protected: std::string name; std::map enum2string; std::map string2enum; protected: EnumBox(const std::string& name) : name(name) { } void add(Enum i, const std::string& name) { enum2string[i] = name; string2enum[name] = i; } public: Enum operator[](const std::string& str) const { typename std::map::const_iterator i = string2enum.find(str); if (i == string2enum.end()) { std::istringstream in(str); Enum tmp; in >> tmp; if (in.fail()) { std::ostringstream out; out << "Couldn't convert '" << str << "' to enum " << name << std::endl; throw std::runtime_error(out.str()); } else { return tmp; } } else { return i->second; } } std::string operator[](Enum v) const { typename std::map::const_iterator i = enum2string.find(v); if (i == enum2string.end()) { // If we can't convert symbolic, just convert the integer to a // string std::ostringstream out; out << v; return out.str(); } else { return i->second; } } }; class EvDevRelEnum : public EnumBox { public: EvDevRelEnum() : EnumBox("EV_REL") { // File.new("/usr/include/linux/input.h") // .grep(/^#define REL/) // .each{|i| name = i.split[1]; puts "add(%s,%s\"%s\");" % [name, " " * (20-name.length), name] }; add(REL_X, "REL_X"); add(REL_Y, "REL_Y"); add(REL_Z, "REL_Z"); add(REL_RX, "REL_RX"); add(REL_RY, "REL_RY"); add(REL_RZ, "REL_RZ"); add(REL_HWHEEL, "REL_HWHEEL"); add(REL_DIAL, "REL_DIAL"); add(REL_WHEEL, "REL_WHEEL"); add(REL_MISC, "REL_MISC"); } } evdev_rel_names; class EvDevAbsEnum : public EnumBox { public: EvDevAbsEnum() : EnumBox("EV_ABS") { // File.new("/usr/include/linux/input.h") // .grep(/^#define ABS/) // .each{|i| name = i.split[1]; puts "add(%s,%s\"%s\");" % [name, " " * (20-name.length), name] }; add(ABS_X, "ABS_X"); add(ABS_Y, "ABS_Y"); add(ABS_Z, "ABS_Z"); add(ABS_RX, "ABS_RX"); add(ABS_RY, "ABS_RY"); add(ABS_RZ, "ABS_RZ"); add(ABS_THROTTLE, "ABS_THROTTLE"); add(ABS_RUDDER, "ABS_RUDDER"); add(ABS_WHEEL, "ABS_WHEEL"); add(ABS_GAS, "ABS_GAS"); add(ABS_BRAKE, "ABS_BRAKE"); add(ABS_HAT0X, "ABS_HAT0X"); add(ABS_HAT0Y, "ABS_HAT0Y"); add(ABS_HAT1X, "ABS_HAT1X"); add(ABS_HAT1Y, "ABS_HAT1Y"); add(ABS_HAT2X, "ABS_HAT2X"); add(ABS_HAT2Y, "ABS_HAT2Y"); add(ABS_HAT3X, "ABS_HAT3X"); add(ABS_HAT3Y, "ABS_HAT3Y"); add(ABS_PRESSURE, "ABS_PRESSURE"); add(ABS_DISTANCE, "ABS_DISTANCE"); add(ABS_TILT_X, "ABS_TILT_X"); add(ABS_TILT_Y, "ABS_TILT_Y"); add(ABS_TOOL_WIDTH, "ABS_TOOL_WIDTH"); add(ABS_VOLUME, "ABS_VOLUME"); add(ABS_MISC, "ABS_MISC"); } } evdev_abs_names; class EvDevBtnEnum : public EnumBox { public: EvDevBtnEnum() : EnumBox("EV_KEY") { // File.new("/usr/include/linux/input.h") // .grep(/^#define (BTN|KEY)/) // .each{|i| name = i.split[1]; puts "add(%s,%s\"%s\");" % [name, " " * (20-name.length), name] }; add(KEY_RESERVED, "KEY_RESERVED"); add(KEY_ESC, "KEY_ESC"); add(KEY_1, "KEY_1"); add(KEY_2, "KEY_2"); add(KEY_3, "KEY_3"); add(KEY_4, "KEY_4"); add(KEY_5, "KEY_5"); add(KEY_6, "KEY_6"); add(KEY_7, "KEY_7"); add(KEY_8, "KEY_8"); add(KEY_9, "KEY_9"); add(KEY_0, "KEY_0"); add(KEY_MINUS, "KEY_MINUS"); add(KEY_EQUAL, "KEY_EQUAL"); add(KEY_BACKSPACE, "KEY_BACKSPACE"); add(KEY_TAB, "KEY_TAB"); add(KEY_Q, "KEY_Q"); add(KEY_W, "KEY_W"); add(KEY_E, "KEY_E"); add(KEY_R, "KEY_R"); add(KEY_T, "KEY_T"); add(KEY_Y, "KEY_Y"); add(KEY_U, "KEY_U"); add(KEY_I, "KEY_I"); add(KEY_O, "KEY_O"); add(KEY_P, "KEY_P"); add(KEY_LEFTBRACE, "KEY_LEFTBRACE"); add(KEY_RIGHTBRACE, "KEY_RIGHTBRACE"); add(KEY_ENTER, "KEY_ENTER"); add(KEY_LEFTCTRL, "KEY_LEFTCTRL"); add(KEY_A, "KEY_A"); add(KEY_S, "KEY_S"); add(KEY_D, "KEY_D"); add(KEY_F, "KEY_F"); add(KEY_G, "KEY_G"); add(KEY_H, "KEY_H"); add(KEY_J, "KEY_J"); add(KEY_K, "KEY_K"); add(KEY_L, "KEY_L"); add(KEY_SEMICOLON, "KEY_SEMICOLON"); add(KEY_APOSTROPHE, "KEY_APOSTROPHE"); add(KEY_GRAVE, "KEY_GRAVE"); add(KEY_LEFTSHIFT, "KEY_LEFTSHIFT"); add(KEY_BACKSLASH, "KEY_BACKSLASH"); add(KEY_Z, "KEY_Z"); add(KEY_X, "KEY_X"); add(KEY_C, "KEY_C"); add(KEY_V, "KEY_V"); add(KEY_B, "KEY_B"); add(KEY_N, "KEY_N"); add(KEY_M, "KEY_M"); add(KEY_COMMA, "KEY_COMMA"); add(KEY_DOT, "KEY_DOT"); add(KEY_SLASH, "KEY_SLASH"); add(KEY_RIGHTSHIFT, "KEY_RIGHTSHIFT"); add(KEY_KPASTERISK, "KEY_KPASTERISK"); add(KEY_LEFTALT, "KEY_LEFTALT"); add(KEY_SPACE, "KEY_SPACE"); add(KEY_CAPSLOCK, "KEY_CAPSLOCK"); add(KEY_F1, "KEY_F1"); add(KEY_F2, "KEY_F2"); add(KEY_F3, "KEY_F3"); add(KEY_F4, "KEY_F4"); add(KEY_F5, "KEY_F5"); add(KEY_F6, "KEY_F6"); add(KEY_F7, "KEY_F7"); add(KEY_F8, "KEY_F8"); add(KEY_F9, "KEY_F9"); add(KEY_F10, "KEY_F10"); add(KEY_NUMLOCK, "KEY_NUMLOCK"); add(KEY_SCROLLLOCK, "KEY_SCROLLLOCK"); add(KEY_KP7, "KEY_KP7"); add(KEY_KP8, "KEY_KP8"); add(KEY_KP9, "KEY_KP9"); add(KEY_KPMINUS, "KEY_KPMINUS"); add(KEY_KP4, "KEY_KP4"); add(KEY_KP5, "KEY_KP5"); add(KEY_KP6, "KEY_KP6"); add(KEY_KPPLUS, "KEY_KPPLUS"); add(KEY_KP1, "KEY_KP1"); add(KEY_KP2, "KEY_KP2"); add(KEY_KP3, "KEY_KP3"); add(KEY_KP0, "KEY_KP0"); add(KEY_KPDOT, "KEY_KPDOT"); add(KEY_ZENKAKUHANKAKU, "KEY_ZENKAKUHANKAKU"); add(KEY_102ND, "KEY_102ND"); add(KEY_F11, "KEY_F11"); add(KEY_F12, "KEY_F12"); add(KEY_RO, "KEY_RO"); add(KEY_KATAKANA, "KEY_KATAKANA"); add(KEY_HIRAGANA, "KEY_HIRAGANA"); add(KEY_HENKAN, "KEY_HENKAN"); add(KEY_KATAKANAHIRAGANA,"KEY_KATAKANAHIRAGANA"); add(KEY_MUHENKAN, "KEY_MUHENKAN"); add(KEY_KPJPCOMMA, "KEY_KPJPCOMMA"); add(KEY_KPENTER, "KEY_KPENTER"); add(KEY_RIGHTCTRL, "KEY_RIGHTCTRL"); add(KEY_KPSLASH, "KEY_KPSLASH"); add(KEY_SYSRQ, "KEY_SYSRQ"); add(KEY_RIGHTALT, "KEY_RIGHTALT"); add(KEY_LINEFEED, "KEY_LINEFEED"); add(KEY_HOME, "KEY_HOME"); add(KEY_UP, "KEY_UP"); add(KEY_PAGEUP, "KEY_PAGEUP"); add(KEY_LEFT, "KEY_LEFT"); add(KEY_RIGHT, "KEY_RIGHT"); add(KEY_END, "KEY_END"); add(KEY_DOWN, "KEY_DOWN"); add(KEY_PAGEDOWN, "KEY_PAGEDOWN"); add(KEY_INSERT, "KEY_INSERT"); add(KEY_DELETE, "KEY_DELETE"); add(KEY_MACRO, "KEY_MACRO"); add(KEY_MUTE, "KEY_MUTE"); add(KEY_VOLUMEDOWN, "KEY_VOLUMEDOWN"); add(KEY_VOLUMEUP, "KEY_VOLUMEUP"); add(KEY_POWER, "KEY_POWER"); add(KEY_KPEQUAL, "KEY_KPEQUAL"); add(KEY_KPPLUSMINUS, "KEY_KPPLUSMINUS"); add(KEY_PAUSE, "KEY_PAUSE"); add(KEY_KPCOMMA, "KEY_KPCOMMA"); add(KEY_HANGEUL, "KEY_HANGEUL"); add(KEY_HANGUEL, "KEY_HANGUEL"); add(KEY_HANJA, "KEY_HANJA"); add(KEY_YEN, "KEY_YEN"); add(KEY_LEFTMETA, "KEY_LEFTMETA"); add(KEY_RIGHTMETA, "KEY_RIGHTMETA"); add(KEY_COMPOSE, "KEY_COMPOSE"); add(KEY_STOP, "KEY_STOP"); add(KEY_AGAIN, "KEY_AGAIN"); add(KEY_PROPS, "KEY_PROPS"); add(KEY_UNDO, "KEY_UNDO"); add(KEY_FRONT, "KEY_FRONT"); add(KEY_COPY, "KEY_COPY"); add(KEY_OPEN, "KEY_OPEN"); add(KEY_PASTE, "KEY_PASTE"); add(KEY_FIND, "KEY_FIND"); add(KEY_CUT, "KEY_CUT"); add(KEY_HELP, "KEY_HELP"); add(KEY_MENU, "KEY_MENU"); add(KEY_CALC, "KEY_CALC"); add(KEY_SETUP, "KEY_SETUP"); add(KEY_SLEEP, "KEY_SLEEP"); add(KEY_WAKEUP, "KEY_WAKEUP"); add(KEY_FILE, "KEY_FILE"); add(KEY_SENDFILE, "KEY_SENDFILE"); add(KEY_DELETEFILE, "KEY_DELETEFILE"); add(KEY_XFER, "KEY_XFER"); add(KEY_PROG1, "KEY_PROG1"); add(KEY_PROG2, "KEY_PROG2"); add(KEY_WWW, "KEY_WWW"); add(KEY_MSDOS, "KEY_MSDOS"); add(KEY_COFFEE, "KEY_COFFEE"); add(KEY_SCREENLOCK, "KEY_SCREENLOCK"); add(KEY_DIRECTION, "KEY_DIRECTION"); add(KEY_CYCLEWINDOWS, "KEY_CYCLEWINDOWS"); add(KEY_MAIL, "KEY_MAIL"); add(KEY_BOOKMARKS, "KEY_BOOKMARKS"); add(KEY_COMPUTER, "KEY_COMPUTER"); add(KEY_BACK, "KEY_BACK"); add(KEY_FORWARD, "KEY_FORWARD"); add(KEY_CLOSECD, "KEY_CLOSECD"); add(KEY_EJECTCD, "KEY_EJECTCD"); add(KEY_EJECTCLOSECD, "KEY_EJECTCLOSECD"); add(KEY_NEXTSONG, "KEY_NEXTSONG"); add(KEY_PLAYPAUSE, "KEY_PLAYPAUSE"); add(KEY_PREVIOUSSONG, "KEY_PREVIOUSSONG"); add(KEY_STOPCD, "KEY_STOPCD"); add(KEY_RECORD, "KEY_RECORD"); add(KEY_REWIND, "KEY_REWIND"); add(KEY_PHONE, "KEY_PHONE"); add(KEY_ISO, "KEY_ISO"); add(KEY_CONFIG, "KEY_CONFIG"); add(KEY_HOMEPAGE, "KEY_HOMEPAGE"); add(KEY_REFRESH, "KEY_REFRESH"); add(KEY_EXIT, "KEY_EXIT"); add(KEY_MOVE, "KEY_MOVE"); add(KEY_EDIT, "KEY_EDIT"); add(KEY_SCROLLUP, "KEY_SCROLLUP"); add(KEY_SCROLLDOWN, "KEY_SCROLLDOWN"); add(KEY_KPLEFTPAREN, "KEY_KPLEFTPAREN"); add(KEY_KPRIGHTPAREN, "KEY_KPRIGHTPAREN"); add(KEY_NEW, "KEY_NEW"); add(KEY_REDO, "KEY_REDO"); add(KEY_F13, "KEY_F13"); add(KEY_F14, "KEY_F14"); add(KEY_F15, "KEY_F15"); add(KEY_F16, "KEY_F16"); add(KEY_F17, "KEY_F17"); add(KEY_F18, "KEY_F18"); add(KEY_F19, "KEY_F19"); add(KEY_F20, "KEY_F20"); add(KEY_F21, "KEY_F21"); add(KEY_F22, "KEY_F22"); add(KEY_F23, "KEY_F23"); add(KEY_F24, "KEY_F24"); add(KEY_PLAYCD, "KEY_PLAYCD"); add(KEY_PAUSECD, "KEY_PAUSECD"); add(KEY_PROG3, "KEY_PROG3"); add(KEY_PROG4, "KEY_PROG4"); add(KEY_SUSPEND, "KEY_SUSPEND"); add(KEY_CLOSE, "KEY_CLOSE"); add(KEY_PLAY, "KEY_PLAY"); add(KEY_FASTFORWARD, "KEY_FASTFORWARD"); add(KEY_BASSBOOST, "KEY_BASSBOOST"); add(KEY_PRINT, "KEY_PRINT"); add(KEY_HP, "KEY_HP"); add(KEY_CAMERA, "KEY_CAMERA"); add(KEY_SOUND, "KEY_SOUND"); add(KEY_QUESTION, "KEY_QUESTION"); add(KEY_EMAIL, "KEY_EMAIL"); add(KEY_CHAT, "KEY_CHAT"); add(KEY_SEARCH, "KEY_SEARCH"); add(KEY_CONNECT, "KEY_CONNECT"); add(KEY_FINANCE, "KEY_FINANCE"); add(KEY_SPORT, "KEY_SPORT"); add(KEY_SHOP, "KEY_SHOP"); add(KEY_ALTERASE, "KEY_ALTERASE"); add(KEY_CANCEL, "KEY_CANCEL"); add(KEY_BRIGHTNESSDOWN, "KEY_BRIGHTNESSDOWN"); add(KEY_BRIGHTNESSUP, "KEY_BRIGHTNESSUP"); add(KEY_MEDIA, "KEY_MEDIA"); add(KEY_SWITCHVIDEOMODE, "KEY_SWITCHVIDEOMODE"); add(KEY_KBDILLUMTOGGLE, "KEY_KBDILLUMTOGGLE"); add(KEY_KBDILLUMDOWN, "KEY_KBDILLUMDOWN"); add(KEY_KBDILLUMUP, "KEY_KBDILLUMUP"); add(KEY_SEND, "KEY_SEND"); add(KEY_REPLY, "KEY_REPLY"); add(KEY_FORWARDMAIL, "KEY_FORWARDMAIL"); add(KEY_SAVE, "KEY_SAVE"); add(KEY_DOCUMENTS, "KEY_DOCUMENTS"); add(KEY_BATTERY, "KEY_BATTERY"); add(KEY_BLUETOOTH, "KEY_BLUETOOTH"); add(KEY_WLAN, "KEY_WLAN"); add(KEY_UWB, "KEY_UWB"); add(KEY_UNKNOWN, "KEY_UNKNOWN"); add(KEY_VIDEO_NEXT, "KEY_VIDEO_NEXT"); add(KEY_VIDEO_PREV, "KEY_VIDEO_PREV"); add(KEY_BRIGHTNESS_CYCLE,"KEY_BRIGHTNESS_CYCLE"); add(KEY_BRIGHTNESS_ZERO, "KEY_BRIGHTNESS_ZERO"); add(KEY_DISPLAY_OFF, "KEY_DISPLAY_OFF"); add(KEY_WIMAX, "KEY_WIMAX"); add(BTN_MISC, "BTN_MISC"); add(BTN_0, "BTN_0"); add(BTN_1, "BTN_1"); add(BTN_2, "BTN_2"); add(BTN_3, "BTN_3"); add(BTN_4, "BTN_4"); add(BTN_5, "BTN_5"); add(BTN_6, "BTN_6"); add(BTN_7, "BTN_7"); add(BTN_8, "BTN_8"); add(BTN_9, "BTN_9"); add(BTN_MOUSE, "BTN_MOUSE"); add(BTN_LEFT, "BTN_LEFT"); add(BTN_RIGHT, "BTN_RIGHT"); add(BTN_MIDDLE, "BTN_MIDDLE"); add(BTN_SIDE, "BTN_SIDE"); add(BTN_EXTRA, "BTN_EXTRA"); add(BTN_FORWARD, "BTN_FORWARD"); add(BTN_BACK, "BTN_BACK"); add(BTN_TASK, "BTN_TASK"); add(BTN_JOYSTICK, "BTN_JOYSTICK"); add(BTN_TRIGGER, "BTN_TRIGGER"); add(BTN_THUMB, "BTN_THUMB"); add(BTN_THUMB2, "BTN_THUMB2"); add(BTN_TOP, "BTN_TOP"); add(BTN_TOP2, "BTN_TOP2"); add(BTN_PINKIE, "BTN_PINKIE"); add(BTN_BASE, "BTN_BASE"); add(BTN_BASE2, "BTN_BASE2"); add(BTN_BASE3, "BTN_BASE3"); add(BTN_BASE4, "BTN_BASE4"); add(BTN_BASE5, "BTN_BASE5"); add(BTN_BASE6, "BTN_BASE6"); add(BTN_DEAD, "BTN_DEAD"); add(BTN_GAMEPAD, "BTN_GAMEPAD"); add(BTN_A, "BTN_A"); add(BTN_B, "BTN_B"); add(BTN_C, "BTN_C"); add(BTN_X, "BTN_X"); add(BTN_Y, "BTN_Y"); add(BTN_Z, "BTN_Z"); add(BTN_TL, "BTN_TL"); add(BTN_TR, "BTN_TR"); add(BTN_TL2, "BTN_TL2"); add(BTN_TR2, "BTN_TR2"); add(BTN_SELECT, "BTN_SELECT"); add(BTN_START, "BTN_START"); add(BTN_MODE, "BTN_MODE"); add(BTN_THUMBL, "BTN_THUMBL"); add(BTN_THUMBR, "BTN_THUMBR"); add(BTN_DIGI, "BTN_DIGI"); add(BTN_TOOL_PEN, "BTN_TOOL_PEN"); add(BTN_TOOL_RUBBER, "BTN_TOOL_RUBBER"); add(BTN_TOOL_BRUSH, "BTN_TOOL_BRUSH"); add(BTN_TOOL_PENCIL, "BTN_TOOL_PENCIL"); add(BTN_TOOL_AIRBRUSH, "BTN_TOOL_AIRBRUSH"); add(BTN_TOOL_FINGER, "BTN_TOOL_FINGER"); add(BTN_TOOL_MOUSE, "BTN_TOOL_MOUSE"); add(BTN_TOOL_LENS, "BTN_TOOL_LENS"); add(BTN_TOUCH, "BTN_TOUCH"); add(BTN_STYLUS, "BTN_STYLUS"); add(BTN_STYLUS2, "BTN_STYLUS2"); add(BTN_TOOL_DOUBLETAP, "BTN_TOOL_DOUBLETAP"); add(BTN_TOOL_TRIPLETAP, "BTN_TOOL_TRIPLETAP"); add(BTN_WHEEL, "BTN_WHEEL"); add(BTN_GEAR_DOWN, "BTN_GEAR_DOWN"); add(BTN_GEAR_UP, "BTN_GEAR_UP"); add(KEY_OK, "KEY_OK"); add(KEY_SELECT, "KEY_SELECT"); add(KEY_GOTO, "KEY_GOTO"); add(KEY_CLEAR, "KEY_CLEAR"); add(KEY_POWER2, "KEY_POWER2"); add(KEY_OPTION, "KEY_OPTION"); add(KEY_INFO, "KEY_INFO"); add(KEY_TIME, "KEY_TIME"); add(KEY_VENDOR, "KEY_VENDOR"); add(KEY_ARCHIVE, "KEY_ARCHIVE"); add(KEY_PROGRAM, "KEY_PROGRAM"); add(KEY_CHANNEL, "KEY_CHANNEL"); add(KEY_FAVORITES, "KEY_FAVORITES"); add(KEY_EPG, "KEY_EPG"); add(KEY_PVR, "KEY_PVR"); add(KEY_MHP, "KEY_MHP"); add(KEY_LANGUAGE, "KEY_LANGUAGE"); add(KEY_TITLE, "KEY_TITLE"); add(KEY_SUBTITLE, "KEY_SUBTITLE"); add(KEY_ANGLE, "KEY_ANGLE"); add(KEY_ZOOM, "KEY_ZOOM"); add(KEY_MODE, "KEY_MODE"); add(KEY_KEYBOARD, "KEY_KEYBOARD"); add(KEY_SCREEN, "KEY_SCREEN"); add(KEY_PC, "KEY_PC"); add(KEY_TV, "KEY_TV"); add(KEY_TV2, "KEY_TV2"); add(KEY_VCR, "KEY_VCR"); add(KEY_VCR2, "KEY_VCR2"); add(KEY_SAT, "KEY_SAT"); add(KEY_SAT2, "KEY_SAT2"); add(KEY_CD, "KEY_CD"); add(KEY_TAPE, "KEY_TAPE"); add(KEY_RADIO, "KEY_RADIO"); add(KEY_TUNER, "KEY_TUNER"); add(KEY_PLAYER, "KEY_PLAYER"); add(KEY_TEXT, "KEY_TEXT"); add(KEY_DVD, "KEY_DVD"); add(KEY_AUX, "KEY_AUX"); add(KEY_MP3, "KEY_MP3"); add(KEY_AUDIO, "KEY_AUDIO"); add(KEY_VIDEO, "KEY_VIDEO"); add(KEY_DIRECTORY, "KEY_DIRECTORY"); add(KEY_LIST, "KEY_LIST"); add(KEY_MEMO, "KEY_MEMO"); add(KEY_CALENDAR, "KEY_CALENDAR"); add(KEY_RED, "KEY_RED"); add(KEY_GREEN, "KEY_GREEN"); add(KEY_YELLOW, "KEY_YELLOW"); add(KEY_BLUE, "KEY_BLUE"); add(KEY_CHANNELUP, "KEY_CHANNELUP"); add(KEY_CHANNELDOWN, "KEY_CHANNELDOWN"); add(KEY_FIRST, "KEY_FIRST"); add(KEY_LAST, "KEY_LAST"); add(KEY_AB, "KEY_AB"); add(KEY_NEXT, "KEY_NEXT"); add(KEY_RESTART, "KEY_RESTART"); add(KEY_SLOW, "KEY_SLOW"); add(KEY_SHUFFLE, "KEY_SHUFFLE"); add(KEY_BREAK, "KEY_BREAK"); add(KEY_PREVIOUS, "KEY_PREVIOUS"); add(KEY_DIGITS, "KEY_DIGITS"); add(KEY_TEEN, "KEY_TEEN"); add(KEY_TWEN, "KEY_TWEN"); add(KEY_VIDEOPHONE, "KEY_VIDEOPHONE"); add(KEY_GAMES, "KEY_GAMES"); add(KEY_ZOOMIN, "KEY_ZOOMIN"); add(KEY_ZOOMOUT, "KEY_ZOOMOUT"); add(KEY_ZOOMRESET, "KEY_ZOOMRESET"); add(KEY_WORDPROCESSOR, "KEY_WORDPROCESSOR"); add(KEY_EDITOR, "KEY_EDITOR"); add(KEY_SPREADSHEET, "KEY_SPREADSHEET"); add(KEY_GRAPHICSEDITOR, "KEY_GRAPHICSEDITOR"); add(KEY_PRESENTATION, "KEY_PRESENTATION"); add(KEY_DATABASE, "KEY_DATABASE"); add(KEY_NEWS, "KEY_NEWS"); add(KEY_VOICEMAIL, "KEY_VOICEMAIL"); add(KEY_ADDRESSBOOK, "KEY_ADDRESSBOOK"); add(KEY_MESSENGER, "KEY_MESSENGER"); add(KEY_DISPLAYTOGGLE, "KEY_DISPLAYTOGGLE"); add(KEY_SPELLCHECK, "KEY_SPELLCHECK"); add(KEY_LOGOFF, "KEY_LOGOFF"); add(KEY_DOLLAR, "KEY_DOLLAR"); add(KEY_EURO, "KEY_EURO"); add(KEY_FRAMEBACK, "KEY_FRAMEBACK"); add(KEY_FRAMEFORWARD, "KEY_FRAMEFORWARD"); add(KEY_CONTEXT_MENU, "KEY_CONTEXT_MENU"); #ifdef KEY_MEDIA_REPEAT add(KEY_MEDIA_REPEAT, "KEY_MEDIA_REPEAT"); #endif add(KEY_DEL_EOL, "KEY_DEL_EOL"); add(KEY_DEL_EOS, "KEY_DEL_EOS"); add(KEY_INS_LINE, "KEY_INS_LINE"); add(KEY_DEL_LINE, "KEY_DEL_LINE"); add(KEY_FN, "KEY_FN"); add(KEY_FN_ESC, "KEY_FN_ESC"); add(KEY_FN_F1, "KEY_FN_F1"); add(KEY_FN_F2, "KEY_FN_F2"); add(KEY_FN_F3, "KEY_FN_F3"); add(KEY_FN_F4, "KEY_FN_F4"); add(KEY_FN_F5, "KEY_FN_F5"); add(KEY_FN_F6, "KEY_FN_F6"); add(KEY_FN_F7, "KEY_FN_F7"); add(KEY_FN_F8, "KEY_FN_F8"); add(KEY_FN_F9, "KEY_FN_F9"); add(KEY_FN_F10, "KEY_FN_F10"); add(KEY_FN_F11, "KEY_FN_F11"); add(KEY_FN_F12, "KEY_FN_F12"); add(KEY_FN_1, "KEY_FN_1"); add(KEY_FN_2, "KEY_FN_2"); add(KEY_FN_D, "KEY_FN_D"); add(KEY_FN_E, "KEY_FN_E"); add(KEY_FN_F, "KEY_FN_F"); add(KEY_FN_S, "KEY_FN_S"); add(KEY_FN_B, "KEY_FN_B"); add(KEY_BRL_DOT1, "KEY_BRL_DOT1"); add(KEY_BRL_DOT2, "KEY_BRL_DOT2"); add(KEY_BRL_DOT3, "KEY_BRL_DOT3"); add(KEY_BRL_DOT4, "KEY_BRL_DOT4"); add(KEY_BRL_DOT5, "KEY_BRL_DOT5"); add(KEY_BRL_DOT6, "KEY_BRL_DOT6"); add(KEY_BRL_DOT7, "KEY_BRL_DOT7"); add(KEY_BRL_DOT8, "KEY_BRL_DOT8"); add(KEY_BRL_DOT9, "KEY_BRL_DOT9"); add(KEY_BRL_DOT10, "KEY_BRL_DOT10"); add(KEY_MIN_INTERESTING, "KEY_MIN_INTERESTING"); } } evdev_btn_names; class Keysym2Keycode { public: // Map KeySym to kernel keycode std::map mapping; Keysym2Keycode() { //std::cout << "Initing Keysym2Keycode" << std::endl; Display* dpy = XOpenDisplay(NULL); if (!dpy) { throw std::runtime_error("Keysym2Keycode: Couldn't open X11 display"); } else { process_keymap(dpy); XCloseDisplay(dpy); } } void process_keymap(Display* dpy) { int min_keycode, max_keycode; XDisplayKeycodes(dpy, &min_keycode, &max_keycode); int num_keycodes = max_keycode - min_keycode + 1; int keysyms_per_keycode; KeySym* keymap = XGetKeyboardMapping(dpy, min_keycode, num_keycodes, &keysyms_per_keycode); for(int i = 0; i < num_keycodes; ++i) { if (keymap[i*keysyms_per_keycode] != NoSymbol) { KeySym keysym = keymap[i*keysyms_per_keycode]; // FIXME: Duplicate entries confuse the conversion // std::map::iterator it = mapping.find(keysym); // if (it != mapping.end()) // std::cout << "Duplicate keycode: " << i << std::endl; mapping[keysym] = i; } } XFree(keymap); } }; int xkeysym2keycode(const std::string& name) { static Keysym2Keycode sym2code; KeySym keysym = XStringToKeysym(name.substr(3).c_str()); if (keysym == NoSymbol) { throw std::runtime_error("xkeysym2keycode: Couldn't convert name '" + name + "' to xkeysym"); } std::map::iterator i = sym2code.mapping.find(keysym); if (i == sym2code.mapping.end()) { throw std::runtime_error("xkeysym2keycode: Couldn't convert xkeysym '" + name + "' to evdev keycode"); } else { if (0) std::cout << name << " -> " << keysym << " -> " << XKeysymToString(keysym) << " -> " << btn2str(i->second) << "(" << i->second << ")" << std::endl; return i->second; } } bool str2event(const std::string& name, int& type, int& code) { if (name == "void" || name == "none") { type = -1; code = -1; return true; } else if (name.compare(0, 3, "REL") == 0) { type = EV_REL; code = evdev_rel_names[name]; return true; } else if (name.compare(0, 3, "ABS") == 0) { type = EV_ABS; code = evdev_abs_names[name]; return true; } else if (name.compare(0, 2, "XK") == 0) { type = EV_KEY; code = xkeysym2keycode(name); return true; } else if (name.compare(0, 2, "JS") == 0) { int int_value = 0; std::istringstream(name.substr(3)) >> int_value; type = EV_KEY; code = BTN_JOYSTICK + int_value; return true; } else if (name.compare(0, 3, "KEY") == 0 || name.compare(0, 3, "BTN") == 0) { type = EV_KEY; code = evdev_btn_names[name]; return true; } else { return false; } } std::string btn2str(int i) { return evdev_btn_names[i]; } std::string abs2str(int i) { return evdev_abs_names[i]; } std::string rel2str(int i) { return evdev_rel_names[i]; } /* EOF */ jstest-gtk-0.1.1~git20090722/src/axis_widget.cpp0000644000175000017500000000535111531037643020207 0ustar stevesteve/* ** jstest-gtk - A graphical joystick tester ** Copyright (C) 2009 Ingo Ruhnke ** ** This program is free software: you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation, either version 3 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program. If not, see . */ #include "axis_widget.hpp" AxisWidget::AxisWidget(int width, int height) : Gtk::Alignment(Gtk::ALIGN_CENTER, Gtk::ALIGN_TOP, 0.0f, 0.0f), x(0), y(0) { //modify_bg(Gtk::STATE_NORMAL , Gdk::Color("white")); //modify_fg(Gtk::STATE_NORMAL , Gdk::Color("black")); add(drawingarea); drawingarea.signal_expose_event().connect(sigc::mem_fun(this, &AxisWidget::on_my_expose_event)); drawingarea.set_size_request(width, height); } bool AxisWidget::on_my_expose_event(GdkEventExpose* event) { Glib::RefPtr window = drawingarea.get_window(); if(window) { Cairo::RefPtr cr = window->create_cairo_context(); if (0) { cr->rectangle(event->area.x, event->area.y, event->area.width, event->area.height); cr->clip(); } int w = drawingarea.get_allocation().get_width() - 10; int h = drawingarea.get_allocation().get_height() - 10; int px = w/2 + (w/2 * x); int py = h/2 + (h/2 * y); cr->translate(5, 5); // Outer Rectangle cr->set_source_rgb(0.0, 0.0, 0.0); cr->set_line_width(1.0); cr->rectangle(0, 0, w, h); cr->stroke(); // BG Circle cr->arc(w/2, h/2, w/2, 0.0, 2.0 * M_PI); cr->set_source_rgba(0.0, 0.0, 0.0, 0.1); cr->fill(); // Cross cr->set_line_width(0.5); cr->set_source_rgba(0.0, 0.0, 0.0, 0.5); cr->move_to(w/2, 0); cr->line_to(w/2, h); cr->set_source_rgba(0.0, 0.0, 0.0, 0.5); cr->move_to(0, h/2); cr->line_to(w, h/2); cr->stroke(); // Cursor cr->set_source_rgb(0.0, 0.0, 0.0); cr->set_line_width(2.0); cr->move_to(px, py-5); cr->line_to(px, py+5); cr->move_to(px-5, py); cr->line_to(px+5, py); cr->stroke(); } return true; } void AxisWidget::set_x_axis(double x_) { x = x_; queue_draw(); } void AxisWidget::set_y_axis(double y_) { y = y_; queue_draw(); } /* EOF */ jstest-gtk-0.1.1~git20090722/src/joystick_map_widget.cpp0000644000175000017500000000472511531037643021743 0ustar stevesteve/* ** jstest-gtk - A graphical joystick tester ** Copyright (C) 2009 Ingo Ruhnke ** ** This program is free software: you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation, either version 3 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program. If not, see . */ #include #include "evdev_helper.hpp" #include "joystick.hpp" #include "joystick_map_widget.hpp" JoystickMapWidget::JoystickMapWidget(Joystick& joystick) : Gtk::Dialog("Mapping: " + joystick.get_name()), label("Change the order of axis and button. The order applies directly to the " "joystick kernel driver, so it will work in any game, it is however not " "persistant across reboots."), axis_map(joystick, RemapWidget::REMAP_AXIS), button_map(joystick, RemapWidget::REMAP_BUTTON) { set_has_separator(false); set_border_width(5); label.set_line_wrap(); hbox.add(axis_map); hbox.add(button_map); get_vbox()->pack_start(label, Gtk::PACK_SHRINK); get_vbox()->pack_start(hbox, Gtk::PACK_EXPAND_WIDGET); add_button(Gtk::Stock::REVERT_TO_SAVED, 1); add_button(Gtk::Stock::CLOSE, 0); const std::vector& button_mapping = joystick.get_button_mapping(); for(std::vector::const_iterator i = button_mapping.begin(); i != button_mapping.end(); ++i) { std::ostringstream s; s << (i - button_mapping.begin()) << ": " << btn2str(*i); button_map.add_entry(*i, s.str()); } const std::vector& axis_mapping = joystick.get_axis_mapping(); for(std::vector::const_iterator i = axis_mapping.begin(); i != axis_mapping.end(); ++i) { std::ostringstream s; s << (i - axis_mapping.begin()) << ": " << abs2str(*i); axis_map.add_entry(*i, s.str()); } signal_response().connect(sigc::mem_fun(this, &JoystickMapWidget::on_response)); } void JoystickMapWidget::on_response(int v) { if (v == 0) { hide(); } else if (v == 1) { button_map.on_clear(); axis_map.on_clear(); } } /* EOF */ jstest-gtk-0.1.1~git20090722/src/joystick.hpp0000644000175000017500000000601711531037643017544 0ustar stevesteve/* ** jstest-gtk - A graphical joystick tester ** Copyright (C) 2009 Ingo Ruhnke ** ** This program is free software: you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation, either version 3 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program. If not, see . */ #ifndef HEADER_JSTEST_GTK_JOYSTICK_HPP #define HEADER_JSTEST_GTK_JOYSTICK_HPP #include #include #include #include #include #include "joystick_description.hpp" class XMLReader; class XMLWriter; class Joystick { public: struct CalibrationData { bool calibrate; bool invert; int center_min; int center_max; int range_min; int range_max; }; private: int fd; std::string filename; std::string orig_name; Glib::ustring name; int axis_count; int button_count; std::vector axis_state; std::vector orig_calibration_data; sigc::connection connection; public: Joystick(const std::string& filename); ~Joystick(); int get_fd() const { return fd; } void update(); bool on_in(Glib::IOCondition cond); std::string get_filename() const { return filename; } Glib::ustring get_name() const { return name; } int get_axis_count() const { return axis_count; } int get_button_count() const { return button_count; } sigc::signal axis_move; sigc::signal button_move; int get_axis_state(int id); static std::vector get_joysticks(); std::vector get_calibration(); void set_calibration(const std::vector& data); void reset_calibration(); /** Clears all calibration data, note that this will mean raw USB input values, not values scaled to -32767/32767 */ void clear_calibration(); std::vector get_button_mapping(); std::vector get_axis_mapping(); void set_button_mapping(const std::vector& mapping); void set_axis_mapping(const std::vector& mapping); /** Corrects calibration data after remaping axes */ void correct_calibration(const std::vector& mapping_old, const std::vector& mapping_new); void write(XMLWriter& out); void load(const XMLReader& reader); /** Get the evdev that this joystick device is based on. This call is just a guess, not guranteed to be the exact same device, but for our uses that should be enough. */ std::string get_evdev() const; private: Joystick(const Joystick&); Joystick& operator=(const Joystick&); }; #endif /* EOF */ jstest-gtk-0.1.1~git20090722/src/xml_writer.cpp0000644000175000017500000000374311531037643020077 0ustar stevesteve/* ** jstest-gtk - A graphical joystick tester ** Copyright (C) 2009 Ingo Ruhnke ** ** This program is free software: you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation, either version 3 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program. If not, see . */ #include #include "xml_writer.hpp" XMLWriter::XMLWriter(const std::string& filename) : out(new std::ofstream(filename.c_str())), depth(0) { if (!*out) { throw std::runtime_error("couldn't open " + filename); } else { (*out) << "" << std::endl; } } void XMLWriter::indent() { for(int i = 0; i < depth; ++i) *out << " "; } void XMLWriter::start_section(const std::string& name) { indent(); (*out.get()) << "<" << name << ">" << std::endl; depth += 1; } void XMLWriter::end_section(const std::string& name) { depth -= 1; indent(); *out << "" << std::endl; } void XMLWriter::write(const std::string& name, const std::string& value) { indent(); // FIXME: Implement magic to convert things to UTF-8 *out << "<" << name << ">"; *out << value; *out << "" << std::endl; } void XMLWriter::write(const std::string& name, int value) { indent(); *out << "<" << name << ">"; *out << value; *out << "" << std::endl; } void XMLWriter::write(const std::string& name, bool value) { indent(); *out << "<" << name << ">"; *out << value; *out << "" << std::endl; } /* EOF */ jstest-gtk-0.1.1~git20090722/src/evdev_helper.hpp0000644000175000017500000000176411531037643020361 0ustar stevesteve/* ** Xbox360 USB Gamepad Userspace Driver ** Copyright (C) 2008 Ingo Ruhnke ** ** This program is free software: you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation, either version 3 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program. If not, see . */ #ifndef HEADER_EVDEV_HELPER_HPP #define HEADER_EVDEV_HELPER_HPP #include bool str2event(const std::string& name, int& type, int& code); std::string btn2str(int i); std::string abs2str(int i); std::string rel2str(int i); #endif /* EOF */ jstest-gtk-0.1.1~git20090722/src/throttle_widget.cpp0000644000175000017500000000411511531037643021105 0ustar stevesteve/* ** jstest-gtk - A graphical joystick tester ** Copyright (C) 2009 Ingo Ruhnke ** ** This program is free software: you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation, either version 3 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program. If not, see . */ #include "throttle_widget.hpp" ThrottleWidget::ThrottleWidget(int width, int height, bool invert_) : invert(invert_), pos(0.0) { set_size_request(width, height); //modify_bg(Gtk::STATE_NORMAL , Gdk::Color("white")); //modify_fg(Gtk::STATE_NORMAL , Gdk::Color("black")); } bool ThrottleWidget::on_expose_event(GdkEventExpose* event) { double p = 1.0 - (pos + 1.0) / 2.0; if (0) { int h = (get_allocation().get_height() * p); get_window()->draw_rectangle(get_style()->get_fg_gc(get_state()), true, 0, get_allocation().get_height() - h, get_allocation().get_width(), h); } Glib::RefPtr window = get_window(); if(window) { Cairo::RefPtr cr = window->create_cairo_context(); int w = get_allocation().get_width()-10; int h = get_allocation().get_height()-10; cr->translate(5, 5); // Outer Rectangle cr->set_source_rgb(0.0, 0.0, 0.0); cr->set_line_width(1.0); cr->rectangle(0, 0, w, h); cr->stroke(); int dh = h*p; cr->rectangle(0, h - dh, w, dh); cr->fill(); } return true; } void ThrottleWidget::set_pos(double p) { if (invert) pos = -p; else pos = p; queue_draw(); } /* EOF */ jstest-gtk-0.1.1~git20090722/src/joystick.cpp0000644000175000017500000003457311531037643017547 0ustar stevesteve/* ** jstest-gtk - A graphical joystick tester ** Copyright (C) 2009 Ingo Ruhnke ** ** This program is free software: you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation, either version 3 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program. If not, see . */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "evdev_helper.hpp" #include "xml_writer.hpp" #include "xml_reader.hpp" #include "joystick.hpp" Joystick::Joystick(const std::string& filename_) : filename(filename_) { if ((fd = open(filename.c_str(), O_RDONLY)) < 0) { std::ostringstream str; str << filename << ": " << strerror(errno); throw std::runtime_error(str.str()); } else { // ok uint8_t num_axis = 0; uint8_t num_button = 0; ioctl(fd, JSIOCGAXES, &num_axis); ioctl(fd, JSIOCGBUTTONS, &num_button); axis_count = num_axis; button_count = num_button; // Get Name char name_c_str[1024]; if (ioctl(fd, JSIOCGNAME(sizeof(name_c_str)), name_c_str) < 0) { std::ostringstream str; str << filename << ": " << strerror(errno); throw std::runtime_error(str.str()); } else { orig_name = name_c_str; try { name = Glib::convert_with_fallback(name_c_str, "UTF-8", "ISO-8859-1"); } catch(Glib::ConvertError& err) { std::cout << err.what() << std::endl; } } axis_state.resize(axis_count); } orig_calibration_data = get_calibration(); connection = Glib::signal_io().connect(sigc::mem_fun(this, &Joystick::on_in), fd, Glib::IO_IN); } Joystick::~Joystick() { connection.disconnect(); close(fd); } bool Joystick::on_in(Glib::IOCondition cond) { update(); return true; } void Joystick::update() { struct js_event event; ssize_t len = read(fd, &event, sizeof(event)); if (len < 0) { std::ostringstream str; str << filename << ": " << strerror(errno); throw std::runtime_error(str.str()); } else if (len == sizeof(event)) { // ok if (event.type & JS_EVENT_AXIS) { //std::cout << "Axis: " << (int)event.number << " -> " << (int)event.value << std::endl; axis_state[event.number] = event.value; axis_move(event.number, event.value); } else if (event.type & JS_EVENT_BUTTON) { //std::cout << "Button: " << (int)event.number << " -> " << (int)event.value << std::endl; button_move(event.number, event.value); } } else { throw std::runtime_error("Joystick::update(): unknown read error"); } } std::vector Joystick::get_joysticks() { std::vector joysticks; for(int i = 0; i < 32; ++i) { try { std::ostringstream str; str << "/dev/input/js" << i; Joystick joystick(str.str()); joysticks.push_back(JoystickDescription(joystick.get_filename(), joystick.get_name(), joystick.get_axis_count(), joystick.get_button_count())); } catch(std::exception& err) { // ok } } return joysticks; } Joystick::CalibrationData corr2cal(const struct js_corr& corr_) { struct js_corr corr = corr_; Joystick::CalibrationData data; if (corr.type) { data.calibrate = true; data.invert = (corr.coef[2] < 0 && corr.coef[3] < 0); data.center_min = corr.coef[0]; data.center_max = corr.coef[1]; if (data.invert) { corr.coef[2] = -corr.coef[2]; corr.coef[3] = -corr.coef[3]; } // Need to use double and rint(), since calculation doesn't end // up on clean integer positions (i.e. 0.9999 can happen) data.range_min = rint(data.center_min - ((32767.0 * 16384) / corr.coef[2])); data.range_max = rint((32767.0 * 16384) / corr.coef[3] + data.center_max); } else { data.calibrate = false; data.invert = false; data.center_min = 0; data.center_max = 0; data.range_min = 0; data.range_max = 0; } return data; } std::vector Joystick::get_calibration() { std::vector corr(get_axis_count()); if (ioctl(fd, JSIOCGCORR, &*corr.begin()) < 0) { std::ostringstream str; str << filename << ": " << strerror(errno); throw std::runtime_error(str.str()); } else { std::vector data; std::transform(corr.begin(), corr.end(), std::back_inserter(data), corr2cal); return data; } } struct js_corr cal2corr(const Joystick::CalibrationData& data) { struct js_corr corr; if (data.calibrate && (data.center_min - data.range_min) != 0 && (data.range_max - data.center_max) != 0) { corr.type = 1; corr.prec = 0; corr.coef[0] = data.center_min; corr.coef[1] = data.center_max; corr.coef[2] = (32767 * 16384) / (data.center_min - data.range_min); corr.coef[3] = (32767 * 16384) / (data.range_max - data.center_max); if (data.invert) { corr.coef[2] = -corr.coef[2]; corr.coef[3] = -corr.coef[3]; } } else { corr.type = 0; corr.prec = 0; memset(corr.coef, 0, sizeof(corr.coef)); } return corr; } void Joystick::set_calibration(const std::vector& data) { std::vector corr; std::transform(data.begin(), data.end(), std::back_inserter(corr), cal2corr); if (ioctl(fd, JSIOCSCORR, &*corr.begin()) < 0) { std::ostringstream str; str << filename << ": " << strerror(errno); throw std::runtime_error(str.str()); } } void Joystick::clear_calibration() { std::vector data; for(int i = 0; i < get_axis_count(); ++i) { CalibrationData cal; cal.calibrate = false; cal.invert = false; cal.center_min = 0; cal.center_max = 0; cal.range_min = 0; cal.range_max = 0; data.push_back(cal); } set_calibration(data); } void Joystick::reset_calibration() { set_calibration(orig_calibration_data); } std::vector Joystick::get_button_mapping() { uint16_t btnmap[KEY_MAX - BTN_MISC + 1]; if (ioctl(fd, JSIOCGBTNMAP, btnmap) < 0) { std::ostringstream str; str << filename << ": " << strerror(errno); throw std::runtime_error(str.str()); } else { std::vector mapping; std::copy(btnmap, btnmap + button_count, std::back_inserter(mapping)); return mapping; } } std::vector Joystick::get_axis_mapping() { uint8_t axismap[ABS_MAX + 1]; if (ioctl(fd, JSIOCGAXMAP, axismap) < 0) { std::ostringstream str; str << filename << ": " << strerror(errno); throw std::runtime_error(str.str()); } else { std::vector mapping; std::copy(axismap, axismap + axis_count, std::back_inserter(mapping)); return mapping; } } void Joystick::set_button_mapping(const std::vector& mapping) { assert((int)mapping.size() == button_count); uint16_t btnmap[KEY_MAX - BTN_MISC + 1]; memset(btnmap, 0, sizeof(btnmap)); std::copy(mapping.begin(), mapping.end(), btnmap); if (0) for(int i = 0; i < button_count; ++i) { std::cout << i << " -> " << btnmap[i] << std::endl; } if (ioctl(fd, JSIOCSBTNMAP, btnmap) < 0) { std::ostringstream str; str << filename << ": " << strerror(errno); throw std::runtime_error(str.str()); } } int Joystick::get_axis_state(int id) { if (id >= 0 && id < (int)axis_state.size()) return axis_state[id]; else return 0; } void Joystick::set_axis_mapping(const std::vector& mapping) { assert((int)mapping.size() == axis_count); uint8_t axismap[ABS_MAX + 1]; std::copy(mapping.begin(), mapping.end(), axismap); if (ioctl(fd, JSIOCSAXMAP, axismap) < 0) { std::ostringstream str; str << filename << ": " << strerror(errno); throw std::runtime_error(str.str()); } } void Joystick::correct_calibration(const std::vector& mapping_old, const std::vector& mapping_new) { int axes[ABS_MAX + 1]; // axes[name] -> old_idx for(std::vector::const_iterator i = mapping_old.begin(); i != mapping_old.end(); ++i) { axes[*i] = i - mapping_old.begin(); } std::vector callib_old = get_calibration(); std::vector callib_new; for(std::vector::const_iterator i = mapping_new.begin(); i != mapping_new.end(); ++i) { callib_new.push_back(callib_old[axes[*i]]); } set_calibration(callib_new); } void Joystick::write(XMLWriter& out) { out.start_section("joystick"); out.write("name", name); out.write("device", filename); { // write CalibrationData std::vector data = get_calibration(); out.start_section("calibration"); for(std::vector::iterator i = data.begin(); i != data.end(); ++i) { out.start_section("axis"); //out.write("id", i - data.begin()); out.write("calibrate", i->calibrate); out.write("center-min", i->center_min); out.write("center-max", i->center_max); out.write("range-min", i->range_min); out.write("range-max", i->range_max); out.write("invert", i->invert); out.end_section("axis"); } out.end_section("calibration"); } { std::vector mapping = get_axis_mapping(); out.start_section("axis-map"); for(std::vector::iterator i = mapping.begin(); i != mapping.end(); ++i) { out.write("axis", abs2str(*i)); } out.end_section("axis-map"); } { std::vector mapping = get_button_mapping(); out.start_section("button-map"); for(std::vector::iterator i = mapping.begin(); i != mapping.end(); ++i) { out.write("button", btn2str(*i)); } out.end_section("button-map"); } out.end_section("joystick"); } void Joystick::load(const XMLReader& root_reader) { std::string cfg_name; if (root_reader.read("name", cfg_name) && name == cfg_name) { // Read calibration data if (XMLReader reader = root_reader.get_section("calibration")) { std::vector calibration_data; const std::vector& sections = reader.get_sections(); for(std::vector::const_iterator i = sections.begin(); i != sections.end(); ++i) { CalibrationData data; //i->read("axis", ); //i->read("precision", ); i->read("invert", data.invert); i->read("center-min", data.center_min); i->read("center-max", data.center_max); i->read("range-min", data.range_min); i->read("range-max", data.range_max); calibration_data.push_back(data); } set_calibration(calibration_data); } { // Read axis mapping const std::vector& cfg_axis_map = root_reader.get_string_list("axis-map"); std::vector mapping; for(std::vector::const_iterator i = cfg_axis_map.begin(); i != cfg_axis_map.end(); ++i) { int type = 0; int code = 0; str2event(*i, type, code); mapping.push_back(code); } set_axis_mapping(mapping); } { // Read button mapping const std::vector& cfg_button_map = root_reader.get_string_list("button-map"); std::vector mapping; for(std::vector::const_iterator i = cfg_button_map.begin(); i != cfg_button_map.end(); ++i) { int type = 0; int code = 0; str2event(*i, type, code); mapping.push_back(code); } set_button_mapping(mapping); } } } std::string Joystick::get_evdev() const { // See /usr/share/doc/linux-doc-2.6.28/devices.txt.gz for(int i = 0; i < 32; ++i) { std::ostringstream out; out << "/dev/input/event" << i; int evdev_fd; if ((evdev_fd = open(out.str().c_str(), O_RDONLY)) < 0) { // ignore } else { char evdev_name[256]; if (ioctl(evdev_fd, EVIOCGNAME(sizeof(evdev_name)), evdev_name) < 0) { std::cout << out.str() << ": " << strerror(errno) << std::endl; } else { if (orig_name == evdev_name) { // Found a device that matches, so return it close(evdev_fd); return out.str(); } } close(evdev_fd); } } throw std::runtime_error("couldn't find evdev for " + filename); } #ifdef __TEST__ // g++ -D__TEST__ joystick.cpp evdev_helper.cpp xml_writer.cpp xml_reader.cpp -o joystick-test `pkg-config --cflags --libs gtkmm-2.4 sigc++-2.0` int main(int argc, char** argv) { for(int i = 1; i < argc; ++i) { Joystick joystick(argv[i]); std::cout << "Filename: '" << joystick.get_filename() << "'\n"; std::cout << "Name: '" << joystick.get_name() << "'\n"; std::cout << "Axis: " << joystick.get_axis_count() << "\n"; std::cout << "Button: " << joystick.get_button_count() << "\n"; std::cout << "Evdev: '" << joystick.get_evdev() << "'\n"; } return 0; } #endif /* EOF */ jstest-gtk-0.1.1~git20090722/src/joystick_list_widget.cpp0000644000175000017500000001037511531037643022137 0ustar stevesteve/* ** jstest-gtk - A graphical joystick tester ** Copyright (C) 2009 Ingo Ruhnke ** ** This program is free software: you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation, either version 3 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program. If not, see . */ #include #include "main.hpp" #include "joystick.hpp" #include "joystick_description.hpp" #include "joystick_list_widget.hpp" class DeviceListColumns : public Gtk::TreeModel::ColumnRecord { private: static DeviceListColumns* instance_; public: static DeviceListColumns& instance() { if (instance_) return *instance_; else return *(instance_ = new DeviceListColumns()); } Gtk::TreeModelColumn > icon; Gtk::TreeModelColumn path; Gtk::TreeModelColumn name; private: DeviceListColumns() { add(icon); add(path); add(name); } }; DeviceListColumns* DeviceListColumns::instance_ = 0; JoystickListWidget::JoystickListWidget() : Gtk::Dialog("Joystick Preferences"), label("Below is a list of available joysticks on the system. Press Refresh to " "update the list, press Properties to get a seperate device dialog. The " "devices listed are only joystick devices, not evdev devices or SDL " "devices, you can view the other ones via the top tab.") //frame("Device List"), { set_has_separator(false); set_default_size(450, 310); label.set_line_wrap(); scrolled.set_border_width(5); scrolled.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_ALWAYS); scrolled.add(treeview); get_vbox()->add(scrolled); add_button(Gtk::Stock::REFRESH, 2); add_button(Gtk::Stock::PROPERTIES, 1); add_button(Gtk::Stock::CLOSE, 0); signal_response().connect(sigc::mem_fun(this, &JoystickListWidget::on_response)); // Set model device_list = Gtk::ListStore::create(DeviceListColumns::instance()); treeview.set_model(device_list); treeview.set_headers_visible(false); treeview.append_column("Icon", DeviceListColumns::instance().icon); treeview.append_column("Name", DeviceListColumns::instance().name); treeview.signal_row_activated().connect(sigc::mem_fun(this, &JoystickListWidget::on_row_activated)); on_refresh(); } void JoystickListWidget::on_row_activated(const Gtk::TreeModel::Path& path, Gtk::TreeViewColumn* column) { Gtk::TreeModel::iterator it = treeview.get_model()->get_iter(path); if (it) { Main::current()->show_device_property_dialog((*it)[DeviceListColumns::instance().path]); } } void JoystickListWidget::on_response(int v) { if (v == 0) { hide(); } else if (v == 1) { on_properties(); } else if (v == 2) { on_refresh(); } } void JoystickListWidget::on_refresh() { const std::vector& joysticks = Joystick::get_joysticks(); device_list->clear(); for(std::vector::const_iterator i = joysticks.begin(); i != joysticks.end(); ++i) { Gtk::ListStore::iterator it = device_list->append(); (*it)[DeviceListColumns::instance().icon] = Gdk::Pixbuf::create_from_file("data/generic.png"); (*it)[DeviceListColumns::instance().path] = i->filename; std::ostringstream out; out << i->name << "\n" << "Device: " << i->filename << "\n" << "Axes: " << i->axis_count << "\n" << "Buttons: " << i->button_count; (*it)[DeviceListColumns::instance().name] = out.str(); } if (!joysticks.empty()) treeview.get_selection()->select(device_list->children().begin()); } void JoystickListWidget::on_properties() { Gtk::TreeModel::iterator it = treeview.get_selection()->get_selected(); if (it) { Main::current()->show_device_property_dialog((*it)[DeviceListColumns::instance().path]); } } /* EOF */ jstest-gtk-0.1.1~git20090722/src/joystick_calibration_widget.hpp0000644000175000017500000000351311531037643023454 0ustar stevesteve/* ** jstest-gtk - A graphical joystick tester ** Copyright (C) 2009 Ingo Ruhnke ** ** This program is free software: you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation, either version 3 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program. If not, see . */ #ifndef HEADER_JOYSTICK_CALIBRATION_WIDGET_HPP #define HEADER_JOYSTICK_CALIBRATION_WIDGET_HPP #include #include #include #include #include #include "joystick.hpp" class JoystickCalibrationWidget : public Gtk::Dialog { private: Joystick& joystick; Gtk::Label label; Gtk::Frame axis_frame; Gtk::Table axis_table; Gtk::HButtonBox buttonbox; Gtk::Button calibration_button; struct CalibrationData { Gtk::CheckButton* invert; Gtk::Adjustment* center_min; Gtk::Adjustment* center_max; Gtk::Adjustment* range_min; Gtk::Adjustment* range_max; }; std::vector calibration_data; public: JoystickCalibrationWidget(Joystick& joystick); void update_with(const std::vector& data); void on_clear(); void on_apply(); void on_response(int i); void on_calibrate(); private: JoystickCalibrationWidget(const JoystickCalibrationWidget&); JoystickCalibrationWidget& operator=(const JoystickCalibrationWidget&); }; #endif /* EOF */ jstest-gtk-0.1.1~git20090722/src/calibrate_maximum_dialog.hpp0000644000175000017500000000276511531037643022715 0ustar stevesteve/* ** jstest-gtk - A graphical joystick tester ** Copyright (C) 2009 Ingo Ruhnke ** ** This program is free software: you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation, either version 3 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program. If not, see . */ #ifndef HEADER_JSTEST_GTK_CALIBRATE_MAXIMUM_DIALOG_HPP #define HEADER_JSTEST_GTK_CALIBRATE_MAXIMUM_DIALOG_HPP #include #include class Joystick; class CalibrateMaximumDialog : public Gtk::Dialog { private: Joystick& joystick; std::vector orig_data; Gtk::Label label; sigc::connection connection; std::vector is_init_axis_state; std::vector min_axis_state; std::vector max_axis_state; public: CalibrateMaximumDialog(Joystick& joystick); void on_response(int v); void on_axis_move(int id, int value); private: CalibrateMaximumDialog(const CalibrateMaximumDialog&); CalibrateMaximumDialog& operator=(const CalibrateMaximumDialog&); }; #endif /* EOF */ jstest-gtk-0.1.1~git20090722/src/rudder_widget.hpp0000644000175000017500000000225711531037643020537 0ustar stevesteve/* ** jstest-gtk - A graphical joystick tester ** Copyright (C) 2009 Ingo Ruhnke ** ** This program is free software: you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation, either version 3 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program. If not, see . */ #ifndef HEADER_JSTEST_GTK_RUDDER_WIDGET_HPP #define HEADER_JSTEST_GTK_RUDDER_WIDGET_HPP #include class RudderWidget : public Gtk::DrawingArea { private: double pos; public: RudderWidget(int width, int height); bool on_expose_event(GdkEventExpose* event); void set_pos(double p); private: RudderWidget(const RudderWidget&); RudderWidget& operator=(const RudderWidget&); }; #endif /* EOF */ jstest-gtk-0.1.1~git20090722/src/joystick_description.hpp0000644000175000017500000000247211531037643022150 0ustar stevesteve/* ** jstest-gtk - A graphical joystick tester ** Copyright (C) 2009 Ingo Ruhnke ** ** This program is free software: you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation, either version 3 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program. If not, see . */ #ifndef HEADER_JSTEST_GTK_JOYSTICK_DESCRIPTION_HPP #define HEADER_JSTEST_GTK_JOYSTICK_DESCRIPTION_HPP #include class JoystickDescription { private: public: std::string filename; std::string name; int axis_count; int button_count; JoystickDescription(const std::string& filename_, const std::string& name_, int axis_count_, int button_count_) : filename(filename_), name(name_), axis_count(axis_count_), button_count(button_count_) {} }; #endif /* EOF */ jstest-gtk-0.1.1~git20090722/src/xml_writer.hpp0000644000175000017500000000257011531037643020101 0ustar stevesteve/* ** jstest-gtk - A graphical joystick tester ** Copyright (C) 2009 Ingo Ruhnke ** ** This program is free software: you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation, either version 3 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program. If not, see . */ #ifndef HEADER_JSTEST_GTK_XML_WRITER_HPP #define HEADER_JSTEST_GTK_XML_WRITER_HPP #include #include class XMLWriter { private: std::auto_ptr out; int depth; public: XMLWriter(const std::string& filename); void indent(); void start_section(const std::string& name); void end_section(const std::string& name); void write(const std::string& name, const std::string& value); void write(const std::string& name, int value); void write(const std::string& name, bool value); private: XMLWriter(const XMLWriter&); XMLWriter& operator=(const XMLWriter&); }; #endif /* EOF */ jstest-gtk-0.1.1~git20090722/src/remap_widget.cpp0000644000175000017500000001100211531037643020335 0ustar stevesteve/* ** jstest-gtk - A graphical joystick tester ** Copyright (C) 2009 Ingo Ruhnke ** ** This program is free software: you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation, either version 3 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program. If not, see . */ #include #include #include "joystick.hpp" #include "remap_widget.hpp" class RemapWidgetColumns : public Gtk::TreeModel::ColumnRecord { public: static RemapWidgetColumns* instance_; public: static RemapWidgetColumns& instance() { if (instance_) return *instance_; else return *(instance_ = new RemapWidgetColumns()); } Gtk::TreeModelColumn id; Gtk::TreeModelColumn name; private: RemapWidgetColumns() { add(id); add(name); } }; RemapWidgetColumns* RemapWidgetColumns::instance_ = 0; RemapWidget::RemapWidget(Joystick& joystick_, Mode mode_) : joystick(joystick_), mode(mode_) { map_list = Gtk::ListStore::create(RemapWidgetColumns::instance()); treeview.set_model(map_list); if (mode == REMAP_AXIS) treeview.append_column("Axes", RemapWidgetColumns::instance().name); else treeview.append_column("Buttons", RemapWidgetColumns::instance().name); set_border_width(5); treeview.set_border_width(5); pack_start(treeview, Gtk::PACK_EXPAND_WIDGET); treeview.set_reorderable(); map_list->signal_row_inserted().connect(sigc::mem_fun(this, &RemapWidget::on_my_row_inserted)); map_list->signal_row_deleted().connect(sigc::mem_fun(this, &RemapWidget::on_my_row_deleted)); map_list->signal_rows_reordered().connect(sigc::mem_fun(this, &RemapWidget::on_my_rows_reordered)); } void RemapWidget::add_entry(int id, const std::string& str) { Gtk::ListStore::iterator it = map_list->append(); (*it)[RemapWidgetColumns::instance().id] = id; (*it)[RemapWidgetColumns::instance().name] = str; } struct RemapEntry { int id; std::string name; bool operator<(const RemapEntry& rhs) const { return id < rhs.id; } }; void RemapWidget::on_clear() { // We simple sort the list here by 'id' // Convert the ListStore into a vector std::vector rows; for(Gtk::TreeIter i = map_list->children().begin(); i != map_list->children().end(); ++i) { RemapEntry entry; entry.id = (*i)[RemapWidgetColumns::instance().id]; entry.name = (*i)[RemapWidgetColumns::instance().name]; rows.push_back(entry); } // Sort the vector std::sort(rows.begin(), rows.end()); // Renter the vector into the liststore map_list->clear(); for(std::vector::iterator i = rows.begin(); i != rows.end(); ++i) { add_entry(i->id, i->name); } on_apply(); } void RemapWidget::on_apply() { std::vector mapping; std::vector mapping_old; for(Gtk::TreeIter i = map_list->children().begin(); i != map_list->children().end(); ++i) { mapping.push_back((*i)[RemapWidgetColumns::instance().id]); } if (mode == REMAP_AXIS) { mapping_old = joystick.get_axis_mapping(); joystick.set_axis_mapping(mapping); joystick.correct_calibration(mapping_old, mapping); } else if (mode == REMAP_BUTTON) { joystick.set_button_mapping(mapping); } } void RemapWidget::on_my_rows_reordered(const Gtk::TreeModel::Path& path, const Gtk::TreeModel::iterator& iter, int* new_order) { // std::cout << "on_my_rows_reordered" << std::endl; } void RemapWidget::on_my_row_inserted(const Gtk::TreeModel::Path& path, const Gtk::TreeModel::iterator& iter) { // std::cout << "on_my_rows_inserted" << std::endl; } void RemapWidget::on_my_row_deleted(const Gtk::TreeModel::Path& path) { // std::cout << "on_my_rows_deleted" << std::endl; if (mode == REMAP_AXIS) { if (joystick.get_axis_count() == (int)map_list->children().size()) { on_apply(); } } else if (mode == REMAP_BUTTON) { if (joystick.get_button_count() == (int)map_list->children().size()) { on_apply(); } } } /* EOF */ jstest-gtk-0.1.1~git20090722/src/xml_reader.hpp0000644000175000017500000000273711531037643020034 0ustar stevesteve/* ** jstest-gtk - A graphical joystick tester ** Copyright (C) 2009 Ingo Ruhnke ** ** This program is free software: you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation, either version 3 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program. If not, see . */ #ifndef HEADER_JSTEST_GTK_XML_READER_HPP #define HEADER_JSTEST_GTK_XML_READER_HPP #include class XMLListNode; class XMLNode; class XMLReader { private: XMLListNode* root; public: XMLReader(XMLListNode* node); operator bool() const { return root; } std::string get_name() const; XMLNode* get_node(const std::string& name) const; XMLReader get_section(const std::string& name) const; std::vector get_sections() const; std::vector get_string_list(const std::string& name) const; bool read(const std::string& name, bool& value) const; bool read(const std::string& name, int& value) const; bool read(const std::string& name, std::string& value) const; }; #endif /* EOF */ jstest-gtk-0.1.1~git20090722/src/xml_reader.cpp0000644000175000017500000000567711531037643020035 0ustar stevesteve/* ** jstest-gtk - A graphical joystick tester ** Copyright (C) 2009 Ingo Ruhnke ** ** This program is free software: you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation, either version 3 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program. If not, see . */ #include "xml_parser.hpp" #include "xml_reader.hpp" XMLReader::XMLReader(XMLListNode* root_) : root(root_) { } std::string XMLReader::get_name() const { return root->get_name(); } XMLNode* XMLReader::get_node(const std::string& name) const { if (root) { for(std::vector::const_iterator i = root->children.begin(); i != root->children.end(); ++i) { if ((*i)->get_name() == name) return *i; } } return 0; } XMLReader XMLReader::get_section(const std::string& name) const { return XMLReader(dynamic_cast(get_node(name))); } std::vector XMLReader::get_sections() const { std::vector lst; if (root) { for(std::vector::const_iterator i = root->children.begin(); i != root->children.end(); ++i) { lst.push_back(XMLReader(dynamic_cast(*i))); } } return lst; } std::vector XMLReader::get_string_list(const std::string& name) const { std::vector lst; XMLListNode* node = dynamic_cast(get_node(name)); if (node) { for(std::vector::iterator i = node->children.begin(); i != node->children.end(); ++i) { if (XMLDataNode* data = dynamic_cast(*i)) { lst.push_back(data->data); } } return lst; } else { return lst; } } bool XMLReader::read(const std::string& name, bool& value) const { XMLDataNode* node = dynamic_cast(get_node(name)); if (node) { value = (node->data != "0"); return true; } else { return false; } } bool XMLReader::read(const std::string& name, int& value) const { XMLDataNode* node = dynamic_cast(get_node(name)); if (node) { value = atoi(node->data.c_str()); return true; } else { return false; } } bool XMLReader::read(const std::string& name, std::string& value) const { XMLDataNode* node = dynamic_cast(get_node(name)); if (node) { value = node->data; return true; } else { return false; } } /* EOF */ jstest-gtk-0.1.1~git20090722/src/button_widget.hpp0000644000175000017500000000233211531037643020557 0ustar stevesteve/* ** jstest-gtk - A graphical joystick tester ** Copyright (C) 2009 Ingo Ruhnke ** ** This program is free software: you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation, either version 3 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program. If not, see . */ #ifndef HEADER_JSTEST_GTK_BUTTON_WIDGET_HPP #define HEADER_JSTEST_GTK_BUTTON_WIDGET_HPP #include class ButtonWidget : public Gtk::DrawingArea { private: std::string name; bool down; public: ButtonWidget(int width, int height, const std::string& name); bool on_expose_event(GdkEventExpose* event); void set_down(bool t); private: ButtonWidget(const ButtonWidget&); ButtonWidget& operator=(const ButtonWidget&); }; #endif /* EOF */ jstest-gtk-0.1.1~git20090722/src/main.hpp0000644000175000017500000000305511531037643016630 0ustar stevesteve/* ** jstest-gtk - A graphical joystick tester ** Copyright (C) 2009 Ingo Ruhnke ** ** This program is free software: you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation, either version 3 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program. If not, see . */ #ifndef HEADER_JSTEST_GTK_MAIN_HPP #define HEADER_JSTEST_GTK_MAIN_HPP #include #include class Joystick; class JoystickListWidget; class Main { private: static Main* current_; public: static Main* current() { return current_; } private: JoystickListWidget* list_dialog; std::vector joysticks; std::vector dialogs; std::string cfg_directory; void on_dialog_hide(Gtk::Dialog* dialog); public: Main(); ~Main(); void show_device_list_dialog(); void show_device_property_dialog(const std::string& filename); void show_calibration_dialog(Joystick& joystick); void show_mapping_dialog(Joystick& joystick); int main(int argc, char** argv); std::string get_cfg_directory() const { return cfg_directory; } }; #endif /* EOF */ jstest-gtk-0.1.1~git20090722/src/joystick_calibration_widget.cpp0000644000175000017500000001507711531037643023457 0ustar stevesteve/* ** jstest-gtk - A graphical joystick tester ** Copyright (C) 2009 Ingo Ruhnke ** ** This program is free software: you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation, either version 3 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program. If not, see . */ #include #include #include #include #include "joystick.hpp" #include "calibrate_maximum_dialog.hpp" #include "joystick_calibration_widget.hpp" JoystickCalibrationWidget::JoystickCalibrationWidget(Joystick& joystick) : Gtk::Dialog("Calibration: " + joystick.get_name()), joystick(joystick), label("The center values are the minimum and the maximum values of the deadzone. " "The min and max values refer to the outer values. You have to unplug " "your joystick or reboot to reset the values to their original default.\n" "\n" "To run the calibration wizard, press the Calibrate button."), axis_frame("Axes"), axis_table(joystick.get_axis_count() + 1, 5), buttonbox(Gtk::BUTTONBOX_SPREAD), calibration_button("Start Calibration") { set_has_separator(false); set_border_width(5); axis_frame.set_border_width(5); axis_table.set_border_width(5); label.set_use_markup(true); label.set_line_wrap(); get_vbox()->pack_start(label, Gtk::PACK_SHRINK); calibration_button.signal_clicked().connect(sigc::mem_fun(this, &JoystickCalibrationWidget::on_calibrate)); buttonbox.set_border_width(5); buttonbox.add(calibration_button); get_vbox()->pack_start(buttonbox, Gtk::PACK_SHRINK); axis_table.attach(*Gtk::manage(new Gtk::Label("Axes")), 0, 1, 0, 1); axis_table.attach(*Gtk::manage(new Gtk::Label("CenterMin")), 1, 2, 0, 1); axis_table.attach(*Gtk::manage(new Gtk::Label("CenterMax")), 2, 3, 0, 1); axis_table.attach(*Gtk::manage(new Gtk::Label("RangeMin")), 3, 4, 0, 1); axis_table.attach(*Gtk::manage(new Gtk::Label("RangeMax")), 4, 5, 0, 1); axis_table.attach(*Gtk::manage(new Gtk::Label("Invert")), 5, 6, 0, 1); axis_table.set_col_spacing(2, 8); for(int i = 0; i < joystick.get_axis_count(); ++i) { CalibrationData data; Gtk::SpinButton& center_min = *Gtk::manage(new Gtk::SpinButton(*Gtk::manage(data.center_min = new Gtk::Adjustment(0, -32768, 32767)))); Gtk::SpinButton& center_max = *Gtk::manage(new Gtk::SpinButton(*Gtk::manage(data.center_max = new Gtk::Adjustment(0, -32768, 32767)))); Gtk::SpinButton& range_min = *Gtk::manage(new Gtk::SpinButton(*Gtk::manage(data.range_min = new Gtk::Adjustment(0, -32768, 32767)))); Gtk::SpinButton& range_max = *Gtk::manage(new Gtk::SpinButton(*Gtk::manage(data.range_max = new Gtk::Adjustment(0, -32768, 32767)))); Gtk::CheckButton& invert = *(data.invert = Gtk::manage(new Gtk::CheckButton())); center_min.signal_value_changed().connect(sigc::mem_fun(this, &JoystickCalibrationWidget::on_apply)); center_max.signal_value_changed().connect(sigc::mem_fun(this, &JoystickCalibrationWidget::on_apply)); range_min.signal_value_changed().connect(sigc::mem_fun(this, &JoystickCalibrationWidget::on_apply)); range_max.signal_value_changed().connect(sigc::mem_fun(this, &JoystickCalibrationWidget::on_apply)); invert.signal_clicked().connect(sigc::mem_fun(this, &JoystickCalibrationWidget::on_apply)); center_min.set_tooltip_text("The minimal value of the dead zone"); center_max.set_tooltip_text("The maximum value of the dead zone"); range_min.set_tooltip_text("The minimal position reachable"); range_max.set_tooltip_text("The maximum position reachable"); calibration_data.push_back(data); std::ostringstream str; str << i; axis_table.attach(*Gtk::manage(new Gtk::Label(str.str())), 0, 1, i+1, i+2); axis_table.attach(center_min, 1, 2, i+1, i+2); axis_table.attach(center_max, 2, 3, i+1, i+2); axis_table.attach(range_min, 3, 4, i+1, i+2); axis_table.attach(range_max, 4, 5, i+1, i+2); axis_table.attach(invert, 5, 6, i+1, i+2, Gtk::SHRINK, Gtk::SHRINK); } add_button(Gtk::Stock::REVERT_TO_SAVED, 2); add_button("Raw Events", 1); add_button(Gtk::Stock::CLOSE, 0); axis_frame.add(axis_table); get_vbox()->pack_start(axis_frame, Gtk::PACK_EXPAND_WIDGET); signal_response().connect(sigc::mem_fun(this, &JoystickCalibrationWidget::on_response)); update_with(joystick.get_calibration()); } void JoystickCalibrationWidget::on_clear() { joystick.clear_calibration(); update_with(joystick.get_calibration()); } void JoystickCalibrationWidget::update_with(const std::vector& data) { assert(data.size() == calibration_data.size()); for(int i = 0; i < (int)data.size(); ++i) { calibration_data[i].invert->set_active(data[i].invert); calibration_data[i].center_min->set_value(data[i].center_min); calibration_data[i].center_max->set_value(data[i].center_max); calibration_data[i].range_min->set_value(data[i].range_min); calibration_data[i].range_max->set_value(data[i].range_max); } } void JoystickCalibrationWidget::on_apply() { std::vector data(calibration_data.size()); for(int i = 0; i < (int)data.size(); ++i) { data[i].calibrate = true; data[i].invert = calibration_data[i].invert->get_active(); data[i].center_min = calibration_data[i].center_min->get_value(); data[i].center_max = calibration_data[i].center_max->get_value(); data[i].range_min = calibration_data[i].range_min->get_value(); data[i].range_max = calibration_data[i].range_max->get_value(); } joystick.set_calibration(data); } void JoystickCalibrationWidget::on_calibrate() { CalibrateMaximumDialog dialog(joystick); dialog.show_all(); dialog.run(); update_with(joystick.get_calibration()); } void JoystickCalibrationWidget::on_response(int i) { if (i == 0) { hide(); } else if (i == 1) { on_clear(); } else if (i == 2) { joystick.reset_calibration(); update_with(joystick.get_calibration()); } } /* EOF */ jstest-gtk-0.1.1~git20090722/src/xml_parser.hpp0000644000175000017500000000672011531037643020062 0ustar stevesteve/* ** jstest-gtk - A graphical joystick tester ** Copyright (C) 2009 Ingo Ruhnke ** ** This program is free software: you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation, either version 3 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program. If not, see . */ #ifndef HEADER_JSTREE_GTK_XML_TREE_HPP #define HEADER_JSTREE_GTK_XML_TREE_HPP #include #include #include #include /* * The code below does not produce a full DOM, but a drastically * simplified one, namely nodes can either contain text or they can * contain child nodes, but not both. Nodes are also not allowed to * have attributes. */ class XMLNode { public: XMLNode() {} virtual ~XMLNode() {} virtual std::string get_name() const =0; virtual void print(std::ostream& out, int depth = 0) =0; }; class XMLListNode : public XMLNode { public: std::string name; std::vector children; XMLListNode(const std::string& name_) : name(name_) { } ~XMLListNode() { for(std::vector::iterator i = children.begin(); i != children.end(); ++i) { delete *i; } } std::string get_name() const { return name; } void print(std::ostream& out, int depth = 0) { std::cout << std::string(2*depth, ' ') << "<" << name << ">" << std::endl; for(std::vector::iterator i = children.begin(); i != children.end(); ++i) { (*i)->print(out, depth + 1); } std::cout << std::string(2*depth, ' ') << "" << std::endl; } private: XMLListNode(const XMLListNode&); XMLListNode& operator=(const XMLListNode&); }; class XMLDataNode : public XMLNode { public: std::string name; std::string data; XMLDataNode(const std::string& name_, const std::string& data_) : name(name_), data(data_) {} std::string get_name() const { return name; } void print(std::ostream& out, int depth = 0) { out << std::string(2*depth, ' ') << "<" << name << ">" << data << "" << std::endl; } private: XMLDataNode(const XMLDataNode&); XMLDataNode& operator=(const XMLDataNode&); }; class XMLParser { public: static std::auto_ptr parse(const std::string& filename); private: std::string filename; XML_Parser parser; std::auto_ptr root_node; std::vector node_stack; std::string node; std::string cdata; XMLParser(const std::string& filename); ~XMLParser(); std::auto_ptr get_root() { return root_node; } void on_start_element(const char* el, const char** attr); void on_end_element(const char* el); void on_character_data(const char* s, int len); void raise_error(const std::string& str); private: static void start_element(void* userdata, const char* el, const char** attr); static void end_element(void* userdata, const char* el); static void character_data(void* userdata, const char* s, int len); XMLParser(const XMLParser&); XMLParser& operator=(const XMLParser&); }; #endif /* EOF */ jstest-gtk-0.1.1~git20090722/src/joystick_configuration.hpp0000644000175000017500000000301511531037643022466 0ustar stevesteve/* ** jstest-gtk - A graphical joystick tester ** Copyright (C) 2009 Ingo Ruhnke ** ** This program is free software: you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by ** the Free Software Foundation, either version 3 of the License, or ** (at your option) any later version. ** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. ** ** You should have received a copy of the GNU General Public License ** along with this program. If not, see . */ #ifndef HEADER_JSTEST_GTK_JOYSTICK_CONFIGURATION_HPP #define HEADER_JSTEST_GTK_JOYSTICK_CONFIGURATION_HPP #include class JoystickConfiguration { private: public: JoystickConfiguration(const std::string& filename); ~JoystickConfiguration(); void on_start_element(const char* el, const char** attr); void on_end_element(const char* el); void on_character_data(const char* s, int len); private: static void start_element(void* userdata, const char* el, const char** attr); static void end_element(void* userdata, const char* el); static void character_data(void* userdata, const char* s, int len); private: JoystickConfiguration(const JoystickConfiguration&); JoystickConfiguration& operator=(const JoystickConfiguration&); }; #endif /* EOF */ jstest-gtk-0.1.1~git20090722/README0000644000175000017500000000537111531037643015267 0ustar stevesteve[[ jstest-gtk ]] ================ jstest-gtk is a simple joystick tester based on Gtk+. It provides you with a list of attached joysticks, a way to display which buttons and axis are pressed, a way to remap axis and buttons and a way to calibrate your joystick. You can find the latest version at: * http://github.com/Grumbel/jstest-gtk/tree/master Questions, comments and bug reporst can be given to: * Ingo Ruhnke [[ Compiling ]] =============== Make sure you have the following pieces of software installed (they are part of most distributions): * scons * sigc++ * gtkmm * exapt You can compile it by typing: $ scons [[ Usage ]] =========== Once compiled you can start jstest-gtk with: $ ./jstest-gtk or if you know the device you want to test with: $ ./jstest-gtk /dev/input/js0 The main window will provide you with a list of currently available joysticks. When you double click a joystick it will display the Test dialog, allowing you to test buttons and axes on the joystick. The mapping dialog allows you to reorder the buttons and axis. This is useful for example when a game expects the dpad to be on axis 0 and 1, while in reality it is often on axis 4 and 5 on a dual-analogstick gamepad. The calibration dialog allows you to manipulate some low level details on how the raw axis values are mapped to the joystick device. For example you can inverse an axis, disable an axis or remove its deadzone, to gain more fine control on small movements. This is especially useful as the default calibration values for most joysticks give it a far bigger deadzone then needed, thus reducing your ability for fine movements. [[ SDL Notes ]] =============== Depending on what version and what compilation flags where used, your version of SDL might not use the joystick interface at all, but instead use the /dev/input/event* device directly. That means that any calibration or button/axis mapping will be ignored, as those apply to the joystick interface, not evdev. To work around that you have to set an environment variable that forces SDL to use the joystick device: $ SDL_JOYSTICK_DEVICE="/dev/input/js0" $ export SDL_JOYSTICK_DEVICE When you need two or more joysticks this will not work and you might need to recompile SDL and disable the evdev support. More info can be found at: * ftp://ptah.lnf.kth.se/pub/misc/sdl-env-vars SDL_LINUX_JOYSTICK Special joystick configuration string for linux. The format is "name numaxes numhats numballs" where name is the name string of the joystick (possibly in single quotes), and the rest are the number of axes, hats and balls respectively. SDL_JOYSTICK_DEVICE Joystick device to use in the linux joystick driver, in addition to the usual: /dev/js*, /dev/input/event*, /dev/input/js* # EOF # jstest-gtk-0.1.1~git20090722/SConstruct0000644000175000017500000000267311531037643016443 0ustar stevesteve## -*- python -*- ## jstest-gtk - A graphical joystick tester ## Copyright (C) 2009 Ingo Ruhnke ## ## This program is free software: you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation, either version 3 of the License, or ## (at your option) any later version. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with this program. If not, see . env = Environment(CXXFLAGS=["-g", "-Wall", "-Werror"], LIBS=["expat"]) env.ParseConfig('pkg-config --cflags --libs gtkmm-2.4 sigc++-2.0') env.Program('jstest-gtk', [ 'src/axis_widget.cpp', 'src/button_widget.cpp', 'src/throttle_widget.cpp', 'src/rudder_widget.cpp', 'src/xml_writer.cpp', 'src/xml_reader.cpp', 'src/xml_parser.cpp', 'src/joystick_list_widget.cpp', 'src/joystick_test_widget.cpp', 'src/joystick_calibration_widget.cpp', 'src/joystick_map_widget.cpp', 'src/joystick.cpp', 'src/calibrate_maximum_dialog.cpp', 'src/remap_widget.cpp', 'src/evdev_helper.cpp', 'src/main.cpp' ]) # EOF # jstest-gtk-0.1.1~git20090722/COPYING0000644000175000017500000010437411531037643015445 0ustar stevesteve GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU General Public License is a free, copyleft license for software and other kinds of works. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. We, the Free Software Foundation, use the GNU General Public License for most of our software; it applies also to any other work released this way by its authors. You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. To protect your rights, we need to prevent others from denying you these rights or asking you to surrender the rights. Therefore, you have certain responsibilities if you distribute copies of the software, or if you modify it: responsibilities to respect the freedom of others. For example, if you distribute copies of such a program, whether gratis or for a fee, you must pass on to the recipients the same freedoms that you received. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. Developers that use the GNU GPL protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License giving you legal permission to copy, distribute and/or modify it. For the developers' and authors' protection, the GPL clearly explains that there is no warranty for this free software. For both users' and authors' sake, the GPL requires that modified versions be marked as changed, so that their problems will not be attributed erroneously to authors of previous versions. Some devices are designed to deny users access to install or run modified versions of the software inside them, although the manufacturer can do so. This is fundamentally incompatible with the aim of protecting users' freedom to change the software. The systematic pattern of such abuse occurs in the area of products for individuals to use, which is precisely where it is most unacceptable. Therefore, we have designed this version of the GPL to prohibit the practice for those products. If such problems arise substantially in other domains, we stand ready to extend this provision to those domains in future versions of the GPL, as needed to protect the freedom of users. Finally, every program is threatened constantly by software patents. States should not allow patents to restrict development and use of software on general-purpose computers, but in those that do, we wish to avoid the special danger that patents applied to a free program could make it effectively proprietary. To prevent this, the GPL assures that patents cannot be used to render the program non-free. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Use with the GNU Affero General Public License. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the special requirements of the GNU Affero General Public License, section 13, concerning interaction through a network will apply to the combination as such. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. If the program does terminal interaction, make it output a short notice like this when it starts in an interactive mode: Copyright (C) This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, your program's commands might be different; for a GUI interface, you would use an "about box". You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU GPL, see . The GNU General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Lesser General Public License instead of this License. But first, please read . jstest-gtk-0.1.1~git20090722/NEWS0000644000175000017500000000075311531037643015105 0ustar stevestevejstest-gtk 0.1.1 (2009-05-??) ============================= * removed accidental boost and gtkglextmm-1.2 dependencies * improved support for PS3 controller and other with huge axis/button counts * implemented calibration wizard * added man-page jstest-gtk 0.1.0 (2009-05-08) ============================= * initial release * displays list of available joysticks * displays current button and axis state * manual joystick calibration * remapping of axis * remapping of buttons # EOF # jstest-gtk-0.1.1~git20090722/data/0002755000175000017500000000000011531037643015314 5ustar stevestevejstest-gtk-0.1.1~git20090722/data/xbox360_small.png0000644000175000017500000001367511531037643020435 0ustar stevestevePNG  IHDRP<'=sRGB pHYs B(xtIME203OIDATx՜{\U?կ鞙d2&! fyKA @D,JiUtvղV]+hĘd!݈"! @%Ɗ 0aȼyw#\NyDݮ:Փ~{~Dh}koa>gm Qwh=Y,O,?Zԥ+4hQUߖdop02Kbb9 9F1hbE*@ oɈ|<!IbboS_98[a hi\4P&PpX9`XY#5H?B"$RT$ e%{FwHقh%ѕTj0~; |NQ34DjBV ".?z>Q;Kg3:`6E`~ΝK,#8*#r($mBRW.[|FE2[n!NhoogtvvJZׁa;Yv6JI f>d馛7o1k,,}t]رcW~! R$1FBRT$o)MMM~\xf!FGGqݻw3H HȜmx*cMMM,XF<#ϣMd}R[g}FGF]B  ,K_˗/gxx-5 Mp"iL&ikkq>z{{=kiɉÛP PZ`ppilڴK/A (LJAID+项gyVz{{ms+**9s&_|1\s ,`xx880cѴ9$SI$L:įk}Q+\N@=$}3Ci&Q,u=P>< ޓR>LbH?B۶mu:XD"eYd22 CCCaxo{'mjj>H,O8N\.LJ?alہWRq7%]QUVqm8XJ:::صkGs=qb̟?ݻwkB^6P`c4%}mF.#SQQwǩ}G&{\ %S$$Y+Kˑ͑H&0 #0K۞-%pp%ApZJ4###WNI,!ٳgh"eee| >hmq.2L =>iji{>}:|+]?qD-²,bXN')+K\Ï~t?y5C =q8]w"Sq+W5%)Bkn4\.Gz{{) FX'Nى-߿.w~ϗ/3ݚέ[MqOZ4~޽{ybha}:ET>7ofzzylcw<|/q28-ZĊ+XlmS]mrso\~[nFeO__' XڵTǟ4sAV.xO@sR@c̙r9Rڊi]2 ^{d2I2}GڴVںX \'0MBpr2vKE \ulܼ9!x<[¹H,%ugpp0 . bYV}0K.)* ̛7-4 MrCxFޯm6 5T*E}}"46c@-䟙5+U⩵|.?Thk_xvPd}!ʕ+,ԧmSRWWܹs4MVZUb$4t?\z.nܢ;9<00MD"A.#JN%hnK[Y8+R/2VIE'ür-~.b̘1cFql"5&S@50 X ǂ ؾ};xG21Wg}[.:Wn`tt;J- DŽ}O>͝/tO*4jj<wt=*%O$qFmAMٱ .O~o.Qx<]VVFGGbٳg@X,b&Xx< q@BW`Ac̵rGژ9c&aYa!q"KK6^.˩{:#dO<5%sl9SKG>Hiyba022Byy9ة*lftuuXx1+W ۶<)Uhĵ8n}?zJR856mD,A)Ï c0={6UUU:uj9, C/L\P() A,_3 S+{̽˕W^$IL 8iD")Sp|I^~e2L@W<'oYS\=ActU/_0M('Qy.1AP4?)Tq\Ų,R?Oٶmuuutuu5j*4X gx5WlܸJdddWQQAUU_ש<)auk2m4z{{Yd ]]]TWWs}N4,DG 3'cd2ɖ-[1co&ec8===444L&EH6ŶFS]]͒%K<#Ih_)S6DUB$qv,:# l8'OTxlypDcǎ:}?T*UZ+]=44_.ߤTXyyhh`KA$R*$aӠ~FR,K25aa-e]&_ H%j$$\\8+VԩS$HH&^vCaҥAHF|T*O$ϙtV(QvPŗ _ o>}̙ìY.)6H_ _===$P(p뭷rĉ <3fڵkp̈́=L&ᢋ.BR- @)&8qa͖-[}Df͚'#>(`Y/"dl6֭[) %UӪf '8/P(!r8 PUq gΝlڴVٳmH {Z,bm믿N}}=3gΤ]׃(g~9_̖-[7n\XW|N 6|1%-ʮq" x<3w|9<(5*P@;I,;yqxEϟ? A#;5pr%S%WjQ϶@[5ñ(‡>eee;O؞O-*,S]]aaHY$/ eeg<[Q(:DB TLT.\H<TNw*,[ity%LZu,*`_3R^XYqI`*e+¥(P_s'xewF|ڶM>'Z*9E)mjP)]XuKsYf̘cDzQAx$%U9P1)yDd2e#J&Խ<ӝ:× ~,N+p3&& /=z͚5khkk(q"/,} `F㕇;wIJ,֭[-1w#O3Ep7!) A-֮_~QVV{DVY;6:;;' /g˲صka|Gw$oS@WɬΐmbG]eÆ dY>LgggMԸEޢʝ tuu]c سg~z {!$7Z3VN)b Sony PLAYSTATION(R)3 Controller My Profile ABS_X 0 1 -8 -8 -128 -127 ABS_Y 0 1 -8 -8 -128 -127 ABS_X ABS_Y jstest-gtk-0.1.1~git20090722/data/generic.png0000644000175000017500000001412211531037643017434 0ustar stevestevePNG  IHDRPPsRGBbKGD pHYs  tIME1IDATx|{y;;{g4-@`cY85bZW*)R qu׉78v;6$ڬ يKb@xŎ]Hǝ}oWwA/UZ>~紀vy;oRBRRi a=)_j*.c!Zk%/J5J6bS{n9ty9DJ爐732`B\IXXw~fq]27n\2'f,@`_ʁR7Tzss |\)jMع .B1C2df ˝Li JY 9H3D .>Q( ~!`S9p /LN>0,"N `H“rرNM41 ǁm4̠ O)B L "!i=)-AL 0#BS)4BKJRP}NTj1b`K mm &@BC)4)O :\z"E{#_ k-+f$߅DhKVcmxN'' yxQƂ`qPu]̺.6Xt,jh( )"iubZq% $-)PZS[0ůرDia!|K3b}[mRhJКZDGs@xhnnA]R}M!є͸xPK*D_y5f{ˆ5_̤3rH)|DJ}/Fpr:ǣ~ɻ#ڸ L/<4YF{~C|+ކ[nKջ= =֠Yj`p2~/]z1?0OK.6m7Y`i `G>;O3Swu)Ty}JyI҆YTɅG!DiWP/ FNX[ouhn~T*q|;lA0y N7#el3=@Hp]Si"Lز~+_}{.!J)sbu{w}[c=QRㄩT" C#!8a㞿Ww_ Y  령X #~՗@g p}o}[;[RR#ZAuos]6>!} uB-|mM/\?S՝M?|4ype X feCl[/ʕT*7oJR+R+]Egs"NvgƯHG_m D>TU֍_*F)Wd y ,Zhjx/ ;q=J2|!(Gybg޸G3'HK?^P(R JKփ뺋tL&ѣG?}s!ĭ6lxr z=TŴ P~y 5&^!pS"9_>!|GkD[\ _)շdu֍8CGjA_uU_ƴC\ne$|bF<ݼJj f4\r(˅ c`aC1wp]{H}kma N$Xzt*=ۦ0.({++ ɃD `,SLDR q3_m۶OCXE`(#d֑AS12(>=4y2_Gqc-@2R IC7NV* RBHhqAnݺ 6LLLLD —ֶ+jE ;2'Y(@lL~p}?<0|T:2( q'cAH.,Eׇt*mk\shhJ2DqnLx _|yb~|/}t㦋ZH+jOi{1 m6aj5zFQ9Y $-'H)1bFE]/k-ڞv A/1 PJ!r堕Dh4=Z;RB#3[ntnQ#yS!J|-B@@ C3DXjx陙n^#hĞB6A*Qd$lh:.G*< ' ߬}ooIIvqcG!7MU" z-X`Gyi608_ ~c:Zf c \ǁ R*d}qqקx fPk7~䗿Xk}}}! !S"K+IKK+8ۗŋ#eT6lU+ $,BeAT(> @E# øx>- xJJH%!^H &Dqna戔B_:wW\~9زgvZ,h4Ơ %sJqȄ(w%GF <241XՒ] aBJ@&AşQ3"e=0Ƈ- 6q%@J)eǹů[L`zq 3 5Utlq!N#~Cv*Oƪ[`D`pC*0h6P2$2~%m7-71v00$fR BWjK`,C$DLRB$am '}R^R"J##X043p2 "2\W>KVjudY_߉dRRc [ u(0:!ud39y^jB@i Lj !Z٠n6 HZ:E!ׇ\L:KꈴV 0,n+ !3)fNobE`BY'^F$l6\mݴH8jy4uc"(% +X@.G:$G~lnwe56 *7>6vYk9 C0@'uQGsh%ˎD!BT9,KhB:Y" yf؏2\Ǎe5$ߘP b!JsDQ>)jǦgffQ/v)~"\iDK%!h[ h{-JfZAkA: ɃxiAK P kWGihtJ$Abvns h{^RЎ)F h4vMNMFTz,Z -vH)h4EjELNR RL;E{à$ \aʥan B{\) +.ڈۈW&$sv7, '7  #]zq+0`xxtF 䕴mBRX1rVZT*80BV$tm07W*qJ5wU*>?l|[kRx.xAI:OEH)~ͥ)DƊQYTjٖ-"ub@Ns#Gns ?k_5]y;sL3b{:"rx=:a$Y t.Nzf}l`kaũ&?,ylFFb'N $JCCK 0‹{^j5B__VZ5 g AncZE^_g"DvtZDkW*ಱ"'#J8=Ԃ6\.chh)ׅUjV@kB@QQ 9@k L"}jLDŽJ ']QA?(d{$Xs|ljL.`A0Appq4s]Y"|JG-ZfC"$Bqd2]VJFZѩRJxÇ1=3Z Q.+`tԢa0'wyї_wI78 w?sEL,DX5k02< z &0Z*v*!l=3tK fmT&~iQJ)]Zk  #ˡjavv Obڥ`\)y1|'T^uaecc.n! $/!=ɾ3:z81pץE\>]Lgde汱'L:9 ;r9; fѳ+kg[.$w89mh&Zs DVw%xD_%f^|R83!LD Y0y;ov| ,^4]wIENDB`jstest-gtk-0.1.1~git20090722/data/jstest-gtk.10000644000175000017500000000534311531037643017500 0ustar stevesteve.\" Copyright (C) 2009, Miriam Ruiz .\" .\" This document is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. .TH "jstest-gtk" "1" "May 9, 2009" "" "" .SH "NAME" jstest\-gtk \- joystick testing and configuration tool .SH "SYNOPSIS" .B jstest\-gtk .RI [ options ] ... .RI [ device ] ... .SH "DESCRIPTION" jstest\-gtk is a simple joystick tester based on Gtk+. It provides a list of attached joysticks, a way to display which buttons and axis are pressed, a way to remap axis and buttons and a way to calibrate your joystick. Even when your joystick is working mostly fine, you might want to give it a try, as the calibration lets you get rid of overlarge default deadzones that many joysticks use and then is a noticeable problem in some games. .SH "USAGE" jstest\-gtk is mainly a graphical interface to check that your joysticks and pads work properly. You can find precise information on each axis, you can optionally recalibrate it and also change the mapping. If you run the program without parameters, you will get a window showing all the joystick devices in your system (there can be more than one). When you double click on one of them, you will get a new window with detailed information about its axes and buttons. There are two buttons in the detailed window called "Mapping" adn "Calibration", that allows you to reconfigurate the device. If you run the program with a device as an argument (for example /dev/input/js0), you will get the detailed window for that device directly, without getting the whole list of joysticks in the system. Calibration of the axis consists in a simple window in which you set the values that go directly into the operative system configuration, without doing any changes on them. They're divided in range and dead zone (or center). In both of them you have to set a minimum and a maximum. You also have a checkbox for inverting the axis. Values are changed and applied in the same instant that you modify them, there's no need for clicking anywhere or doing anything else for applying the changes. .SH "OPTIONS" These program follows the usual GNU command line syntax, with long options starting with two dashes (`\-'). .TP .B \-h, \-\-help Display help information and exit .TP .B \-v, \-\-version Display version information and exit .SH "SEE ALSO" You can find more information if you visit http://pingus.seul.org/~grumbel/jstest\-gtk/ .SH "AUTHOR" jstest\-gtk was written by Ingo Ruhnke . .PP This manual page was written by Miriam Ruiz , for the Debian project (and may be used by others). jstest-gtk-0.1.1~git20090722/data/xbox360.png0000644000175000017500000002715711531037643017245 0ustar stevestevePNG  IHDRlNsRGB pHYs B(xtIME%Z; IDATx}yp\ՕE_ZZ-lya$d22@B  aT TjԄRN!` 1``@^$a˶l}{PsL2$[ե^r=`  s1)f@q _xhKKg^Ҳ(r iT*Uܹo߾?؟^`,C42w_|H@LLOX,cصkם}}}/8$I? "6y^beMMM_5kLز"EのHyGy1 zQ(&Oauuu_洦' p8L(R,z "4 \P3ϼ[o:)r7|ۢEZ0uT&IQeT \1`߾}GxL՟Lb 0n͘1cN:[QbJz񀈘a:LdDDJ@D$e\*{v}=o|~ӟ/Ѩ0::jڴ+ $0 :1JI(*4McGŻKضmG}%jX}}7xc!g}P__d2i$f{lg%3I1 Gov^z~?BUɲ|u]w9眳φ릪Yɟ?AHv{nttts[d;ԧ_xᅬ"4DW#.Dcz( Ad2G⭷Jf27QS\"Buuugb/,]tɹ瞋H$χ|>L$JL 'Ȳ<L@['UUuVfwyqQ6e ^{k׮U À1Ys2Vrq IǃT*nCUx2KRct:JҚ隦骪jbQ5MӔeYv\($IU`pibKK ZZZ` |mǟ("yJI " :'ADꢵk׎D{HP`)|wuOS??,c10]$(B>pa@UUTWW#+xsvQ4MV:iJB$Y%_3IubTUek/u9( _E6᭷zyvz=c?B(t!4 D"ںuo 444 N~y]{B!y\.B /W_E:(0M3f̠+"ˡI4Meȁj:Y}2mǴG0s~LEq\se;o=Q,>q.pV,qE]t+'N|+W~i֬Yi'Dߏr |IȲp8 χH$'NǏ~#K].5|R +1YdlyEDL"z$Z4 T) 1s89Ufc2y5Ж먯7.]z5eg͝;3gB4eGGG^D"455!L2bsN>(ZiO8f[X,"LBDDŽuGGp\=T.ż9/QC&a69pBf{ܺF4ǾL c 55k^U`,a 6HUVAQk+}gnD$h;H$F0M(hkkܤxXF( LaM?&lmo0;3.rh 'q6 1 I^7nCM144'3t(p` y<ӗ!0L(,ˤ*ao(1 Ncҥ֭[wcE"FFF `P,-1F,ѣlxx (lƌBoxU/?{KUU즏n‚8:_t=TSkB#  #G|>l6K3g΄*4GQ*9sB!!0OBӎ@p"O10 H<ÐfDov7`,(E0S.ҕ%J2i Mtr9\. Ao"Q ,H?>iJ=̇"4!cLӄB2/{;6[/n}VTͭmsx~=OC? __u~h=Q !2 ٣0IQVBQD ,ZC^eA%0F YD>az16QH-p`VW]Ŧϝ+|ٳjkk-s8{hl0 P(@$|>+, ð>󨮮FWWEcʕ?u8ֆiӦ0 $ɏCPCO3`b4]HI) k_C~ }O#lk={6j*^5ntkV#nűc8F</@$"""#B*5T*l6o4YO= ;&0MMX~Y|RxZ \uU_lllak1M`LdSLAmm-=  @0D[[{!"m=_DQ1_t M_)G.=LEa_GpZCEiӦu,3y a  Yyww7yn9! w\( ,Xr9adYlܸC6@ z\KnݍvW#a`hio\> î]D O)\.``@\t B@ !@tra,Gu.PA[ ӧOj 3#D"yb65:jkkQSSUU,>)@ EQJl2 8b˵|>x(̑A0r}}>UG֕u_ ~I&PLd<Ϭ 0J$[A25 `e[ MPWSǫL^I Dǃ5k\۶mc%7oW̙|>/n0S.! 0 A^`&Lӄ$IF400˗I3 7d2( 0m4@  ᛁBu[~YZԿiw@y+:uh4?FXl65k֠ cccTį%(g?g@ fL7ޘ0 o5M[UXpxN]^p,A>ʕ+>s;K$&nyKi3fhhh "B6Ess3:,tttQMM LӤD"k"=AMd+pBEnHe{KB"9woRb$I"*EF\0uܻb$TU%AxȎJ'8yr/GI{֭ ҙgNXT7+@&2"H7Pڊ qUn7zoq1YI?}g38wR͊qN(w}fΜii2Y-3822Bw}7[b c(dCN54n f u7^;Ze*q @]}x|qB%@lmn< Y ap$e2P(0USU7C! ،`$Spy'{{hJ4 -bTJ֭[[rsq%|kՋn7ROve͚5Evލ%C4 Q,w]jkkC<(##tDv%颎FucuDC!J*h=xp΃1”)S“k0P,f \!"H4i2MQ%JO ?bdԍ>3'TՁLD|[zooo֭[0jX:tG3 WK 5%^w|T(}v@u l2,X\ŢUuiQ31LӤ @L3iLFߣGaj!hB*Ӛ5-{bLb/Rl?ɺa21mIl]sJ {遟6$R YQsJ?YFۚij1پKA8ck֬_l>,0Q /o( + ^BK4MC:TnOXha")$ϟiӦ=H6ly> L&f8Čk$Ik#߂ cxW & RxA|1=Q#?ÛބL2})|mנ{thIR7X*?͟?g}'إ^U&r+^/,Jwމ#G OT6-! … Q[[t: Y6`L,cϞ=`0S B!0ƨS~q_J, 0<\ؑH=Cv3Q rSm߾uvv2IJo[zYZs,Kg,I|>0X ə0O6ʄ/W544`̙WE* W3 .jv:95'O"c|~Ƿ;jMӐfa+`EA__D066RAsps8BKK 6o IJc;yo UU: @þ}̊={6ԩS?Fa!y @${H<22bGT8?AJ85rav-" BI5-2 DQR@Bi2?UeX,bpn@}[[t[^I(]V '[{Ŋɮk>y'å{.8l2hI0444^jŊ+|zPUzmh &'RvEQxUʴ"q &}5Mn%斓Kuqb(vi8vfAnEݦ yG,'r,^z|N[b>Ϯ4 `8鴕o} L^555v^$毌?cڴi1^Q`˗/,"-{ggg:"FsUUٳdLQx<8>~30X.cb\%ST\.,XB+ ,rp:l4FUUի< Le Q7`i"s]0f755-朼?prøkvdH'l(n7$TUɓ'/jw ؄2 n 󡺺$S-ZbEQ,W\q/(%dEQԬ{Oe]v$IP]Kxc aɒ%$I{-_veY&N,̙3?1sHdQ M[ ^G2LX(be˖K. "rvJڻ+d^\D]Q(j*a׮]L&\+?d2488.?~?c/,3S6Zdl2{( ]tjllD<Pmn{%8)rA皿v驧ډV U_l݀dkfJ"@(w$VUU!ӳ>vaLUWWW_ڐJNbqR;a卥~?d2(90N$ RU9?VAvϖ;KTd4݉/;wK'Tʜ7^2e5Q,1<< ۍ~ׇRsNj366fcps4Qx{.tαkP.r'z[`N()[H̩#ʶvҥ {zzN),miioCTe8]SËG IDATI)q>d@DEVZݼ8Zeq^}rp~׮%vSXnTB[a(4{ovg`].Ne3ۍFiʙKe̙cXV %IXaUN&䅧[ťgܥHcD;?a EN_Ũ< 8M>hE8k Mu\X:V'CSd$1u" Nt8?/j+Ugd1c,`Vu1;>e`__MM BP%7zSl9WS[lIJI4gqԬnp!Ñw3d [ij'N4NBSjf[̱CMJHx0(yrgF׹)q\PUd'Ne2 W,1s@hV5Sŝ /QX @=NA-&#*97A,VF4bkI%r:''>Wf+T<ıcbddinȆO0|/2S aa,:;;Q[[&466ZJ₝$dv㨮[V4M{OT*T9NDZ;)q)ɓ'i,3EQ1FdbcllH$\Nfq]0{iIh$A5MKƼ(~(bvG}>}^B4:144Ç_[G&(KOH1@@Pʱ+5 鶨 ].,8?Dz,aD<|}tt!7ǞR&9 N)~?2L7'x ̙3g~SSӪ@ L555_|Gi'.L"UU!;zR}P>$ɲH$_Fkk!;:CyǩS%KTWW,Lu;vaɒ%buh3~p (ĉX~~?[XiElڴ|fӦM+wdY&I{g 2$" %Be/rg4w v1<<,nڴi % (" 7o|={rQ;C(+N4R ,ˬ11I&qv1عs'$I2GFF3owaHR|^ڴigۡ( v؁T*5A*@{ZvT 088W*rQʩ$*-f.î] f6lٲ*K O ^"۹s'@pV)fpVtE9|p 4 ˮY_dX^~}|_ 4M8q]wuSO=uGww7|>%I{nks2B:iTcxd< 'ؾ};ɤiˇݻ@׿5N'|#Gc``v"-|$I8~8FGG>^Ib+.]Xi p}vJu]x׎;@|g:v-644dP__^@N%S>~Ǧi2{%۶P*dYf\۶mC24$m޼yϮ]Xl٤˿Q-l_*mMAرcEQE4 }}}c7H&?7-NrpvIt>#qƍ7w}o}''xo^(4::;v @QS8[ Ŋ"}m&$xˊ+Ʒt;tګ$^zzzo߾gyD"q/./ul޼W?yɓlEÆ([/cr a8ƦM'^&v` NZ|yXWer9ݻl"{;v`߾}Q]]l6k98@Q{r߾}۳lc2dHu&\vӛoI?/O? s9gWn;חz߿whh^wv4z