fernandojsg / aframe-input-mapping-component

https://fernandojsg.github.io/aframe-input-mapping-component
MIT License
24 stars 7 forks source link

Fix #15 - Remove default state #20

Closed fernandojsg closed 6 years ago

fernandojsg commented 6 years ago

As discussed at https://github.com/fernandojsg/aframe-input-mapping-component/issues/15#issuecomment-344924485.

I've removed the need to have a default key on the mappings. The new "default" state is something that the app developer should define, not the user when doing the mappings. You have two options here:

Use an optional parameter when registering input actions to define the initial state:

  var inputActions = {
    task1: {
      changeTask: { label: 'Change task' },
      logdefault: { label: 'Test Log' },
      logtask1: { label: 'Test Log Task 1' },
      lefthand: { label: 'Left hand' },
      righthand: { label: 'Right hand' },
    },
    task2: {
      changeTask: { label: 'Change task' },
      logtask2: { label: 'Test Log Task 2' }
    }
  }

  AFRAME.registerInputActions(inputActions, 'task1');

Or define it manually by setting the currentInputMapping variable:

AFRAME.currentInputMapping = 'task';

I've added some warnings when you try try to emit an event but the current mapping is not defined.