Beispiel #1
0
void
dmz::JsExtV8Input::receive_button_event (
      const Handle Channel,
      const InputEventButton &Value) {

   if (_v8Context.IsEmpty () == false) {

      v8::Context::Scope cscope(_v8Context);
      v8::HandleScope scope;

      V8Object event = v8::Object::New ();

      event->Set (_sourceStr, v8::Integer::New (Value.get_source_handle ()));
      event->Set (_idStr, v8::Integer::New (Value.get_button_id ()));
      event->Set (_valueStr, v8::Boolean::New (Value.get_button_value ()));
      event->Set (_previousStr, v8::Boolean::New (Value.get_button_previous_value ()));

      const int Argc (3);
      V8Value argv[Argc];
      argv[0] = v8::Integer::New (Channel);
      argv[1] = event;

      _do_all_callbacks (Argc, argv, _buttonTable);
   }
}
Beispiel #2
0
void
dmz::ExPluginInput::receive_button_event (
   const UInt32 Channel,
   const InputEventButton &Value) {

   _log.out << "[receive_button_event] channel: " << Channel
            << " source: " << Value.get_source_handle ()
            << " button: " << Value.get_button_id ()
            << " value: " << (Value.get_button_value () ? "Down" : "Up") << endl;
}
void
dmz::InputModuleBasic::send_button_event (const InputEventButton &Event) {

   if (_inEvent) { _que_event (new ButtonQueStruct (Event)); }
   else {

      _inEvent = True;

      _eventCount++;

      HashTableHandleIterator it;

      ChannelStruct *cs (_channelTable.get_first (it));

      ControllerStruct *controller (_get_controller (Event.get_source_handle ()));

      if (controller) {

         InputEventButton *tmp (controller->buttonTable.lookup (Event.get_button_id ()));

         if (tmp) {

            if (*tmp != Event) { *tmp = Event; }
            else { cs = 0; } // event already sent; don't send again
         }
         else {

            tmp = new InputEventButton (Event);

            if (tmp && !controller->buttonTable.store (Event.get_button_id (), tmp)) {

               delete tmp; tmp = 0;
            }
         }
      }

      while (cs) {

         if (cs->active) {

            HashTableHandleIterator osIt;

            ObsStruct *os (cs->buttonTable.get_first (osIt));

            while (os) {

               if (os->eventCount != _eventCount) {

                  os->obs.receive_button_event (cs->ChannelHandle, Event);
                  os->eventCount = _eventCount;
               }

               os = cs->buttonTable.get_next (osIt);
            }
         }

         cs = _channelTable.get_next (it);
      }

      _inEvent = False;
      _do_qued_events ();
   }
}