To add support for a new wheel to emulate a Fanatec DD Pro, you will need to understand several key components of the GIMX codebase. Below is a breakdown of the files you should study and their relevance to implementing support for a new wheel:
1. Core Controller Files
These files define the core logic for managing controllers, including their axis mappings, button mappings, and emulation logic.
Implements the functions declared in controller.h.
Defines the controllers array, which stores all registered controller types.
Functions to modify:
Add a new entry in the controllers array for the Fanatec DD Pro.
Implement a new fp_build_report function specific to the DD Pro, which formats the report packet (e.g., buttons or axis data) as required by the hardware.
./repos/GIMX/shared/gimxcontroller/include/defs.h
Defines controller-related constants and enums.
Key enums to modify:
e_controller_type - Add an entry for the new wheel (e.g., C_TYPE_FANATEC_DD_PRO).
e_controller_axis_index - Define any new axis indices for the DD Pro, if needed.
Axis value ranges (MAX_AXIS_VALUE_16BITS, etc.) are defined here, which could be critical for configuring the DD Pro.
2. USB or Protocol Details
The Fanatec DD Pro communicates via USB or another protocol. You need to emulate its communication protocol.
Key Files:
./repos/GIMX/core/controller.h
Defines the s_adapter structure, which represents a connected adapter (USB, Bluetooth, etc.).
Contains functions for managing the communication between GIMX and the emulated hardware.
Functions to study:
adapter_set_axis - Sets axis values for the emulated controller.
adapter_forward_interrupt_in - Handles incoming USB interrupt packets.
adapter_forward_control_in - Handles incoming control packets.
./repos/GIMX/core/controller.c
Implements adapter-specific communication logic.
Functions to study:
adapter_write - Sends data to the hardware.
adapter_process_packet - Processes incoming packets from the adapter.
Emulation of a new wheel may require implementing specific USB packets for the Fanatec DD Pro.
./repos/GIMX/core/config.h
Allows configuration of devices and profiles for controllers.
Defines structures like s_mapper and s_mapper_table for creating mappings between devices and emulated controllers.
./repos/GIMX/core/config_reader.*
Handles loading configuration files for controllers.
You may need to allow configuration of the new Fanatec DD Pro wheel, including its custom axis and button mappings.
3. Force Feedback (FFB) System
The Fanatec DD Pro supports advanced force feedback. You need to ensure that GIMX can send FFB effects to the DD Pro.
Key Files:
./repos/GIMX/core/controller.h
Contains:
adapter_set_haptic_sink - Configures where force feedback data is sent.
adapter_forward_out_reports - May handle FFB data packets.
./repos/GIMX/core/config.c
Functions like cfg_process_rumble_event are used to handle force feedback events.
Ensure your new wheel can process FFB events correctly.
./repos/GIMX/core/config_reader.c
Configures force feedback tweaks (e.g., inversion, gain) for the new wheel.
Ensure the configuration parser can read and map the DD Pro’s axes and buttons.
5. Testing and Debugging
To test the new wheel, you will need to debug the axis and button mappings, as well as the FFB behavior.
Key Files:
./repos/GIMX/core/controller.c
Add debug logs in functions like adapter_write and adapter_process_packet to monitor data sent to and from the DD Pro.
./repos/GIMX/core/config.c
Use functions like cfg_process_event to ensure the wheel's inputs are processed correctly.
./repos/GIMX/core/stats.h and stats.c
If needed, extend these files to capture and output statistics for the new wheel.
Additional Steps
Research Fanatec DD Pro Protocol
Understand the USB communication protocol of the DD Pro (e.g., HID descriptors, report formats).
Tools like USB analyzers (e.g., Wireshark with USBPCap) can help reverse-engineer the protocol.
Test with Real Hardware
Once implemented, test the emulation using the actual Fanatec DD Pro hardware to validate behavior.
Update Documentation
Add details about the new wheel to the GIMX documentation for future users.
By focusing on these files and components, you can successfully add support for the Fanatec DD Pro to GIMX. Let me know if you need help with specific code or implementation details!