0

I want wrap/use Logitech C/C++ libraries in python code:

  1. http://gaming.logitech.com/sdk/LCDSDK_8.57.148.zip
  2. https://www.logitechg.com/sdk/LED_SDK_9.00.zip
  3. http://gaming.logitech.com/sdk/GkeySDK_8.57.148.zip

With first two (LCD and LED) is quite easy even for me. You need download zips and there is a pdf with reference, i.e.: 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]

I have problem with 3rd one Gkey, take a look page 16 and 17 - logiGkeyCBContext Structure. In order to call LogiGkeyInit() I need:

The LogiGkeyInit() function initializes the G-key SDK. It must be called before your application can see G-key/button events.

BOOL LogiGkeyInit(logiGkeyCBContext* gkeyCBContext);

Parameters:

  • gkeyCBContext: context for callback. See sample code above or sample program in Samples folder. This value

The logiGkeyCBContext is used to give the SDK enough information to allow the G-key events to be sent back to your application. The registered callback is called when the user presses/releases the G-key/mouse buttons, and the SDK client is currently in the foreground.

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;

The callback function logiGkeyCB is defined as follows:

typedef void (__cdecl *logiGkeyCB)(GkeyCode gkeyCode, const wchar_t* gkeyOrButtonString, void* context);

QUESTION
So, how can I define all that stuff in python to call and use it. I want use LogiGkeyIsKeyboardGkeyPressed() and LogiGkeyGetKeyboardGkeyString() so I need LogiGkeyInit() and way to define callback in python for logiGkeyCBContext

emcek
  • 459
  • 1
  • 6
  • 17
  • Does this answer your question? [Python objects as userdata in ctypes callback functions](https://stackoverflow.com/questions/2469975/python-objects-as-userdata-in-ctypes-callback-functions) – Botje Jan 13 '20 at 12:18
  • thx... looks similar... but problem is I'm know to little about C/C++ to solve my problem... any more specific hint appreciated ;) – emcek Jan 13 '20 at 12:46

0 Answers0