XCTRL.cpp 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  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. LOGE("XCTRL_TouchGetCount");
  111. return rand();
  112. }
  113. //-------------------------------------------------------------------------------------------------
  114. //0011A614 ^_^
  115. bool XCTRL_TouchIsTouching(int i1) {
  116. LOGE("XCTRL_TouchIsTouching=%d",i1);
  117. return rand();
  118. }
  119. //-------------------------------------------------------------------------------------------------
  120. //0011A624
  121. TPoint XCTRL_TouchGetDownPos(int dIndex) {
  122. TPoint d;
  123. LOGE("XCTRL_TouchGetPos%d",dIndex);
  124. d.dx_0=rand();
  125. d.dy_4=rand();
  126. return d;
  127. }
  128. //-------------------------------------------------------------------------------------------------
  129. //0011A63C ^_^
  130. void XCTRL_TouchSetDownPos(int i1, TPoint tPoint2) {
  131. }
  132. //-------------------------------------------------------------------------------------------------
  133. //0011a654 ^_^
  134. int XCTRL_TouchGetDownTime(int i1) {
  135. return 12;
  136. }
  137. //-------------------------------------------------------------------------------------------------
  138. //0011A664 //^_^
  139. TPoint XCTRL_TouchGetPos(int dIndex) {
  140. TPoint d;
  141. LOGE("XCTRL_TouchGetPos%d",dIndex);
  142. d.dx_0=rand();
  143. d.dy_4=rand();
  144. return d;
  145. }
  146. //-------------------------------------------------------------------------------------------------
  147. //0011A67C ^_^
  148. int XCTRL_TouchLastTime(int i1) {
  149. return false;
  150. }
  151. //-------------------------------------------------------------------------------------------------
  152. //0011A68C ^_^
  153. bool XCTRL_TouchIsPressed(int i1) {
  154. LOGE("XCTRL_TouchIsPressed=%d",i1);
  155. return rand();
  156. }
  157. //-------------------------------------------------------------------------------------------------
  158. //0011A69C ^_^
  159. bool XCTRL_TouchIsReleased(int i1) {
  160. LOGE("XCTRL_TouchIsReleased=%d",i1);
  161. return rand();
  162. }
  163. //-------------------------------------------------------------------------------------------------
  164. //0011A6AC
  165. bool XCTRL_TouchIsDoubleTapped(int i1) {
  166. return false;
  167. }
  168. //-------------------------------------------------------------------------------------------------
  169. //0011A6BC ^_^
  170. bool XCTRL_TouchGetSwipe(int i1) {
  171. return false;
  172. }
  173. //-------------------------------------------------------------------------------------------------
  174. //0011A6CC
  175. void XCTRL_TouchResetHW() {
  176. }
  177. //-------------------------------------------------------------------------------------------------
  178. //0011A6EC ^_^
  179. void XCTRL_TouchReset() {
  180. }
  181. //-------------------------------------------------------------------------------------------------
  182. //0011A70C
  183. void XCTRL_TouchProcessHW() {
  184. // if (CFTTRewardedVideos::AdOnScreen() == false)
  185. {
  186. gs_i_34A598++;
  187. // loc_11A73C
  188. for (int i = 0; i < gs_icountHW_34A594; i++) {
  189. if (gs_ptouchEventHW_34A490[i].bisReleased_11 || gs_ptouchEventHW_34A490[i].bisTouch_13 == false) {
  190. memmove(&gs_ptouchEventHW_34A490[i], &gs_ptouchEventHW_34A490[i + 1], (3 - i) * sizeof(XCTRL_Touch));
  191. gs_icountHW_34A594--;
  192. i--;
  193. memset(&gs_ptouchEventHW_34A490[gs_icountHW_34A594], 0, sizeof(XCTRL_Touch));
  194. } else if (gs_ptouchEventHW_34A490[i].bisPressed_12) {
  195. gs_ptouchEventHW_34A490[i].bisPressed_12 = false;
  196. }
  197. }
  198. // loc_11A77E
  199. do {
  200. // loc_11A8C2
  201. TPoint tpos;
  202. UseByAddTouchEvent_Internal touvhEvent = FTTInput_GetTouchEvent();
  203. if (touvhEvent.field_0 == ETouchEvent_neg1)
  204. return;
  205. // loc_11A7AC
  206. tpos.dx_0 = (touvhEvent.field_4 * SCR_WID) / CFE::s_fHardwareWidth;
  207. tpos.dy_4 = (touvhEvent.field_8 * SCR_HEI) / CFE::s_fHardwareHeight;
  208. if (touvhEvent.field_0 != ETouchEvent_0) {
  209. if (gs_icountHW_34A594 < 1)
  210. continue;
  211. else {
  212. int i_r10 = 0x7FFFFFFF;
  213. int j = 0;
  214. for (int i = 0; i < gs_icountHW_34A594; i++) {
  215. if (gs_ptouchEventHW_34A490[i].bisTouch_13) {
  216. int i_distance_r0 = XMATH_Distance(&tpos, &gs_ptouchEventHW_34A490[i].tpos_8);
  217. if (i_distance_r0 < i_r10) {
  218. j = i;
  219. i_r10 = i_distance_r0;
  220. }
  221. }
  222. }
  223. switch (touvhEvent.field_0) {
  224. case ETouchEvent_1:
  225. case ETouchEvent_3: { // loc_11A852
  226. gs_ptouchEventHW_34A490[j].bisTouch_13 = false;
  227. gs_ptouchEventHW_34A490[j].bisReleased_11 = true;
  228. gs_ptouchEventHW_34A490[j].bisPressed_12 = false;
  229. break;
  230. }
  231. case ETouchEvent_Touch_2: {
  232. // loc_11A8A8
  233. gs_ptouchEventHW_34A490[j].bisTouch_13 = true;
  234. gs_ptouchEventHW_34A490[j].tpos_8 = &tpos;
  235. break;
  236. }
  237. }
  238. }
  239. } else if (gs_icountHW_34A594 <= 3) {
  240. // loc_11A864 ok
  241. memset(&gs_ptouchEventHW_34A490[gs_icountHW_34A594], 0, sizeof(XCTRL_Touch));
  242. gs_ptouchEventHW_34A490[gs_icountHW_34A594].bisPressed_12 = 1;
  243. gs_ptouchEventHW_34A490[gs_icountHW_34A594].bisTouch_13 = 1;
  244. gs_ptouchEventHW_34A490[gs_icountHW_34A594].tpos_8 = &tpos;
  245. gs_ptouchEventHW_34A490[gs_icountHW_34A594].ttouchDownPos_0 = &tpos;
  246. gs_icountHW_34A594++;
  247. }
  248. } while (1);
  249. }
  250. // loc_11A8D0
  251. }
  252. //-------------------------------------------------------------------------------------------------
  253. //0011A8F8 ^_^
  254. void XCTRL_TouchSetHWToDevice() {
  255. for (int i = 0; i != 4; i++) {
  256. TPoint tp1 = gs_ptouchEvent_34A510[i].ttouchDownPos_0;
  257. int ilastTime = gs_ptouchEvent_34A510[i].ilastTime_18;
  258. int touchDownTime = gs_ptouchEvent_34A510[i].touchDownTime_1C;
  259. memcpy(&gs_ptouchEvent_34A510[i], &gs_ptouchEventHW_34A490[i], sizeof(XCTRL_Touch));
  260. gs_ptouchEvent_34A510[i].ttouchDownPos_0 = tp1;
  261. gs_ptouchEvent_34A510[i].ilastTime_18 = ilastTime;
  262. gs_ptouchEvent_34A510[i].touchDownTime_1C = touchDownTime;
  263. }
  264. gs_icount_34A590 = gs_icountHW_34A594;
  265. for (int i = 0; i != 4; i++) {
  266. if (gs_ptouchEvent_34A510[i].bisPressed_12) {
  267. gs_ptouchEvent_34A510[i].ttouchDownPos_0 =
  268. gs_ptouchEvent_34A510[i].tpos_8;
  269. gs_ptouchEvent_34A510[i].touchDownTime_1C = 0;
  270. }
  271. if (gs_ptouchEvent_34A510[i].bisTouch_13)
  272. gs_ptouchEvent_34A510[i].touchDownTime_1C++;
  273. }
  274. sub_11AA24();
  275. for (int i = 0; i != 4; i++) {
  276. gs_ptouchEvent_34A510[i].bWipe_10 = 0;
  277. if (gs_ptouchEvent_34A510[i].bisReleased_11) {
  278. int ix = gs_ptouchEvent_34A510[i].tpos_8.dx_0 -
  279. gs_ptouchEvent_34A510[i].ttouchDownPos_0.dx_0;
  280. int iy = gs_ptouchEvent_34A510[i].tpos_8.dy_4 -
  281. gs_ptouchEvent_34A510[i].ttouchDownPos_0.dy_4;
  282. if ((ix * ix + iy * iy) > 0x400) {
  283. int iabsX = ix;
  284. int iabsY = iy;
  285. if (iy < 0)
  286. iabsY = -iy;
  287. if (ix < 0)
  288. iabsX = -ix;
  289. if (iabsX <= iabsY) {
  290. if (iy >= 1)
  291. gs_ptouchEvent_34A510[i].bWipe_10 = 2;
  292. else
  293. gs_ptouchEvent_34A510[i].bWipe_10 = 1;
  294. } else if (ix >= 1) {
  295. gs_ptouchEvent_34A510[i].bWipe_10 = 4;
  296. } else
  297. gs_ptouchEvent_34A510[i].bWipe_10 = 3;
  298. }
  299. }
  300. }
  301. }
  302. //-------------------------------------------------------------------------------------------------
  303. //0011A9F4
  304. void XCTRL_TouchProcess_ClearTriggers() {
  305. LOGE("XCTRL_TouchProcess_ClearTriggers");
  306. }
  307. //-------------------------------------------------------------------------------------------------