XCTRL.cpp 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  1. #include "XCTRL.h"
  2. #include "FTTInput.h"
  3. #include "CFE.h"
  4. #include "GFXRENDER.h"
  5. struct XCTRL_Touch {
  6. TPoint ttouchDownPos_0;
  7. TPoint tpos_8;
  8. uint8 bWipe_10; //是否向右滑动
  9. bool bisReleased_11;
  10. bool bisPressed_12;
  11. bool bisTouch_13;
  12. bool bisDoubleTapped_14; //是否双击
  13. bool bfield_15;
  14. bool bfield_16;
  15. bool bfield_17;
  16. int ilastTime_18;
  17. int touchDownTime_1C;
  18. };
  19. MYSTATIC XCTRL_Touch gs_ptouchEventHW_34A490[4];
  20. MYSTATIC XCTRL_Touch gs_ptouchEvent_34A510[4];
  21. MYSTATIC int gs_icount_34A590; //未使用会被优化掉
  22. MYSTATIC int gs_icountHW_34A594; //未使用会被优化掉
  23. MYSTATIC int gs_i_34A598; //未使用会被优化掉
  24. //0x0011AA24 ^_^
  25. void sub_11AA24() {
  26. }
  27. //-------------------------------------------------------------------------------------------------
  28. //0011A5C4
  29. void XCTRL_ProcessHW() {
  30. }
  31. //-------------------------------------------------------------------------------------------------
  32. //0011A5C8
  33. // void XCTRL_TouchSetHWToDevice() {
  34. // for (int i = 0; i != 4; i++) {
  35. // TPoint tp1 = gs_ptouchEvent_34A510[i].ttouchDownPos_0;
  36. // int ilastTime = gs_ptouchEvent_34A510[i].ilastTime_18;
  37. // int touchDownTime = gs_ptouchEvent_34A510[i].touchDownTime_1C;
  38. // memcpy(&gs_ptouchEvent_34A510[i], &gs_ptouchEventHW_34A490[i], sizeof(XCTRL_Touch));
  39. // gs_ptouchEvent_34A510[i].ttouchDownPos_0 = tp1;
  40. // gs_ptouchEvent_34A510[i].ilastTime_18 = ilastTime;
  41. // gs_ptouchEvent_34A510[i].touchDownTime_1C = touchDownTime;
  42. // }
  43. // gs_icount_34A590 = gs_icountHW_34A594;
  44. // for (int i = 0; i != 4; i++) {
  45. // if (gs_ptouchEvent_34A510[i].bisPressed_12) {
  46. // gs_ptouchEvent_34A510[i].ttouchDownPos_0 =
  47. // gs_ptouchEvent_34A510[i].tpos_8;
  48. // gs_ptouchEvent_34A510[i].touchDownTime_1C = 0;
  49. // }
  50. // if (gs_ptouchEvent_34A510[i].bisTouch_13)
  51. // gs_ptouchEvent_34A510[i].touchDownTime_1C++;
  52. // }
  53. // sub_11AA24();
  54. // for (int i = 0; i != 4; i++) {
  55. // gs_ptouchEvent_34A510[i].bWipe_10 = 0;
  56. // if (gs_ptouchEvent_34A510[i].bisReleased_11) {
  57. // int ix = gs_ptouchEvent_34A510[i].tpos_8.dx_0 -
  58. // gs_ptouchEvent_34A510[i].ttouchDownPos_0.dx_0;
  59. // int iy = gs_ptouchEvent_34A510[i].tpos_8.dy_4 -
  60. // gs_ptouchEvent_34A510[i].ttouchDownPos_0.dy_4;
  61. // if ((ix * ix + iy * iy) > 0x400) {
  62. // int iabsX = ix;
  63. // int iabsY = iy;
  64. // if (iy < 0)
  65. // iabsY = -iy;
  66. // if (ix < 0)
  67. // iabsX = -ix;
  68. // if (iabsX <= iabsY) {
  69. // if (iy >= 1)
  70. // gs_ptouchEvent_34A510[i].bWipe_10 = 2;
  71. // else
  72. // gs_ptouchEvent_34A510[i].bWipe_10 = 1;
  73. // } else if (ix >= 1) {
  74. // gs_ptouchEvent_34A510[i].bWipe_10 = 4;
  75. // } else
  76. // gs_ptouchEvent_34A510[i].bWipe_10 = 3;
  77. // }
  78. // }
  79. // }
  80. // }
  81. //-------------------------------------------------------------------------------------------------
  82. //0011A5CC
  83. void XCTRL_Process_ClearTriggers() {
  84. LOGE("XCTRL_Process_ClearTriggers");
  85. }
  86. //-------------------------------------------------------------------------------------------------
  87. //0011A5D0
  88. bool XCTRL_TouchHWIsPressed() {
  89. return false;
  90. }
  91. //-------------------------------------------------------------------------------------------------
  92. //0011A5DC ^_^
  93. bool XCTRL_TouchHWIsReleased() {
  94. return false;
  95. }
  96. //-------------------------------------------------------------------------------------------------
  97. //0011A5E8 ^_^
  98. bool XCTRL_TouchHWIsTouching() {
  99. return false;
  100. }
  101. //-------------------------------------------------------------------------------------------------
  102. //0011A5F4
  103. TPoint XCTRL_TouchHWGetPos() {
  104. TPoint d;
  105. return d;
  106. }
  107. //-------------------------------------------------------------------------------------------------
  108. //0011A608
  109. int XCTRL_TouchGetCount() {
  110. return 10;
  111. }
  112. //-------------------------------------------------------------------------------------------------
  113. //0011A614 ^_^
  114. bool XCTRL_TouchIsTouching(int i1) {
  115. return false;
  116. }
  117. //-------------------------------------------------------------------------------------------------
  118. //0011A624
  119. TPoint XCTRL_TouchGetDownPos(int dIndex) {
  120. TPoint d;
  121. return d;
  122. }
  123. //-------------------------------------------------------------------------------------------------
  124. //0011A63C ^_^
  125. void XCTRL_TouchSetDownPos(int i1, TPoint tPoint2) {
  126. }
  127. //-------------------------------------------------------------------------------------------------
  128. //0011a654 ^_^
  129. int XCTRL_TouchGetDownTime(int i1) {
  130. return 12;
  131. }
  132. //-------------------------------------------------------------------------------------------------
  133. //0011A664 //^_^
  134. TPoint XCTRL_TouchGetPos(int dIndex) {
  135. TPoint d;
  136. return d;
  137. }
  138. //-------------------------------------------------------------------------------------------------
  139. //0011A67C ^_^
  140. int XCTRL_TouchLastTime(int i1) {
  141. return false;
  142. }
  143. //-------------------------------------------------------------------------------------------------
  144. //0011A68C ^_^
  145. bool XCTRL_TouchIsPressed(int i1) {
  146. return false;
  147. }
  148. //-------------------------------------------------------------------------------------------------
  149. //0011A69C ^_^
  150. bool XCTRL_TouchIsReleased(int i1) {
  151. return false;
  152. }
  153. //-------------------------------------------------------------------------------------------------
  154. //0011A6AC
  155. bool XCTRL_TouchIsDoubleTapped(int i1) {
  156. return false;
  157. }
  158. //-------------------------------------------------------------------------------------------------
  159. //0011A6BC ^_^
  160. bool XCTRL_TouchGetSwipe(int i1) {
  161. return false;
  162. }
  163. //-------------------------------------------------------------------------------------------------
  164. //0011A6CC
  165. void XCTRL_TouchResetHW() {
  166. }
  167. //-------------------------------------------------------------------------------------------------
  168. //0011A6EC ^_^
  169. void XCTRL_TouchReset() {
  170. }
  171. //-------------------------------------------------------------------------------------------------
  172. //0011A70C
  173. void XCTRL_TouchProcessHW() {
  174. // if (CFTTRewardedVideos::AdOnScreen() == false)
  175. {
  176. gs_i_34A598++;
  177. // loc_11A73C
  178. for (int i = 0; i < gs_icountHW_34A594; i++) {
  179. if (gs_ptouchEventHW_34A490[i].bisReleased_11 || gs_ptouchEventHW_34A490[i].bisTouch_13 == false) {
  180. memmove(&gs_ptouchEventHW_34A490[i], &gs_ptouchEventHW_34A490[i + 1], (3 - i) * sizeof(XCTRL_Touch));
  181. gs_icountHW_34A594--;
  182. i--;
  183. memset(&gs_ptouchEventHW_34A490[gs_icountHW_34A594], 0, sizeof(XCTRL_Touch));
  184. } else if (gs_ptouchEventHW_34A490[i].bisPressed_12) {
  185. gs_ptouchEventHW_34A490[i].bisPressed_12 = false;
  186. }
  187. }
  188. // loc_11A77E
  189. do {
  190. // loc_11A8C2
  191. TPoint tpos;
  192. UseByAddTouchEvent_Internal touvhEvent = FTTInput_GetTouchEvent();
  193. if (touvhEvent.field_0 == ETouchEvent_neg1)
  194. return;
  195. // loc_11A7AC
  196. tpos.dx_0 = (touvhEvent.field_4 * SCR_WID) / CFE::s_fHardwareWidth;
  197. tpos.dy_4 = (touvhEvent.field_8 * SCR_HEI) / CFE::s_fHardwareHeight;
  198. if (touvhEvent.field_0 != ETouchEvent_0) {
  199. if (gs_icountHW_34A594 < 1)
  200. continue;
  201. else {
  202. int i_r10 = 0x7FFFFFFF;
  203. int j = 0;
  204. for (int i = 0; i < gs_icountHW_34A594; i++) {
  205. if (gs_ptouchEventHW_34A490[i].bisTouch_13) {
  206. int i_distance_r0 = XMATH_Distance(&tpos, &gs_ptouchEventHW_34A490[i].tpos_8);
  207. if (i_distance_r0 < i_r10) {
  208. j = i;
  209. i_r10 = i_distance_r0;
  210. }
  211. }
  212. }
  213. switch (touvhEvent.field_0) {
  214. case ETouchEvent_1:
  215. case ETouchEvent_3: { // loc_11A852
  216. gs_ptouchEventHW_34A490[j].bisTouch_13 = false;
  217. gs_ptouchEventHW_34A490[j].bisReleased_11 = true;
  218. gs_ptouchEventHW_34A490[j].bisPressed_12 = false;
  219. break;
  220. }
  221. case ETouchEvent_Touch_2: {
  222. // loc_11A8A8
  223. gs_ptouchEventHW_34A490[j].bisTouch_13 = true;
  224. gs_ptouchEventHW_34A490[j].tpos_8 = &tpos;
  225. break;
  226. }
  227. }
  228. }
  229. } else if (gs_icountHW_34A594 <= 3) {
  230. // loc_11A864 ok
  231. memset(&gs_ptouchEventHW_34A490[gs_icountHW_34A594], 0, sizeof(XCTRL_Touch));
  232. gs_ptouchEventHW_34A490[gs_icountHW_34A594].bisPressed_12 = 1;
  233. gs_ptouchEventHW_34A490[gs_icountHW_34A594].bisTouch_13 = 1;
  234. gs_ptouchEventHW_34A490[gs_icountHW_34A594].tpos_8 = &tpos;
  235. gs_ptouchEventHW_34A490[gs_icountHW_34A594].ttouchDownPos_0 = &tpos;
  236. gs_icountHW_34A594++;
  237. }
  238. } while (1);
  239. }
  240. // loc_11A8D0
  241. }
  242. //-------------------------------------------------------------------------------------------------
  243. //0011A8F8 ^_^
  244. void XCTRL_TouchSetHWToDevice() {
  245. for (int i = 0; i != 4; i++) {
  246. TPoint tp1 = gs_ptouchEvent_34A510[i].ttouchDownPos_0;
  247. int ilastTime = gs_ptouchEvent_34A510[i].ilastTime_18;
  248. int touchDownTime = gs_ptouchEvent_34A510[i].touchDownTime_1C;
  249. memcpy(&gs_ptouchEvent_34A510[i], &gs_ptouchEventHW_34A490[i], sizeof(XCTRL_Touch));
  250. gs_ptouchEvent_34A510[i].ttouchDownPos_0 = tp1;
  251. gs_ptouchEvent_34A510[i].ilastTime_18 = ilastTime;
  252. gs_ptouchEvent_34A510[i].touchDownTime_1C = touchDownTime;
  253. }
  254. gs_icount_34A590 = gs_icountHW_34A594;
  255. for (int i = 0; i != 4; i++) {
  256. if (gs_ptouchEvent_34A510[i].bisPressed_12) {
  257. gs_ptouchEvent_34A510[i].ttouchDownPos_0 =
  258. gs_ptouchEvent_34A510[i].tpos_8;
  259. gs_ptouchEvent_34A510[i].touchDownTime_1C = 0;
  260. }
  261. if (gs_ptouchEvent_34A510[i].bisTouch_13)
  262. gs_ptouchEvent_34A510[i].touchDownTime_1C++;
  263. }
  264. sub_11AA24();
  265. for (int i = 0; i != 4; i++) {
  266. gs_ptouchEvent_34A510[i].bWipe_10 = 0;
  267. if (gs_ptouchEvent_34A510[i].bisReleased_11) {
  268. int ix = gs_ptouchEvent_34A510[i].tpos_8.dx_0 -
  269. gs_ptouchEvent_34A510[i].ttouchDownPos_0.dx_0;
  270. int iy = gs_ptouchEvent_34A510[i].tpos_8.dy_4 -
  271. gs_ptouchEvent_34A510[i].ttouchDownPos_0.dy_4;
  272. if ((ix * ix + iy * iy) > 0x400) {
  273. int iabsX = ix;
  274. int iabsY = iy;
  275. if (iy < 0)
  276. iabsY = -iy;
  277. if (ix < 0)
  278. iabsX = -ix;
  279. if (iabsX <= iabsY) {
  280. if (iy >= 1)
  281. gs_ptouchEvent_34A510[i].bWipe_10 = 2;
  282. else
  283. gs_ptouchEvent_34A510[i].bWipe_10 = 1;
  284. } else if (ix >= 1) {
  285. gs_ptouchEvent_34A510[i].bWipe_10 = 4;
  286. } else
  287. gs_ptouchEvent_34A510[i].bWipe_10 = 3;
  288. }
  289. }
  290. }
  291. }
  292. //-------------------------------------------------------------------------------------------------
  293. //0011A9F4
  294. void XCTRL_TouchProcess_ClearTriggers() {
  295. LOGE("XCTRL_TouchProcess_ClearTriggers");
  296. }
  297. //-------------------------------------------------------------------------------------------------