Original Post
The function I'm trying to use is ManyMouse_PollEvent the C code looks something like this: In C# I'm stuck at [DllImport("ManyMouseDLL.dll",CharSet = CharSet.Ansi)] internal static extern int ManyMouse_PollEvent(??); Any help is greatly appreciated. [EDIT] After some search it looks like I should define the struct in C#. I have adapted what I found to my code: It this the right way to do things? how to get the C enum working (ManyMouseEventType)?
typedef enum
{
MANYMOUSE_EVENT_ABSMOTION = 0,
MANYMOUSE_EVENT_RELMOTION,
MANYMOUSE_EVENT_BUTTON,
MANYMOUSE_EVENT_SCROLL,
MANYMOUSE_EVENT_DISCONNECT,
MANYMOUSE_EVENT_MAX
} ManyMouseEventType;
__declspec(dllexport) typedef struct
{
ManyMouseEventType type;
unsigned int device;
unsigned int item;
int value;
int minval;
int maxval;
} ManyMouseEvent;
__declspec(dllexport) int ManyMouse_PollEvent(ManyMouseEvent *event);
[DllImport("ManyMouseDLL.dll",CharSet = CharSet.Ansi)]
internal static extern int
ManyMouse_PollEvent([MarshalAs(UnmanagedType.LPStruct)] ManyMouseEvent
MouseEvent);
[StructLayout (LayoutKind.Sequential)]
internal struct ManyMouseEvent
{
public int device;
public int item;
public int value;
public int minval;
public int maxval;
};