123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- 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<Int32> 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<Uint8> ptr = calloc<Uint8>(length);
- ptr.asTypedList(length).setAll(0, byteArray);
- sdk.gameProcess(_shoe_id, ptr, length, result);
- }
- List<int> 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<Int8> ptr = calloc<Int8>(32);
- sdk.getGameVersion(ptr);
- var utf8 = ptr.cast<Utf8>();
- print("getVersion ${utf8} ${utf8.length}");
- return utf8.toDartString();
- }
- Pointer<Int8> getGameDataStrPointer = calloc<Int8>(2048);
- String getGameDataStr() {
- sdk.getGameDataStr(_shoe_id, getGameDataStrPointer);
- var utf8 = getGameDataStrPointer.cast<Utf8>();
- String result = utf8.toDartString();
- return result;
- }
- }
|