How does a horizontal situation indicator (HSI) work?
Your understanding is partly right. Usually HSI indicators are associated with a slaving transmitter that includes the flux gate (the magnetic sensor), but also other elements such the directional gyro unit and a slaving control.

So a typical system will usually include the below components (there are different designs, so check the characteristics of the equipment in your aircraft):


The Horizontal Situation Indicator (HSI) is the panel mounted cockpit indicator that provides a comprehensive display including usually at least heading, course, and glide scope. The heading indicator of the HSI is a remote indicating compass that gets its information from a remote slaving transmitter.
The magnetic slaving transmitter includes the flux gate that is the magnetic sensor itself, and some electronics to send the heading information to the directional gyro and HSI. This transmitter and its associated flux gate is usually located in a wingtip to minimize as much as possible magnetic interference.
a directional gyro unit that is usually remote mounted. It is using its internal gyroscope to keep and provide a stable heading reference during turns. This gyro unit is driven/slaved to the slaving transmitter.
The slaving control is panel mounted and allows to selected either "slaved gyro" or "free gyro" mode. Usually, the system is in "slaved gyro" mode and will be slaved automatically. In "free gyro" mode, a slaving meter indicator displays the difference between indicator display and earth's magnetic field, and it is possible to align manually the switch using clockwise or counterclockwise buttons.


The manual of the Bendix-King KCS 55A provides a good introduction to HSI design and operation.