You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I would love to have the option to output in key-value format. This would make life easier when using the output for scripting and not making multiple calls to get different information.
It's actually a very good idea and probably much better than the short option right now.
However it would need a bit of work. I would prefer a separate file which receives an array, and which can convert this to both YAML, JSON or ENV variables depending on preference. Similar to the -o option of kubectl and most Go programs.
It's actually a very good idea and probably much better than the short option right now.
However it would need a bit of work. I would prefer a separate file which receives an array, and which can convert this to both YAML, JSON or ENV variables depending on preference. Similar to the -o option of kubectl and most Go programs.
Had the same thoughts. I was aiming to keep it as simple as possible and at the same time not introducing new problems. The only reason why I didn't give JSON as an example it that it is a PITA to write compared to YAML :)
The absolute best solution would be to have multiple formatters (JSON/YAML/TAML/INI/SH) but implementing that would require some rewrites.
I took a look again at which responses we have inside the code. And actually we don't have any nested or dynamic responses, also everything is already there in main.c . That means implementing that feature (even with support of multiple languages) could be quite easy.
However, we would need to define how responses should look like. It should be simple and easy to parse.
I think at the beginning I would support YAML, Sourceable/ENV format, JSON.
Thats what I would purpose (example given in JSON):
Successful response for command
Will be responded when setting Sidetone. But also when nothing is specified, so that the program can retrieve the number of the connected headset. When nothing is specified, we could also additionally include the capabilities (see below)
I am especially not sure about how to pass errors exactly to the user, here is my purpose. Everything is on one level to make it easier to parse:
{
"status": "error",
"errortype": "notfound", # e.g. could be notfound, timeout, parametererror, hiderror"errormessage": "Device not found"# Depending on what error type is, this will contain a message from headsetcontrol, or errormessage/number from HIDAPI
}
Also for battery requests, there are additionally BATTERY_UNAVAILABLE and BATTERY_CHARGING. We could also incoperate them into errortype or use batterystatus like above
Capabilities
When nothing is specified, or when explicitly requesting caps. In theory we could also return it on every command:
How would this be implemented ? Additionally to the existing stuff or as replacement ?
How can I find out if JSON is a supported output ?
I like the JSON example:
{
"status": "success",
"batterystatus": "DISCHARGING"
"battery": 42
}
How would this be implemented ? Additionally to the existing stuff or as replacement ?
As an addition for now. I would deprecate the short output, but it would still be there for probably the next two years or so (maybe longer, or also shorter when most 3rd party software migrated).
The short output could receive a warning in the --help text, and probably a message via stderr when it is used (so that it does not affect current third party software).
How can I find out if JSON is a supported output ?
When this is implemented, you would simply use it like this: headsetcontrol -b -o json simply typing headsetcontrol -o would list all supported formats.
headsetcontrol -?
Found SteelSeries Arctis (7/Pro)!
Capabilities:
* sidetone
* battery
* notification sound
* lights
* inactive time
with -? the chatmix is missing and also the "* battery status" is now only "* battery"
but "-o json" gives me the chatmix
the capabilities between -? and -o json do not match ? why ? I guess notification sound should be chatmix ?
Other then -? not matching -o json it works quite well.
I updated my extension to use -o json - and when it does not work it will fall back to the old format.
I wanted to clarify the findings before I release the new version though
Good catch! Will have to check it. I also noticed another bug where it will output the capabilities where it shouldnt (I think when just calling the program).
Also as side note -? will be then just meant for human output.
The battery status also does not seem to work.
I get always BATTERY_DISCHARGING - even when the headset is plugged into the charger or if it is turned off.
it should show charging - it is plugged to the USB cable which supplies power. When it it turned off level shows 0 but still status wrong.
Yeah this is probably not fully implemented for your headset, that why it always show DISCHARGING, only some implementations also implement the other states.
it should show charging - it is plugged to the USB cable which supplies power. When it it turned off level shows 0 but still status wrong.
Yeah this is probably not fully implemented for your headset, that why it always show DISCHARGING, only some implementations also implement the other states.
Ah I see. Maybe instead of show "BATTERY_DISCHARGING" just show "UNKNOWN" or "NOTIMPLEMENTED".
What are the possible BATTERY states anyways ?
I think it would be good to know If the BATTERY status is relyable or not.
it should show charging - it is plugged to the USB cable which supplies power. When it it turned off level shows 0 but still status wrong.
Yeah this is probably not fully implemented for your headset, that why it always show DISCHARGING, only some implementations also implement the other states.
Ah I see. Maybe instead of show "BATTERY_DISCHARGING" just show "UNKNOWN" or "NOTIMPLEMENTED". What are the possible BATTERY states anyways ? I think it would be good to know If the BATTERY status is relyable or not.
Problem is, if there are no special flags, it always assumes AVAILABLE or DISCHARGING (as long as the packet was received successfully). So there is not really a way to show unknown or something like that. One could in theory guess that when its 0, but its just an assumption.
it should show charging - it is plugged to the USB cable which supplies power. When it it turned off level shows 0 but still status wrong.
Yeah this is probably not fully implemented for your headset, that why it always show DISCHARGING, only some implementations also implement the other states.
Ah I see. Maybe instead of show "BATTERY_DISCHARGING" just show "UNKNOWN" or "NOTIMPLEMENTED". What are the possible BATTERY states anyways ? I think it would be good to know If the BATTERY status is relyable or not.
Problem is, if there are no special flags, it always assumes AVAILABLE or DISCHARGING (as long as the packet was received successfully). So there is not really a way to show unknown or something like that. One could in theory guess that when its 0, but its just an assumption.
Thanks for explaining. I think I will not show the status in my extension to not confuse the users.
It will only show discharging for some and they might file issues :(
Thanks for explaining. I think I will not show the status in my extension to not confuse the users.
It will only show discharging for some and they might file issues :(
Well it is implemented in such a way that its best to basically show nothing when its DISCHARGING. But show the status UNAVAILABLE or CHARGING when this is reported, as those are only shown when they are implemented.
Will probably included it in the docs. Also another way would be renaming it to BATTERY_SUCCESS, that maybe is a bit less ambivalent
I think "DISCHARGING" is fine.
And I can add only the charging state to my extension when the status is "BATTERY_CHARGING".
Every other state I simply do not visualize.
@ChrisLauinger77 I fixed the capabilities. Also I renamed BATTERY_DISCHARGING into BATTERY_AVAILABLE.
Also it can now return the battery level and BATTERY_CHARGING at the same time.
Activity
Sapd commentedon Mar 4, 2023
It's actually a very good idea and probably much better than the short option right now.
However it would need a bit of work. I would prefer a separate file which receives an array, and which can convert this to both YAML, JSON or ENV variables depending on preference. Similar to the
-ooption of kubectl and most Go programs.devnore commentedon Mar 13, 2023
Had the same thoughts. I was aiming to keep it as simple as possible and at the same time not introducing new problems. The only reason why I didn't give JSON as an example it that it is a PITA to write compared to YAML :)
The absolute best solution would be to have multiple formatters (JSON/YAML/TAML/INI/SH) but implementing that would require some rewrites.
Sapd commentedon Apr 30, 2023
I took a look again at which responses we have inside the code. And actually we don't have any nested or dynamic responses, also everything is already there in main.c . That means implementing that feature (even with support of multiple languages) could be quite easy.
However, we would need to define how responses should look like. It should be simple and easy to parse.
I think at the beginning I would support YAML, Sourceable/ENV format, JSON.
Thats what I would purpose (example given in JSON):
Successful response for command
Will be responded when setting Sidetone. But also when nothing is specified, so that the program can retrieve the number of the connected headset. When nothing is specified, we could also additionally include the capabilities (see below)
{ "status": "success", "device": "Corsair Void", "idVendor": "0x1b1c", "idProduct": "0x1b27", }Successful request
(device etc. will be also returned, just left out here for the discussion)
{ "status": "success", "battery": 42 }Also instead of the number BATTERY_CHARGING could be the status. Should we simply make it like this:
{ "status": "success", "battery": "CHARGING" }or
{ "status": "success", "batterystatus": "CHARGING" }and
{ "status": "success", "batterystatus": "DISCHARGING" "battery": 42 }Failed response for command
I am especially not sure about how to pass errors exactly to the user, here is my purpose. Everything is on one level to make it easier to parse:
{ "status": "error", "errortype": "notfound", # e.g. could be notfound, timeout, parametererror, hiderror "errormessage": "Device not found" # Depending on what error type is, this will contain a message from headsetcontrol, or errormessage/number from HIDAPI }Also for battery requests, there are additionally
BATTERY_UNAVAILABLEandBATTERY_CHARGING. We could also incoperate them into errortype or use batterystatus like aboveCapabilities
When nothing is specified, or when explicitly requesting caps. In theory we could also return it on every command:
{ "status": "success", "device": "Corsair Void", "idVendor": "0x1b1c", "idProduct": "0x1b27", "capabilities": ["CAP_SIDETONE", "CAP_BATTERY_STATUS"], "capabilities_str": ["sidetone", "battery status"] }For env, I would so it similar to UNIX ENVs like PATH:
I would be happy for any feedback or suggestions.
Also tagging some people of 3rd party software @centic9 @ChrisLauinger77 @zampierilucas if some of you want to provide feedback.
ChrisLauinger77 commentedon May 1, 2023
How would this be implemented ? Additionally to the existing stuff or as replacement ?
How can I find out if JSON is a supported output ?
I like the JSON example:
{
"status": "success",
"batterystatus": "DISCHARGING"
"battery": 42
}
Sapd commentedon May 1, 2023
As an addition for now. I would deprecate the short output, but it would still be there for probably the next two years or so (maybe longer, or also shorter when most 3rd party software migrated).
The short output could receive a warning in the --help text, and probably a message via stderr when it is used (so that it does not affect current third party software).
When this is implemented, you would simply use it like this:
headsetcontrol -b -o jsonsimply typingheadsetcontrol -owould list all supported formats.ChrisLauinger77 commentedon May 1, 2023
Thx for the answers.
Sapd commentedon Feb 21, 2024
The feature is practically finished and in the feature-output branch: https://github.com/Sapd/HeadsetControl/tree/feature-output
Here is an example when you just call
-o yaml:It will display all information, using
-bor so is not needed.If you use a command which sends something, like sidetone, it looks like this:
Basically you have then an actions array.
This is how errors looks like. In this case
-smakes an error and battery and chatmix:Besides yaml, json and env is supported. Thats how ENV looks like:
ChrisLauinger77 commentedon Feb 27, 2024
I am testing the version:
with -? the chatmix is missing and also the "* battery status" is now only "* battery"
but "-o json" gives me the chatmix
the capabilities between -? and -o json do not match ? why ? I guess notification sound should be chatmix ?
ChrisLauinger77 commentedon Feb 27, 2024
Other then -? not matching -o json it works quite well.
I updated my extension to use -o json - and when it does not work it will fall back to the old format.
I wanted to clarify the findings before I release the new version though
Sapd commentedon Feb 27, 2024
Good catch! Will have to check it. I also noticed another bug where it will output the capabilities where it shouldnt (I think when just calling the program).
Also as side note
-?will be then just meant for human output.Sapd commentedon Feb 27, 2024
Also as a hint, you can test also use test devices to generate test output:
And this one will generate an output with errors (on purpose):
ChrisLauinger77 commentedon Feb 27, 2024
Good to know, thx.
I continue testing when the update is ready.
ChrisLauinger77 commentedon Feb 29, 2024
The battery status also does not seem to work.
I get always BATTERY_DISCHARGING - even when the headset is plugged into the charger or if it is turned off.
-o json
it should show charging - it is plugged to the USB cable which supplies power.
When it is turned off level shows 0 but still status wrong.
Sapd commentedon Feb 29, 2024
Yeah this is probably not fully implemented for your headset, that why it always show DISCHARGING, only some implementations also implement the other states.
ChrisLauinger77 commentedon Feb 29, 2024
Ah I see. Maybe instead of show "BATTERY_DISCHARGING" just show "UNKNOWN" or "NOTIMPLEMENTED".
What are the possible BATTERY states anyways ?
I think it would be good to know If the BATTERY status is relyable or not.
Sapd commentedon Feb 29, 2024
Only this
(while AVAILABLE is same as DISCHARGING).
Problem is, if there are no special flags, it always assumes AVAILABLE or DISCHARGING (as long as the packet was received successfully). So there is not really a way to show unknown or something like that. One could in theory guess that when its 0, but its just an assumption.
ChrisLauinger77 commentedon Feb 29, 2024
Thanks for explaining. I think I will not show the status in my extension to not confuse the users.
It will only show discharging for some and they might file issues :(
Sapd commentedon Feb 29, 2024
Well it is implemented in such a way that its best to basically show nothing when its DISCHARGING. But show the status UNAVAILABLE or CHARGING when this is reported, as those are only shown when they are implemented.
Will probably included it in the docs. Also another way would be renaming it to BATTERY_SUCCESS, that maybe is a bit less ambivalent
ChrisLauinger77 commentedon Feb 29, 2024
I think "DISCHARGING" is fine.
And I can add only the charging state to my extension when the status is "BATTERY_CHARGING".
Every other state I simply do not visualize.
ChrisLauinger77 commentedon Feb 29, 2024
Do you plan to release it in the near future ? version 2.8.0 ?
Sapd commentedon Feb 29, 2024
Yes, probably in around one month
Sapd commentedon Mar 18, 2024
@ChrisLauinger77 I fixed the capabilities. Also I renamed BATTERY_DISCHARGING into BATTERY_AVAILABLE.
Also it can now return the battery level and BATTERY_CHARGING at the same time.
Btw I renamed battery status in just battery
ChrisLauinger77 commentedon Mar 18, 2024
Thx 4 info. My extension still works :)
Sapd commentedon Apr 1, 2024
Completed in #333