#Pairing a Bluetooth Device using Windows API

108 messages ยท Page 1 of 1 (latest)

quartz drumBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.

graceful arrow
#

this may stem from the fact that it pairs successfully but the pair state isnt recognized so its still technically 'unpaired' ill take a look and see if i can dig up anything

#

could you edit your error checking statement to give the error code?

#

something like this

result = BluetoothAuthenticateDeviceEx(nullptr, hRadio, &btdi, nullptr, MITMProtectionNotRequired);

if (result != ERROR_SUCCESS) {
    std::cout << "DEBUG: Failed to authenticate device, error code: " << result << std::endl;
} else {
    std::cout << "DEBUG: Successfully authenticated device" << std::endl;
}
#

because its still a little vague

#

@sterile tulip

quartz drumBOT
#

@sterile tulip Has your question been resolved? If so, type !solved :)

graceful arrow
#

sure no worries! just give me a ping

graceful arrow
#

hmmm alright, once i get back ill take a look again and see if i can identify anything

#

it might be due to the device class might be using a different 'paired' identifier as well so ill check that as well

quartz drumBOT
#

@sterile tulip Has your question been resolved? If so, type !solved :)

graceful arrow
#

@sterile tulip found your issue

#

you didnt update the device record on pair so it wouldnt be recognised as 'paired'

#
// Update the device record to ensure it is remembered
    if ((result = BluetoothUpdateDeviceRecord(&btdi)) != ERROR_SUCCESS) {
        LogError(L"BluetoothUpdateDeviceRecord", result);
    } else {
        std::cout << "DEBUG: Device record updated successfully" << std::endl;
    }
#

make sure you put it after your authentication as it wont work before since authentication comes first

#

try to force the fRemembered flag before it like this btdi.fRemembered = TRUE;

#

same output as well? strange, ill take another look, i swear it should work as it should but ill take another look

#

try refetching your info after you run update device record:

 BLUETOOTH_DEVICE_INFO_STRUCT updatedBtdi = { sizeof(BLUETOOTH_DEVICE_INFO_STRUCT) };
    updatedBtdi.Address = btdi.Address; 
#

also keep in mind, it might also be due to bluetooth conflicts so after making these changes forget your BT device and try to re-pair

#

ah alright so it wasnt pre existing so thats fine

graceful arrow
#

that makes no sense Hmm

#

try to implement a sort of 'clean' stage since ive had issues with BT connections even when it fails to authenticate and remember connected devices theres a false state which doesnt allow it to reconnect

#
    // Remove the device before pairing to ensure a clean start
    if ((result = BluetoothRemoveDevice(&btdi.Address)) != ERROR_SUCCESS) {
        LogError(L"BluetoothRemoveDevice", result);
    } else {
        std::cout << "DEBUG: Device removed successfully before pairing" << std::endl;
    }
#

add this before your auth

#

im very close to just forcing authenticated to be true atp

#

yeah might as well just in case some weird state happens like auth and connected success but remembrance failure

#

because yk

#

windows.

#

i wrote a sort of hack-ish way that to fix pairdevice, it does a validate and clean then tries to force the flag (which will determine if its device side or api side)

#

yeah thats due to the remembrance state being false

#

sorry *auth

#

force auth
authentication: no
???

#

hold on it might be due to my cleanup

#

this might be a sign to switch to the windows devices enum api

#

which one?

#

yep

#

how does this make any sense:

DEBUG: Pairing callback was called
DEBUG: Successfully authenticated device
DEBUG: Successfully paired device
DEBUG: Device record updated successfully

yet auth fails

#

yeah sorry about that problem, do you know how to implement it? if not i can give you functional code so you can get a head start

#

and since you were using the windows api previously im going to assume you have the win10 sdk already installed.

#

Alright, check it when you can.

#

Represents a picker flyout that contains a list of devices for the user to choose from. In a desktop app, before using an instance of this class in a way that displays UI, you'll need to associate the object with its owner's window handle. For more info, and code examples, see Display WinRT UI objects that depend on CoreWindow.

Contains information and enables pairing for a device.

#

everyday in the life of an indie engine dev

#

except my problems are just stupid like mismatching shader ID's since i refuse to use a shader debugger

#

half of the skill is understanding your error logs Wheeze

#

but youll get it

#

force of habit

#

I remember homebrew apps for the original Wii, was worth it sideloading crappy call of duty ports

#

oh yeah, emulators are pretty unreliable actually simulating the real hardware sometimes

#

also

#

nintendo

#

nah its usually more adaptable in most cases

#

funny

#

especially with their failure of their baby boy they would sue you to keep their platform relevant

#

its not giving up at least shrug

#

tell me if the pairdevice set up i give you works once you install RT

#

๐Ÿ‘€

#

nah im just talking about how they shit critisize on the switch lite

#

release it as a switch but get rid of the switch functionality

#

real genius

#

just like forcing a auth flag for it to fail a force

#

instead of making the hardware weaker to make it cost friendly they really just said 'fuck you' and melted the joycons to the screen

#

exactly so its even worse

#

wait

#

are you making this program so that you can use joycons for PC games?

#

ohh

#

you know theres those USB BT switches that automatically do that but this is a good project

#

yep

#

its like 5USD where i am

#

but i do live in SEA where everything is worth 2 bubblegums and a can of coke

#

yes

#

oh sorry, the second one

#

very versatile as well, supported dualshock so i didnt have to use DS4 anymore

#

oh yeah good luck finding anything not out of SEA regions where they usually mass produce these

#

where are you situated in

#

oh wow yes thats understandable

#

this project really becomes a necessity now

#

yes no

#

a lot of steam games still suck implementing them

#

games like BeamNG or NFS refuse to natively support dualshock 4

#

like man why is my R2 open map

#

yes

#

basically treats it like any controller base for an xbox platform

#

haven't tried out gyro motion out yet but i might get to testing it, since iirc it might not support DualShock gyro but it might support the Switch

#

ill see

#

i lost it though sad

#

true, im not too knowledgable in this field so i probably only know the barebones api functionality

#

ahh i see

#

i hear 8BitDo BT switches are able to use the Switch's gyro motion though but im not exactly clear if thats true or not

#

to my knowledge you know more than me about the field so i wouldnt know if it wasnt pepe_laugh

#

fair enough because theres no native support on xbox based platforms that supported motion controls anyway

#

except

#

that

#

but thats a visual skeleton method of input

#

it all depends on the BT adapter driver and its configured outputs because you can technically still output motion data without any motion controls on the controller but it would just remain 0 at all times

#

no problem good luck, mark it as solved as well

quartz drumBOT
#

Thank you and let us know if you have any more questions!

This thread is now set to auto-hide after an hour of inactivity