CString GetAccelKeyName(DWORD dwShift, DWORD dwKeyCode) { CString strText; if ((dwShift & 0x2) != 0) { strText += _T("Ctrl"); } if ((dwShift & 0x4) != 0) { if (!strText.IsEmpty()) strText += _T(" + "); strText += _T("Alt"); } if ((dwShift & 0x1) != 0) { if (!strText.IsEmpty()) strText += _T(" + "); strText += _T("Shift"); } if (dwKeyCode != VK_CONTROL && dwKeyCode != VK_MENU && dwKeyCode != VK_SHIFT) { LPCTSTR pKeyName = GetKeyName(dwKeyCode); if (pKeyName != NULL) { if (!strText.IsEmpty()) strText += _T(" + "); strText += GetKeyName(dwKeyCode); } } return strText; }
LRESULT CALLBACK MyListProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) { static TCHAR szText[1024]; switch (msg) { case WM_CHAR: wsprintf(szText, TEXT("WM_CHAR %c"), (TCHAR)wParam); SendMessage(hList, LB_ADDSTRING, 0, (LONG_PTR)szText); break; case WM_KEYDOWN: wsprintf(szText, TEXT("WM_KEYDOWN %s"), GetKeyName(wParam)); SendMessage(hList, LB_ADDSTRING, 0, (LONG_PTR)szText); break; case WM_KEYUP: wsprintf(szText, TEXT("WM_KEYUP %s"), GetKeyName(wParam)); SendMessage(hList, LB_ADDSTRING, 0, (LONG_PTR)szText); break; case WM_SYSKEYDOWN: wsprintf(szText, TEXT("WM_SYSKEYDOWN %s"), GetKeyName(wParam)); SendMessage(hList, LB_ADDSTRING, 0, (LONG_PTR)szText); break; case WM_SYSKEYUP: wsprintf(szText, TEXT("WM_SYSKEYUP %s"), GetKeyName(wParam)); SendMessage(hList, LB_ADDSTRING, 0, (LONG_PTR)szText); break; default: break; } return CallWindowProc(DefaultListWndProc, hWnd, msg, wParam, lParam); }
void plObjectInVolumeDetector::ITrigger(plKey hitter, bool entering, bool immediate) { hsRefCnt_SafeUnRef(fSavedActivatorMsg); fSavedActivatorMsg = new plActivatorMsg; fSavedActivatorMsg->AddReceivers(fReceivers); if (fProxyKey) fSavedActivatorMsg->fHiteeObj = fProxyKey; else fSavedActivatorMsg->fHiteeObj = GetTarget()->GetKey(); fSavedActivatorMsg->fHitterObj = hitter; fSavedActivatorMsg->SetSender(GetKey()); if (entering) { DetectorLog("%s: Saving Entering volume - Evals=%d", GetKeyName().c_str(), fNumEvals); fSavedActivatorMsg->SetTriggerType(plActivatorMsg::kVolumeEnter); fLastEnterEval = fNumEvals; } else { DetectorLog("%s: Saving Exiting volume - Evals=%d", GetKeyName().c_str(), fNumEvals); fSavedActivatorMsg->SetTriggerType(plActivatorMsg::kVolumeExit); fLastExitEval = fNumEvals; } if (immediate) ISendSavedTriggerMsgs(); }
LONG CRegistryKey::OpenSubkey(REGSAM samDesired, const TCHAR *pszSubkeyName, CRegistryKey &rKey) { HKEY hKey; LONG nError = OpenSubkey(samDesired, pszSubkeyName, hKey); if (nError == ERROR_SUCCESS) { const TCHAR *pszKeyName = GetKeyName(); size_t size = _tcslen(pszKeyName) + _tcslen(pszSubkeyName) + 1; TCHAR *pszSubkeyFullName = new (std::nothrow) TCHAR [size]; if (!pszSubkeyFullName) { nError = RegCloseKey(hKey); ASSERT(nError == ERROR_SUCCESS); return ERROR_OUTOFMEMORY; } _tcscpy(pszSubkeyFullName,pszKeyName); _tcscat(pszSubkeyFullName,pszSubkeyName); HRESULT hr = rKey.Init(hKey,GetKeyName(),pszSubkeyName,samDesired); delete[] pszSubkeyName; if (FAILED(hr)) { nError = RegCloseKey(hKey); ASSERT(nError == ERROR_SUCCESS); if (hr == (HRESULT)E_OUTOFMEMORY) return ERROR_OUTOFMEMORY; else return ERROR_INTERNAL_ERROR; } } return nError; }
void plCameraRegionDetector::ITrigger(plKey hitter, bool entering, bool immediate) { if (fSavingSendMsg) DetectorLogRed("%s: Stale messages on ITrigger. This should never happen!", GetKeyName().c_str()); if (fIsInside && entering) DetectorLogRed("%s: Duplicate enter! Did we miss an exit?", GetKeyName().c_str()); else if (!fIsInside && !entering) DetectorLogRed("%s: Duplicate exit! Did we miss an enter?", GetKeyName().c_str()); fSavingSendMsg = true; fSavedMsgEnterFlag = entering; if (entering) { DetectorLog("%s: Saving camera Entering volume - Evals=%d", GetKeyName().c_str(),fNumEvals); fLastEnterEval = fNumEvals; } else { DetectorLog("%s: Saving camera Exiting volume - Evals=%d", GetKeyName().c_str(),fNumEvals); fLastExitEval = fNumEvals; } if (immediate) ISendSavedTriggerMsgs(); }
void OnInitDlg(HWND hDlg) { LoadSettings(); UpdateData(DIRECTION, BUTTON, SPEED); SetNumTimeReplay(REPLAYTIME); Button_SetCheck(GetDlgItem(hDlg, IDC_AUTORUN), AUTORUN); OldEditProc = (WNDPROC)GetWindowLongPtr(GetDlgItem(hDlg, IDC_EDITRIGHT), GWLP_WNDPROC); SetWindowLongPtr(GetDlgItem(hDlg, IDC_EDITRIGHT), GWLP_WNDPROC, (LONG_PTR)NewEditProc); SetWindowLongPtr(GetDlgItem(hDlg, IDC_EDITLEFT), GWLP_WNDPROC, (LONG_PTR)NewEditProc); SetWindowLongPtr(GetDlgItem(hDlg, IDC_EDITUP), GWLP_WNDPROC, (LONG_PTR)NewEditProc); SetWindowLongPtr(GetDlgItem(hDlg, IDC_EDITDOWN), GWLP_WNDPROC, (LONG_PTR)NewEditProc); SetWindowLongPtr(GetDlgItem(hDlg, IDC_EDITLBUTTON), GWLP_WNDPROC, (LONG_PTR)NewEditProc); SetWindowLongPtr(GetDlgItem(hDlg, IDC_EDITRBUTTON), GWLP_WNDPROC, (LONG_PTR)NewEditProc); SetWindowLongPtr(GetDlgItem(hDlg, IDC_EDITMBUTTON), GWLP_WNDPROC, (LONG_PTR)NewEditProc); SetWindowLongPtr(GetDlgItem(hDlg, IDC_EDITWUP), GWLP_WNDPROC, (LONG_PTR)NewEditProc); SetWindowLongPtr(GetDlgItem(hDlg, IDC_EDITWDOWN), GWLP_WNDPROC, (LONG_PTR)NewEditProc); TCHAR buffer[100]; Edit_SetText(GetDlgItem(hDlg, IDC_EDITDOWN), GetKeyName(DIRECTION[DOWN], buffer)); Edit_SetText(GetDlgItem(hDlg, IDC_EDITUP), GetKeyName(DIRECTION[UP], buffer)); Edit_SetText(GetDlgItem(hDlg, IDC_EDITLEFT), GetKeyName(DIRECTION[LEFT], buffer)); Edit_SetText(GetDlgItem(hDlg, IDC_EDITRIGHT), GetKeyName(DIRECTION[RIGHT], buffer)); Edit_SetText(GetDlgItem(hDlg, IDC_EDITLBUTTON), GetKeyName(BUTTON[LBUTTON], buffer)); Edit_SetText(GetDlgItem(hDlg, IDC_EDITRBUTTON), GetKeyName(BUTTON[RBUTTON], buffer)); Edit_SetText(GetDlgItem(hDlg, IDC_EDITMBUTTON), GetKeyName(BUTTON[MBUTTON], buffer)); Edit_SetText(GetDlgItem(hDlg, IDC_EDITWUP), GetKeyName(BUTTON[WHEELUP], buffer)); Edit_SetText(GetDlgItem(hDlg, IDC_EDITWDOWN), GetKeyName(BUTTON[WHEELDOWN], buffer)); _itow(SPEED, buffer, 10); Edit_SetText(GetDlgItem(hDlg, IDC_EDITSPEED), buffer); _itow(REPLAYTIME, buffer, 10); Edit_SetText(GetDlgItem(hDlg, IDC_EDITREPLAY), buffer); }
void plObjectInVolumeDetector::ISendSavedTriggerMsgs() { if (fSavedActivatorMsg) { if (fSavedActivatorMsg->fTriggerType == plActivatorMsg::kVolumeEnter) DetectorLog("%s: Sending Entering volume - Evals=%d", GetKeyName().c_str(), fNumEvals); else DetectorLog("%s: Sending Exiting volume - Evals=%d", GetKeyName().c_str(), fNumEvals); // we're saving the message to be dispatched later... plgDispatch::MsgSend(fSavedActivatorMsg); } fSavedActivatorMsg = nil; }
void CPreferencesKeyboard::OnSelchangeKeydlgCmdlist() { m_Combo.ResetContent(); m_Remove.EnableWindow(false); m_Edit.SetWindowText(""); int Sel = m_List.GetCurSel(); if (Sel == LB_ERR) return; LC_KEYBOARD_COMMAND& Cmd = KeyboardShortcuts[m_List.GetItemData(Sel)]; // Update the combo box with the shortcuts for the current selection. if (Cmd.Key1) { CString str; if (Cmd.Flags & LC_KEYMOD1_SHIFT) str = "Shift+"; if (Cmd.Flags & LC_KEYMOD1_CONTROL) str += "Ctrl+"; str += GetKeyName(Cmd.Key1); m_Combo.AddString(str); m_Combo.SetCurSel(0); m_Remove.EnableWindow(true); if (Cmd.Key2) { str = ""; if (Cmd.Flags & LC_KEYMOD2_SHIFT) str = "Shift+"; if (Cmd.Flags & LC_KEYMOD2_CONTROL) str += "Ctrl+"; str += GetKeyName(Cmd.Key2); m_Combo.AddString(str); } } m_Edit.EnableWindow(Cmd.Key2 == 0); m_Assign.EnableWindow((Cmd.Key2 == 0) && m_Edit.m_Key); }
// Called after the simulation has run....sends new positions to the various scene objects // *** want to do this in response to an update message.... void plPXPhysical::SendNewLocation(bool synchTransform, bool isSynchUpdate) { // we only send if: // - the body is active or forceUpdate is on // - the mass is non-zero // - the physical is not passive bool bodyActive = !fActor->isSleeping(); bool dynamic = fActor->isDynamic(); if ((bodyActive || isSynchUpdate) && dynamic)// && fInitialTransform) { plProfile_Inc(MaySendLocation); if (!GetProperty(plSimulationInterface::kPassive)) { hsMatrix44 curl2w = fCachedLocal2World; // we're going to cache the transform before sending so we can recognize if it comes back IGetTransformGlobal(fCachedLocal2World); if (!CompareMatrices(curl2w, fCachedLocal2World, .0001f)) { plProfile_Inc(LocationsSent); plProfile_BeginLap(PhysicsUpdates, GetKeyName().c_str()); // quick peek at the translation...last time it was corrupted because we applied a non-unit quaternion // hsAssert(real_finite(fCachedLocal2World.fMap[0][3]) && // real_finite(fCachedLocal2World.fMap[1][3]) && // real_finite(fCachedLocal2World.fMap[2][3]), "Bad transform outgoing"); if (fCachedLocal2World.GetTranslate().fZ < kMaxNegativeZPos) { SimLog("Physical %s fell to %.1f (%.1f is the max). Suppressing.", GetKeyName().c_str(), fCachedLocal2World.GetTranslate().fZ, kMaxNegativeZPos); // Since this has probably been falling for a while, and thus not getting any syncs, // make sure to save it's current pos so we'll know to reset it later DirtySynchState(kSDLPhysical, plSynchedObject::kBCastToClients); IEnable(false); } hsMatrix44 w2l; fCachedLocal2World.GetInverse(&w2l); plCorrectionMsg *pCorrMsg = new plCorrectionMsg(GetObjectKey(), fCachedLocal2World, w2l, synchTransform); pCorrMsg->Send(); if (fProxyGen) fProxyGen->SetTransform(fCachedLocal2World, w2l); plProfile_EndLap(PhysicsUpdates, GetKeyName().c_str()); } } } }
const char* ShortcutsSpec::GetCellText(int whichColumn) const { const char* temp = ""; // default switch(whichColumn) { case KEY_COLUMN_INDEX: { if ((fKey > 0) && (fKey <= 0xFF)) { temp = GetKeyName(fKey); if (temp == NULL) temp = ""; } else if (fKey > 0xFF) { sprintf(fScratch, "#%lx", fKey); return fScratch; } break; } case STRING_COLUMN_INDEX: temp = fCommand; break; default: if ((whichColumn >= 0) && (whichColumn < NUM_META_COLUMNS)) temp = sMetaMaps[whichColumn].GetNthStateDesc( fMetaCellStateIndex[whichColumn]); break; } return temp; }
void plResponderModifier::Trigger(plNotifyMsg *msg) { #if 0 plNetClientApp::GetInstance()->DebugMsg("RM: Responder {} is triggering, num cmds={}, enabled={}, curCmd={}, t={f}\n", GetKeyName(), fStates[fCurState].fCmds.GetCount(), fEnabled, fCurCommand, hsTimer::GetSysSeconds()); #endif // If we're not in the middle of sending, reset and start sending commands if (fCurCommand == int8_t(-1) && fEnabled) { ResponderLog(ILog(plStatusLog::kGreen, "Trigger")); fNotifyMsgFlags = msg->GetAllBCastFlags(); fTriggerer = msg->GetSender(); fPlayerKey = msg->GetAvatarKey(); ISetResponderStateFromNotify(msg); proCollisionEventData *cEvent = (proCollisionEventData *)msg->FindEventRecord(proEventData::kCollision); fEnter = (cEvent ? cEvent->fEnter : false); fCompletedEvents.Reset(); fCurCommand = 0; DirtySynchState(kSDLResponder, 0); IContinueSending(); } else { ResponderLog(ILog(plStatusLog::kRed, "Rejected Trigger, %s", !fEnabled ? "responder disabled" : "responder is running")); } }
BOOL CopyKeyName(HWND hWnd, HKEY hRootKey, LPCWSTR keyName) { BOOL bClipboardOpened = FALSE; BOOL bSuccess = FALSE; WCHAR szBuffer[512]; HGLOBAL hGlobal; LPWSTR s; if (!OpenClipboard(hWnd)) goto done; bClipboardOpened = TRUE; if (!EmptyClipboard()) goto done; if (!GetKeyName(szBuffer, COUNT_OF(szBuffer), hRootKey, keyName)) goto done; hGlobal = GlobalAlloc(GMEM_MOVEABLE, (wcslen(szBuffer) + 1) * sizeof(WCHAR)); if (!hGlobal) goto done; s = GlobalLock(hGlobal); wcscpy(s, szBuffer); GlobalUnlock(hGlobal); SetClipboardData(CF_UNICODETEXT, hGlobal); bSuccess = TRUE; done: if (bClipboardOpened) CloseClipboard(); return bSuccess; }
void plResponderModifier::ILog(uint32_t color, const char* format, ...) { #ifdef STATUS_LOG if (!gLog) gLog = plStatusLogMgr::GetInstance().CreateStatusLog(15, "Responder", plStatusLog::kFilledBackground | plStatusLog::kDeleteForMe | plStatusLog::kDontWriteFile | plStatusLog::kAlignToTop); if (!format || *format == '\0') return; ST::string keyName = GetKeyName(); // Make sure this key isn't in our list of keys to deny for (const auto& it : gNoLogStrings) { if (keyName.starts_with(it)) return; } // Format the log text char buf[256]; va_list args; va_start(args, format); int numWritten = hsVsnprintf(buf, sizeof(buf), format, args); hsAssert(numWritten > 0, "Buffer too small"); va_end(args); // Strip the redundant part off the key name ST_ssize_t modPos = keyName.find("_ResponderModifier"); if (modPos != -1) keyName = keyName.left(modPos); ST::string logLine = ST::format("{}: {}", keyName, buf); gLog->AddLine(logLine.c_str(), color); #endif // STATUS_LOG }
void plWin32StreamingSound::IStreamUpdate() { if(!fReallyPlaying) return; if(hsTimer::GetMilliSeconds() - fLastStreamingUpdate < STREAMING_UPDATE_MS) // filter out update requests so we aren't doing this more that we need to return; plProfile_BeginTiming( StreamSndShoveTime ); if(fDSoundBuffer) { if(fDSoundBuffer->BuffersQueued() == 0 && fDataStream->NumBytesLeft() == 0 && !fDSoundBuffer->IsLooping()) { // If we are fading out it's possible that we will hit this multiple times causing this sound to try and fade out multiple times, never allowing it to actually stop if(!fStopping) { fStopping = true; Stop(); plProfile_EndTiming( StreamSndShoveTime ); } return; } if(!fDSoundBuffer->StreamingFillBuffer(fDataStream)) { plStatusLog::AddLineS("audio.log", "%s Streaming buffer fill failed", GetKeyName().c_str()); } } plProfile_EndTiming( StreamSndShoveTime ); }
bool wxIniConfig::Read(const wxString& szKey, wxString *pstr, const wxString& szDefault) const { wxConfigPathChanger path(this, szKey); wxString strKey = GetPrivateKeyName(path.Name()); wxChar szBuf[1024]; // @@ should dynamically allocate memory... // first look in the private INI file // NB: the lpDefault param to GetPrivateProfileString can't be NULL // GetPrivateProfileString(m_strGroup, strKey, "", // szBuf, WXSIZEOF(szBuf), m_strLocalFilename); if ( ::wxIsEmpty((PSZ)szBuf) ) { // now look in win.ini wxString strKey = GetKeyName(path.Name()); // GetProfileString(m_strGroup, strKey, "", szBuf, WXSIZEOF(szBuf)); } if ( ::wxIsEmpty((PSZ)szBuf) ) { *pstr = szDefault; return false; } else { *pstr = szBuf ; return true; } }
BOOL CKeyBoardSet::OnInitDialog() { CTopAceDialog::OnInitDialog(); // TODO: 在此添加额外的初始化 if( !m_cfg.LoadCfg() ) { EndDialog( IDCANCEL ); return FALSE; } m_cList.SetExtendedStyle( m_cList.GetExtendedStyle() | LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES ); m_cList.InsertColumn( 0 , L"功能" , LVCFMT_LEFT , 100 ); m_cList.InsertColumn( 1 , L"按键" , LVCFMT_LEFT , 100 ); m_cList.SetRedraw( FALSE ); for( int i = 0 ; i < E_GO_MAX ; ++i ) { if( i != m_cList.InsertItem( i , m_cfg.GetItemName( EGameOperate(i) ) ) ) { EndDialog( IDCANCEL ); return FALSE; } m_cList.SetItemData( i , (DWORD_PTR)EGameOperate(i) ); m_cList.SetItemText( i , 1 , GetKeyName(m_cfg.GetItemMapKey( EGameOperate(i) )) ); } m_cList.SetRedraw( TRUE ); return TRUE; // return TRUE unless you set the focus to a control // 异常: OCX 属性页应返回 FALSE }
bool plExcludeRegionModifier::MsgReceive(plMessage* msg) { plExcludeRegionMsg *exclMsg = plExcludeRegionMsg::ConvertNoRef(msg); if (exclMsg) { if (exclMsg->GetCmd() == plExcludeRegionMsg::kClear) { DetectorLogSpecial("Clearing exclude region %s", GetKeyName().c_str()); IMoveAvatars(); fContainedAvatars.Reset(); ISetPhysicalState(true); } else if (exclMsg->GetCmd() == plExcludeRegionMsg::kRelease) { DetectorLogSpecial("Releasing exclude region %s", GetKeyName().c_str()); ISetPhysicalState(false); } GetTarget()->DirtySynchState(kSDLXRegion, exclMsg->fSynchFlags); return true; } // Avatar entering or exiting our volume. Only the owner of the SO logs this since // it does all the moving at clear time. plCollideMsg *collideMsg = plCollideMsg::ConvertNoRef(msg); if (collideMsg) { if (collideMsg->fEntering) { //DetectorLogSpecial("Avatar enter exclude region %s",GetKeyName().c_str()); fContainedAvatars.Append(collideMsg->fOtherKey); } else { //DetectorLogSpecial("Avatar exit exclude region %s",GetKeyName().c_str()); int idx = fContainedAvatars.Find(collideMsg->fOtherKey); if (idx != fContainedAvatars.kMissingIndex) fContainedAvatars.Remove(idx); } return true; } return plSingleModifier::MsgReceive(msg); }
void GetRegistryChanges(HKEY hKey) { TCHAR szKey[MAX_KEY_LENGTH]; DWORD cbName; DWORD cSubKeys=0; FILETIME ftWrite; DWORD i, ret; HKEY hNewKey; ULARGE_INTEGER tmWrite; TCHAR szName[MAX_KEY_LENGTH]; // get the number of subkeys ret = RegQueryInfoKey( // WinReg.h hKey, NULL, NULL, NULL, &cSubKeys, NULL, NULL, NULL, NULL, NULL, NULL, NULL); // for each subkey, see if it changed based on its // last write timestamp for (i=0; i<cSubKeys; i++) { cbName = MAX_KEY_LENGTH; ret = RegEnumKeyEx( // WinReg.h hKey, i, szKey, &cbName, NULL, NULL, NULL, &ftWrite); if (ret == ERROR_SUCCESS) { tmWrite.HighPart = ftWrite.dwHighDateTime; tmWrite.LowPart = ftWrite.dwLowDateTime; // it changed if the last write is greater than // our start time if (tmWrite.QuadPart > g_tmStart.QuadPart) { memset(szName, 0, sizeof(szName)); GetKeyName(hKey, szName); _tcscat(szName, _T("\\")); // 문자열 추가 strcat_s _tcscat(szName, szKey); if (!IsWhitelisted(szName)) { Output(FOREGROUND_BLUE, _T("[REGISTRY] %s\n"), szName); } } ret = RegOpenKeyEx(hKey, szKey, 0, KEY_READ, &hNewKey); if (ret == ERROR_SUCCESS) { GetRegistryChanges(hNewKey); RegCloseKey(hNewKey); } } } }
nglString nuiHotKeyImpl<nglKeyCode>::ShortcutToString() const { nglString shortcut = ModifiersToString(mModifiers); shortcut += GetKeyName(mTrigger); shortcut.ToUpper(); return shortcut; }
void hsGMaterial::Eval(double secs, uint32_t frame) { plProfile_BeginLap(MaterialAnims, GetKeyName().c_str()); int i; for( i = 0; i < GetNumLayers(); i++ ) { if( fLayers[i] ) fLayers[i]->Eval(secs, frame, 0); } for( i = 0; i < GetNumPiggyBacks(); i++ ) { if( fPiggyBacks[i] ) fPiggyBacks[i]->Eval(secs, frame, 0); } plProfile_EndLap(MaterialAnims, GetKeyName().c_str()); }
void plObjectInVolumeAndFacingDetector::ICheckForTrigger() { plArmatureMod* armMod = plAvatarMgr::GetInstance()->GetLocalAvatar(); plSceneObject* avatar = armMod ? armMod->GetTarget(0) : nil; plSceneObject* target = GetTarget(); if (armMod && target) { hsVector3 playerView = avatar->GetCoordinateInterface()->GetLocalToWorld().GetAxis(hsMatrix44::kView); hsVector3 objView = target->GetCoordinateInterface()->GetLocalToWorld().GetAxis(hsMatrix44::kView); playerView.Normalize(); objView.Normalize(); float dot = playerView * objView; // hsStatusMessageF("Dot: %f Tolerance: %f", dot, fFacingTolerance); bool facing = dot >= fFacingTolerance; bool movingForward = false; if (fNeedWalkingForward) { // And are we walking towards it? plArmatureBrain* abrain = armMod->FindBrainByClass(plAvBrainHuman::Index()); //armMod->GetCurrentBrain(); plAvBrainHuman* brain = plAvBrainHuman::ConvertNoRef(abrain); if (brain && brain->IsMovingForward() && brain->fWalkingStrategy->IsOnGround()) movingForward = true; } else movingForward = true; if (facing && movingForward && !fTriggered) { DetectorLog("%s: Trigger InVolume&Facing", GetKeyName().c_str()); fTriggered = true; ISendTriggerMsg(avatar->GetKey(), true); } else if (!facing && fTriggered) { DetectorLog("%s: Untrigger InVolume&Facing", GetKeyName().c_str()); fTriggered = false; ISendTriggerMsg(avatar->GetKey(), false); } } }
plPXPhysical::~plPXPhysical() { SpamMsg(plSimulationMgr::Log("Destroying physical %s", GetKeyName().c_str())); if (fActor) { // Grab any mesh we may have (they need to be released manually) NxConvexMesh* convexMesh = nil; NxTriangleMesh* triMesh = nil; NxShape* shape = fActor->getShapes()[0]; if (NxConvexShape* convexShape = shape->isConvexMesh()) convexMesh = &convexShape->getConvexMesh(); else if (NxTriangleMeshShape* trimeshShape = shape->isTriangleMesh()) triMesh = &trimeshShape->getTriangleMesh(); if (!fActor->isDynamic()) plPXPhysicalControllerCore::RebuildCache(); if (fActor->isDynamic() && fActor->readBodyFlag(NX_BF_KINEMATIC)) { if (fGroup == plSimDefs::kGroupDynamic) fNumberAnimatedPhysicals--; else fNumberAnimatedActivators--; } // Release the actor NxScene* scene = plSimulationMgr::GetInstance()->GetScene(fWorldKey); scene->releaseActor(*fActor); fActor = nil; // Now that the actor is freed, release the mesh if (convexMesh) plSimulationMgr::GetInstance()->GetSDK()->releaseConvexMesh(*convexMesh); if (triMesh) plSimulationMgr::GetInstance()->GetSDK()->releaseTriangleMesh(*triMesh); // Release the scene, so it can be cleaned up if no one else is using it plSimulationMgr::GetInstance()->ReleaseScene(fWorldKey); } if (fWorldHull) delete [] fWorldHull; if (fSaveTriangles) delete [] fSaveTriangles; delete fProxyGen; // remove sdl modifier plSceneObject* sceneObj = plSceneObject::ConvertNoRef(fObjectKey->ObjectIsLoaded()); if (sceneObj && fSDLMod) { sceneObj->RemoveModifier(fSDLMod); } delete fSDLMod; }
plLayer* hsGMaterial::MakeBaseLayer() { plLayer* newLay = new plLayer; newLay->InitToDefault(); IClearLayers(); hsAssert(GetKey(), "All materials need a key (or temp key)"); plString buff; if( !GetKeyName().IsNull() ) buff = plString::Format("%s_Layer", GetKeyName().c_str()); else buff = "Layer"; hsgResMgr::ResMgr()->NewKey( buff, newLay, GetKey() != nil ? GetKey()->GetUoid().GetLocation() : plLocation::kGlobalFixedLoc ); // Add layer so we have it now. AddLayerViaNotify(newLay); return newLay; }
int EView::ShowKey(ExState &/*State*/) { char buf[100]; KeySel ks; ks.Mask = 0; ks.Key = MView->Win->GetChar(0); GetKeyName(buf, sizeof(buf), ks); Msg(S_INFO, "Key: '%s' - '%8X'", buf, ks.Key); return 1; }
/** * Returns the name of a pressed key combination. * * @param c A keycode * * @return The name of the key combination. * * TODO: Replace return value with parameter. **/ char* GetKeyComboName(int c) { static char text[80]; text[0] = '\0'; if(!c) { return text; } if ((c & CMD_KEY_CTRL) == CMD_KEY_CTRL) { strcat(text, "Ctrl + "); } else if ((c & CMD_KEY_CTRL) == CMD_KEY_LCTRL) { strcat(text, "Left Ctrl + "); } else if ((c & CMD_KEY_CTRL) == CMD_KEY_RCTRL) { strcat(text, "Right Ctrl + "); } if ((c & CMD_KEY_ALT) == CMD_KEY_ALT) { strcat(text, "Alt + "); } else if ((c & CMD_KEY_ALT) == CMD_KEY_LALT) { strcat(text, "Left Alt + "); } else if ((c & CMD_KEY_ALT) == CMD_KEY_RALT) { strcat(text, "Right Alt + "); } if ((c & CMD_KEY_SHIFT) == CMD_KEY_SHIFT) { strcat(text, "Shift + "); } else if ((c & CMD_KEY_SHIFT) == CMD_KEY_LSHIFT) { strcat(text, "Left Shift + "); } else if ((c & CMD_KEY_SHIFT) == CMD_KEY_RSHIFT) { strcat(text, "Right Shift + "); } strcat(text, GetKeyName(c & CMD_KEY_MASK)); return text; }
void OnKeyPressed( int key, int action ){ const char* key_name = GetKeyName(key); if(key_name == 0) return; if(action == GLFW_PRESS) printf("'%s' (%i) key is pressed\n", key_name, key); if(action == GLFW_RELEASE) printf("'%s' (%i) key is released\n", key_name, key); if(action == GLFW_RELEASE && key == GLFW_KEY_ENTER) PullInfo(); }
void plObjectInVolumeDetector::IHandleEval(plEvalMsg*) { bookKeepingList::iterator it = fCollisionList.begin(); while (it != fCollisionList.end()) { plCollisionBookKeepingInfo* collisionInfo = *it; #ifdef USE_PHYSX_COLLISION_FLUTTER_WORKAROUND if (plSimulationMgr::GetInstance()->GetStepCount() - collisionInfo->fLastStep > 1) { #endif // USE_PHYSX_COLLISION_FLUTTER_WORKAROUND ResidentSet::iterator j = fCurrentResidents.find(collisionInfo->fHitter); bool wasInside = j != fCurrentResidents.end(); if (collisionInfo->fEntering != wasInside) { if (collisionInfo->fEntering) { fCurrentResidents.insert(collisionInfo->fHitter); DetectorLog("%s: Sending Volume Enter ActivatorMsg", GetKeyName().c_str()); ISendTriggerMsg(collisionInfo->fHitter, true); } else { fCurrentResidents.erase(j); DetectorLog("%s: Sending Volume Exit ActivatorMsg", GetKeyName().c_str()); ISendTriggerMsg(collisionInfo->fHitter, false); } } delete collisionInfo; #ifdef USE_PHYSX_COLLISION_FLUTTER_WORKAROUND it = fCollisionList.erase(it); } else { ++it; } #else ++it; #endif // USE_PHYSX_COLLISION_FLUTTER_WORKAROUND } }
plPhysical& plPXPhysical::SetProperty(int prop, bool status) { if (GetProperty(prop) == status) { const char* propName = "(unknown)"; switch (prop) { case plSimulationInterface::kDisable: propName = "kDisable"; break; case plSimulationInterface::kPinned: propName = "kPinned"; break; case plSimulationInterface::kPassive: propName = "kPassive"; break; case plSimulationInterface::kPhysAnim: propName = "kPhysAnim"; break; case plSimulationInterface::kStartInactive: propName = "kStartInactive"; break; case plSimulationInterface::kNoSynchronize: propName = "kNoSynchronize"; break; } plString name = "(unknown)"; if (GetKey()) name = GetKeyName(); if (plSimulationMgr::fExtraProfile) plSimulationMgr::Log("Warning: Redundant physical property set (property %s, value %s) on %s", propName, status ? "true" : "false", name.c_str()); } switch (prop) { case plSimulationInterface::kDisable: IEnable(!status); break; case plSimulationInterface::kPinned: if (fActor->isDynamic()) { // if the body is already unpinned and you unpin it again, // you'll wipe out its velocity. hence the check. bool current = fActor->readBodyFlag(NX_BF_FROZEN); if (status != current) { if (status) fActor->raiseBodyFlag(NX_BF_FROZEN); else { fActor->clearBodyFlag(NX_BF_FROZEN); LogActivate("SetProperty"); fActor->wakeUp(); } } } break; } fProps.SetBit(prop, status); return *this; }
static BPopUpMenu* CreateKeysPopUp() { BPopUpMenu* popup = new BPopUpMenu(NULL, false); int numKeys = GetNumKeyIndices(); for (int i = 0; i < numKeys; i++) { const char* next = GetKeyName(i); if (next) popup->AddItem(new BMenuItem(next, NULL)); } return popup; }
hsBool plLogicModBase::MsgReceive(plMessage* msg) { // read messages: plServerReplyMsg* pSMsg = plServerReplyMsg::ConvertNoRef(msg); if (pSMsg) { hsAssert(pSMsg->GetType() != plServerReplyMsg::kUnInit, "uninit server reply msg"); #if 1 plNetClientApp::GetInstance()->DebugMsg("LM: LogicModifier %s recvd trigger request reply:%s, wasRequesting=%d, t=%f\n", GetKeyName().c_str(), pSMsg->GetType() == plServerReplyMsg::kDeny ? "denied" : "confirmed", HasFlag(kRequestingTrigger), hsTimer::GetSysSeconds()); #endif if (pSMsg->GetType() == plServerReplyMsg::kDeny) { if (HasFlag(kRequestingTrigger)) { plNetClientApp::GetInstance()->DebugMsg("\tLM: Denied, clearing requestingTrigger"); ClearFlag(kRequestingTrigger); } else plNetClientApp::GetInstance()->DebugMsg("\tLM: Denied, but not requesting?"); } else { hsBool netRequest=false; // we're triggering as a result of a local activation PreTrigger(netRequest); IUpdateSharedState(false /* untriggering */); } return true; } plEnableMsg* pEnable = plEnableMsg::ConvertNoRef(msg); if (pEnable) { if (pEnable->Cmd(plEnableMsg::kDisable)) fDisabled = true; else if (pEnable->Cmd(plEnableMsg::kEnable)) { ClearFlag(kTriggered); ClearFlag(kRequestingTrigger); fDisabled = false; } return true; } return plSingleModifier::MsgReceive(msg); }