Skip to content

Commit

Permalink
Move the bluetooth initialization code on correct place
Browse files Browse the repository at this point in the history
Uncomment some code on pademu_connect
  • Loading branch information
Wolf3s committed Dec 6, 2024
1 parent 3c09905 commit 15bd0e9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 20 deletions.
14 changes: 6 additions & 8 deletions modules/pademu/ds3bt.c
Original file line number Diff line number Diff line change
Expand Up @@ -323,18 +323,10 @@ static int HCI_Command(int nbytes, u8 *dataptr)

static int hci_reset()
{
int pad = 0;
hci_cmd_buf[0] = HCI_OCF_RESET;
hci_cmd_buf[1] = HCI_OGF_CTRL_BBAND;
hci_cmd_buf[2] = 0x00; // Parameter Total Length = 0

padf[pad].priv = &ds3pad[pad];
padf[pad].get_status = ds3bt_get_status;
padf[pad].get_model = ds3bt_get_model;
padf[pad].get_data = ds3bt_get_data;
padf[pad].set_rumble = ds3bt_set_rumble;
padf[pad].set_mode = ds3bt_set_mode;

return HCI_Command(3, hci_cmd_buf);
}

Expand Down Expand Up @@ -679,6 +671,12 @@ static void ds3pad_clear(int pad)
ds3pad[pad].data[1] = 0xFF;
mips_memset(&ds3pad[pad].data[2], 0x7F, 4);
mips_memset(&ds3pad[pad].data[6], 0x00, 12);
padf[pad].priv = &ds3pad[pad];
padf[pad].get_status = ds3bt_get_status;
padf[pad].get_model = ds3bt_get_model;
padf[pad].get_data = ds3bt_get_data;
padf[pad].set_rumble = ds3bt_set_rumble;
padf[pad].set_mode = ds3bt_set_mode;
}

static void ds3pad_init()
Expand Down
14 changes: 6 additions & 8 deletions modules/pademu/ds4bt.c
Original file line number Diff line number Diff line change
Expand Up @@ -321,18 +321,10 @@ static int HCI_Command(int nbytes, u8 *dataptr)

static int hci_reset()
{
int pad = 0;
hci_cmd_buf[0] = HCI_OCF_RESET;
hci_cmd_buf[1] = HCI_OGF_CTRL_BBAND;
hci_cmd_buf[2] = 0x00; // Parameter Total Length = 0

padf[pad].priv = &ds4pad[pad];
padf[pad].get_status = ds4bt_get_status;
padf[pad].get_model = ds4bt_get_model;
padf[pad].get_data = ds4bt_get_data;
padf[pad].set_rumble = ds4bt_set_rumble;
padf[pad].set_mode = ds4bt_set_mode;

return HCI_Command(3, hci_cmd_buf);
}

Expand Down Expand Up @@ -680,6 +672,12 @@ static void ds4pad_clear(int pad)
ds4pad[pad].data[1] = 0xFF;
mips_memset(&ds4pad[pad].data[2], 0x7F, 4);
mips_memset(&ds4pad[pad].data[6], 0x00, 12);
padf[pad].priv = &ds4pad[pad];
padf[pad].get_status = ds4bt_get_status;
padf[pad].get_model = ds4bt_get_model;
padf[pad].get_data = ds4bt_get_data;
padf[pad].set_rumble = ds4bt_set_rumble;
padf[pad].set_mode = ds4bt_set_mode;
}

static void ds4pad_init()
Expand Down
8 changes: 4 additions & 4 deletions modules/pademu/pademu.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,13 @@ int _start(int argc, char *argv[])
void pademu_connect(struct pad_funcs *pf)
{
int i;
// DPRINTF("%s\n", __FUNCTION__);
DPRINTF("%s\n", __FUNCTION__);
for (i = 0; i < MAX_PORTS; i++) {
if (padf[i] == NULL) {
DPRINTF("connect pad %d\n", i);
padf[i] = pf;
// pad[i].enabled = 1;
// padf[i]->set_mode(padf[i], pad[i].mode, pad[i].mode_lock);
pad[i].enabled = 1;
padf[i]->set_mode(padf[i], pad[i].mode, pad[i].mode_lock);
break;
}
}
Expand All @@ -168,7 +168,7 @@ void pademu_disconnect(struct pad_funcs *pf)
if (padf[i] == pf) {
DPRINTF("disconnect pad %d\n", i);
padf[i] = NULL;
// pad[i].enabled = 0;
pad[i].enabled = 0;
break;
}
}
Expand Down

0 comments on commit 15bd0e9

Please sign in to comment.