JoyType ([port])
Blitz3D Forums/Blitz3D Beginners Area/JoyType ([port])
| ||
Something I don't understand 1) JoyType ([port]) returns what kind of joystick you have connected (if any). Is there a similar command to determine the mouse type? 2) JoyType ([port]) says in the docs that "port" is optional. But how many ports are there to "check"? |
| ||
Up to you. How many do you want to check for? Ports are number from 0 upwards. Most PCs will only have one joypad attached, so there's rarely a need to check for any more. A few may have 2 attached, so check ports 0 and 1 (0 being the default one). Fewer still may have 4 attached, so check 0 to 3. Basically, just check for as many as you need to for your game. If it's single player, then you only ever need to check port 0. |
| ||
@JazzieB It's for a computer diagnostics tool, so I need to take into consideration "X" number of options ... I wonder what the MAX number is ... ?? |
| ||
There is no reason why you can't check for 1000 joysticks. It may seem excessive but at least you know there won't be that many joysticks connected so you're covered. Something like this (untested): For jt=0 to 999 If JoyType(jt)>0 Then Print "Joystick type "+JoyType(jt)+" attached to port "+jt Next Btw, is that you Hans? |
| ||
@VIP3R I understand what you are saying, but of course 1000 is not technically possible. Does anyone actually know how many ports there are (i.e. how many joysticks you can actually connect) to a PC at any given time? |
| ||
Well I believe that the USB spec allows (theoretically) 127 devices per port. Multiply that by the number of USB controllers on the motherboard and in any add-in cards. And then you have to add possibilities for gameport devices, bluetooth devices, firewire devices (do they exist?) and any other that come out. So to answer your question, there's really no specific "maximum". You're better off supporting "up to" 1000 joysticks or something, and just doing what vip3r said. Actually, if you really wanted to enumerate all the joysticks connected, there MAY be a function available in the WinAPI, but I don't know what it is. |
| ||
@Soja Thanks again I think I will check for only 4 joystick(s) / pads. That would cover the majority I believe. |
| ||
And here is my result:Function Display_JoySticks() Local PortCount% = 0 PortID% = 0 PortString$ = "" Text (Cursor_X2Pos,Cursor_Y2Pos,"Joystick(s) connected : ",False,False) For PortCount = 0 To 3 PortID = JoyType(PortCount) Select PortID Case 0 : PortString$ = "None" Case 1 : PortString$ = "Digital" Case 2 : PortString$ = "Analog" End Select Text (Cursor_X2Pos,Cursor_Y2Pos," Port" + " " + PortCount + " - " + PortString$,False,False) Cursor_Y2Pos = Cursor_Y2Pos + Cursor_Size Next End Function |