我希望在python代码中包装/使用Logitech C/C++库:
使用前两个(LCD和LED)即使对我来说也很容易。您需要下载zips,这里有一个带有参考的pdf,即:python for LCD:
from ctypes import CDLL, c_bool, c_wchar_p, c_int
lcd_dll = CDLL('C:\\Program Files\\Logitech Gaming Software\\LCDSDK_8.57.148\\Lib\\GameEnginesWrapper\\x64\\LogitechLcdEnginesWrapper.dll')
LogiLcdInit = lcd_dll['LogiLcdInit']
LogiLcdInit.restype = c_bool
LogiLcdInit.argtypes = (c_wchar_p, c_int)
LogiLcdIsConnected = lcd_dll['LogiLcdIsConnected']
LogiLcdIsConnected.restype = c_bool
LogiLcdIsConnected.argtypes = [c_int]
我对第三个Gkey有问题,看看第16页和第17页-logiGkeyCBContext结构。为了调用LogiGkeyInit()
,我需要:
函数的作用是初始化G-key SDK。必须先调用它,应用程序才能看到G键/按钮事件
BOOL LogiGkeyInit(logiGkeyCBContext* gkeyCBContext);
参数:
logiGkeyCBContext用于向SDK提供足够的信息,以允许将G-key事件发送回应用程序。当用户按下/释放G键/鼠标按钮,并且SDK客户端当前位于前台时,将调用已注册的回调
typedef struct
{
logiGkeyCB gkeyCallBack;
void* gkeyContext;
} logiGkeyCBContext;
typedef struct
{
unsigned int keyIdx : 8; // index of the G key or mouse button, for example, 6 for G6 or Button 6
unsigned int keyDown : 1; // key up or down, 1 is down, 0 is up
unsigned int mState : 2; // mState (1, 2 or 3 for M1, M2 and M3)
unsigned int mouse : 1; // indicate if the Event comes from a mouse, 1 is yes, 0 is no.
unsigned int reserved1 : 4; // reserved1
unsigned int reserved2 : 16; // reserved2
} GkeyCode;
回调函数logiGkeyCB的定义如下:
typedef void (__cdecl *logiGkeyCB)(GkeyCode gkeyCode, const wchar_t* gkeyOrButtonString, void* context);
问题
那么,我如何在python中定义所有这些东西来调用和使用它呢。我想使用LogiGkeyIsKeyboardGkeyPressed()
和LogiGkeyGetKeyboardGkeyString()
,所以我需要LogiGkeyInit()
和在python中为logiGkeyCBContext
定义回调的方法
目前没有回答
相关问题 更多 >
编程相关推荐