| 1 | // SPDX-FileCopyrightText: 2009 Ingo Ruhnke <[email protected]>cxx . . $ `<file>/src/joystick.hpp`/ |
| 2 | // SPDX-FileCopyrightText: 2025 Raphael Rosch <[email protected]> |
| 3 | // SPDX-License-Identifier: GPL-3.0-or-later |
| 4 | |
| 5 | #ifndef HEADER_JSTEST_GTK_JOYSTICK_HPP |
| 6 | #define HEADER_JSTEST_GTK_JOYSTICK_HPPcxx . . $ `src/joystick.hpp:6:9`! |
| 7 | |
| 8 | #include <sigc++/signal.h> |
| 9 | #include <sigc++/connection.h> |
| 10 | #include <glibmm/main.h> |
| 11 | #include <glibmm/ustring.h> |
| 12 | #include <linux/joystick.h> |
| 13 | #include <libudev.h> |
| 14 | #include "joystick_description.hpp"cxx . . $ `<file>/src/joystick_description.hpp`/ |
| 15 | #include "joystick_config_files.hpp"cxx . . $ `<file>/src/joystick_config_files.hpp`/ |
| 16 | |
| 17 | stdcxx . . $ std/::stringcxx . . $ std/string# get_js_dev_id_from_filenamecxx . . $ get_js_dev_id_from_filename(fd626fc03107dd24).(const stdcxx . . $ std/::stringcxx . . $ std/string#& filename_); |
| 18 | |
| 19 | class Joystickcxx . . $ Joystick# |
| 20 | { |
| 21 | public: |
| 22 | struct CalibrationDatacxx . . $ Joystick#CalibrationData# { |
| 23 | bool calibratecxx . . $ Joystick#CalibrationData#calibrate.; |
| 24 | bool invertcxx . . $ Joystick#CalibrationData#invert.; |
| 25 | int center_mincxx . . $ Joystick#CalibrationData#center_min.; |
| 26 | int center_maxcxx . . $ Joystick#CalibrationData#center_max.; |
| 27 | int range_mincxx . . $ Joystick#CalibrationData#range_min.; |
| 28 | int range_maxcxx . . $ Joystick#CalibrationData#range_max.; |
| 29 | }; |
| 30 | |
| 31 | private: |
| 32 | int fdcxx . . $ Joystick#fd. = -1; |
| 33 | |
| 34 | stdcxx . . $ std/::stringcxx . . $ std/string# filenamecxx . . $ Joystick#filename.; |
| 35 | stdcxx . . $ std/::stringcxx . . $ std/string# orig_namecxx . . $ Joystick#orig_name.; |
| 36 | Glibcxx . . $ Glib/::ustringcxx . . $ Glib/ustring# namecxx . . $ Joystick#name.; |
| 37 | stdcxx . . $ std/::stringcxx . . $ std/string# js_idcxx . . $ Joystick#js_id.; |
| 38 | stdcxx . . $ std/::stringcxx . . $ std/string# js_typecxx . . $ Joystick#js_type.; |
| 39 | stdcxx . . $ std/::stringcxx . . $ std/string# vendor_idcxx . . $ Joystick#vendor_id.; |
| 40 | stdcxx . . $ std/::stringcxx . . $ std/string# product_idcxx . . $ Joystick#product_id.; |
| 41 | stdcxx . . $ std/::stringcxx . . $ std/string# usb_idcxx . . $ Joystick#usb_id.; |
| 42 | int axis_countcxx . . $ Joystick#axis_count. = 0; |
| 43 | int button_countcxx . . $ Joystick#button_count. = 0; |
| 44 | |
| 45 | void connect_jscxx . . $ Joystick#connect_js(49f6e7a06ebc5aa8).(); |
| 46 | int get_new_joystick_fdcxx . . $ Joystick#get_new_joystick_fd(b126dc7c1de90089).(); |
| 47 | bool try_adopt_devicecxx . . $ Joystick#try_adopt_device(1667653f663d0d88).(const stdcxx . . $ std/::stringcxx . . $ std/string#& path, const stdcxx . . $ std/::stringcxx . . $ std/string#& new_js_id); |
| 48 | stdcxx . . $ std/::paircxx . . $ std/pair#<stdcxx . . $ std/::stringcxx . . $ std/string#, stdcxx . . $ std/::stringcxx . . $ std/string#> get_usb_id_pair_from_udevcxx . . $ Joystick#get_usb_id_pair_from_udev(a72b7ff781e8654f).(const stdcxx . . $ std/::stringcxx . . $ std/string#& sysname); |
| 49 | |
| 50 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<int> axis_statecxx . . $ Joystick#axis_state.; |
| 51 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<CalibrationDatacxx . . $ Joystick#CalibrationData#> orig_calibration_datacxx . . $ Joystick#orig_calibration_data.; |
| 52 | |
| 53 | sigccxx . . $ sigc/::connectioncxx . . $ sigc/connection# connectioncxx . . $ Joystick#connection.; |
| 54 | |
| 55 | public: |
| 56 | Joystickcxx . . $ Joystick#Joystick(c3ca1c130ce09c52).(const stdcxx . . $ std/::stringcxx . . $ std/string#& filename, const stdcxx . . $ std/::stringcxx . . $ std/string#& js_id); |
| 57 | ~cxx . . $ Joystick#`~Joystick`(49f6e7a06ebc5aa8).Joystickcxx . . $ Joystick#(); |
| 58 | |
| 59 | JoystickConfigcxx . . $ JoystickConfig# js_cfgcxx . . $ Joystick#js_cfg.; |
| 60 | int get_fdcxx . . $ Joystick#get_fd(455f465bc33b4cdf).() const { return fdcxx . . $ Joystick#fd.; } |
| 61 | |
| 62 | void updatecxx . . $ Joystick#update(49f6e7a06ebc5aa8).(); |
| 63 | bool on_incxx . . $ Joystick#on_in(eeaa91d3ba1dceee).(Glibcxx . . $ Glib/::IOConditioncxx . . $ Glib/IOCondition# cond); |
| 64 | bool reconnectedcxx . . $ Joystick#reconnected(c9857a73d68e59ba).(); |
| 65 | |
| 66 | stdcxx . . $ std/::stringcxx . . $ std/string# get_filenamecxx . . $ Joystick#get_filename(219584694fe2b248).() const { return filenamecxx . . $ std/__cxx11/basic_string#basic_string(a47f53d4115f6ce5).; } |
| 67 | Glibcxx . . $ Glib/::ustringcxx . . $ Glib/ustring# get_namecxx . . $ Joystick#get_name(fff0f585954e56f3).() const { return namecxx . . $ Joystick#name.; } |
| 68 | stdcxx . . $ std/::stringcxx . . $ std/string# get_js_idcxx . . $ Joystick#get_js_id(219584694fe2b248).() const { return js_idcxx . . $ Joystick#js_id.; } |
| 69 | stdcxx . . $ std/::stringcxx . . $ std/string# get_js_typecxx . . $ Joystick#get_js_type(219584694fe2b248).() const { return js_typecxx . . $ Joystick#js_type.; } |
| 70 | stdcxx . . $ std/::stringcxx . . $ std/string# get_vendor_idcxx . . $ Joystick#get_vendor_id(219584694fe2b248).() const { return vendor_idcxx . . $ std/__cxx11/basic_string#basic_string(a47f53d4115f6ce5).; } |
| 71 | stdcxx . . $ std/::stringcxx . . $ std/string# get_product_idcxx . . $ Joystick#get_product_id(219584694fe2b248).() const { return product_idcxx . . $ Joystick#product_id.; } |
| 72 | stdcxx . . $ std/::stringcxx . . $ std/string# get_usb_idcxx . . $ Joystick#get_usb_id(219584694fe2b248).() const { return usb_idcxx . . $ std/__cxx11/basic_string#basic_string(a47f53d4115f6ce5).; } |
| 73 | int get_axis_countcxx . . $ Joystick#get_axis_count(455f465bc33b4cdf).() const { return axis_countcxx . . $ Joystick#axis_count.; } |
| 74 | int get_button_countcxx . . $ Joystick#get_button_count(455f465bc33b4cdf).() const { return button_countcxx . . $ Joystick#button_count.; } |
| 75 | |
| 76 | stdcxx . . $ std/::stringcxx . . $ std/string# get_js_type_from_configcxx . . $ Joystick#get_js_type_from_config(ae472d0fb84499ed).(const JoystickConfigcxx . . $ JoystickConfig#& js_cfg); |
| 77 | |
| 78 | sigccxx . . $ sigc/::signalcxx . . $ sigc/signal#<void, int, int> axis_movecxx . . $ Joystick#axis_move.; |
| 79 | sigccxx . . $ sigc/::signalcxx . . $ sigc/signal#<void, int, bool> button_presscxx . . $ Joystick#button_press.; |
| 80 | |
| 81 | int get_axis_statecxx . . $ Joystick#get_axis_state(7864480464b09eea).(int id); |
| 82 | |
| 83 | static stdcxx . . $ std/::vectorcxx . . $ std/vector#<JoystickDescriptioncxx . . $ JoystickDescription#> get_joystickscxx . . $ Joystick#get_joysticks(53f4d129233960e1).(); |
| 84 | |
| 85 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<CalibrationDatacxx . . $ Joystick#CalibrationData#> get_calibrationcxx . . $ Joystick#get_calibration(2ef09a8d9ed4db48).(); |
| 86 | void set_calibrationcxx . . $ Joystick#set_calibration(6fc732b2aab18c50).(const stdcxx . . $ std/::vectorcxx . . $ std/vector#<CalibrationDatacxx . . $ Joystick#CalibrationData#>& data); |
| 87 | void reset_calibrationcxx . . $ Joystick#reset_calibration(49f6e7a06ebc5aa8).(); |
| 88 | |
| 89 | /** Clears all calibration data, note that this will mean raw USB |
| 90 | input values, not values scaled to -32767/32767 */ |
| 91 | void clear_calibrationcxx . . $ Joystick#clear_calibration(49f6e7a06ebc5aa8).(); |
| 92 | |
| 93 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<int> get_button_mappingcxx . . $ Joystick#get_button_mapping(95cc8889724c44b9).(); |
| 94 | stdcxx . . $ std/::vectorcxx . . $ std/vector#<int> get_axis_mappingcxx . . $ Joystick#get_axis_mapping(95cc8889724c44b9).(); |
| 95 | |
| 96 | void set_button_mappingcxx . . $ Joystick#set_button_mapping(ae0b87eb58a4c9e5).(const stdcxx . . $ std/::vectorcxx . . $ std/vector#<int>& mapping); |
| 97 | void set_axis_mappingcxx . . $ Joystick#set_axis_mapping(ae0b87eb58a4c9e5).(const stdcxx . . $ std/::vectorcxx . . $ std/vector#<int>& mapping); |
| 98 | |
| 99 | /** Corrects calibration data after remaping axes */ |
| 100 | void correct_calibrationcxx . . $ Joystick#correct_calibration(30bcad1052d5d57f).(const stdcxx . . $ std/::vectorcxx . . $ std/vector#<int>& mapping_old, const stdcxx . . $ std/::vectorcxx . . $ std/vector#<int>& mapping_new); |
| 101 | |
| 102 | /** Get the evdev that this joystick device is based on. This call |
| 103 | is just a guess, not guranteed to be the exact same device, but |
| 104 | for our uses that should be enough. */ |
| 105 | stdcxx . . $ std/::stringcxx . . $ std/string# get_evdevcxx . . $ Joystick#get_evdev(219584694fe2b248).() const; |
| 106 | |
| 107 | private: |
| 108 | Joystickcxx . . $ Joystick#Joystick(612b526911bdc3a1).(const Joystickcxx . . $ Joystick#&); |
| 109 | Joystickcxx . . $ Joystick#& operatorcxx . . $ Joystick#`operator=`(c9590ae06d4e4402).=(const Joystickcxx . . $ Joystick#&); |
| 110 | }; |
| 111 | |
| 112 | #endif |
| 113 | |
| 114 | /* EOF */ |