Stuff?
This commit is contained in:
+4
-8
@@ -44,18 +44,14 @@ DLL_FUNCTION(void) BU_Time_Destroy(time_t* pTime) {
|
||||
delete pTime;
|
||||
}
|
||||
|
||||
char* BU_Time_Format_Buffer = new char[1024];
|
||||
DLL_FUNCTION(const char*) BU_Time_Format(time_t* pTime, const char* pchFormatString) {
|
||||
#pragma comment(linker, "/EXPORT:BU_Time_Format=_BU_Time_Format@8")
|
||||
std::string buffer;
|
||||
tm* pTM = new tm;
|
||||
localtime_s(pTM, pTime);
|
||||
|
||||
uint32_t length = strlen(pchFormatString);
|
||||
buffer.resize(length);
|
||||
while (strftime(&buffer[0], buffer.size(), pchFormatString, pTM) == 0) {
|
||||
buffer.resize(buffer.size() * 2);
|
||||
}
|
||||
|
||||
strftime(BU_Time_Format_Buffer, 1024, pchFormatString, pTM);
|
||||
delete pTM;
|
||||
return buffer.c_str();
|
||||
|
||||
return BU_Time_Format_Buffer;
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
// BlitzUtility - Expanding the normal Blitz functionality.
|
||||
// Copyright (C) 2015 Xaymar (Michael Fabian Dirks)
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#include "Timer.h"
|
||||
#include <string.h>
|
||||
#include <string>
|
||||
#include <functional>
|
||||
#include <chrono>
|
||||
#include <future>
|
||||
#include <cstdio>
|
||||
|
||||
using namespace std;
|
||||
|
||||
struct BlitzTimerInfo {
|
||||
uint32_t Interval;
|
||||
|
||||
HANDLE hSemaphore;
|
||||
};
|
||||
|
||||
int32_t BU_Timer_Index = 0;
|
||||
std::map<int32_t, BlitzTimerInfo> BU_Timer_List;// = new std::map<int32_t, HANDLE>();
|
||||
|
||||
VOID CALLBACK BU_Timer_PROC(
|
||||
_In_ HWND hwnd,
|
||||
_In_ UINT uMsg,
|
||||
_In_ UINT_PTR idEvent,
|
||||
_In_ DWORD dwTime
|
||||
) {
|
||||
BlitzTimerInfo myTimer = BU_Timer_List[idEvent];
|
||||
ReleaseSemaphore(myTimer.hSemaphore, 1, NULL);
|
||||
}
|
||||
|
||||
DLL_FUNCTION(int32_t) BU_Timer_Create(uint32_t Interval, HWND hwnd) {
|
||||
UINT_PTR timer = SetTimer(hwnd, 32767, Interval, &BU_Timer_PROC);
|
||||
|
||||
if (timer) {
|
||||
BlitzTimerInfo myTimer = BlitzTimerInfo();
|
||||
myTimer.Interval = Interval;
|
||||
myTimer.hSemaphore = CreateSemaphore(NULL, 0, 32767, NULL);
|
||||
BU_Timer_List[timer] = myTimer;
|
||||
return timer;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
DLL_FUNCTION(void) BU_Timer_Destroy(uint32_t Id) {
|
||||
BlitzTimerInfo myTimer = BU_Timer_List[Id];
|
||||
CloseHandle(myTimer.hSemaphore);
|
||||
BU_Timer_List.erase(Id);
|
||||
}
|
||||
|
||||
DLL_FUNCTION(int32_t) BU_Timer_Wait(uint32_t Id) {
|
||||
BlitzTimerInfo myTimer = BU_Timer_List[Id];
|
||||
|
||||
//HANDLE myHandles[] = { myTimer.hSemaphore };
|
||||
//MsgWaitForMultipleObjects(1, myHandles, true, 0xFFFFFFFF, QS_TIMER);
|
||||
return WaitForSingleObject(myTimer.hSemaphore, 0xFFFFFFFF);
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
// BlitzUtility - Expanding the normal Blitz functionality.
|
||||
// Copyright (C) 2015 Xaymar (Michael Fabian Dirks)
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License as
|
||||
// published by the Free Software Foundation, either version 3 of the
|
||||
// License, or (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#pragma once
|
||||
#include "BlitzUtility.h"
|
||||
#include <map>
|
||||
|
||||
//DLL_FUNCTION(int32_t) BU_Timer_Create(uint32_t Interval);
|
||||
//DLL_FUNCTION(void) BU_Timer_Destroy(uint32_t Id);
|
||||
//DLL_FUNCTION(int32_t) BU_Timer_Wait(uint32_t Id);
|
||||
Reference in New Issue
Block a user