| 1 | // SPDX-FileCopyrightText: 2009 Ingo Ruhnke <[email protected]> |
| 2 | // SPDX-License-Identifier: GPL-3.0-or-later |
| 3 | |
| 4 | #ifndef HEADER_JOYSTICK_CALIBRATION_WIDGET_HPP |
| 5 | #define HEADER_JOYSTICK_CALIBRATION_WIDGET_HPP |
| 6 | |
| 7 | #include <gtkmm/box.h> |
| 8 | #include <gtkmm/checkbutton.h> |
| 9 | #include <gtkmm/frame.h> |
| 10 | #include <gtkmm/label.h> |
| 11 | #include <gtkmm/table.h> |
| 12 | #include <gtkmm/dialog.h> |
| 13 | #include <gtkmm/scrolledwindow.h> |
| 14 | |
| 15 | #include "joystick.hpp" |
| 16 | |
| 17 | class JoystickCalibrationWidget : public Gtk::Dialog |
| 18 | { |
| 19 | private: |
| 20 | Joystick& joystick; |
| 21 | |
| 22 | Gtk::Label label; |
| 23 | Gtk::Frame axis_frame; |
| 24 | Gtk::Table axis_table; |
| 25 | Gtk::HButtonBox buttonbox; |
| 26 | Gtk::Button calibration_button; |
| 27 | Gtk::ScrolledWindow scroll; |
| 28 | |
| 29 | struct CalibrationData { |
| 30 | Gtk::CheckButton* invert; |
| 31 | Glib::RefPtr<Gtk::Adjustment> center_min; |
| 32 | Glib::RefPtr<Gtk::Adjustment> center_max; |
| 33 | Glib::RefPtr<Gtk::Adjustment> range_min; |
| 34 | Glib::RefPtr<Gtk::Adjustment> range_max; |
| 35 | }; |
| 36 | |
| 37 | std::vector<CalibrationData> calibration_data; |
| 38 | |
| 39 | public: |
| 40 | JoystickCalibrationWidget(Joystick& joystick); |
| 41 | |
| 42 | void update_with(const std::vector<Joystick::CalibrationData>& data); |
| 43 | |
| 44 | void on_clear(); |
| 45 | void on_apply(); |
| 46 | void on_response(int i) override; |
| 47 | void on_calibrate(); |
| 48 | |
| 49 | private: |
| 50 | JoystickCalibrationWidget(const JoystickCalibrationWidget&); |
| 51 | JoystickCalibrationWidget& operator=(const JoystickCalibrationWidget&); |
| 52 | }; |
| 53 | |
| 54 | #endif |
| 55 | |
| 56 | /* EOF */ |