Today I started playing around with the Logitech Arx Control SDK.
You can actually use it without any hardware, just install the newse Logitech Gaming Software and start using it.
To finally use it in C#, an appropriate wrapper is already provided.
All you need to add is the following class to import the calls:
public static class LogitechArx
{
public const int LOGI_ARX_ORIENTATION_PORTRAIT = 0x01;
public const int LOGI_ARX_ORIENTATION_LANDSCAPE = 0x10;
public const int LOGI_ARX_EVENT_FOCUS_ACTIVE = 0x01;
public const int LOGI_ARX_EVENT_FOCUS_INACTIVE = 0x02;
public const int LOGI_ARX_EVENT_TAP_ON_TAG = 0x04;
public const int LOGI_ARX_EVENT_MOBILEDEVICE_ARRIVAL = 0x08;
public const int LOGI_ARX_EVENT_MOBILEDEVICE_REMOVAL = 0x10;
public const int LOGI_ARX_DEVICETYPE_IPHONE = 0x01;
public const int LOGI_ARX_DEVICETYPE_IPAD = 0x02;
public const int LOGI_ARX_DEVICETYPE_ANDROID_SMALL = 0x03;
public const int LOGI_ARX_DEVICETYPE_ANDROID_NORMAL = 0x04;
public const int LOGI_ARX_DEVICETYPE_ANDROID_LARGE = 0x05;
public const int LOGI_ARX_DEVICETYPE_ANDROID_XLARGE = 0x06;
public const int LOGI_ARX_DEVICETYPE_ANDROID_OTHER = 0x07;
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate void logiArxCB(int eventType, int eventValue, [MarshalAs(UnmanagedType.LPWStr)]String eventArg, IntPtr context);
public struct logiArxCbContext
{
public logiArxCB arxCallBack;
public IntPtr arxContext;
}
[DllImport("LogitechGArxControlEnginesWrapper.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern bool LogiArxInit(String identifier, String friendlyName, ref logiArxCbContext callback);
[DllImport("LogitechGArxControlEnginesWrapper.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern bool LogiArxAddFileAs(String filePath, String fileName, String mimeType = "");
[DllImport("LogitechGArxControlEnginesWrapper.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern bool LogiArxAddContentAs(byte[] content, int size, String fileName, String mimeType = "");
[DllImport("LogitechGArxControlEnginesWrapper.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern bool LogiArxAddUTF8StringAs(String stringContent, String fileName, String mimeType = "");
[DllImport("LogitechGArxControlEnginesWrapper.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern bool LogiArxAddImageFromBitmap(byte[] bitmap, int width, int height, String fileName);
[DllImport("LogitechGArxControlEnginesWrapper.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern bool LogiArxSetIndex(String fileName);
[DllImport("LogitechGArxControlEnginesWrapper.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern bool LogiArxSetTagPropertyById(String tagId, String prop, String newValue);
[DllImport("LogitechGArxControlEnginesWrapper.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern bool LogiArxSetTagsPropertyByClass(String tagsClass, String prop, String newValue);
[DllImport("LogitechGArxControlEnginesWrapper.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern bool LogiArxSetTagContentById(String tagId, String newContent);
[DllImport("LogitechGArxControlEnginesWrapper.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern bool LogiArxSetTagsContentByClass(String tagsClass, String newContent);
[DllImport("LogitechGArxControlEnginesWrapper.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern int LogiArxGetLastError();
[DllImport("LogitechGArxControlEnginesWrapper.dll", CharSet = CharSet.Unicode, CallingConvention = CallingConvention.Cdecl)]
public static extern void LogiArxShutdown();
}
Now you can use it in any c# application!
Here are some snippets which help you with it:
LogitechArx.logiArxCbContext contextCallback;
contextCallback.arxCallBack = new LogitechArx.logiArxCB(SDKCallback);
contextCallback.arxContext = System.IntPtr.Zero;
bool retVal = LogitechArx.LogiArxInit("your.company.appname", "AppName", ref contextCallback);
if (!retVal)
{
int retCode = LogitechArx.LogiArxGetLastError();
Console.WriteLine("Loading sdk failed: "+ retCode);
}
static void ArxCallback(int eventType, int eventValue, String eventArg, IntPtr context)
{
if (eventType == LogitechArx.LOGI_ARX_EVENT_MOBILEDEVICE_ARRIVAL)
{
// Send your files here
}
else if (eventType == LogitechArx.LOGI_ARX_EVENT_MOBILEDEVICE_REMOVAL)
{
// Device disconnected
}
else if (eventType == LogitechArx.LOGI_ARX_EVENT_TAP_ON_TAG)
{
if (eventArg == "myBtn")
{
// Do something on this input
}
}
}
LogitechArx.LogiArxAddFileAs(@"Resources\index.html", "index.html");
LogitechArx.LogiArxSetIndex("index.html");
To also add an icon, just set the icon in your application as you do usually. It should automatically work in Arx as well (it seems to take the icon from the .exe file).
This might help getting you started. I’ll post more on this topic later.