pal_utils.cpp 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. #include "main.h"
  2. #include <fat.h>
  3. #include <ogcsys.h>
  4. #include <gccore.h>
  5. #include <fcntl.h>
  6. #include <network.h>
  7. #include <debug.h>
  8. #include <errno.h>
  9. #include <unistd.h>
  10. #ifdef DEBUG
  11. extern "C"{
  12. # include <net_print.h>
  13. }
  14. #endif
  15. static int input_event_filter(const SDL_Event *lpEvent, volatile PALINPUTSTATE *state)
  16. {
  17. switch (lpEvent->type)
  18. {
  19. case SDL_JOYHATMOTION:
  20. switch (lpEvent->jhat.value)
  21. {
  22. case SDL_HAT_LEFT:
  23. state->prevdir = (gpGlobals->fInBattle ? kDirUnknown : state->dir);
  24. state->dir = kDirWest;
  25. state->dwKeyPress = kKeyLeft;
  26. break;
  27. case SDL_HAT_RIGHT:
  28. state->prevdir = (gpGlobals->fInBattle ? kDirUnknown : state->dir);
  29. state->dir = kDirEast;
  30. state->dwKeyPress = kKeyRight;
  31. break;
  32. case SDL_HAT_UP:
  33. state->prevdir = (gpGlobals->fInBattle ? kDirUnknown : state->dir);
  34. state->dir = kDirNorth;
  35. state->dwKeyPress = kKeyUp;
  36. break;
  37. case SDL_HAT_DOWN:
  38. state->prevdir = (gpGlobals->fInBattle ? kDirUnknown : state->dir);
  39. state->dir = kDirSouth;
  40. state->dwKeyPress = kKeyDown;
  41. break;
  42. }
  43. return 1;
  44. case SDL_JOYBUTTONDOWN:
  45. switch (lpEvent->jbutton.button)
  46. {
  47. case 2:
  48. state->dwKeyPress |= kKeyMenu;
  49. return 1;
  50. case 3:
  51. state->dwKeyPress |= kKeySearch;
  52. return 1;
  53. }
  54. }
  55. return 0;
  56. }
  57. BOOL
  58. UTIL_GetScreenSize(
  59. DWORD *pdwScreenWidth,
  60. DWORD *pdwScreenHeight
  61. )
  62. {
  63. return (pdwScreenWidth && pdwScreenHeight && *pdwScreenWidth && *pdwScreenHeight);
  64. }
  65. BOOL
  66. UTIL_IsAbsolutePath(
  67. LPCSTR lpszFileName
  68. )
  69. {
  70. return FALSE;
  71. }
  72. int UTIL_Platform_Startup(
  73. int argc,
  74. char* argv[]
  75. )
  76. {
  77. #if defined(DEBUG)
  78. VIDEO_SetBlack(FALSE);
  79. VIDEO_Flush();
  80. VIDEO_WaitVSync();
  81. char localip[16] = {0};
  82. char gateway[16] = {0};
  83. char netmask[16] = {0};
  84. int ret = if_config ( localip, netmask, gateway, TRUE);
  85. if (ret>=0) {
  86. printf ("\n network configured, ip: %s, gw: %s, mask %s\n", localip, gateway, netmask);
  87. net_print_init(NULL,0);
  88. printf("net_print_init() called.\n");
  89. net_print_string(__FILE__,__LINE__, "initial net_print from %s...\n",localip);
  90. DEBUG_Init(100,5656);
  91. printf("after DEBUG_Init()...\n");
  92. printf("Before _break() is called.\n");
  93. _break();
  94. printf("After _break() is called.\n");
  95. }
  96. #endif
  97. fatInitDefault();
  98. return 0;
  99. }
  100. INT
  101. UTIL_Platform_Init(
  102. int argc,
  103. char* argv[]
  104. )
  105. {
  106. #ifdef DEBUG
  107. UTIL_LogAddOutputCallback([](LOGLEVEL, const char* str, const char*)->void {
  108. net_print_string(__FILE__,__LINE__, "%s\n",str);
  109. }, PAL_DEFAULT_LOGLEVEL);
  110. #endif
  111. UTIL_LogOutput(LOGLEVEL_WARNING, "try net_print logout");
  112. PAL_RegisterInputFilter(NULL, input_event_filter, NULL);
  113. gConfig.fLaunchSetting = FALSE;
  114. return 0;
  115. }
  116. VOID
  117. UTIL_Platform_Quit(
  118. VOID
  119. )
  120. {
  121. }