sdk_parse.dart 812 B

1234567891011121314151617181920212223242526272829303132333435
  1. import 'dart:ffi';
  2. import 'dart:typed_data';
  3. import 'package:ffi/ffi.dart';
  4. import 'package:shoes_sdk/shoes_sdk.dart';
  5. void gameInit(int type) {
  6. sdk.gameInit(type, 1);
  7. }
  8. Pointer<Int32> result = int32ListToArrayPointer([-1, -1, -1, -1]);
  9. void gameProcess(Uint8List byteArray) {
  10. int length = byteArray.length;
  11. Pointer<Uint8> ptr = calloc<Uint8>(length);
  12. ptr.asTypedList(length).setAll(0, byteArray);
  13. sdk.gameProcessBuf(0, ptr, length, result);
  14. }
  15. List<int> getMotion() {
  16. sdk.getGameResult(0, result);
  17. return result.asTypedList(4);
  18. }
  19. int getInteractionCMD() {
  20. return sdk.getInteractionCMD();
  21. }
  22. String getVersion() {
  23. Pointer<Int8> ptr = calloc<Int8>(32);
  24. sdk.getGameVersion(ptr);
  25. var utf8 = ptr.cast<Utf8>();
  26. print("getVersion ${utf8} ${utf8.length}");
  27. return utf8.toDartString();
  28. }