malgo icon indicating copy to clipboard operation
malgo copied to clipboard

Allow DeviceInfo to use native Go types

Open daniel-sullivan opened this issue 8 months ago • 6 comments

Inspired by https://github.com/gen2brain/malgo/pull/30

This originally come from the requirement to have a consistent device ID which can be stored as a string (for example in a UI select box) and then be used to select the same device later.

daniel-sullivan avatar Mar 25 '25 04:03 daniel-sullivan

Thanks. I don't like including C and header file just for a few constants, is it really needed?

gen2brain avatar Mar 25 '25 04:03 gen2brain

Completely agree! Unfortunately, not including it results in:

../../constants.go:10:10: could not determine what C.ma_bool32 refers to

unless the header is included in the same file.

I tried to maintain the existing format (with constants being in constants.go)

There's a couple of alternates if you prefer:

  • I could move the ma_true and ma_false definitions into device_info.go where the header's already included
  • Change the line newDevice.IsDefault = device.isDefault == True to newDevice.IsDefault = device.isDefault == C.ma_true

daniel-sullivan avatar Mar 25 '25 04:03 daniel-sullivan

Is ma_bool32 really needed? These are just 1 and 0.

gen2brain avatar Mar 25 '25 04:03 gen2brain

Not really. If you're happy hardcoding to those, that makes everything a lot simpler. I've just had upstream libraries I'm wrapping screw around with values you expect to be constant so I'm fairly defensive.

daniel-sullivan avatar Mar 25 '25 05:03 daniel-sullivan

Yes please, that will never change I guess, so hardcoding is fine.

gen2brain avatar Mar 25 '25 05:03 gen2brain

Just for cross-linking, this PR should also fix https://github.com/gen2brain/malgo/issues/28

daniel-sullivan avatar Mar 25 '25 06:03 daniel-sullivan