Sapd / HeadsetControl

Sidetone and Battery status for Logitech G930, G533, G633, G933 SteelSeries Arctis 7/PRO 2019 and Corsair VOID (Pro) in Linux and MacOSX
GNU General Public License v3.0
1.43k stars 174 forks source link

Add Eqalizer info to json output #354

Closed nicola02nb closed 2 months ago

nicola02nb commented 3 months ago

Description

Add for devices that supports the equalizer -e --equalizer argument some info when calling -o json like EQUALIZER_BANDS_SIZE, EQUALIZER_BAND_MIN, EQUALIZER_BAND_MAX. It can be a sectionlike this:

{
  "name": "HeadsetControl",
  "devices": [
    {
      "status": "success",
      "device": "HeadsetControl Test device",
      "vendor": "HeadsetControl",
      "product": "Test device",
      "id_vendor": "0xf00b",
      "id_product": "0xa00c",
      "capabilities": [
        "CAP_EQUALIZER",
      ],
      "capabilities_str": [
        "equalizer"
      ],
      "equalizer": {
        "band_size": 10
        "min": -10,
        "max": 10
      },
    }
  ]
}
nicola02nb commented 3 months ago

It would be also cool a section equalizer_preset that returns the presets of the headpones:

euqalizer_preset[
   flat: [0,....0,],
   bass: [....],
   ....
]
Sapd commented 3 months ago

Yeah that is quite easy to do.

However I do not fully understand your preset example. So basically what I see what we can return is something like this:

euqalizer_preset[
   flat,
   bass,
   smiley,
   focus
]

Where are the numbers in your example come from? (can you also link me the device file when you reference a specific one)

nicola02nb commented 3 months ago

Yeah, sorrry I missed some information... I was thinking something like this:

"euqalizer_preset":[
   "flat":[0,0,0,0,0,0,0],
   "bass":[0,0,0,0,0,0,0],
   "smiley":[0,0,0,0,0,0,0],
   "focus":[0,0,0,0,0,0,0]
]

I'm writing a GUI for HeadsetControl, and having those informations would be useful. Those values should come from the specific device... Take as example the Steelseries Artic Nova 7: image

Sapd commented 3 months ago

Ah yes now I get it, I saw the code before didn't realize that the command actually simply contains equalizer-payload.

Probably needs some code cleanup with more data-driven approach (defining the equalizer as struct and also using it to directly pass it to hid_write), but otherwise easily doable.

I think it can be implemented as a device function, which simply returns that information somewhere here - similar to other request functions (but that it instead returns the data from variables instead of from HID): https://github.com/Sapd/HeadsetControl/blob/f64ac48384cbb7df3878749cbe9635adefdae84c/src/device.h#L235

Can do so in the near future

nicola02nb commented 3 months ago

Yeah, it could be an idea... it seems also quite simply to implement... Tell me if you need anithing else

nicola02nb commented 3 months ago

@Sapd I done a commit on my fork where I added the feature for json output... It needs some refactor of some comments on device.h added function firms, and it also needs to get implemented all missing functions for compatible devices... can you give a look at it?

Sapd commented 3 months ago

Some suggestions:

nicola02nb commented 3 months ago

Did a rollback and a new commit following your idea.

Sapd commented 3 months ago

Looks fine to me on first looks, in any case you can create a PR from your fork