Skip to content

Commit

Permalink
[PS] Restore turbo and fix pressure mode
Browse files Browse the repository at this point in the history
  • Loading branch information
darthcloud committed Oct 15, 2023
1 parent 15e53ca commit be6b1bd
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
9 changes: 5 additions & 4 deletions main/adapter/wired/ps.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ static DRAM_ATTR const uint32_t ps_btns_mask[32] = {
BIT(PS_L2), BIT(PS_L1), 0, BIT(PS_L3),
BIT(PS_R2), BIT(PS_R1), 0, BIT(PS_R3),
};
static const uint8_t ps_btns_idx[32] = {
static DRAM_ATTR const uint8_t ps_btns_idx[32] = {
0, 0, 0, 0,
0, 0, 0, 0,
5, 4, 7, 6,
Expand Down Expand Up @@ -180,9 +180,10 @@ void IRAM_ATTR ps_init_buffer(int32_t dev_mode, struct wired_data *wired_data) {
memset((void *)map, 0, sizeof(*map));
map->buttons = 0xFFFF;
map->analog_btn = 0x00;
for (uint32_t i = 0; i < ADAPTER_MAX_AXES; i++) {
for (uint32_t i = 0; i < 4; i++) {
map->axes[ps_axes_idx[i]] = ps_axes_meta[i].neutral;
}
memset(map->pressure, 0x00, sizeof(map->pressure));

map_mask->buttons = 0x0000;
map_mask->sticks = 0x00000000;
Expand Down Expand Up @@ -252,7 +253,7 @@ static void ps_ctrl_from_generic(struct wired_ctrl *ctrl_data, struct wired_data
}
}

for (uint32_t i = 0; i < ADAPTER_MAX_AXES; i++) {
for (uint32_t i = 0; i < 4; i++) {
if (ctrl_data->map_mask[0] & (axis_to_btn_mask(i) & ps_desc[0])) {
if (ctrl_data->axes[i].value > ctrl_data->axes[i].meta->size_max) {
map_tmp.axes[ps_axes_idx[i]] = 255;
Expand Down Expand Up @@ -393,5 +394,5 @@ void IRAM_ATTR ps_gen_turbo_mask(struct wired_data *wired_data) {
}
}

wired_gen_turbo_mask_axes8(wired_data, map_mask->axes, ADAPTER_MAX_AXES, ps_axes_idx, ps_axes_meta);
wired_gen_turbo_mask_axes8(wired_data, map_mask->axes, 4, ps_axes_idx, ps_axes_meta);
}
21 changes: 20 additions & 1 deletion main/wired/ps_spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,26 @@ static void ps_cmd_rsp_hdlr(struct ps_ctrl_port *port, uint8_t id, uint8_t cmd,
load_mouse_axes(id + port->mt_first_port, &rsp[2]);
break;
default:
memcpy(rsp, wired_adapter.data[id + port->mt_first_port].output, size);
*(uint16_t *)&rsp[0] = wired_adapter.data[id + port->mt_first_port].output16[0]
| wired_adapter.data[id + port->mt_first_port].output_mask16[0];
if (size > 2) {
for (uint32_t i = 2; i < 6; ++i) {
rsp[i] = (wired_adapter.data[id + port->mt_first_port].output_mask[i]) ?
wired_adapter.data[id + port->mt_first_port].output_mask[i]
: wired_adapter.data[id + port->mt_first_port].output[i];
}
}
if (size > 6) {
*(uint16_t *)&rsp[6] = wired_adapter.data[id + port->mt_first_port].output16[3]
& wired_adapter.data[id + port->mt_first_port].output_mask16[3];
*(uint32_t *)&rsp[8] = wired_adapter.data[id + port->mt_first_port].output32[2]
& wired_adapter.data[id + port->mt_first_port].output_mask32[2];
*(uint32_t *)&rsp[12] = wired_adapter.data[id + port->mt_first_port].output32[3]
& wired_adapter.data[id + port->mt_first_port].output_mask32[3];
*(uint16_t *)&rsp[16] = wired_adapter.data[id + port->mt_first_port].output16[8]
& wired_adapter.data[id + port->mt_first_port].output_mask16[8];
}
++wired_adapter.data[id + port->mt_first_port].frame_cnt;
break;
}
if (cmd != 0x42 && cmd != 0x43) {
Expand Down

0 comments on commit be6b1bd

Please sign in to comment.