diff --git a/game/client/imgui/imgui_impl_source.cpp b/game/client/imgui/imgui_impl_source.cpp index f657f8f0..66e0f7f7 100644 --- a/game/client/imgui/imgui_impl_source.cpp +++ b/game/client/imgui/imgui_impl_source.cpp @@ -159,6 +159,23 @@ void ImGui_ImplSource_RenderDrawData( ImDrawData *draw_data ) ctx->PopMatrix(); } +static const char* ImGui_ImplSource_GetClipboardText(ImGuiContext* ctx) +{ + auto &g = *static_cast( ctx ); + g.ClipboardHandlerData.clear(); + auto len = vgui::system()->GetClipboardTextCount(); + if ( !len ) + return nullptr; + g.ClipboardHandlerData.resize( len ); + vgui::system()->GetClipboardText( 0, g.ClipboardHandlerData.Data, g.ClipboardHandlerData.Size ); + return g.ClipboardHandlerData.Data; +} + +static void ImGui_ImplSource_SetClipboardText(ImGuiContext*, const char* text) +{ + vgui::system()->SetClipboardText( text, V_strlen( text ) ); +} + bool ImGui_ImplSource_Init() { // Setup backend capabilities flags @@ -167,22 +184,8 @@ bool ImGui_ImplSource_Init() io.BackendPlatformName = "source"; io.BackendRendererName = "imgui_impl_source"; io.BackendFlags = ImGuiBackendFlags_None; - platform_io.Platform_SetClipboardTextFn = []( void *, const char *c ) - { - vgui::system()->SetClipboardText( c, V_strlen( c ) ); - }; - platform_io.Platform_GetClipboardTextFn = []( void *ctx ) -> const char * - { - auto &g = *static_cast( ctx ); - g.ClipboardHandlerData.clear(); - auto len = vgui::system()->GetClipboardTextCount(); - if ( !len ) - return nullptr; - g.ClipboardHandlerData.resize( len ); - vgui::system()->GetClipboardText( 0, g.ClipboardHandlerData.Data, g.ClipboardHandlerData.Size ); - return g.ClipboardHandlerData.Data; - }; - + platform_io.Platform_SetClipboardTextFn = ImGui_ImplSource_SetClipboardText; + platform_io.Platform_GetClipboardTextFn = ImGui_ImplSource_GetClipboardText; ImGui_ImplSource_CreateDeviceObjects(); return true; } diff --git a/public/tier1/microprofiler.h b/public/tier1/microprofiler.h index a369f1a5..f226ef3c 100644 --- a/public/tier1/microprofiler.h +++ b/public/tier1/microprofiler.h @@ -30,39 +30,11 @@ PLATFORM_INTERFACE int64 GetHardwareClockReliably(); #include #endif -#if (defined(_LINUX) || defined( OSX )) && !defined(__e2k__) inline unsigned long long GetTimebaseRegister( void ) { -#ifdef PLATFORM_64BITS - unsigned long long Low, High; - __asm__ __volatile__ ( "rdtsc" : "=a" (Low), "=d" (High) ); - return ( High << 32 ) | ( Low & 0xffffffff ); -#else - unsigned long long Val; - __asm__ __volatile__ ( "rdtsc" : "=A" (Val) ); - return Val; -#endif + return Plat_Rdtsc(); } -#else -// Warning: THere's a hardware bug with 64-bit MFTB on PS3 (not sure about X360): sometimes it returns incorrect results (when low word overflows, the high word doesn't increment for some time) -inline int64 GetTimebaseRegister() -{ -#if defined( _X360 ) - return __mftb32(); // X360: ~64 CPU ticks resolution -#elif defined( _PS3 ) - // The timebase frequency on PS/3 is 79.8 MHz, see sys_time_get_timebase_frequency() - // this works out to 40.10025 clock ticks per timebase tick - return __mftb(); -#elif defined( OSX ) - return GetTimebaseRegister(); -#else - return __rdtsc(); -#endif -} -#endif - - #if ENABLE_MICRO_PROFILER > 0