Skip to content

Commit 534e894

Browse files
committed
add moza sdk
1 parent 974161b commit 534e894

9 files changed

Lines changed: 50 additions & 0 deletions

File tree

41.5 KB
Binary file not shown.

libs/SDK_CSharp/AnyCPU/readme.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
AnyCPU仅为C# DLL,C# SDK还依赖于C++实现的SDK,所以需要根据运行的目标平台选择对应版本的“MOZA_API_C.dll”和“MOZA_SDK.dll”。
2+
3+
AnyCPU applies only to the C# DLL.
4+
Since the C# SDK also depends on the SDK implemented in C++, you need to select the corresponding versions of MOZA_API_C.dll and MOZA_SDK.dll according to the target platform you are running on.
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*************************************************************************************
2+
* This file is an example code on how to use MOZA Shifter device-related interfaces with MOZA SDK C#
3+
*
4+
* For other APIs in MOZA SDK, please refer to the example code file `sdk_api_test.cc` in the MOZA SDK C++ version.
5+
* You can also refer to the API documentation of the C++ version, located at `docsEng/index.html`.
6+
* The API in the MOZA SDK C# version is almost identical to the C++ version in terms of function names and input parameters.
7+
*************************************************************************************/
8+
9+
using mozaAPI;
10+
using static mozaAPI.mozaAPI;
11+
12+
MozaShifterTest();
13+
Console.WriteLine("Program finished.");
14+
return;
15+
16+
void MozaShifterTest()
17+
{
18+
var devices = EnumShifterDevices(out var error);
19+
if (error != ERRORCODE.NORMAL || devices.Count == 0)
20+
{
21+
Console.WriteLine($"No MOZA Shifter device found, error = {error}");
22+
return;
23+
}
24+
25+
var device = devices[0];
26+
if (!device.Open())
27+
{
28+
Console.WriteLine("Device open failed.");
29+
return;
30+
}
31+
32+
Console.WriteLine($"MOZA Shifter device '{device.Path}' is opened.");
33+
34+
var gear = 0;
35+
while (device.IsConnected)
36+
{
37+
// The `GetCurrentGear` function waits for the HID report while reading data, until valid data is received or an error occurs.
38+
// This means the execution time of this function may be relatively long, and it is not recommended to call it in the main thread.
39+
var currentGear = device.GetCurrentGear();
40+
if (gear == currentGear) continue;
41+
Console.WriteLine($"The gear has been switched from {gear} to {currentGear}");
42+
gear = currentGear;
43+
}
44+
45+
Console.WriteLine("The device has been disconnected.");
46+
}

libs/SDK_CSharp/x64/MOZA_API_C.dll

66.5 KB
Binary file not shown.
41 KB
Binary file not shown.

libs/SDK_CSharp/x64/MOZA_SDK.dll

4.57 MB
Binary file not shown.

libs/SDK_CSharp/x86/MOZA_API_C.dll

73.5 KB
Binary file not shown.
41.5 KB
Binary file not shown.

libs/SDK_CSharp/x86/MOZA_SDK.dll

3.51 MB
Binary file not shown.

0 commit comments

Comments
 (0)