So moving the axis also counts as a button push? That makes _DEVICES almost worthless to add into a program. I’ll do you some testing later, and if I can duplicate the results, I’ll end up stripping joystick support out of my projects. We really need a complete input overhaul for QB64. :(@SMcNeill
The project I wrote to which I added joystick support (i) works as expected (ii) required no complete overhaul. Maybe it's the way you're writing your routines?DO
https://fellippeheitor.itch.io/spaceship
Tempodi got good results with my code (we were just discussing it at Discord). Your controller sure is requiring some calibration. But do not underestimate the fact that you are doing some weird ordering of commands to get input from joysticks, as opposed to treating it more like we treat _MOUSEINPUT, which is what I've offered.
WHILE _DEVICEINPUT(found): WEND
FOR i = 1 TO _LASTBUTTON(found)
LOCATE x + i, 1: PRINT USING "##: ##"; i; _BUTTON(i)
NEXT
FOR i = 1 TO _LASTAXIS(found)
LOCATE x + i, 20: PRINT USING "##: +#.##"; i; _AXIS(i)
LOCATE x + i, 30: PRINT STRING$(41, 176);
LOCATE x + i, 50 + INT(map(_AXIS(i), -1, 1, -20, 20)): PRINT CHR$(219);
NEXT
I try to be clearer : _AXIS gives as output a single precision number that is -1/1 if the knob of joystick reaches the extreme inferior / superior point of its range of movement, while when it stands on the middle he gives back a value very long in single precision digit.
The joystick that I have used is a generic joystick USB similar to that of PS3
Analog Joysticks are just that Analog, so there is some "noise", this shows up even in my Windows Game Controllers properties panel. the little center cross hairs "vibrate" just a tiny bit when the stick is just siting on the desk, and tends to get a little "jiggle" if buttons are pressed. That of course would have nothing to do with QB64.
Thats where the programmer would have to deal with the noise from the device, I'm pretty sure if you could hack a console game for anything that uses one of those controllers, you would probably find some code in game to cancel that out or a special instruction set to cancel out controller noise before the game even sees it.
So, lets say, if you were to use a _BYTE to monitor joystick motion, you would want to ignore anything that returned, say, a value of +\- 3.
SPOK
what do you think about -0?
I'm trying to send joystick data to a computer. The data is a byte value where each value corresponds to a particular position.
The computer derives the position from the byte values as:
center = 0
max left = 1
max right = -1
A full 128 increments on either side of joystick center would require the byte plus another indicating bit of data that gives a total of 257 states.
I wanted to send a single byte of data.
bLeftTrigger
The current value of the left trigger analog control. The value is between 0 and 255.
bRightTrigger
The current value of the right trigger analog control. The value is between 0 and 255.
sThumbLX
Left thumbstick x-axis value. Each of the thumbstick axis members is a signed value between -32768 and 32767 describing the position of the thumbstick. A value of 0 is centered. Negative values signify down or to the left. Positive values signify up or to the right. The constants XINPUT_GAMEPAD_LEFT_THUMB_DEADZONE or XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE can be used as a positive and negative value to filter a thumbstick input.
sThumbLY
Left thumbstick y-axis value. The value is between -32768 and 32767.
sThumbRX
Right thumbstick x-axis value. The value is between -32768 and 32767.
sThumbRY
Right thumbstick y-axis value. The value is between -32768 and 32767.
This is the same type results I’m producing, with the same style joystick. At startup, everything I have reads zero properly. All I need do is press a simple button, and then I generate the very long single precision digit. (Which is, oddly enough, exactly 1/127 — which is the tolerance level STICK and STRIG tolerates without glitching out.)
Works with my USB gamepad, without any issues, which confuses the heck out of me. The glitch my controller reports is always around a 0.0078... range of variance off center. STICK offers a range from 1 to 254, with 127 being center, giving us 127 levels of precision in any direction. 1/127 is 0.0078... The variance _DEVICES reports is *exactly* the same amount as 1 level off on STICK — yet, it’s not going off center
STICK offer a range of 1 to 254