pal_utils.c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. #include "main.h"
  2. static int input_event_filter(const SDL_Event *lpEvent, PALINPUTSTATE *state)
  3. {
  4. switch (lpEvent->type)
  5. {
  6. case SDL_JOYAXISMOTION:
  7. switch (lpEvent->jaxis.axis)
  8. {
  9. case 0:
  10. //
  11. // X axis
  12. //
  13. if (lpEvent->jaxis.value > MAX_DEADZONE) {
  14. state->prevdir = (gpGlobals->fInBattle ? kDirUnknown : state->dir);
  15. state->dir = kDirEast;
  16. state->dwKeyPress = kKeyRight;
  17. }
  18. else if (lpEvent->jaxis.value < MIN_DEADZONE) {
  19. state->prevdir = (gpGlobals->fInBattle ? kDirUnknown : state->dir);
  20. state->dir = kDirWest;
  21. state->dwKeyPress = kKeyLeft;
  22. }
  23. else {
  24. state->dir = kDirUnknown;
  25. }
  26. return 1;
  27. case 1:
  28. //
  29. // Y axis
  30. //
  31. if (lpEvent->jaxis.value > MAX_DEADZONE) {
  32. state->prevdir = (gpGlobals->fInBattle ? kDirUnknown : state->dir);
  33. state->dir = kDirSouth;
  34. state->dwKeyPress = kKeyDown;
  35. }
  36. else if (lpEvent->jaxis.value < MIN_DEADZONE) {
  37. state->prevdir = (gpGlobals->fInBattle ? kDirUnknown : state->dir);
  38. state->dir = kDirNorth;
  39. state->dwKeyPress = kKeyUp;
  40. }
  41. else {
  42. state->dir = kDirUnknown;
  43. }
  44. return 1;
  45. }
  46. break;
  47. case SDL_JOYBUTTONDOWN:
  48. switch (lpEvent->jbutton.button)
  49. {
  50. #if defined(GP2XWIZ)
  51. case 14:
  52. #elif defined(CAANOO)
  53. case 3:
  54. #endif
  55. state->dwKeyPress = kKeyMenu;
  56. return 1;
  57. #if defined(GP2XWIZ)
  58. case 13:
  59. #elif defined(CAANOO)
  60. case 2:
  61. #endif
  62. state->dwKeyPress = kKeySearch;
  63. return 1;
  64. }
  65. break;
  66. }
  67. return 0;
  68. }
  69. BOOL
  70. UTIL_GetScreenSize(
  71. DWORD *pdwScreenWidth,
  72. DWORD *pdwScreenHeight
  73. )
  74. {
  75. return FALSE;
  76. }
  77. BOOL
  78. UTIL_IsAbsolutePath(
  79. LPCSTR lpszFileName
  80. )
  81. {
  82. return FALSE;
  83. }
  84. INT
  85. UTIL_Platform_Init(
  86. int argc,
  87. char* argv[]
  88. )
  89. {
  90. PAL_RegisterInputFilter(NULL, input_event_filter, NULL);
  91. gConfig.fLaunchSetting = FALSE;
  92. return 0;
  93. }
  94. VOID
  95. UTIL_Platform_Quit(
  96. VOID
  97. )
  98. {
  99. chdir("/usr/gp2x");
  100. execl("./gp2xmenu", "./gp2xmenu", NULL);
  101. }