Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int SceTouchAlarm0_func(void)
- {
- int prev_state;
- prev_state = ksceKernelCpuSuspendIntr(&g_intr);
- new_touch_data(0, 0, 0);
- g_sce_touch_alarm0 = -1;
- ksceKernelCpuResumeIntr(&g_intr, prev_state);
- return 0;
- }
- int syscon_cb_1(SceSysconPacket *packet,SceSysconPacket *argp)
- {
- ushort cmd;
- int prev_state;
- uint mask;
- if (argp == NULL)
- return -1;
- prev_state = ksceKernelCpuSuspendIntr(&g_intr);
- if (*(short *)&argp[1].next != 1) {
- ksceKernelCpuResumeIntr(&g_intr, prev_state);
- return -1;
- }
- *(short *)&argp[1].next = 0;
- cmd = packet->tx[0] | (packet->tx[1] << 8);
- if (cmd == 0x300) {
- mask = 3;
- } else if (cmd == 0x301) {
- mask = 1;
- } else if (cmd == 0x302) {
- mask = 2;
- } else {
- ksceKernelCpuResumeIntr(&g_intr, prev_state);
- return -1;
- }
- new_touch_data(mask, packet->unk1[1], packet->unk1[2]);
- ksceKernelCpuResumeIntr(&g_intr, prev_state);
- return 0;
- }
- int syscon_cb_2(SceSysconPacket *packet, SceSysconPacket *argp)
- {
- ushort cmd;
- bool set_flag;
- int prev_state;
- uint time_low;
- uint cur_enabled;
- uint diff_enabled;
- bool send;
- if (argp == NULL)
- return -1;
- prev_state = ksceKernelCpuSuspendIntr(&g_intr);
- if (*(short *)&argp[1].next != 1) {
- ksceKernelCpuResumeIntr(&g_intr, prev_state);
- return -1;
- }
- *(short *)&argp[1].next = 0;
- cmd = packet->tx[0] | (packet->tx[1] << 8);
- if (cmd == 0x381) {
- cur_enabled = 0
- if (argp->tx[3] != 0)
- cur_enabled |= 1;
- if (argp->tx[5] != 0)
- cur_enabled |= 2;
- diff_enabled = cur_enabled ^ g_enabled_port_mask;
- g_enabled_port_mask = cur_enabled;
- time_low = ksceKernelGetSystemTimeLow();
- if ((g_enabled_port_mask & 1) && (diff_enabled & 1))
- g_front_enabled_time = time_low;
- if ((g_enabled_port_mask & 2) && (diff_enabled & 2))
- g_back_enabled_time = time_low;
- if (g_baryon_version < 0x90003) {
- set_flag = true;
- send = false;
- } else {
- if (diff_enabled & 1) {
- if (g_enabled_port_mask & 1)
- g_cur_front_cmd = g_enable_front_cmd;
- else
- g_cur_front_cmd = 0;
- }
- if (diff_enabled & 2) {
- if (g_enabled_port_mask & 2)
- g_cur_back_cmd = g_enable_back_cmd;
- else
- g_cur_back_cmd = 0
- }
- set_flag = false;
- argp->tx[0] = 0x87;
- argp->tx[1] = 3;
- argp->tx[2] = 9;
- argp->tx[3] = diff_enabled & 1;
- argp->tx[4] = g_cur_front_cmd;
- argp->tx[5] = 0;
- argp->tx[6] = 0;
- argp->tx[7] = (diff_enabled >> 1) & 1;
- argp->tx[8] = g_cur_back_cmd;
- argp->tx[9] = 0;
- argp->tx[10] = 0;
- *(short *)&argp[1].next = 1;
- *(short *)((int)&argp[1].next + 2) = 0;
- send = true;
- }
- } else if (cmd == 0x387) {
- if (argp->tx[3])
- g_front_sampling = g_cur_front_cmd;
- if (argp->tx[7])
- g_back_sampling = g_cur_back_cmd;
- send = !argp->tx[7];
- set_flag = true;
- } else {
- ksceKernelCpuResumeIntr(&g_intr,prev_state);
- return -1;
- }
- if (g_touch_status == 4) {
- if (g_enabled_port_mask != 0) {
- set_flag = false;
- }
- if (set_flag) {
- if (g_SceTouchUpdate_evflag_uid != -1) {
- ksceKernelSetEventFlag(g_SceTouchUpdate_evflag_uid, 1);
- }
- ksceKernelCpuResumeIntr(&g_intr, prev_state);
- return 0;
- }
- }
- ksceKernelCpuResumeIntr(&g_intr,prev_state);
- if (send) {
- prev_state = ksceSysconCmdExecAsync(argp, 0, syscon_cb_2, argp);
- if (prev_state < 0) {
- *(short *)&argp[1].next = 0;
- }
- }
- return 0;
- }
- #define FRONT (1u << 0)
- #define BACK (1u << 1)
- #define FAKE (1u << 2)
- int SceTouchVblank_handler(void)
- {
- int prev_state;
- uint uVar3;
- uint change_back;
- byte tx4;
- uint send_front_packet;
- uint uVar4;
- uint back_set_status;
- uint change_front;
- prev_state = ksceKernelCpuSuspendIntr(&g_intr);
- if (g_front_packet_pending) {
- uVar3 = FAKE;
- uVar4 = FRONT;
- send_front_packet = 0;
- g_retries_front = g_retries_front + 1;
- } else {
- if (g_touch_status == 2) {
- required_mask = 0
- if (g_front_panel_present)
- required_mask |= 1;
- if (g_back_panel_present)
- required_mask |= 2;
- if (g_baryon_version < 0x40000) {
- uVar3 = FAKE;
- uVar4 = FRONT;
- send_front_packet = 0;
- } else {
- if (g_enabled_port_mask == required_mask) {
- if (g_baryon_version < 0x90003) {
- uVar3 = FAKE;
- uVar4 = FRONT;
- send_front_packet = 0;
- } else {
- // Front
- if (g_enabled_port_mask & 1) {
- if (BYTE_8100bb0e != 0) {
- if (BYTE_8100bb0e == 2) {
- g_cur_front_cmd = g_front_packet_size;
- } else if (BYTE_8100bb0e != 3) {
- g_cur_front_cmd = g_enable_front_cmd;
- }
- g_cur_front_cmd = 0;
- }
- BYTE_8100bb0e = 0;
- }
- // Back
- if (g_enabled_port_mask & 2) {
- if (BYTE_8100bbf6 != 0) {
- if (BYTE_8100bbf6 == 2) {
- g_cur_back_cmd = g_back_packet_size;
- } else if (BYTE_8100bbf6 != 3) {
- g_cur_back_cmd = g_enable_back_cmd;
- }
- g_cur_back_cmd = 0;
- }
- BYTE_8100bbf6 = 0;
- }
- change_front = g_front_sampling != g_cur_front_cmd;
- change_back = g_back_sampling != g_cur_back_cmd;
- if (change_front || change_back) {
- g_front_packet_pending = 1;
- g_packet1.tx[0] = 0x87;
- g_packet1.tx[1] = 3;
- g_packet1.tx[2] = 9;
- g_packet1.tx[3] = change_front;
- g_packet1.tx[4] = g_cur_front_cmd;
- g_packet1.tx[5] = 0;
- g_packet1.tx[6] = 0;
- g_packet1.tx[7] = change_back;
- g_packet1.tx[8] = g_cur_back_cmd;
- g_packet1.tx[9] = 0;
- g_packet1.tx[10] = 0;
- g_retries_front = 0;
- uVar3 = BACK | FAKE;
- uVar4 = FRONT | BACK;
- send_front_packet = BACK;
- } else {
- uVar3 = FAKE;
- uVar4 = FRONT;
- send_front_packet = 0;
- }
- }
- } else { /* g_enabled_port_mask != required_mask */
- uint8_t cmd4 = 0;
- uint8_t cmd6 = 0;
- if (required_mask != 0) {
- uVar4 = required_mask & 3;
- if ((uVar4 == 2) || (uVar4 == 3)) {
- cmd4 = 0;
- cmd6 = g_back_vendor_id_dependant;
- } else {
- if (uVar4 == 1) {
- cmd4 = g_front_vendor_id_non_dependant;
- cmd6 = 0;
- } else {
- cmd4 = 0;
- cmd6 = 0;
- }
- }
- }
- g_packet1.tx[0] = 0x81;
- g_packet1.tx[1] = 3;
- g_packet1.tx[2] = 5;
- g_packet1.tx[3] = required_mask & 1;
- g_packet1.tx[4] = cmd4 | g_cmd_byte_1;
- g_packet1.tx[5] = (required_mask >> 1) & 1;
- g_packet1.tx[6] = cmd6 | g_cmd_byte_2;
- g_retries_front = 0;
- g_front_packet_pending = 1;
- uVar3 = BACK | FAKE;
- uVar4 = FRONT | BACK;
- send_front_packet = BACK;
- }
- }
- } else { /* g_touch_status != 2 */
- if (((g_touch_status != 3) && (g_touch_status != 1) && (g_touch_status != 4)) || (g_enabled_port_mask == 0)) {
- uVar3 = FAKE;
- uVar4 = FRONT;
- send_front_packet = 0;
- } else {
- g_packet1.tx[0] = 0x81;
- g_packet1.tx[1] = 3;
- g_packet1.tx[2] = 5;
- g_packet1.tx[3] = 0;
- g_packet1.tx[4] = g_cmd_byte_1;
- g_packet1.tx[5] = 0;
- g_packet1.tx[6] = g_cmd_byte_2;
- g_retries_front = 0;
- g_front_packet_pending = 1;
- uVar3 = BACK | FAKE;
- uVar4 = FRONT | BACK;
- send_front_packet = BACK;
- }
- }
- }
- if (g_back_packet_pending) {
- uVar4 = send_front_packet;
- g_retries_back = g_retries_back + 1;
- } else {
- if ((g_touch_status != 2) || (g_enabled_port_mask == 0)) {
- uVar4 = send_front_packet;
- if (g_sce_touch_alarm0 == -1) {
- uVar4 = uVar3;
- }
- } else {
- if (g_enabled_port_mask == 1)
- g_packet2.tx[0] = 1;
- else if (g_enabled_port_mask == 2)
- g_packet2.tx[0] = 2;
- else
- g_packet2.tx[0] = 0;
- g_packet2.tx[1] = 3;
- g_packet2.tx[2] = 1;
- g_retries_back = 0;
- g_back_packet_pending = 1;
- }
- }
- ksceKernelCpuResumeIntr(&g_intr, prev_state);
- if ((uVar4 & FRONT) && (ret = ksceSysconCmdExecAsync(&g_packet2, 0x400, syscon_cb_1, &g_packet2), ret < 0)) {
- g_back_packet_pending = 0;
- }
- if ((uVar4 & BACK) && (ret = ksceSysconCmdExecAsync(&g_packet1, 0, syscon_cb_2, &g_packet1), ret < 0)) {
- g_front_packet_pending = 0;
- }
- if (uVar4 & FAKE) {
- g_sce_touch_alarm0 = ksceKernelRegisterTimer("SceTouchAlarm0", 1000, SceTouchAlarm0_func);
- }
- return -1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement