Outerra forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

Outerra Tech Demo download. Help with graphics driver issues

Author Topic: How to register more actions associated with keys ?  (Read 7489 times)

fly77

  • Outerra Master Modder
  • Hero Member
  • *****
  • Posts: 1755
How to register more actions associated with keys ?
« on: December 07, 2018, 12:26:55 pm »

As we develop more complex models with more buttons and knobs we need to associate more and more actions/events to keys registering them. While it is clear how to do this
there is however a difficulty to find out/guess  the right  token& name.

//Register event action handler
    //@param name hierarchic action name, file/group/action
    //@param group activation group where the action is assigned (can be enabled/disabled together)
    //@param channels number of extra channels that the handler supports
    //@return slot id or -1 on fail
    int register_event__( const coid::token& name, uint group = 0, uint channels = 0 );

(https://github.com/Outerra/anteworld/blob/master/include/ot/vehicle_physics.h)


By having a look at the F1 -> control  menu of key associations for some events the correct token name can be guessed with some luck and trial and error, for others I could't guess the right token name.


"Passing beam lamps"  --->  this.register_event("car/lights/passing",  function(v) {some code ....;});   // key L             not so obvious but could deduce from models available

               "Horn"          -->  this.register_event("car/controls/horn",  function(v) {some code ....;});   // key H              by trial I could find it out that it works but not if token name is "car/controls/Horn" as would be guessed instead
       
 "Master Arm on/off"      -->   this.register_event("air/weapons/master_arm", function(v) {some code ....;});  // key J    again seems that Capitals must be avoided in token name

"Toggle geo stabilized tracking on/off"  --> ??   couldn't guess so far which token name works....    // key K

similarly for lots of other actions it is not really easy to guess the token name that works..

Any help from developers is greatly appreciated .

   
« Last Edit: December 07, 2018, 02:14:48 pm by fly77 »
Logged

cameni

  • Brano Kemen
  • Outerra Administrator
  • Hero Member
  • *****
  • Posts: 6721
  • No sense of urgency.
    • outerra.com
Re: How to register more actions associated with keys ?
« Reply #1 on: December 08, 2018, 04:15:10 am »

Go to the iomap folder and check the cfg files there. The action name is file_name/group/action
Logged

fly77

  • Outerra Master Modder
  • Hero Member
  • *****
  • Posts: 1755
Re: How to register more actions associated with keys ?
« Reply #2 on: December 08, 2018, 06:30:20 am »

Thank you very much cameni ! 
Logged

fly77

  • Outerra Master Modder
  • Hero Member
  • *****
  • Posts: 1755
Re: How to register more actions associated with keys ?
« Reply #3 on: December 30, 2018, 02:14:19 pm »

I am trying to register an axis of an airplaine using LEFT RIGHT UP DOWN arrows using the default binding defined in iomaps (verified in the air/sensor menu) to control the fps camera position of the Cessna by the arrow keys.
however the controlled variable that i named "camx" does not change as verified by printing its value on a canvas. What is wrong with the code below ?

Code: [Select]
var camx;

function initialize(reload){
...
   camx=0;
   this.register_axis("air/sensor/slew_azimuth", {minval:0, maxval:1, vel:1, center:0}, function(v){       
    camx = v*2;
  });

}


function update_frame(dt){
....
this.set_fps_camera_pos({x:-0.25+camx, y:-0.2, z:0.8});
...
}

« Last Edit: December 30, 2018, 02:21:36 pm by fly77 »
Logged

cameni

  • Brano Kemen
  • Outerra Administrator
  • Hero Member
  • *****
  • Posts: 6721
  • No sense of urgency.
    • outerra.com
Re: How to register more actions associated with keys ?
« Reply #4 on: January 29, 2019, 01:14:42 am »

How are the keys bound in your air.cfg?
Logged

fly77

  • Outerra Master Modder
  • Hero Member
  • *****
  • Posts: 1755
Re: How to register more actions associated with keys ?
« Reply #5 on: January 29, 2019, 02:41:34 am »

Hi cameni. This is how the keys are bound and it does not have any effect on the camx and camy variables when the axis are registered in the cessna

Code: [Select]
"name": "slew_azimuth",
                    "comment": "Slew azimuth command",
                    "important": true,
                    "bindings": [
                        {
                            "event_name": "Left",
                            "mode": "-"
                        },
                        {
                            "event_name": "Right",
                            "mode": "+"
                        }
                    ]
                },
                {
                    "name": "slew_elevation",
                    "comment": "Slew elevation command",
                    "important": true,
                    "bindings": [
                        {
                            "event_name": "Up",
                            "mode": "+"
                        },
                        {
                            "event_name": "Down",
                            "mode": "-"
                        }
                    ]
                },


Strangely enough if I use the same registering of axis as below in a vehicle it works ! The same code pasted into the cessna however does not have any effect.

Code: [Select]
  this.register_axis("air/sensor/slew_azimuth", {minval:-1, maxval:1, vel:1, center:1}, function(v){ camx = camx + 0.1*v;});   

  this.register_axis("air/sensor/slew_elevation", {minval:-1, maxval:1, vel:1, center:1}, function(v){camy = camy + 0.1*v;});

Logged

cameni

  • Brano Kemen
  • Outerra Administrator
  • Hero Member
  • *****
  • Posts: 6721
  • No sense of urgency.
    • outerra.com
Re: How to register more actions associated with keys ?
« Reply #6 on: January 29, 2019, 03:52:59 am »

There may be another action using the same keys. I think they were used for side looks in cockpits ...
Logged

fly77

  • Outerra Master Modder
  • Hero Member
  • *****
  • Posts: 1755
Re: How to register more actions associated with keys ?
« Reply #7 on: January 29, 2019, 11:20:10 am »

hmm...with the default cessna or for that matter with any of the planes the arrow keys UP DOWN LEFT RIGHT do not have any effect on view direction, nor on anything else as far as I could judge.
Where might any such "hidden" actions be defined ? In the javascript there is nothing associated with these keys.
Logged

cameni

  • Brano Kemen
  • Outerra Administrator
  • Hero Member
  • *****
  • Posts: 6721
  • No sense of urgency.
    • outerra.com
Re: How to register more actions associated with keys ?
« Reply #8 on: January 29, 2019, 11:58:09 am »

Um, actually slew_azimuth & co is already used in aircraft, bound under action group 3 (sensors). Try disabling it via action_group(3, false). Not sure why it doesn't re-register to your action, perhaps because of the non-default group.

It's supposed to do something in sensor mode, but I guess this isn't active yet, or needs enabling sensor mode first ...
Logged

fly77

  • Outerra Master Modder
  • Hero Member
  • *****
  • Posts: 1755
Re: How to register more actions associated with keys ?
« Reply #9 on: January 29, 2019, 12:32:08 pm »

Wow! it works !  thanks a lot !
Logged