BGUI / python issue

Hi

I try to understand the BGUI with object oriented programming. I’m not familiar with two items.

I try to make a joystick axes assignment and calibration menu.

See, my attached .blend file (sel ans calib buttons don’t work yet).

  1. How I can get a current axis values figures to read in initialization phase?

  2. How I can detect a ‘active axis’, means a axis, which is clearly moved.

  3. How I can assign this ‘active axis’ ID (joystick index and it axis index) saved to the GFAA list?

Thanks for the hints :slight_smile:

Attachments

js_test.blend (49.8 KB)

I am not sure that I understand your questions, but I do my best.

I try to make a joystick axes assignment and calibration menu.
I don’t know what you want to calibrate. You have to calibrate the joystick in the operating system. The only thing that you need to calibrate is a death zone. Then you can linear interpolate from the max size of the death zone to max joystick values (-32768, +32767).

  1. How I can get a current axis values figures to read in initialization phase?

I think you mean the number of joystick axis.
In def main(self):

 
  joystick = cont.sensors['Joystick']
  num = joystick .numAxis # get number of axis
  jind = 0 # joystick index

  1. How I can detect a ‘active axis’, means a axis, which is clearly moved.

I think you mean this.
In def main(self):

with math and abs()

 
   form math import *
   for i in range(num):
    if abs(val1) > 32760:
     # do some thing eg. save axis number
     GFAA[i][1] = self.butNum
 

or without math and abs()

   for i in range(num):
    if -32760 > val1 or val1 > 32760:
     # do some thing eg. save axis number 
     GFAA[i][1] = self.butNum
  1. How I can assign this ‘active axis’ ID (joystick index and it axis index) saved to the GFAA list?

I don’t know how you like it. Press the button and move then the joystick or the other way round.
If the select button is pressed set with the button call back function an integer value eg.
In def init(self):

  # Setup an on_click callback for the Yaw 
  self.button3.on_click = self.Store_ButNum_click

A new function

 # Callback function for the Yaw 
 def Store_ButNum_click(self, widget):
  self.butNum = 3 

Here two links to the SCA_JoystickSensor class.
http://www.tutorialsforblender3d.com/GameModule/ClassSCA_JoystickSensor.html
http://www.blender.org/documentation/blender_python_api_2_59_0/bge.types.html#bge.types.SCA_JoystickSensor

Hi HG1,

And thank you for your feedback.

The reason for my request is, my target audience/users often have a more than one joystick input devices.

Example I have a three different ‘joystick’ devices:

  • Logitech wheel & pedels(tot. 4 axes). I would only use a 1-axis (pedals) for the yaw control.
  • CH FigherStick(tot. 3 axes). I would only a two axes for the pitch & roll controls.
  • Customized Saitek X35T throttle (tot. 6-axes). I would only use a 1-axis (throttle) for the throttle control.

I would like to have a ingame calibration routine to ensure the all different joystick input values are correctly interpolated to the ingame input values.

  1. When code is runned first time, I would like to read the actual axes values. Now I need to move the axes, before the values are read.

  2. So, if I have a several joysticks with multiple axes , how I cane tell, which is moved(joystick and axis index)?

  3. Example, if I select a Pitch with Sel button and move certain joystick axis, how I can get this joystick index and axes index data extracted?

Thanks

The reason for my request is, my target audience/users often have a more than one joystick input devices.
I would like to have a in game calibration routine to ensure the all different joystick input values are correctly interpolated to the in game input values.

But calibrating in game makes still no sense, because when you have calibrated all joysticks in windows then all joysticks have a value range from -32768 to 32767. Calibrating in game only reduce the resolution.
Calibrating in game only makes makes sense when want to linear interpolate from the max size of the death zone to max joystick values (-32768, +32767).

  1. Not possible. You must move the axis to trigger the readout.
    2-3. You must iterate trought all joysticks and axis. Look in the js_test.blend
    But I have tested it only with one joystick (I have only one).

To store the last setup you can store the values in the globaldict or a text file.
The analogJoystick2_53.blend have in game calibration, storing and loading in a text file.

Attachments

js_test.blend (50.4 KB)analogJoystick2_53.blend (384 KB)

Hi HG1,

Good points.

Anyhow the controllers (and/or drivers) do not always give a perfect -32768 to 32768 output value range.

If game internal calculations are done with -32768 to 32768 range assumption, the user inputs can be offset way or another.

Thanks for the help & files.