Thank you Martins, SDL source is indeed very informative. At times however, I find it a bit difficult to grasp the fundamentals from it as it supports so many use cases.
Thank you too David for your code snippet. I found
linux input community docs to be very helpful in discerning the particular button mappings I was after.
I will indeed go ahead using linux_input.
To implement the same behaviour in macosx, I have far less intuition than I do for linux. I have found that there is Game Controller framework, however this only seems to support a very small subset of gamepads that Apple likes, making it impractical for me to test. Alternatively, it seems I can use HID Manager, however looking at SDL source it seems a lot of work to implement. Do you know if HID Manager is the way to go to support the widest array of popular controllers?
Thanks again.