import 'dart:ffi'; import 'dart:io'; import 'dart:typed_data'; import 'package:ffi/ffi.dart'; import 'package:shoes_sdk/generated_bindings.dart'; import 'package:shoes_sdk/shoes_sdk.dart'; class SDKApi { late NativeLibrary sdk; SDKApi() { sdk = NativeLibrary(Platform.isAndroid ? DynamicLibrary.open("libnative-lib.so") : DynamicLibrary.process()); } void gameInit(int type) { sdk.gameInit(type, 1); } Pointer result = int32ListToArrayPointer([-1, -1, -1, -1,-1, -1, -1, -1,-1, -1]); static const _shoe_id = 0; void gameProcess(Uint8List byteArray) { int length = byteArray.length; Pointer ptr = calloc(length); ptr.asTypedList(length).setAll(0, byteArray); sdk.gameProcess(_shoe_id, ptr, length, result); } List getMotion() { // sdk.getGameResult(_shoe_id, result); return result.asTypedList(10); } int getInteractionCMD() { return sdk.getInteractionCMD(); } int getStepFreq() { return sdk.getStepFreq(_shoe_id); } int getStepCount() { return sdk.getStepCount(_shoe_id); } int getMotionCount(int type) { return sdk.getMotionCount(_shoe_id, type); } int getGameStepVel() { return sdk.getGameStepVel(_shoe_id); } int getAttX() { return sdk.NativeGetAttX(_shoe_id); } String getVersion() { Pointer ptr = calloc(32); sdk.getGameVersion(ptr); var utf8 = ptr.cast(); print("getVersion ${utf8} ${utf8.length}"); return utf8.toDartString(); } Pointer getGameDataStrPointer = calloc(2048); String getGameDataStr() { sdk.getGameDataStr(_shoe_id, getGameDataStrPointer); var utf8 = getGameDataStrPointer.cast(); String result = utf8.toDartString(); return result; } }