### Error Example for Get Configuration Source: https://github.com/nirenjan/libx52/blob/master/daemon/protocol.dox Illustrates the error response format when a configuration parameter cannot be retrieved. ```bash ERR\0Error getting 'foo.bar'\0 ``` -------------------------------- ### Install Packages on Ubuntu Source: https://github.com/nirenjan/libx52/blob/master/INSTALL.md Installs the required packages for building libx52 on Ubuntu using apt-get. ```bash sudo apt-get install meson gettext libhidapi-dev libevdev-dev libusb-1.0-0-dev libinih-dev pkg-config python3 git ``` -------------------------------- ### Compile and Install libx52 Source: https://github.com/nirenjan/libx52/blob/master/INSTALL.md Compiles and installs the libx52 library using Meson. ```bash meson compile -C build && meson install -C build ``` -------------------------------- ### Configuration Override Example Source: https://github.com/nirenjan/libx52/blob/master/daemon/daemon.dox Example of how to override a configuration parameter using the -o command-line argument. This specific example sets the secondary clock timezone. ```bash -o clock.secondary=America/New_York ``` -------------------------------- ### Send Get Mouse Speed Command Source: https://github.com/nirenjan/libx52/blob/master/daemon/protocol.dox Example of sending a 'config get mouse speed' command to retrieve the mouse speed setting. The command must be NUL-terminated. ```shell send "config\0get\0mouse\0speed\0" ``` -------------------------------- ### Install Packages on Fedora Source: https://github.com/nirenjan/libx52/blob/master/INSTALL.md Installs the required packages for building libx52 on Fedora using dnf. ```bash sudo dnf install meson gettext-devel findutils hidapi-devel libusb-devel libevdev-devel inih-devel pkg-config python3 git ``` -------------------------------- ### Install libx52 on Ubuntu Source: https://github.com/nirenjan/libx52/blob/master/README.md Add the PPA, update package lists, and install the libx52 package on Ubuntu systems. ```bash sudo apt-add-repository ppa:nirenjan/libx52 sudo apt update sudo apt install libx52-1 ``` -------------------------------- ### Error Example for Set Configuration Source: https://github.com/nirenjan/libx52/blob/master/daemon/protocol.dox Shows the error response format when setting a configuration parameter fails due to invalid arguments. ```bash ERR\0Error 22 setting 'led.fire'='none': Invalid argument\0 ``` -------------------------------- ### Configure the libx52 Build Source: https://github.com/nirenjan/libx52/blob/master/INSTALL.md Configures the build system for libx52 using Meson. The default installation prefix is /usr. ```bash cd libx52 meson setup build -Dprefix=/usr ``` -------------------------------- ### Install Packages on macOS with Homebrew Source: https://github.com/nirenjan/libx52/blob/master/INSTALL.md Installs the required packages for building libx52 on macOS using Homebrew. ```bash brew install meson gettext hidapi libusb pkg-config python3 git ``` -------------------------------- ### Install Packages on Arch Linux Source: https://github.com/nirenjan/libx52/blob/master/INSTALL.md Installs the required packages for building libx52 on Arch Linux using pacman. ```bash pacman -S base-devel meson libusb hidapi libevdev libinih python git ``` -------------------------------- ### Receive Mouse Speed Data Response Source: https://github.com/nirenjan/libx52/blob/master/daemon/protocol.dox Example of receiving the mouse speed data from the X52 daemon. The response starts with 'DATA' followed by the key and its value. ```shell recv "DATA\0mouse\0speed\010\0" ``` -------------------------------- ### Get Configuration Parameter Source: https://github.com/nirenjan/libx52/blob/master/daemon/protocol.dox Requests a specific configuration value using the 'config get' command. Requires section and key names derived from the base configuration. ```bash DATA\0mouse\0enabled\0true\0 ``` -------------------------------- ### Configure Systemd Unit Directory Source: https://github.com/nirenjan/libx52/blob/master/INSTALL.md Configures the Meson build to install the systemd service file in a custom directory. This option is ignored if systemd is not found. ```bash -Dsystemd-unit-dir=/path/to/systemd/system ``` -------------------------------- ### Send Reload Configuration Command Source: https://github.com/nirenjan/libx52/blob/master/daemon/protocol.dox Example of sending a 'config reload' command to the X52 daemon. Ensure the command is NUL-terminated and sent in a single call. ```shell send "config\0reload\0" ``` -------------------------------- ### Receive Reload Configuration Response Source: https://github.com/nirenjan/libx52/blob/master/daemon/protocol.dox Example of receiving a successful 'config reload' response from the X52 daemon. The response indicates success and confirms the action. ```shell recv "OK\0config\0reload\0" ``` -------------------------------- ### Receive Invalid Command Response Source: https://github.com/nirenjan/libx52/blob/master/daemon/protocol.dox Example of receiving an error response for an invalid command. The response indicates an error and provides a description of the issue. ```shell recv "ERR\0Unknown command 'config reload'\0" ``` -------------------------------- ### Send Invalid Command Source: https://github.com/nirenjan/libx52/blob/master/daemon/protocol.dox Example of sending an invalid command to the X52 daemon. The daemon expects NUL-terminated strings and will return an error for malformed commands. ```shell send "config reload" ``` -------------------------------- ### Initialize and Deinitialize libx52 Device Source: https://github.com/nirenjan/libx52/blob/master/docs/integration.dox Initializes the libx52 library and connects to a supported joystick. Ensure libx52_init is called before any other operations and libx52_exit is called before termination. ```c #include libx52_device* init_libx52(void) { libx52_device *dev; int rc; // Initialize the libx52 library rc = libx52_init(&dev); if (rc != LIBX52_SUCCESS) { fputs(libx52_strerror(rc), stderr); return NULL; } // Connect to the supported joystick rc = libx52_connect(dev); if (rc != LIBX52_SUCCESS) { fputs(libx52_strerror(rc), stderr); // A failure usually just means that there is no joystick connected // Look at the return codes for more information. } return dev; } // Close the library and any associated devices libx52_exit(dev); ``` -------------------------------- ### Set Configuration Parameter Source: https://github.com/nirenjan/libx52/blob/master/daemon/protocol.dox Sets a configuration parameter using the 'config set' command. The daemon applies parsing logic and may ignore unknown keys without error. ```bash OK\0config\0set\0section\0key\0value\0 ``` -------------------------------- ### Enable specific logging format fields at build time Source: https://github.com/nirenjan/libx52/blob/master/subprojects/pinelog/README.md Control which fields (date, level, backtrace, file path) are included in the log output by setting corresponding preprocessor flags during compilation. ```C -DPINELOG_SHOW_LEVEL=1 -DPINELOG_SHOW_DATE=1 ``` -------------------------------- ### Redirect log output to a file at runtime Source: https://github.com/nirenjan/libx52/blob/master/subprojects/pinelog/README.md Use pinelog_set_output_file to specify a file path for log messages at runtime. ```C pinelog_set_output_file("/var/log/app.log"); ``` -------------------------------- ### x52_mfd_create_page Source: https://github.com/nirenjan/libx52/blob/master/docs/design/x52_mfd_pages.md Creates a new page on the MFD display. It takes a pointer to store the new page ID, a description for the page, and a callback handler for page events. ```APIDOC ## Function: x52_mfd_create_page ### Description Creates a new page on the MFD display. This function initializes a new page and associates a callback handler with it for handling user interactions. ### Signature ```c x52_mfd_create_page(uint8_t *page_id, char *description, x52_page_callback *handler) ``` ### Parameters #### Path Parameters - **page_id** (*uint8_t*) - Output - Pointer to store the ID of the newly created page. - **description** (*char*) - Input - A string describing the page. - **handler** (*x52_page_callback*) - Input - A function pointer to the callback handler for this page. ``` -------------------------------- ### Clone the libx52 Repository Source: https://github.com/nirenjan/libx52/blob/master/INSTALL.md Clones the libx52 source code from the GitHub repository. ```bash git clone https://github.com/nirenjan/libx52.git ``` -------------------------------- ### Default x52d Configuration Source: https://github.com/nirenjan/libx52/blob/master/daemon/daemon.dox This is the default configuration file for the x52d daemon. It is an INI-style file. ```ini [logging] level=warning [led] state=on brightness=100 [mfd] brightness=100 [clock] secondary=UTC ``` -------------------------------- ### Set Custom Input Group for Udev Rules Source: https://github.com/nirenjan/libx52/blob/master/INSTALL.md Configures the Meson build to use a custom group for input device access via udev rules. ```bash -Dinput-group=group ``` -------------------------------- ### Override udev Rules Directory Source: https://github.com/nirenjan/libx52/blob/master/INSTALL.md Configures the Meson build to use a custom directory for udev rules. ```bash -Dudev-rules-dir=/path/to/udev/rules.d ``` -------------------------------- ### Redirect log output stream at runtime Source: https://github.com/nirenjan/libx52/blob/master/subprojects/pinelog/README.md Use pinelog_set_output_stream to redirect log messages to a specified FILE pointer at runtime. ```C FILE *out = fopen("/run/app.fifo", "w"); pinelog_set_output_stream(out); ``` -------------------------------- ### Set default logging level at build time Source: https://github.com/nirenjan/libx52/blob/master/subprojects/pinelog/README.md Configure the default logging level during compilation using the PINELOG_DEFAULT_LEVEL preprocessor flag. ```C -DPINELOG_DEFAULT_LEVEL=PINELOG_LVL_WARNING ``` -------------------------------- ### Log an informational message with printf-style formatting Source: https://github.com/nirenjan/libx52/blob/master/subprojects/pinelog/README.md Use PINELOG_INFO to log messages with formatting. This macro is part of the standard logging macros provided by Pinelog. ```C PINELOG_INFO("configuration file %s not found, using defaults", config_file); ``` -------------------------------- ### Set default output stream at build time Source: https://github.com/nirenjan/libx52/blob/master/subprojects/pinelog/README.md Configure the default output stream for log messages during compilation using the PINELOG_DEFAULT_STREAM preprocessor flag. ```C -DPINELOG_DEFAULT_STREAM=stderr ``` -------------------------------- ### Customize level strings at build time Source: https://github.com/nirenjan/libx52/blob/master/subprojects/pinelog/README.md Define custom strings for log levels during compilation using preprocessor definitions like PINELOG_ERROR_STR and PINELOG_FATAL_STR. ```C -DPINELOG_ERROR_STR=\"E\" -DPINELOG_FATAL_STR=\"F\" ``` -------------------------------- ### X52 MFD API Functions Source: https://github.com/nirenjan/libx52/blob/master/docs/design/x52_mfd_pages.md Core functions for managing MFD pages, including creation, writing text, updating display, and deletion. ```c x52_mfd_create_page(uint8_t *page_id, char *description, x52_page_callback *handler) x52_mfd_write_line(uint8_t page_id, uint8_t line, char *text, uint8_t length) x52_mfd_update_page(uint8_t page_id, uint8_t activate) x52_mfd_delete_page(uint8_t page_id) ``` -------------------------------- ### X52 Daemon IPC Functions Source: https://github.com/nirenjan/libx52/wiki/X52-Daemon These C functions are used to establish connections, create message buffers, and send messages to the X52 daemon. ```c x52d_connection * x52d_connect(); ``` ```c int x52d_listen(); ``` ```c x52d_msgbuffer * x52d_create_msgbuffer(); ``` ```c int x52d_set_led_state(x52d_msgbuffer *, libx52_led_id, libx52_led_state); ``` ```c int x52d_set_clock_format(x52d_msgbuffer *, libx52_clock_id, libx52_clock_format); ``` ```c int x52d_send_msg(x52d_connection *, x52d_msgbuffer *); ``` -------------------------------- ### Saitek X52 USB Report Data Layout Source: https://github.com/nirenjan/libx52/wiki/X52-Controller-Map This diagram illustrates the byte-level layout of the 14-byte USB report sent by the Saitek X52 controller. It shows how different input types are packed into the report. ```text +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- | X axis data | Y axis data | Rz axis data | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- | Throttle | Rx axis data | Ry axis data | Slider data | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- | Buttons 7-0 | Buttons 15-8 | Buttons 23-16 | Buttons 31-24 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- | Hat |///|Btn| MouseX| MouseY| +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ ``` -------------------------------- ### Set runtime logging level Source: https://github.com/nirenjan/libx52/blob/master/subprojects/pinelog/README.md Use pinelog_set_level to control the minimum priority of log messages displayed at runtime. Messages below the set level will be suppressed. ```C pinelog_set_level(PINELOG_LVL_WARNING); ``` -------------------------------- ### x52_mfd_update_page Source: https://github.com/nirenjan/libx52/blob/master/docs/design/x52_mfd_pages.md Activates or deactivates an MFD page. Setting activate to 1 shows the page, and 0 hides it. ```APIDOC ## Function: x52_mfd_update_page ### Description Updates the visibility status of an MFD page. This function can be used to activate (show) or deactivate (hide) a page. ### Signature ```c x52_mfd_update_page(uint8_t page_id, uint8_t activate) ``` ### Parameters #### Path Parameters - **page_id** (*uint8_t*) - Input - The ID of the page to update. - **activate** (*uint8_t*) - Input - A flag to activate (1) or deactivate (0) the page. ``` -------------------------------- ### Saitek X52 USB Report Format Layout Source: https://github.com/nirenjan/libx52/blob/master/docs/specs/x52_controller_map.md Visual representation of the 14-byte USB HID report structure for the Saitek X52 controller, detailing the bit allocation for axes, throttle, rotaries, slider, buttons, hat, and mouse inputs. ```text +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | X axis data | Y axis data | Rz axis data | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Throttle | Rx axis data | Ry axis data | Slider data | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Buttons 7-0 | Buttons 15-8 | Buttons 23-16 | Buttons 31-24 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Hat |///|Btn| MouseY| MouseX| +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ ``` -------------------------------- ### X52 Pro USB Report Data Layout Source: https://github.com/nirenjan/libx52/blob/master/docs/specs/x52pro_controller_map.md This diagram illustrates the byte layout of the USB report data for the X52 Pro joystick, showing the bit allocation for each axis, button, and hat switch. ```text +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | X axis data | Y axis data |///| Rz axis data | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Throttle | Rx axis data | Ry axis data | Slider data | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Buttons 7-0 | Buttons 15-8 | Buttons 23-16 | Buttons 31-24 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |/| Btns 38-32 | Hat |///////| MouseY| MouseX| +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ ``` -------------------------------- ### x52_page_callback Source: https://github.com/nirenjan/libx52/blob/master/docs/design/x52_mfd_pages.md Callback function type for handling MFD page events. It receives the page ID, event type, and button state. ```APIDOC ## Type: x52_page_callback ### Description Defines the signature for a callback function that handles events from MFD pages. This allows for custom logic to be executed when specific buttons are pressed on a page. ### Signature ```c typedef void (*x52_page_callback)(uint8_t page_id, uint8_t event, uint8_t state) ``` ### Parameters #### Path Parameters - **page_id** (*uint8_t*) - Input - The ID of the page where the event occurred. - **event** (*uint8_t*) - Input - The type of event that occurred (e.g., X52_MFD_EVENT_UP, X52_MFD_EVENT_DN, X52_MFD_EVENT_SEL). - **state** (*uint8_t*) - Input - The state of the button associated with the event (e.g., X52_MFD_BUTTON_STATE_UP, X52_MFD_BUTTON_STATE_DN). ``` -------------------------------- ### Disable Systemd Log Timestamps Source: https://github.com/nirenjan/libx52/blob/master/INSTALL.md Configures the Meson build to disable timestamps in systemd logs for the X52 daemon. This is enabled by default. ```bash -Dsystemd-logs=disabled ``` -------------------------------- ### X52 MFD Callback Type Definition Source: https://github.com/nirenjan/libx52/blob/master/docs/design/x52_mfd_pages.md Defines the function signature for MFD page event callbacks, allowing custom handlers for button presses. ```c typedef void (*x52_page_callback)(uint8_t page_id, uint8_t event, uint8_t state) ``` -------------------------------- ### x52_mfd_write_line Source: https://github.com/nirenjan/libx52/blob/master/docs/design/x52_mfd_pages.md Writes text to a specific line on a given MFD page. The text will automatically scroll if it exceeds 16 characters. ```APIDOC ## Function: x52_mfd_write_line ### Description Writes text content to a specified line on an MFD page. Supports automatic scrolling for text longer than 16 characters. ### Signature ```c x52_mfd_write_line(uint8_t page_id, uint8_t line, char *text, uint8_t length) ``` ### Parameters #### Path Parameters - **page_id** (*uint8_t*) - Input - The ID of the page to write to. - **line** (*uint8_t*) - Input - The line number (0-indexed) on the page to write to. - **text** (*char*) - Input - The text string to write. - **length** (*uint8_t*) - Input - The length of the text string. ``` -------------------------------- ### Update Joystick Display Text Source: https://github.com/nirenjan/libx52/blob/master/docs/integration.dox Updates the text displayed on the joystick's built-in screens. Call libx52_update after setting the text to apply the changes to the physical device. ```c libx52_set_text(dev, 0, " Saitek ", 16); libx52_set_text(dev, 1, " X52 Flight ", 16); libx52_set_text(dev, 2, " Control System ", 16); libx52_update(dev); ``` -------------------------------- ### x52_mfd_delete_page Source: https://github.com/nirenjan/libx52/blob/master/docs/design/x52_mfd_pages.md Deletes a specified MFD page. This function should be called to free resources associated with a page when it is no longer needed. ```APIDOC ## Function: x52_mfd_delete_page ### Description Deletes an MFD page and releases any associated resources. This is typically called when a page is no longer required. ### Signature ```c x52_mfd_delete_page(uint8_t page_id) ``` ### Parameters #### Path Parameters - **page_id** (*uint8_t*) - Input - The ID of the page to delete. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.