Author Topic: GETJOY question  (Read 2617 times)

Offline UBERmonkeybot

  • Mr. Polyvector
  • ***
  • Posts: 243
    • View Profile
GETJOY question
« on: 2015-Sep-06 »
Hi,
When i run the following code i am consistenly getting values in  xx and yy outside -1 to 1 how can this be possible?

Prob me being stupid again.


Thanks in advance.

Code: (glbasic) [Select]
REPEAT

LOCAL xx#,yy#,b

FOR i=0 TO GETNUMJOYSTICKS()-1
xx#=GETJOYX(i)
yy#=GETJOYY(i)
b=GETJOYBUTTON(i,0)


IF xx#<-0.991 THEN xx#=-1
IF xx#> 0.991 THEN xx#= 1
IF yy#<-0.991 THEN yy#=-1
IF yy#> 0.991 THEN yy#= 1
DEBUG "\ni "+i+" xx "+xx#

NEXT
PRINT "Joytest",100,100
SHOWSCREEN



UNTIL FALSE

Offline erico

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 4349
    • View Profile
    • FUED
Re: GETJOY question
« Reply #1 on: 2015-Sep-06 »
DidnĀ“t look at the code yet, are you sure your joy is calibrated?

Offline UBERmonkeybot

  • Mr. Polyvector
  • ***
  • Posts: 243
    • View Profile
Re: GETJOY question
« Reply #2 on: 2015-Sep-06 »
I just checked that and it made no differenece

Offline UBERmonkeybot

  • Mr. Polyvector
  • ***
  • Posts: 243
    • View Profile
Re: GETJOY question
« Reply #3 on: 2015-Sep-06 »
The program works as expected on android.
I notice that my wireless xbox controller gives these large numbers (upto 9,-9) when i let the joystick snap back to center.
It does it on both sticks.
But surely the software should catch the fact that xx is limited to 1,-1

I note in the Manual that this is for registered users only,I am not registered but the command seems to work(sort of)
« Last Edit: 2015-Sep-06 by monkeybot1968 »

Offline nabz32

  • Community Developer
  • Dr. Type
  • ******
  • Posts: 316
    • View Profile
Re: GETJOY question
« Reply #4 on: 2015-Sep-06 »
Could it be the 9 is actually 9 , .... e^-x ??
then it is a very small number close to zero,
missread this once also.

Edit:
x^-2 = 1/(x^2)
« Last Edit: 2015-Sep-06 by nabz32 »

Offline UBERmonkeybot

  • Mr. Polyvector
  • ***
  • Posts: 243
    • View Profile
Re: GETJOY question
« Reply #5 on: 2015-Sep-06 »
Ahha i think you may be right.

i Get this as an output

Joy 1  xx -0.1538438052  yy 1.333658863e-002             Joy2 xx -2.954191715e-002  yy 5.148472637e-002
Joy 1  xx -0.6840723753  yy 5.056916922e-002             Joy2 xx -2.954191715e-002  yy 5.148472637e-002
Joy 1  xx -0.8983428478  yy 5.056916922e-002             Joy2 xx -2.954191715e-002  yy 5.148472637e-002
Joy 1  xx -1  yy 6.546220183e-002                                 Joy2 xx -2.954191715e-002  yy 5.148472637e-002

Offline spacefractal

  • Community Developer
  • Prof. Inline
  • ******
  • Posts: 3930
    • View Profile
    • Space Fractal
Re: GETJOY question
« Reply #6 on: 2015-Sep-08 »
you property should uses FORMAT$ or use interger and multiply with 1000 for a more user feedback.

As you not see zero is pretty normal, if you not measure deadzones.
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation and The beagle Jam.

Offline UBERmonkeybot

  • Mr. Polyvector
  • ***
  • Posts: 243
    • View Profile
Re: GETJOY question
« Reply #7 on: 2015-Sep-09 »
I assume that if i didn't count anything under 0.2 would count as a deadzone.