Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Problems with multiple joystick using the same name. set control device inconsistent.

Author
Message
zero32
7
Years of Service
User Offline
Joined: 28th Jul 2016
Location:
Posted: 27th Jan 2020 13:20
Hey, members of the community, everything all right?

i have a problem using the set control device command. the command takes 2 parameters. the first one is the name of the device and the second one is some kind of id.
now i have 2 controller with the same name, so i need to use the second parameter so dbpro knows which joystick i want to access.

this worked fine yesterday, using the name of the controller and id "1" for the first joystick and id "2" for the second joystick.
today i had to use id "0" for the first joystick and id "1" for the second joystick.

copied the exe to another pc using the same controllers the order is different again.

why is this and how can i work around this? if i try to access an invalid id dbpro exits with an error message and there seems to be no command to check if an id is valid or not.
"It is only slightly easier than changing all sugar in a cake into stevia after it has already been baked" -Bisqwit
LBFN
16
Years of Service
User Offline
Joined: 7th Apr 2007
Location: USA
Posted: 28th Jan 2020 14:01
Have you tried using the command SET CONTROL DEVICE INDEX to set the index to either 0 or 1 initially?



So many games to code.....so little time.
zero32
7
Years of Service
User Offline
Joined: 28th Jul 2016
Location:
Posted: 29th Jan 2020 08:25 Edited at: 29th Jan 2020 08:28
i think i already have the solution
it's just dark basic pro being dark basic pro.

you see, to be able to use 2 joysticks with the same name, i have to call


and i didn't know the device index, but turns out the device index is in the same order as the checklist, starting at 0.
so checklist index 1 equals device index 0
so in order to use joysticks i have to set an index i want to use and assign the device using the device name and an index that is most likely the same that i will assign it to. i didn't expect this level redundancy, so that is where my error was.

this is a piece of code that works fine now:



thank you LBFN for trying to help me. have a nice day
"It is only slightly easier than changing all sugar in a cake into stevia after it has already been baked" -Bisqwit
Dimis
12
Years of Service
User Offline
Joined: 12th Jun 2011
Location: Athens, Hellas
Posted: 29th Jan 2020 10:28
Thanks zero32, i had a similar problem yesterday and your latest post helped me solve it! I also use 2 identical controllers and had issues with them.
Everything works fine now, except the "joystick hat angle" function. I can only receive the hat angle number only from 1 controller, the second always returns -1 (neutral), so i can't use the D-pad on both controllers. Even the example code does the same, so i guess i am not doing something wrong.

Mind if i ask if that is the same case with your controllers too? Or can you use the D-pad on both of them?
This is probably a different issue, not related to using the same controllers, maybe it is just a dbpro bug.
zero32
7
Years of Service
User Offline
Joined: 28th Jul 2016
Location:
Posted: 29th Jan 2020 23:34 Edited at: 30th Jan 2020 08:31
i can use the D-pad on both of my controllers. did you use the correct hat number? the hat number should be 0 on both controllers if it's a playstation style controller. any other number will just return -1
can i take a look at your code?

edit: i added a code that works fine for my controllers:

"It is only slightly easier than changing all sugar in a cake into stevia after it has already been baked" -Bisqwit
Dimis
12
Years of Service
User Offline
Joined: 12th Jun 2011
Location: Athens, Hellas
Posted: 30th Jan 2020 00:26
Thanks again, problem is fixed. I am using playstation4 controllers, i misinterpreted the help file example, instead of using zero on both controllers, i was using the device index number....
So no problem, everything works fine now.
Mage
17
Years of Service
User Offline
Joined: 3rd Feb 2007
Location: Canada
Posted: 11th Mar 2020 03:30
You might find that the triggers cancel each other out.
Let me know if you find a way around that.

Mage's Modular Code - Get awesome UI controls and powerful Bitmap Fonts!
Screen Device Recovery - Stop your apps from crashing when minimized/tabbed/screen locked.
CPU Friendly Frame Limiter - Make your app generate less computer heat + noise, and use less battery life!

Login to post a reply

Server time is: 2024-03-29 13:06:52
Your offset time is: 2024-03-29 13:06:52