Skip to content
This repository has been archived by the owner on Oct 12, 2024. It is now read-only.

Commit

Permalink
Idle state is maintained through key presses
Browse files Browse the repository at this point in the history
  • Loading branch information
CrendKing committed Aug 18, 2019
1 parent adbd495 commit ca18ff7
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/clothes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
#include "constants.h"


LASTINPUTINFO lastInput = { sizeof(LASTINPUTINFO) };
POINT lastCursorPos = {};
DWORD lastCursorTime = 0;

inline void ShowCursor() {
while (ShowCursor(TRUE) < 0);
Expand All @@ -13,8 +14,16 @@ inline void HideCursor() {
}

void CALLBACK CheckLastInput(HWND hwnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime) {
GetLastInputInfo(&lastInput);
DWORD idleTime = dwTime - lastInput.dwTime;
POINT curCursorPos;
if (GetCursorPos(&curCursorPos) == FALSE) {
return;
}

if (curCursorPos.x != lastCursorPos.x || curCursorPos.y != lastCursorPos.y) {
lastCursorPos = curCursorPos;
lastCursorTime = dwTime;
}
DWORD idleTime = dwTime - lastCursorTime;

Clothes *_clothes = reinterpret_cast<Clothes *>(GetProp(hwnd, CLOTHES_WINDOW_PROP_NAME));
if (idleTime > _clothes->GetIdleTimeValue()) {
Expand Down

0 comments on commit ca18ff7

Please sign in to comment.