native-lib.cpp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #include <stdint.h>
  2. #include "Game.h"
  3. extern "C" {
  4. Game game[] = {Game(0), Game(0)};
  5. void gameInit(int gameType, int count) {
  6. for (int i = 0; i < count; i++) {
  7. game[i] = Game(gameType);
  8. }
  9. }
  10. void gameProcess(
  11. int id,
  12. uint8_t *buf,
  13. int len,
  14. int *result) {
  15. game[id].GameProcessBuf(buf, len);
  16. game[id].getGameResult(result);
  17. }
  18. void getGameResult(
  19. int id,
  20. int *result) {
  21. game[id].getGameResult(result);
  22. }
  23. void getGameDataStr(
  24. int id,
  25. char *result) {
  26. std::string v = game[id].getGameDataStr();
  27. strcpy(result,v.c_str());
  28. }
  29. int getInteractionCMD() {
  30. return game[0].getInteractionCMD();
  31. }
  32. void getGameVersion(char* version) {
  33. std::string v = GAME_VERSION;
  34. strcpy(version,v.c_str());
  35. }
  36. int getStepFreq(int id) {
  37. return (game[id].getStepFreq(LEFT_FOOT) + game[id].getStepFreq(RIGHT_FOOT)) / 2;
  38. }
  39. int getStepCount(int id) {
  40. return game[id].getMotionCount(STEP_COUNT);
  41. }
  42. int getMotionCount(int id, int type) {
  43. return game[id].getMotionCount(type);
  44. }
  45. int getGameStepVel(int id) {
  46. return game[id].getGameStepVel();
  47. }
  48. int NativeGetAttX(int id){
  49. int length = 3;
  50. int left[length];
  51. int right[length];
  52. game[id].getFootAtt(left, right);
  53. return left[0];
  54. }
  55. }