OldSchoolHack

Registrieren / Anmelden Deutsch

Verhalten von Input in Source-Games

icon Thema: [Help] Verhalten von Input in Source-Games

Anmeldungsdatum: Jul 2014

Beiträge: 12

Benutzer-Bewertung:

3 positiv
0 negativ
Hab's. Ich poste mal mein Resultat. Danke für eure Hilfe!

@Knacker, da ich mich nun intensiver mit dem OSHGui beschäftigen werde und sicher Bugs finden werde: hast du inzwischen einen Tracker oder soll das hier ins Forum? (nutze den letzten Trunk)

TEXT Code:
  1. void Gui::Toggle()
  2. {
  3.     auto app = Application::Instance();
  4.  
  5.     int width, height;
  6.     SDK::Engine->GetScreenSize(width, height);
  7.  
  8.     POINT result;
  9.  
  10.     if (app->IsEnabled())
  11.     {
  12.         hookGetCursorPos_(&mousePosOpen_);
  13.         result = { width / 2, height / 2 };
  14.  
  15. ClientToScreen(GetForegroundWindow(), &result);
  16.     }
  17.     else
  18.     {
  19.         result = mousePosOpen_;
  20.     }
  21.  
  22.     hookSetCursorPos_(result.x, result.y);
  23.     app->Toggle();
  24. }
  25.  
  26. class ErsteForm : public Form
  27. {
  28. private:
  29.     Button *ersterButton;
  30.     void InitializeComponent()
  31.     {
  32.         this->SetText("ErsteForm");
  33.         ersterButton = new Button();
  34.         ersterButton->SetText("klick mich");
  35.         ersterButton->GetClickEvent() += ClickEventHandler(std::bind(&ErsteForm::ersterButton_Click, this, std::placeholders::_1));
  36.         this->AddControl(ersterButton);
  37.     }
  38. public:
  39.     ErsteForm()
  40.     {
  41.         InitializeComponent();
  42.     }
  43. private:
  44.     void ersterButton_Click(Control *sender)
  45.     {
  46.         MessageBox::Show("Ich wurde angeklickt!");
  47.     }
  48. };
  49.  
  50. HRESULT WINAPI Gui::EndScene(LPDIRECT3DDEVICE9 pDevice)
  51. {
  52.     Application *app = Application::Instance();
  53.  
  54.     if (!Implode::Gui->initialized_)
  55.     {
  56.         Implode::Gui->initialized_ = true;
  57.         Implode::Gui->messageHookHandle_ = SetWindowsHookExW(WH_GETMESSAGE, MessageHook, 0, GetCurrentThreadId());
  58.  
  59.         app->Create(new Drawing::RendererDX9(pDevice));
  60.  
  61.         int width, height;
  62.         SDK::Engine->GetScreenSize(width, height);
  63.         app->GetRenderer()->SetRenderRectangle(Drawing::Rectangle(0, 0, width, height));
  64.  
  65.         app->Run(std::shared_ptr<Form>(new ErsteForm()));
  66.     }
  67.  
  68.     if (SDK::Engine->IsConnected() && SDK::Engine->IsInGame() && !SDK::Engine->Con_IsVisible() && !SDK::Engine->IsLevelMainMenuBackground())
  69.     {
  70.         app->GetRenderer()->Begin();
  71.         Implode::ClientHooks->EndScene(pDevice, app->GetRenderer());
  72.         app->Render();
  73.         app->GetRenderer()->End();
  74.     }
  75.  
  76.     return Implode::Gui->hookEndScene_(pDevice);
  77. }
  78.  
  79. LRESULT CALLBACK Gui::MessageHook(int code, WPARAM wParam, LPARAM lParam)
  80. {
  81.     if (lParam & 0x80000000 || lParam & 0x40000000)
  82.     {
  83.         return CallNextHookEx(Implode::Gui->messageHookHandle_, code, wParam, lParam);
  84.     }
  85.  
  86.     if (code == HC_ACTION)
  87.     {
  88.         if (reinterpret_cast<LPMSG>(lParam)->message == WM_MOUSEMOVE)
  89.         {
  90.             return 0;
  91.         }
  92.  
  93.         if (Implode::Gui->input_.ProcessMessage(reinterpret_cast<LPMSG>(lParam)))
  94.         {
  95.             return 1;
  96.         }
  97.     }
  98.  
  99.     return CallNextHookEx(Implode::Gui->messageHookHandle_, code, wParam, lParam);
  100. }
  101.  
  102. BOOL WINAPI Gui::SetCursorPos(int X, int Y)
  103. {
  104.     Implode::Gui->mousePos_ = { X, Y };
  105.  
  106.     if (Application::Instance()->IsEnabled() && SDK::Engine->IsConnected() && SDK::Engine->IsInGame() && !SDK::Engine->Con_IsVisible() && !SDK::Engine->IsLevelMainMenuBackground())
  107.     {
  108.         POINT point;
  109.  
  110.         Implode::Gui->hookGetCursorPos_(&point);
  111.         ScreenToClient(GetForegroundWindow(), &point);
  112.         Application::Instance()->ProcessMouseMessage(MouseMessage(MouseMessage::Move, MouseButton::None, Drawing::Point(point.x, point.y), 0));
  113.  
  114.         return 0;
  115.     }
  116.  
  117.     return Implode::Gui->hookSetCursorPos_(X, Y);
  118. }
  119.  
  120. BOOL WINAPI Gui::GetCursorPos(LPPOINT lpPoint)
  121. {
  122.     auto active = Implode::Gui->hookGetCursorPos_(lpPoint);
  123.  
  124.     if (Application::Instance()->IsEnabled() && SDK::Engine->IsConnected() && SDK::Engine->IsInGame() && !SDK::Engine->Con_IsVisible() && !SDK::Engine->IsLevelMainMenuBackground())
  125.     {
  126.         lpPoint->x = Implode::Gui->mousePos_.x;
  127.         lpPoint->y = Implode::Gui->mousePos_.y;
  128.     }
  129.  
  130.     return active;
  131. }
  132.  
  133. int __fastcall ClientHooks::IN_KeyEvent(void *pThis, int edx, int eventcode, ButtonCode_t keynum, const char *pszCurrentBinding)
  134. {
  135.     if (keynum == ButtonCode_t::KEY_INSERT && eventcode)
  136.     {
  137.         Implode::Gui->Toggle();
  138.     }
  139.  
  140.     if (OSHGui::Application::Instance()->IsEnabled())
  141.     {
  142.         return 0;
  143.     }
  144.  
  145.     return Implode::ClientHooks->vmtManager_->GetMethod<IN_KeyEvent_t>(OffsetIN_KeyEvent)(pThis, eventcode, keynum, pszCurrentBinding);
  146. }


1 positiv
0 negativ
Dieser Beitrag wurde bewertet von:
KN4CK3R (Sa 26. Jul 2014, 00:37)