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); } }
void dmz::WeaponPluginFixedLauncher::receive_button_event ( const Handle Channel, const InputEventButton &Value) { if (_hil) { if (Value.get_button_id () == _launchButton) { LaunchStruct *ls (_get_struct (_hil)); if (ls) { if (Value.get_button_value ()) { const Float64 CTime (_time.get_frame_time ()); ls->activeCount++; if (CTime > (ls->lastLaunchTime + _delay)) { _create_munition (ls->Source); ls->lastLaunchTime = CTime; } } else { ls->activeCount--; } } } } }
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::EntityPluginGroundSimple::receive_button_event ( const Handle Channel, const InputEventButton &Value) { if ((Value.get_button_id () == 1) && Value.get_button_value ()) { const Float64 Time (_time.get_frame_time ()); if (!(_move.turboModifier > 0.0) && (Time > _move.turboRefillTime)) { _move.turboModifier = _move.turboBoost; _move.turboEndTime = Time + _move.turboDuration; } } else if ((Value.get_button_id () == 3) && Value.get_button_value ()) { ObjectModule *objMod (get_object_module ()); if (objMod) { Vector pos; Matrix ori; objMod->lookup_position (_hil, _defaultHandle, pos); objMod->lookup_orientation (_hil, _defaultHandle, ori); _log.out << "\n<position x=\"" << pos.get_x () << "\" y=\"" << pos.get_y () << "\" z=\"" << pos.get_z () << "\"/>\n"; _log.out << "<orientation\n"; Float64 array[9]; ori.to_array (array); for (Int32 ix = 0; ix < 9; ix++) { if (!(ix % 3)) { _log.out << " "; } _log.out << " v" << ix << "=\"" << array[ix] << "\""; if (!((ix + 1) % 3)) { _log.out << "\n"; } } _log.out << "/>" << endl; } } }
void dmz::InputModuleBasic::_decrement_active_count ( const Handle Channel, const Mask EventMask, ObsStruct &os) { if (EventMask & LocalAxisMask) { os.axisActiveCount--; if (os.axisActiveCount == 0) { HashTableHandleIterator it; ControllerStruct *cs (_controllerCache.get_first (it)); while (cs) { HashTableHandleIterator axisIt; InputEventAxis *event (cs->axisTable.get_first (axisIt)); while (event) { InputEventAxis tmp (*event); if (tmp.update_axis_value (0.0f)) { os.obs.receive_axis_event (Channel, tmp); } event = cs->axisTable.get_next (axisIt); } cs = _controllerCache.get_next (it); } } else if (os.axisActiveCount < 0) { _log.error << "Axis Active Count for: " << _defs.lookup_runtime_name (os.obs.get_input_observer_handle ()) << " has a negative value" << endl; } } if (EventMask & LocalButtonMask) { os.buttonActiveCount--; if (os.buttonActiveCount == 0) { HashTableHandleIterator it; ControllerStruct *cs (_controllerCache.get_first (it)); while (cs) { HashTableHandleIterator buttonIt; InputEventButton *event (cs->buttonTable.get_first (buttonIt)); while (event) { InputEventButton tmp (*event); if (tmp.update_button_value (False)) { os.obs.receive_button_event (Channel, tmp); } event = cs->buttonTable.get_next (buttonIt); } cs = _controllerCache.get_next (it); } } else if (os.buttonActiveCount < 0) { _log.error << "Button Active Count for: " << _defs.lookup_runtime_name (os.obs.get_input_observer_handle ()) << " has a negative value" << endl; } } if (EventMask & LocalSwitchMask) { os.switchActiveCount--; if (os.switchActiveCount == 0) { HashTableHandleIterator it; ControllerStruct *cs (_controllerCache.get_first (it)); while (cs) { HashTableHandleIterator switchIt; InputEventSwitch *event (cs->switchTable.get_first (switchIt)); while (event) { InputEventSwitch tmp (*event); if (tmp.update_switch_value (False)) { os.obs.receive_switch_event (Channel, tmp); } event = cs->switchTable.get_next (switchIt); } cs = _controllerCache.get_next (it); } } else if (os.switchActiveCount < 0) { _log.error << "Switch Active Count for: " << _defs.lookup_runtime_name (os.obs.get_input_observer_handle ()) << " has a negative value" << endl; } } if (EventMask & LocalKeyMask) { os.keyActiveCount--; if (os.keyActiveCount == 0) { HashTableHandleIterator it; InputEventKey *event (_keyCache.get_first (it)); while (event) { InputEventKey tmp (*event); if (tmp.update_key_state (False)) { os.obs.receive_key_event (Channel, tmp); } event = _keyCache.get_next (it); } } else if (os.keyActiveCount < 0) { _log.error << "Key Active Count for: " << _defs.lookup_runtime_name (os.obs.get_input_observer_handle ()) << " has a negative value" << endl; } } if (EventMask & LocalMouseMask) { os.mouseActiveCount--; if (os.mouseActiveCount == 0) { InputEventMouse event (_mouseCache); if (event.get_button_mask ()) { event.set_button_mask (0); os.obs.receive_mouse_event (Channel, event); } } else if (os.mouseActiveCount < 0) { _log.error << "Mouse Active Count for: " << _defs.lookup_runtime_name (os.obs.get_input_observer_handle ()) << " has a negative value" << endl; } } }
void dmz::InputModuleBasic::_increment_active_count ( const Handle Channel, const Mask EventMask, ObsStruct &os) { if (EventMask & LocalAxisMask) { os.axisActiveCount++; if (os.axisActiveCount == 1) { HashTableHandleIterator it; ControllerStruct *cs (_controllerCache.get_first (it)); while (cs) { HashTableHandleIterator axisIt; InputEventAxis *event (cs->axisTable.get_first (axisIt)); while (event) { if (!is_zero32 (event->get_axis_value ())) { os.obs.receive_axis_event (Channel, *event); } event = cs->axisTable.get_next (axisIt); } cs = _controllerCache.get_next (it); } } } if (EventMask & LocalButtonMask) { os.buttonActiveCount++; if (os.buttonActiveCount == 1) { HashTableHandleIterator it; ControllerStruct *cs (_controllerCache.get_first (it)); while (cs) { HashTableHandleIterator buttonIt; InputEventButton *event (cs->buttonTable.get_first (buttonIt)); while (event) { if (event->get_button_value ()) { os.obs.receive_button_event (Channel, *event); } event = cs->buttonTable.get_next (buttonIt); } cs = _controllerCache.get_next (it); } } } if (EventMask & LocalKeyMask) { os.keyActiveCount++; if (os.keyActiveCount == 1) { HashTableHandleIterator it; InputEventKey *event (_keyCache.get_first (it)); while (event) { if (event->get_key_state ()) { os.obs.receive_key_event (Channel, *event); } event = _keyCache.get_next (it); } } } if (EventMask & LocalMouseMask) { os.mouseActiveCount++; if (os.mouseActiveCount == 1) { if (_mouseCache.get_button_mask ()) { os.obs.receive_mouse_event (Channel, _mouseCache); } } } if (EventMask & LocalSwitchMask) { os.switchActiveCount++; if (os.switchActiveCount == 1) { HashTableHandleIterator it; ControllerStruct *cs (_controllerCache.get_first (it)); while (cs) { HashTableHandleIterator switchIt; InputEventSwitch *event (cs->switchTable.get_first (switchIt)); while (event) { if (event->get_switch_value ()) { os.obs.receive_switch_event (Channel, *event); } event = cs->switchTable.get_next (switchIt); } cs = _controllerCache.get_next (it); } } } }
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 (); } }