From 15bd0e903780ac31b9d0e92922b273eedb36bb9f Mon Sep 17 00:00:00 2001 From: Wolfywolfy Date: Thu, 5 Dec 2024 08:08:48 -0300 Subject: [PATCH] Move the bluetooth initialization code on correct place Uncomment some code on pademu_connect --- modules/pademu/ds3bt.c | 14 ++++++-------- modules/pademu/ds4bt.c | 14 ++++++-------- modules/pademu/pademu.c | 8 ++++---- 3 files changed, 16 insertions(+), 20 deletions(-) diff --git a/modules/pademu/ds3bt.c b/modules/pademu/ds3bt.c index e86971842..2c9280cd5 100644 --- a/modules/pademu/ds3bt.c +++ b/modules/pademu/ds3bt.c @@ -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); } @@ -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() diff --git a/modules/pademu/ds4bt.c b/modules/pademu/ds4bt.c index 6e4791029..c06c32eb1 100644 --- a/modules/pademu/ds4bt.c +++ b/modules/pademu/ds4bt.c @@ -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); } @@ -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() diff --git a/modules/pademu/pademu.c b/modules/pademu/pademu.c index 3a6390bf3..848210923 100644 --- a/modules/pademu/pademu.c +++ b/modules/pademu/pademu.c @@ -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; } } @@ -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; } }