I'm trying to read my joystick capability by using the winmm.dll
library.
Here is how I'm doing it...
from ctypes import windll, Structure, c_uint, c_ushort, c_char, c_ulong
WORD = c_ushort
UINT = c_uint
TCHAR = c_char
winmm = windll.LoadLibrary('winmm.dll')
class JOYCAPS(Structure):
_fields_ = [
('wMid', WORD),
('wPid', WORD),
('szPname', TCHAR * MAXPNAMELEN), # originally szPname[MAXPNAMELEN]
('wXmin', UINT),
('wXmax', UINT),
('wYmin', UINT),
('wYmax', UINT),
('wZmin', UINT),
('wZmax', UINT),
('wNumButtons', UINT),
('wPeriodMin', UINT),
('wPeriodMax', UINT),
('wRmin', UINT),
('wRmax', UINT),
('wUmin', UINT),
('wUmax', UINT),
('wVmin', UINT),
('wVmax', UINT),
('wCaps', UINT),
('wMaxAxes', UINT),
('wNumAxes', UINT),
('wMaxButtons', UINT),
('szRegKey', TCHAR * MAXPNAMELEN), # originally szRegKey[MAXPNAMELEN]
('szOEMVxD', TCHAR * MAX_JOYSTICKOEMVXDNAME) # originally szOEMVxD[MAX_JOYSTICKOEMVXDNAME]
]
joyinf = JOYCAPS()
err = winmm.joyGetDevCaps(0, pointer(joyinf), sizeof(joyinf))
if err == JOYERR_NOERROR:
for l in [s for s in dir(joyinf) if "_" not in s]:
print(l, getattr(joyinf, l))
When I try to do so I get an error...
function 'joyGetDevCaps' not found
After searching in the source code I found that joyGetDevCapsW
is for unicode and the joyGetDevCapsA
is not. I tried them both and got the same result.
When trying to read them I get an error number of 165 which is not listed in the original function MSDN site but is an error code for JOYERR_PARMS
which means...
The specified joystick identifier is invalid
I'm using windows 10 and python 3.6
The code is working when using the joyGetPos
and joyGetPosEx
.
Thank you