Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix MFD int too long to convert #88

Merged
merged 1 commit into from
Mar 16, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions tradedangerous/mfd/saitek/directoutput.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,10 @@ def RegisterSoftButtonCallback(self, device_handle, function):
Returns:
S_OK: The call completed successfully.
E_HANDLE: The device handle specified is invalid.

"""

logging.debug("DirectOutput.RegisterSoftButtonCallback({}, {})".format(device_handle, function))
return self.DirectOutputDLL.DirectOutput_RegisterSoftButtonCallback(device_handle, function, 0)
return self.DirectOutputDLL.DirectOutput_RegisterSoftButtonCallback(ctypes.wintypes.HANDLE(device_handle), function, 0)

def RegisterPageCallback(self, device_handle, function):
"""
Expand All @@ -182,7 +182,7 @@ def RegisterPageCallback(self, device_handle, function):
E_HANDLE: The device handle specified is invalid.
"""
logging.debug("DirectOutput.RegisterPageCallback({}, {})".format(device_handle,function))
return self.DirectOutputDLL.DirectOutput_RegisterPageCallback(device_handle, function, 0)
return self.DirectOutputDLL.DirectOutput_RegisterPageCallback(ctypes.wintypes.HANDLE(device_handle), function, 0)

def SetProfile(self, device_handle, profile):
"""
Expand All @@ -194,9 +194,9 @@ def SetProfile(self, device_handle, profile):
"""
logging.debug("DirectOutput.SetProfile({}, {})".format(device_handle, profile))
if profile:
return self.DirectOutputDLL.DirectOutput_SetProfile(device_handle, len(profile), ctypes.wintypes.LPWSTR(profile))
return self.DirectOutputDLL.DirectOutput_SetProfile(ctypes.wintypes.HANDLE(device_handle), len(profile), ctypes.wintypes.LPWSTR(profile))
else:
return self.DirectOutputDLL.DirectOutput_SetProfile(device_handle, 0, 0)
return self.DirectOutputDLL.DirectOutput_SetProfile(ctypes.wintypes.HANDLE(device_handle), 0, 0)

def AddPage(self, device_handle, page, name, active):
"""
Expand All @@ -216,7 +216,7 @@ def AddPage(self, device_handle, page, name, active):

"""
logging.debug("DirectOutput.AddPage({}, {}, {}, {})".format(device_handle, page, name, active))
return self.DirectOutputDLL.DirectOutput_AddPage(device_handle, page, active)
return self.DirectOutputDLL.DirectOutput_AddPage(ctypes.wintypes.HANDLE(device_handle), page, active)

def RemovePage(self, device_handle, page):
"""
Expand All @@ -233,7 +233,7 @@ def RemovePage(self, device_handle, page):

"""
logging.debug("DirectOutput.RemovePage({}, {})".format(device_handle, page))
return self.DirectOutputDLL.DirectOutput_RemovePage(device_handle, page)
return self.DirectOutputDLL.DirectOutput_RemovePage(ctypes.wintypes.HANDLE(device_handle), page)

def SetLed(self, device_handle, page, led, value):
"""
Expand All @@ -252,7 +252,7 @@ def SetLed(self, device_handle, page, led, value):

"""
logging.debug("DirectOutput.SetLed({}, {}, {}, {})".format(device_handle, page, led, value))
return self.DirectOutputDLL.DirectOutput_SetLed(device_handle, page, led, value)
return self.DirectOutputDLL.DirectOutput_SetLed(ctypes.wintypes.HANDLE(device_handle), page, led, value)


def SetString(self, device_handle, page, line, string):
Expand All @@ -273,7 +273,7 @@ def SetString(self, device_handle, page, line, string):

"""
logging.debug("DirectOutput.SetString({}, {}, {}, {})".format(device_handle, page, line, string))
return self.DirectOutputDLL.DirectOutput_SetString(device_handle, page, line, len(string), ctypes.wintypes.LPWSTR(string))
return self.DirectOutputDLL.DirectOutput_SetString(ctypes.wintypes.HANDLE(device_handle), page, line, len(string), ctypes.wintypes.LPWSTR(string))


class DirectOutputDevice(object):
Expand Down Expand Up @@ -328,7 +328,7 @@ def __init__(self, debug_level=0, name=None):
# 64-bit machine, are we a 32-bit python?
if platform.architecture()[0] == '32bit':
prog_dir = os.environ["ProgramFiles(x86)"]
dll_path = os.path.join(prog_dir, "Saitek\\DirectOutput\\DirectOutput.dll")
dll_path = os.path.join(prog_dir, "Logitech\\DirectOutput\\DirectOutput.dll")

self.application_name = name or DirectOutputDevice.application_name
self.debug_level = debug_level
Expand Down