  Owing to the variety of possible charge and spin states and to the different
ways of coupling to the environment, paramagnetic centres in wide band-gap
semiconductors and insulators exhibit a strikingly rich spectrum of properties
and functionalities, exploited in commercial light emitters and proposed for
applications in quantum information. Here we demonstrate, by combining
synchrotron techniques with magnetic, optical and \emph{ab initio} studies,
that the codoping of GaN:Mn with Mg allows to control the Mn$^{n+}$ charge and
spin state in the range $3\le n\le 5$ and $2\ge S\ge 1$. According to our
results, this outstanding degree of tunability arises from the formation of
hitherto concealed cation complexes Mn-Mg$_k$, where the number of ligands $k$
is pre-defined by fabrication conditions. The properties of these complexes
allow to extend towards the infrared the already remarkable optical
capabilities of nitrides, open to solotronics functionalities, and generally
represent a fresh perspective for magnetic semiconductors.
