Lynda.com has hired me to do the “code clinic” using Go.
I’ve nailed 4 of the 5 challenges, but this one is stumping me.
Do you have any ideas on how to capture mouse X,Y position?
The lynda.com “code clinic” includes a challenge to have your mouse control sound, and I’d like to figure out how best to do it, eg, easiest, most explainable, most appealing, showcases Go.
Here are the specs of the challenge:
– mouse click means on
– up/down = increase / decrease volume
– left/right = decrease / increase pitch
Probably the most straightforward answer is to leverage work that has been done in C. Look at SDL2 and therefore the go bindings https://github.com/veandco/go-sdl2. It looks like there exist examples for everything you need to do.
Thank you, Mark. I just ran some of the examples and captured mouse X,Y in an open window, and another one which produced sound.
I wish there was some way to do this natively in Go without binding to C.
I want to showcase Go, not some binding.
Any other thoughts?
I was thinking about https://godoc.org/syscall#pkg-constants which has a lot of constants which I don’t understand. I saw a cool program using that in Ivo Balbaert’s book:
If you want to create a GUI application you will definitely need to use some kind of C-bindings because there doesn’t exist (to my knowledge) a bridge between Go and OS X’s windowing server.
Creating a GUI app isn’t one of Go’s strong points right now, and GUI bindings in most languages are a bit of work to get going.