CJaw::CJaw() : m_forcedTargetId(0) , m_firedRockets(0) , m_autoDropPendingTimer(0.0f) , m_dropTime(0.0f) , m_auxSlotUsed(false) , m_auxSlotUsedBQS(false) , m_autoDropping(false) , m_controllingRocket(false) , m_zoomTriggerDown(false) , m_fireTriggerDown(false) , m_firePending(false) , m_smokeActive(false) , m_dropped(false) , m_playedDropAction(false) , m_fired(false) , m_zoomAlreadyToggled(false) , m_extraTubesAdded(false) { CGameInputActionHandlers::TJawActionHandler& jawActionHandler = g_pGame->GetGameInputActionHandlers().GetCJawActionHandler(); if (jawActionHandler.GetNumHandlers() == 0) { # define ADD_HANDLER(action, func) jawActionHandler.AddHandler(actions.action, &CJaw::func) const CGameActions& actions = g_pGame->Actions(); ADD_HANDLER(zoom, OnActionJawZoom); ADD_HANDLER(attack2_xi, OnActionJawZoom); # undef ADD_HANDLER } m_dropJAWAnimEvent = CCrc32::ComputeLowercase("DropJAW"); }
void handler::init_handlers() { ADD_HANDLER("/", handle_root); ADD_HANDLER("/add_log", handle_add_log); ADD_HANDLER("/add_activity", handle_add_activity); ADD_HANDLER("/get_active_users", handle_get_active_users); ADD_HANDLER("/get_user_logs", handle_get_user_logs); }
CC4Detonator::CC4Detonator() { if(s_actionHandler.GetNumHandlers() == 0) { #define ADD_HANDLER(action, func) s_actionHandler.AddHandler(actions.action, &CC4Detonator::func) const CGameActions &actions = g_pGame->Actions(); ADD_HANDLER(zoom, OnActionSelectC4); ADD_HANDLER(xi_zoom, OnActionSelectC4); #undef ADD_HANDLER } }
User::User () : packetHandler_ () , login_ () , world_ (nullptr) , map_ (nullptr) , player_ (nullptr) , account_ (nullptr) { ADD_HANDLER(ClientRequestStartInfo, User::HandleClientRequestStartInfo); ADD_HANDLER(ClientInfoApplyForce, User::HandleClientInfoApplyForce); ADD_HANDLER(ClientInfoGameMessage, User::HandleClientInfoGameMessage); }
void ClientSession::Init () { AddRelay (&user_); user_.SetParent (this); ADD_HANDLER(ClientRequestLogin, ClientSession::HandleClientRequestLogin); ADD_HANDLER( ClientRequestRegistration, ClientSession::HandleClientRequestRegistration); ADD_HANDLER( ClientInfoDeconnection, ClientSession::HandleClientInfoDisconnection); }
void CHeavyMountedWeapon::RegisterActionsHMG() { CGameInputActionHandlers::THMGActionHandler& hmgActionHandler = g_pGame->GetGameInputActionHandlers().GetCHMGActionHandler(); if (hmgActionHandler.GetNumHandlers() == 0) { #define ADD_HANDLER(action, func) hmgActionHandler.AddHandler(actions.action, &CHeavyMountedWeapon::func) const CGameActions& actions = g_pGame->Actions(); ADD_HANDLER(special,OnActionRipOff); ADD_HANDLER(weapon_change_firemode,OnActionFiremode); #undef ADD_HANDLER } }
Map::Map (const yap::ID& id) : yap::Map (id) , worldDrawingPolicy_ (nullptr) , tileLayers_ () , drawableObjects_ () , drawableDynamicObjects_ () , players_ () , npcs_ () , packetHandler_ () { ADD_HANDLER(ServerInfoObjectMoveInfo, Map::HandleServerInfoObjectMoveInfo); ADD_HANDLER( ServerInfoUpdateObjectState, Map::HandleServerInfoUpdateObjectState); ADD_HANDLER(ServerInfoRemoveObject, Map::HandleServerInfoRemoveObject); }
CBinocular::CBinocular(): m_bZoomed(false), m_bNightVisionEnabled(false), m_pNightVisionCVar(NULL), m_pSpecCVar(NULL), m_pPhysWorld(NULL) { if(s_actionHandler.GetNumHandlers() == 0) { #define ADD_HANDLER(action, func) s_actionHandler.AddHandler(actions.action, &CBinocular::func) const CGameActions& actions = g_pGame->Actions(); ADD_HANDLER(xi_zoom,OnActionZoom); ADD_HANDLER(zoom,OnActionZoom); ADD_HANDLER(firemode,OnActionToggleNightVision); ADD_HANDLER(zoom_in,OnActionZoomIn); ADD_HANDLER(v_zoom_in,OnActionZoomIn); ADD_HANDLER(zoom_out,OnActionZoomOut); ADD_HANDLER(v_zoom_out,OnActionZoomOut); #undef ADD_HANDLER } m_pPhysWorld = gEnv->pPhysicalWorld; if(gEnv->pConsole == NULL) return; m_pNightVisionCVar = gEnv->pConsole->GetCVar("r_NightVision"); m_pSpecCVar = gEnv->pConsole->GetCVar("sys_spec"); m_pDefaultNVMode = gEnv->pConsole->GetCVar("pl_nightvisionModeBinocular"); }
//------------------------------------------------------------------------ CFists::CFists() :m_underWater(false) ,m_currentAnimState(eFAS_FIGHT) ,m_inFreeFall(false) ,m_timeOut(0.0f) { m_useFPCamSpacePP = true; //Overwritten by OffHand if (s_actionHandler.GetNumHandlers() == 0) { #define ADD_HANDLER(action, func) s_actionHandler.AddHandler(actions.action, &CFists::func) const CGameActions& actions = g_pGame->Actions(); ADD_HANDLER(attack1, OnActionAttack); ADD_HANDLER(attack2, OnActionAttack); ADD_HANDLER(special, OnActionSpecial); #undef ADD_HANDLER } }
void CWeapon::RegisterActions() { if (s_actionHandler.GetNumHandlers() == 0) { #define ADD_HANDLER(action, func) s_actionHandler.AddHandler(actions.action, &CWeapon::func) const CGameActions& actions = g_pGame->Actions(); ADD_HANDLER(attack1,OnActionAttack); ADD_HANDLER(attack2,OnActionAttackSecondary); ADD_HANDLER(reload,OnActionReload); ADD_HANDLER(special,OnActionSpecial); ADD_HANDLER(modify,OnActionModify); ADD_HANDLER(firemode,OnActionFiremode); ADD_HANDLER(zoom_in,OnActionZoomIn); ADD_HANDLER(zoom_out,OnActionZoomOut); ADD_HANDLER(zoom,OnActionZoom); ADD_HANDLER(xi_zoom,OnActionZoomXI); #undef ADD_HANDLER } }
void CNoWeapon::RegisterActions() { CGameInputActionHandlers::TNoWeaponActionHandler& noWeaponActionHandler = g_pGame->GetGameInputActionHandlers().GetCNoWeaponActionHandler(); if (noWeaponActionHandler.GetNumHandlers() == 0) { #define ADD_HANDLER(action, func) noWeaponActionHandler.AddHandler(actions.action, &CNoWeapon::func) const CGameActions& actions = g_pGame->Actions(); if(gEnv->bMultiplayer) { ADD_HANDLER(special, OnActionMelee); } } }
User::User () : packetHandler_ () , login_ () , id_ (0) , world_ (nullptr) , player_ (nullptr) , playerData_ () , trainer_ (nullptr) { ADD_HANDLER(ServerInfoSetUserPlayer, User::HandleServerInfoSetUserPlayer); ADD_HANDLER(ServerInfoChangeMap, User::HandleServerInfoChangeMap); ADD_HANDLER(ServerInfoAddObject, User::HandleServerInfoAddObject); ADD_HANDLER(ServerInfoGameMessage, User::HandleServerInfoGameMessage); ADD_HANDLER(ServerInfoTriggerBattle, User::HandleServerInfoTriggerBattle); ADD_HANDLER(ServerInfoPokemonTeam, User::HandlerServerInfoPokemonTeam); ADD_HANDLER(ServerInfoChangeMoney, User::HandlerServerInfoChangeMoney); ADD_HANDLER(ServerInfoStartDialog, User::HandleServerInfoStartDialog); }
void CUIInput::InitEventSystem() { if ( !gEnv->pFlashUI || !g_pGame->GetIGameFramework() || !g_pGame->GetIGameFramework()->GetIActionMapManager() ) { assert( false ); return; } IActionMapManager* pAmMgr = g_pGame->GetIGameFramework()->GetIActionMapManager(); pAmMgr->AddExtraActionListener( this ); // set up the handlers if (s_actionHandler.GetNumHandlers() == 0) { #define ADD_HANDLER(action, func) s_actionHandler.AddHandler(actions.action, &CUIInput::func) const CGameActions& actions = g_pGame->Actions(); ADD_HANDLER(ui_toggle_pause, OnActionTogglePause); ADD_HANDLER(ui_start_pause, OnActionStartPause); ADD_HANDLER(ui_up, OnActionUp); ADD_HANDLER(ui_down, OnActionDown); ADD_HANDLER(ui_left, OnActionLeft); ADD_HANDLER(ui_right, OnActionRight); ADD_HANDLER(ui_click, OnActionClick); ADD_HANDLER(ui_back, OnActionBack); ADD_HANDLER(ui_confirm, OnActionConfirm); ADD_HANDLER(ui_reset, OnActionReset); #undef ADD_HANDLER } // ui events (sent to ui) m_pUIFunctions = gEnv->pFlashUI->CreateEventSystem( "Input", IUIEventSystem::eEST_SYSTEM_TO_UI ); m_eventSender.Init(m_pUIFunctions); { SUIEventDesc eventDesc("OnKeyboardDone", "triggered once keyboard is done"); eventDesc.AddParam<SUIParameterDesc::eUIPT_String>("String", "String of keyboard input"); m_eventSender.RegisterEvent<eUIE_OnVirtKeyboardDone>(eventDesc); } { SUIEventDesc eventDesc("OnKeyboardCancelled", "triggered once keyboard is cancelled"); m_eventSender.RegisterEvent<eUIE_OnVirtKeyboardCancelled>(eventDesc); } // ui events (called from ui) m_pUIEvents = gEnv->pFlashUI->CreateEventSystem( "Input", IUIEventSystem::eEST_UI_TO_SYSTEM ); m_eventDispatcher.Init(m_pUIEvents, this, "UIInput"); { SUIEventDesc eventDesc("ShowVirualKeyboard", "Displays the virtual keyboard"); eventDesc.AddParam<SUIParameterDesc::eUIPT_String>("Title", "Title for the virtual keyboard"); eventDesc.AddParam<SUIParameterDesc::eUIPT_String>("Value", "Initial string of virtual keyboard"); eventDesc.AddParam<SUIParameterDesc::eUIPT_Int>("MaxChars", "Maximum chars"); m_eventDispatcher.RegisterEvent( eventDesc, &CUIInput::OnDisplayVirtualKeyboard ); } }
CPlayerInput::CPlayerInput( CPlayer * pPlayer ) : m_pPlayer(pPlayer), m_pStats(&pPlayer->m_stats), m_actions(ACTION_GYROSCOPE), m_deltaRotation(0,0,0), m_lastMouseRawInput(0,0,0), m_deltaMovement(0,0,0), m_xi_deltaMovement(0,0,0), m_xi_deltaRotation(0,0,0), m_xi_deltaRotationRaw(0.0f, 0.0f, 0.0f), m_filteredDeltaMovement(0,0,0), m_buttonPressure(0.0f), m_deltaPitch(0), m_deltaPitchOnce(0), m_cameraStickLR(0), m_cameraStickUD(0), m_moveStickLR(0), m_moveStickUD(0), m_speedLean(0.0f), m_bDisabledXIRot(false), m_fCrouchPressedTime(-1.0f), m_moveButtonState(0), m_bUseXIInput(false), m_checkZoom(false), m_lastPos(0,0,0), m_iCarryingObject(0), m_lastSerializeFrameID(0), m_fSprintTime(0), m_fRestingTime(0) { m_pPlayer->RegisterPlayerEventListener(this); m_pPlayer->GetGameObject()->CaptureActions(this); // Create the input helper class for the new third person camera m_pCameraInputHelper = new CCameraInputHelper(m_pPlayer, this); // (jh) Add hardware mouse listener. if (gEnv->pHardwareMouse) { gEnv->pHardwareMouse->AddListener(this); } // set up the handlers if (s_actionHandler.GetNumHandlers() == 0) { #define ADD_HANDLER(action, func) s_actionHandler.AddHandler(actions.action, &CPlayerInput::func) const CGameActions& actions = g_pGame->Actions(); ADD_HANDLER(moveforward, OnActionMoveForward); // Keyboard ADD_HANDLER(moveback, OnActionMoveBack); // Keyboard ADD_HANDLER(moveleft, OnActionMoveLeft); // Keyboard ADD_HANDLER(moveright, OnActionMoveRight); // Keyboard ADD_HANDLER(rotateyaw, OnActionRotateYaw); // Mouse ADD_HANDLER(rotatepitch, OnActionRotatePitch); // Mouse ADD_HANDLER(jump, OnActionJump); ADD_HANDLER(crouch, OnActionCrouch); ADD_HANDLER(sprint, OnActionSprint); ADD_HANDLER(togglestance, OnActionToggleStance); ADD_HANDLER(prone, OnActionProne); //ADD_HANDLER(zerogbrake, OnActionZeroGBrake); ADD_HANDLER(gyroscope, OnActionGyroscope); ADD_HANDLER(gboots, OnActionGBoots); ADD_HANDLER(leanleft, OnActionLeanLeft); ADD_HANDLER(leanright, OnActionLeanRight); //ADD_HANDLER(holsteritem, OnActionHolsterItem); ADD_HANDLER(use, OnActionUse); ADD_HANDLER(thirdperson, OnActionThirdPerson); ADD_HANDLER(debug_next_actor, OnActionDebugNextActor); ADD_HANDLER(flymode, OnActionFlyMode); ADD_HANDLER(godmode, OnActionGodMode); ADD_HANDLER(toggleaidebugdraw, OnActionAIDebugDraw); ADD_HANDLER(togglepdrawhelpers, OnActionPDrawHelpers); ADD_HANDLER(v_rotateyaw, OnActionVRotateYaw); // needed so player can shake unfreeze while in a vehicle ADD_HANDLER(v_rotatepitch, OnActionVRotatePitch); ADD_HANDLER(xi_v_rotateyaw, OnActionXIRotateYaw); ADD_HANDLER(xi_rotateyaw, OnActionXIRotateYaw); ADD_HANDLER(xi_rotatepitch, OnActionXIRotatePitch); ADD_HANDLER(xi_v_rotatepitch, OnActionXIRotatePitch); ADD_HANDLER(xi_movex, OnActionXIMoveX); ADD_HANDLER(xi_movey, OnActionXIMoveY); ADD_HANDLER(xi_disconnect, OnActionXIDisconnect); ADD_HANDLER(xi_use, OnActionUse); ADD_HANDLER(invert_mouse, OnActionInvertMouse); #undef ADD_HANDLER } }
void CWeapon::RegisterActions() { CGameInputActionHandlers::TWeaponActionHandler& weaponActionHandler = g_pGame->GetGameInputActionHandlers().GetCWeaponActionHandler(); if (weaponActionHandler.GetNumHandlers() == 0) { #define ADD_HANDLER(action, func) weaponActionHandler.AddHandler(actions.action, &CWeapon::func) const CGameActions& actions = g_pGame->Actions(); ADD_HANDLER(attack1, OnActionAttackPrimary); ADD_HANDLER(attack1_xi, OnActionAttackPrimary); ADD_HANDLER(attack2_xi,OnActionAttackSecondary); ADD_HANDLER(reload,OnActionReload); ADD_HANDLER(special,OnActionSpecial); ADD_HANDLER(modify,OnActionModify); ADD_HANDLER(weapon_change_firemode,OnActionFiremode); ADD_HANDLER(zoom_toggle,OnActionZoomToggle); ADD_HANDLER(zoom_in,OnActionZoomIn); ADD_HANDLER(zoom_out,OnActionZoomOut); ADD_HANDLER(zoom,OnActionZoom); ADD_HANDLER(xi_zoom,OnActionZoom); ADD_HANDLER(sprint,OnActionSprint); ADD_HANDLER(sprint_xi,OnActionSprint); //ADD_HANDLER(xi_zoom,OnActionZoomXI); ADD_HANDLER(stabilize,OnActionStabilize); ADD_HANDLER(toggle_flashlight,OnActionToggleFlashLight); #undef ADD_HANDLER } }
static void test1 (void) { SoupClientContext *client; SoupMessage *message; SoupServer *server; UrlRouter *router; router = url_router_new(); matches = g_hash_table_new(g_str_hash, g_str_equal); server = g_object_new(SOUP_TYPE_SERVER, NULL); message = g_object_new(SOUP_TYPE_MESSAGE, NULL); client = GINT_TO_POINTER(1); #define ADD_HANDLER(key) \ url_router_add_handler(router, key, handler, (gpointer)key) #define TEST_HANDLER(key, check) \ G_STMT_START { \ gboolean r = url_router_route(router, server, message, key, NULL, client); \ g_assert(g_hash_table_contains(matches, check)); \ g_assert_cmpint(g_hash_table_size(matches), ==, 1); \ g_assert(r); \ g_hash_table_remove_all(matches); \ } G_STMT_END #define TEST_FAILURE(key) \ G_STMT_START { \ gboolean r = url_router_route(router, server, message, key, NULL, client); \ g_assert_cmpint(g_hash_table_size(matches), ==, 0); \ g_assert(!r); \ g_hash_table_remove_all(matches); \ } G_STMT_END ADD_HANDLER("/v1"); ADD_HANDLER("/v1/users"); ADD_HANDLER("/v1/users/:user"); ADD_HANDLER("/v1/users/:user/devices"); ADD_HANDLER("/v1/users/:user/devices/:device"); TEST_HANDLER("/v1", "/v1"); TEST_HANDLER("/v1/", "/v1"); TEST_HANDLER("/v1/users", "/v1/users"); TEST_HANDLER("/v1/users/", "/v1/users"); TEST_HANDLER("/v1/users/000011110000111100001111", "/v1/users/:user"); TEST_HANDLER("/v1/users/000011110000111100001111/", "/v1/users/:user"); TEST_HANDLER("/v1/users/000011110000111100001111/devices", "/v1/users/:user/devices"); TEST_HANDLER("/v1/users/000011110000111100001111/devices/", "/v1/users/:user/devices"); TEST_HANDLER("/v1/users/000011110000111100001111/devices/111100001111000011110000", "/v1/users/:user/devices/:device"); TEST_HANDLER("/v1/users/000011110000111100001111/devices/111100001111000011110000/", "/v1/users/:user/devices/:device"); TEST_FAILURE("/"); TEST_FAILURE("//"); TEST_FAILURE("////"); TEST_FAILURE("/v1////"); TEST_FAILURE("/v1/users/1234/devices/1234/blah"); #undef TEST_HANDLER #undef ADD_HANDLER g_clear_object(&server); g_clear_object(&message); url_router_free(router); g_hash_table_unref(matches); }
HND_PTR x_ipc_selfRegisterHnd(int sd, MODULE_PTR hndOrg, HND_DATA_PTR hndData, X_IPC_HND_FN hndProc) { int32 localId; MSG_PTR msg; HND_PTR hnd; HND_KEY_TYPE hndKey; msg = x_ipc_findOrRegisterMessage(hndData->msgName); hndKey.num = sd; hndKey.str = hndData->hndName; LOCK_CM_MUTEX; hnd = GET_HANDLER(&hndKey); UNLOCK_CM_MUTEX; if (!hnd) { hnd = NEW(HND_TYPE); hnd->sd = sd; hnd->localId = 0; hnd->msg = NULL; hnd->hndProc = hndProc; hnd->hndOrg = hndOrg; hnd->hndData = hndData; hnd->msgList = x_ipc_listCreate(); hnd->resource = NULL; hnd->hndLanguage = C_LANGUAGE; /* The default */ #ifdef NMP_IPC hnd->clientData = NO_CLIENT_DATA; hnd->isRegistered = TRUE; #endif LOCK_CM_MUTEX; ADD_HANDLER(&hndKey, hnd); localId = x_ipc_idTableInsert((char *)hnd, GET_C_GLOBAL(hndIdTable)); UNLOCK_CM_MUTEX; hnd->localId = localId; if (hndProc) hnd->hndData->refId = localId; } else { LOCK_M_MUTEX; if (!IS_LISP_MODULE() && hndProc != hnd->hndProc) { /* 24-Jun-91: fedor: the warning is not meaningful for lisp because each re-register will cause a pointer change - lisp functions are not at static locations like c */ X_IPC_MOD_WARNING1("\nWARNING: Procedure change ignored for existing handler %s.\n", hnd->hndData->hndName); } UNLOCK_M_MUTEX; } /* 3-Sep-90: fedor: NULL forces initial module cache of a message. */ hnd->msg = NULL; if (!x_ipc_listMemberItem((char *)hnd, msg->hndList)) x_ipc_listInsertItem((char *)hnd, msg->hndList); if (!x_ipc_listMemberItem((char *)msg, hnd->msgList)) x_ipc_listInsertItem((char *)msg, hnd->msgList); return hnd; }