Changes
This commit is contained in:
+2
-2
@@ -149,7 +149,7 @@ IncludeBlocks: Preserve
|
|||||||
|
|
||||||
IndentCaseLabels: true
|
IndentCaseLabels: true
|
||||||
IndentExternBlock: Indent
|
IndentExternBlock: Indent
|
||||||
IndentWidth: 4
|
IndentWidth: 2
|
||||||
InsertNewlineAtEOF: true
|
InsertNewlineAtEOF: true
|
||||||
KeepEmptyLinesAtEOF: true
|
KeepEmptyLinesAtEOF: true
|
||||||
LineEnding: CRLF
|
LineEnding: CRLF
|
||||||
@@ -169,7 +169,7 @@ SpaceAfterTemplateKeyword: false # WSO
|
|||||||
SpaceAroundPointerQualifiers: Before # WSO
|
SpaceAroundPointerQualifiers: Before # WSO
|
||||||
SpacesBeforeTrailingComments: 0 # Better 1; 0 ok, 2+ better not.
|
SpacesBeforeTrailingComments: 0 # Better 1; 0 ok, 2+ better not.
|
||||||
Standard: Latest
|
Standard: Latest
|
||||||
TabWidth: 4 # 4 or 2, WSO
|
TabWidth: 2 # 4 or 2, WSO
|
||||||
# UseTab possible values:
|
# UseTab possible values:
|
||||||
# Never
|
# Never
|
||||||
# ForIndentation
|
# ForIndentation
|
||||||
|
|||||||
Generated
+8
@@ -0,0 +1,8 @@
|
|||||||
|
# Default ignored files
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
||||||
|
# Editor-based HTTP Client requests
|
||||||
|
/httpRequests/
|
||||||
|
# Datasource local storage ignored files
|
||||||
|
/dataSources/
|
||||||
|
/dataSources.local.xml
|
||||||
+4
-1
@@ -15,7 +15,10 @@ set(CMAKE_WIN32_EXECUTABLE true)
|
|||||||
include(CTest)
|
include(CTest)
|
||||||
enable_testing()
|
enable_testing()
|
||||||
|
|
||||||
add_executable(${PROJECT_NAME} main.cpp)
|
add_executable(${PROJECT_NAME} main.cpp
|
||||||
|
def.h
|
||||||
|
InteractManager.cpp
|
||||||
|
InteractManager.h)
|
||||||
set(CPACK_PROJECT_NAME ${PROJECT_NAME})
|
set(CPACK_PROJECT_NAME ${PROJECT_NAME})
|
||||||
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
|
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
|
||||||
include(CPack)
|
include(CPack)
|
||||||
|
|||||||
@@ -0,0 +1,265 @@
|
|||||||
|
//
|
||||||
|
// Created by EmsiaetKadosh on 25-1-14.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "InteractManager.h"
|
||||||
|
|
||||||
|
InteractManager::InteractManager() {
|
||||||
|
keyStatus[0x00].name = L"NONE";
|
||||||
|
keyStatus[0x01].name = L"LeftButton";
|
||||||
|
keyStatus[0x02].name = L"RightButton";
|
||||||
|
keyStatus[0x03].name = L"Cancel";
|
||||||
|
keyStatus[0x04].name = L"MiddleButton";
|
||||||
|
keyStatus[0x05].name = L"XButton1";
|
||||||
|
keyStatus[0x06].name = L"XButton2";
|
||||||
|
keyStatus[0x07].name = L"None";
|
||||||
|
keyStatus[0x08].name = L"Backspace";
|
||||||
|
keyStatus[0x09].name = L"Tab";
|
||||||
|
keyStatus[0x0D].name = L"Enter";
|
||||||
|
keyStatus[0x0A].name = L"None";
|
||||||
|
keyStatus[0x0B].name = L"None";
|
||||||
|
keyStatus[0x0C].name = L"Clear";
|
||||||
|
keyStatus[0x0D].name = L"Enter";
|
||||||
|
keyStatus[0x0E].name = L"None";
|
||||||
|
keyStatus[0x0F].name = L"None";
|
||||||
|
keyStatus[0x10].name = L"Shift";
|
||||||
|
keyStatus[0x11].name = L"Ctrl";
|
||||||
|
keyStatus[0x12].name = L"Alt";
|
||||||
|
keyStatus[0x13].name = L"Pause";
|
||||||
|
keyStatus[0x14].name = L"CapsLock";
|
||||||
|
keyStatus[0x15].name = L"IME-KanaHangul";
|
||||||
|
keyStatus[0x16].name = L"IME-ON";
|
||||||
|
keyStatus[0x17].name = L"IME-Junja";
|
||||||
|
keyStatus[0x18].name = L"IME-Final";
|
||||||
|
keyStatus[0x19].name = L"IME-HanjaKanji";
|
||||||
|
keyStatus[0x1A].name = L"IME-OFF";
|
||||||
|
keyStatus[0x1B].name = L"Escape";
|
||||||
|
keyStatus[0x1C].name = L"IME-Convert";
|
||||||
|
keyStatus[0x1D].name = L"IME-NonConvert";
|
||||||
|
keyStatus[0x1E].name = L"IME-Accept";
|
||||||
|
keyStatus[0x1F].name = L"IME-ModeChange";
|
||||||
|
keyStatus[0x20].name = L"Space";
|
||||||
|
keyStatus[0x21].name = L"PageUp";
|
||||||
|
keyStatus[0x22].name = L"PageDown";
|
||||||
|
keyStatus[0x23].name = L"End";
|
||||||
|
keyStatus[0x24].name = L"Home";
|
||||||
|
keyStatus[0x25].name = L"Left";
|
||||||
|
keyStatus[0x26].name = L"Up";
|
||||||
|
keyStatus[0x27].name = L"Right";
|
||||||
|
keyStatus[0x28].name = L"Down";
|
||||||
|
keyStatus[0x29].name = L"Select";
|
||||||
|
keyStatus[0x2A].name = L"Print";
|
||||||
|
keyStatus[0x2B].name = L"Execute";
|
||||||
|
keyStatus[0x2C].name = L"PrintScreen";
|
||||||
|
keyStatus[0x2D].name = L"Insert";
|
||||||
|
keyStatus[0x2E].name = L"Delete";
|
||||||
|
keyStatus[0x2F].name = L"Help";
|
||||||
|
keyStatus[0x30].name = L"0";
|
||||||
|
keyStatus[0x31].name = L"1";
|
||||||
|
keyStatus[0x32].name = L"2";
|
||||||
|
keyStatus[0x33].name = L"3";
|
||||||
|
keyStatus[0x34].name = L"4";
|
||||||
|
keyStatus[0x35].name = L"5";
|
||||||
|
keyStatus[0x36].name = L"6";
|
||||||
|
keyStatus[0x37].name = L"7";
|
||||||
|
keyStatus[0x38].name = L"8";
|
||||||
|
keyStatus[0x39].name = L"9";
|
||||||
|
keyStatus[0x3A].name = L"None";
|
||||||
|
keyStatus[0x3B].name = L"None";
|
||||||
|
keyStatus[0x3C].name = L"None";
|
||||||
|
keyStatus[0x3D].name = L"None";
|
||||||
|
keyStatus[0x3E].name = L"None";
|
||||||
|
keyStatus[0x3F].name = L"None";
|
||||||
|
keyStatus[0x40].name = L"None";
|
||||||
|
keyStatus[0x41].name = L"A";
|
||||||
|
keyStatus[0x42].name = L"B";
|
||||||
|
keyStatus[0x43].name = L"C";
|
||||||
|
keyStatus[0x44].name = L"D";
|
||||||
|
keyStatus[0x45].name = L"E";
|
||||||
|
keyStatus[0x46].name = L"F";
|
||||||
|
keyStatus[0x47].name = L"G";
|
||||||
|
keyStatus[0x48].name = L"H";
|
||||||
|
keyStatus[0x49].name = L"I";
|
||||||
|
keyStatus[0x4A].name = L"J";
|
||||||
|
keyStatus[0x4B].name = L"K";
|
||||||
|
keyStatus[0x4C].name = L"L";
|
||||||
|
keyStatus[0x4D].name = L"M";
|
||||||
|
keyStatus[0x4E].name = L"N";
|
||||||
|
keyStatus[0x4F].name = L"O";
|
||||||
|
keyStatus[0x50].name = L"P";
|
||||||
|
keyStatus[0x51].name = L"Q";
|
||||||
|
keyStatus[0x52].name = L"R";
|
||||||
|
keyStatus[0x53].name = L"S";
|
||||||
|
keyStatus[0x54].name = L"T";
|
||||||
|
keyStatus[0x55].name = L"U";
|
||||||
|
keyStatus[0x56].name = L"V";
|
||||||
|
keyStatus[0x57].name = L"W";
|
||||||
|
keyStatus[0x58].name = L"X";
|
||||||
|
keyStatus[0x59].name = L"Y";
|
||||||
|
keyStatus[0x5A].name = L"Z";
|
||||||
|
keyStatus[0x5B].name = L"LeftWindows";
|
||||||
|
keyStatus[0x5C].name = L"RightWindows";
|
||||||
|
keyStatus[0x5D].name = L"Applications";
|
||||||
|
keyStatus[0x5E].name = L"None";
|
||||||
|
keyStatus[0x5F].name = L"Sleep";
|
||||||
|
keyStatus[0x60].name = L"NUMPAD-0";
|
||||||
|
keyStatus[0x61].name = L"NUMPAD-1";
|
||||||
|
keyStatus[0x62].name = L"NUMPAD-2";
|
||||||
|
keyStatus[0x63].name = L"NUMPAD-3";
|
||||||
|
keyStatus[0x64].name = L"NUMPAD-4";
|
||||||
|
keyStatus[0x65].name = L"NUMPAD-5";
|
||||||
|
keyStatus[0x66].name = L"NUMPAD-6";
|
||||||
|
keyStatus[0x67].name = L"NUMPAD-7";
|
||||||
|
keyStatus[0x68].name = L"NUMPAD-8";
|
||||||
|
keyStatus[0x69].name = L"NUMPAD-9";
|
||||||
|
keyStatus[0x6A].name = L"*";
|
||||||
|
keyStatus[0x6B].name = L"+";
|
||||||
|
keyStatus[0x6C].name = L"·";
|
||||||
|
keyStatus[0x6D].name = L"-";
|
||||||
|
keyStatus[0x6E].name = L".";
|
||||||
|
keyStatus[0x6F].name = L"/";
|
||||||
|
keyStatus[0x70].name = L"F1";
|
||||||
|
keyStatus[0x71].name = L"F2";
|
||||||
|
keyStatus[0x72].name = L"F3";
|
||||||
|
keyStatus[0x73].name = L"F4";
|
||||||
|
keyStatus[0x74].name = L"F5";
|
||||||
|
keyStatus[0x75].name = L"F6";
|
||||||
|
keyStatus[0x76].name = L"F7";
|
||||||
|
keyStatus[0x77].name = L"F8";
|
||||||
|
keyStatus[0x78].name = L"F9";
|
||||||
|
keyStatus[0x79].name = L"F10";
|
||||||
|
keyStatus[0x7A].name = L"F11";
|
||||||
|
keyStatus[0x7B].name = L"F12";
|
||||||
|
keyStatus[0x7C].name = L"F13";
|
||||||
|
keyStatus[0x7D].name = L"F14";
|
||||||
|
keyStatus[0x7E].name = L"F15";
|
||||||
|
keyStatus[0x7F].name = L"F16";
|
||||||
|
keyStatus[0x80].name = L"F17";
|
||||||
|
keyStatus[0x81].name = L"F18";
|
||||||
|
keyStatus[0x82].name = L"F19";
|
||||||
|
keyStatus[0x83].name = L"F20";
|
||||||
|
keyStatus[0x84].name = L"F21";
|
||||||
|
keyStatus[0x85].name = L"F22";
|
||||||
|
keyStatus[0x86].name = L"F23";
|
||||||
|
keyStatus[0x87].name = L"F24";
|
||||||
|
keyStatus[0x88].name = L"None";
|
||||||
|
keyStatus[0x89].name = L"None";
|
||||||
|
keyStatus[0x8A].name = L"None";
|
||||||
|
keyStatus[0x8B].name = L"None";
|
||||||
|
keyStatus[0x8C].name = L"None";
|
||||||
|
keyStatus[0x8D].name = L"None";
|
||||||
|
keyStatus[0x8E].name = L"None";
|
||||||
|
keyStatus[0x8F].name = L"None";
|
||||||
|
keyStatus[0x90].name = L"NumLock";
|
||||||
|
keyStatus[0x91].name = L"ScrollLock";
|
||||||
|
keyStatus[0x92].name = L"None";
|
||||||
|
keyStatus[0x93].name = L"None";
|
||||||
|
keyStatus[0x94].name = L"None";
|
||||||
|
keyStatus[0x95].name = L"None";
|
||||||
|
keyStatus[0x96].name = L"None";
|
||||||
|
keyStatus[0x97].name = L"None";
|
||||||
|
keyStatus[0x98].name = L"None";
|
||||||
|
keyStatus[0x99].name = L"None";
|
||||||
|
keyStatus[0x9A].name = L"None";
|
||||||
|
keyStatus[0x9B].name = L"None";
|
||||||
|
keyStatus[0x9C].name = L"None";
|
||||||
|
keyStatus[0x9D].name = L"None";
|
||||||
|
keyStatus[0x9E].name = L"None";
|
||||||
|
keyStatus[0x9F].name = L"None";
|
||||||
|
keyStatus[0xA0].name = L"LeftShift";
|
||||||
|
keyStatus[0xA1].name = L"RightShift";
|
||||||
|
keyStatus[0xA2].name = L"LeftCtrl";
|
||||||
|
keyStatus[0xA3].name = L"RightCtrl";
|
||||||
|
keyStatus[0xA4].name = L"LeftAlt";
|
||||||
|
keyStatus[0xA5].name = L"RightAlt";
|
||||||
|
keyStatus[0xA6].name = L"BrowserBack";
|
||||||
|
keyStatus[0xA7].name = L"BrowserForward";
|
||||||
|
keyStatus[0xA8].name = L"BrowserRefresh";
|
||||||
|
keyStatus[0xA9].name = L"BrowserStop";
|
||||||
|
keyStatus[0xAA].name = L"BrowserSearch";
|
||||||
|
keyStatus[0xAB].name = L"BrowserFavorites";
|
||||||
|
keyStatus[0xAC].name = L"BrowserHome";
|
||||||
|
keyStatus[0xAD].name = L"VolumeMute";
|
||||||
|
keyStatus[0xAE].name = L"VolumeDown";
|
||||||
|
keyStatus[0xAF].name = L"VolumeUp";
|
||||||
|
keyStatus[0xB0].name = L"MediaNextTrack";
|
||||||
|
keyStatus[0xB1].name = L"MediaPrevTrack";
|
||||||
|
keyStatus[0xB2].name = L"MediaStop";
|
||||||
|
keyStatus[0xB3].name = L"MediaPlayPause";
|
||||||
|
keyStatus[0xB4].name = L"LaunchMail";
|
||||||
|
keyStatus[0xB5].name = L"LaunchMediaSelect";
|
||||||
|
keyStatus[0xB6].name = L"LaunchApp1";
|
||||||
|
keyStatus[0xB7].name = L"LaunchApp2";
|
||||||
|
keyStatus[0xB8].name = L"None";
|
||||||
|
keyStatus[0xB9].name = L"None";
|
||||||
|
keyStatus[0xBA].name = L"OEM-1;:";
|
||||||
|
keyStatus[0xBB].name = L"OEM+";
|
||||||
|
keyStatus[0xBC].name = L"OEM,";
|
||||||
|
keyStatus[0xBD].name = L"OEM-";
|
||||||
|
keyStatus[0xBE].name = L"OEM.";
|
||||||
|
keyStatus[0xBF].name = L"OEM-2/?";
|
||||||
|
keyStatus[0xC0].name = L"OEM-3`~";
|
||||||
|
keyStatus[0xC1].name = L"None";
|
||||||
|
keyStatus[0xC2].name = L"None";
|
||||||
|
keyStatus[0xC3].name = L"None";
|
||||||
|
keyStatus[0xC4].name = L"None";
|
||||||
|
keyStatus[0xC5].name = L"None";
|
||||||
|
keyStatus[0xC6].name = L"None";
|
||||||
|
keyStatus[0xC7].name = L"None";
|
||||||
|
keyStatus[0xC8].name = L"None";
|
||||||
|
keyStatus[0xC9].name = L"None";
|
||||||
|
keyStatus[0xCA].name = L"None";
|
||||||
|
keyStatus[0xCB].name = L"None";
|
||||||
|
keyStatus[0xCC].name = L"None";
|
||||||
|
keyStatus[0xCD].name = L"None";
|
||||||
|
keyStatus[0xCE].name = L"None";
|
||||||
|
keyStatus[0xCF].name = L"None";
|
||||||
|
keyStatus[0xD0].name = L"None";
|
||||||
|
keyStatus[0xD1].name = L"None";
|
||||||
|
keyStatus[0xD2].name = L"None";
|
||||||
|
keyStatus[0xD3].name = L"None";
|
||||||
|
keyStatus[0xD4].name = L"None";
|
||||||
|
keyStatus[0xD5].name = L"None";
|
||||||
|
keyStatus[0xD6].name = L"None";
|
||||||
|
keyStatus[0xD7].name = L"None";
|
||||||
|
keyStatus[0xD8].name = L"None";
|
||||||
|
keyStatus[0xD9].name = L"None";
|
||||||
|
keyStatus[0xDA].name = L"None";
|
||||||
|
keyStatus[0xDB].name = L"OEM-4{[";
|
||||||
|
keyStatus[0xDC].name = L"OEM-5|\\";
|
||||||
|
keyStatus[0xDD].name = L"OEM-6}]";
|
||||||
|
keyStatus[0xDE].name = L"OEM-7'\"";
|
||||||
|
keyStatus[0xDF].name = L"OEM-8";
|
||||||
|
keyStatus[0xE0].name = L"None";
|
||||||
|
keyStatus[0xE1].name = L"None";
|
||||||
|
keyStatus[0xE2].name = L"OEM-102<>";
|
||||||
|
keyStatus[0xE3].name = L"None";
|
||||||
|
keyStatus[0xE4].name = L"None";
|
||||||
|
keyStatus[0xE5].name = L"IME-ProcessKey";
|
||||||
|
keyStatus[0xE6].name = L"None";
|
||||||
|
keyStatus[0xE7].name = L"IME-Packet";
|
||||||
|
keyStatus[0xE8].name = L"None";
|
||||||
|
keyStatus[0xE9].name = L"None";
|
||||||
|
keyStatus[0xEA].name = L"None";
|
||||||
|
keyStatus[0xEB].name = L"None";
|
||||||
|
keyStatus[0xEC].name = L"None";
|
||||||
|
keyStatus[0xED].name = L"None";
|
||||||
|
keyStatus[0xEE].name = L"None";
|
||||||
|
keyStatus[0xEF].name = L"None";
|
||||||
|
keyStatus[0xF0].name = L"None";
|
||||||
|
keyStatus[0xF1].name = L"None";
|
||||||
|
keyStatus[0xF2].name = L"None";
|
||||||
|
keyStatus[0xF3].name = L"None";
|
||||||
|
keyStatus[0xF4].name = L"None";
|
||||||
|
keyStatus[0xF5].name = L"None";
|
||||||
|
keyStatus[0xF6].name = L"Attn";
|
||||||
|
keyStatus[0xF7].name = L"CrSel";
|
||||||
|
keyStatus[0xF8].name = L"ExSel";
|
||||||
|
keyStatus[0xF9].name = L"ErEof";
|
||||||
|
keyStatus[0xFA].name = L"Play";
|
||||||
|
keyStatus[0xFB].name = L"Zoom";
|
||||||
|
keyStatus[0xFC].name = L"None";
|
||||||
|
keyStatus[0xFD].name = L"PA1";
|
||||||
|
keyStatus[0xFE].name = L"OEM-Clear";
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
//
|
||||||
|
// Created by EmsiaetKadosh on 25-1-14.
|
||||||
|
//
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "def.h"
|
||||||
|
|
||||||
|
struct KeyStatus {
|
||||||
|
String name;
|
||||||
|
unsigned int pressTimes = 0;
|
||||||
|
bool isPressed = false;
|
||||||
|
bool notDealt = false;
|
||||||
|
|
||||||
|
[[nodiscard]] String toString() const noexcept {
|
||||||
|
return L"name: " + name + L" pressTimes: " + std::to_wstring(pressTimes) + L" isPressed";
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class InteractManager {
|
||||||
|
KeyStatus keyStatus[256];
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit InteractManager();
|
||||||
|
|
||||||
|
void update(const int keyCode, const bool isPressed) noexcept {
|
||||||
|
if (keyCode >= 256) return;
|
||||||
|
keyStatus[keyCode].isPressed = isPressed;
|
||||||
|
if (isPressed) {
|
||||||
|
keyStatus[keyCode].pressTimes++;
|
||||||
|
keyStatus[keyCode].notDealt = true;
|
||||||
|
}
|
||||||
|
std::wcout << keyStatus[keyCode].toString() << std::endl;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
inline static InteractManager interactManager = InteractManager();
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
//
|
||||||
|
// Created by EmsiaetKadosh on 25-1-14.
|
||||||
|
//
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <string>
|
||||||
|
#include <map>
|
||||||
|
|
||||||
|
using String = std::wstring;
|
||||||
|
template<typename K, typename V, typename Cmp = std::less<K>, typename Alloc = std::allocator<std::pair<const K, V>>> using Map = std::map<K, V, Cmp, Alloc>;
|
||||||
|
|
||||||
|
#if false
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#define __FUNCSIGW__ L"" __FUNCSIG__
|
||||||
|
#elif defined(__GNUC__) || defined(__clang__)
|
||||||
|
#define __FUNCSIGW__ L"" __PRETTY_FUNCTION__
|
||||||
|
#else
|
||||||
|
#define __FUNCSIGW__ L"" __func__
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if false
|
||||||
|
#define _WINSOCKAPI_ /* 防止winsock.h被引入。winsock.h和winsock2.h冲突。 */
|
||||||
|
#include <WinSock2.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define NOMINMAX
|
||||||
|
#include <Windows.h>
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "def.h"
|
||||||
|
|
||||||
|
|
||||||
|
inline BOOL NewProcess(const String& cmdline) noexcept {
|
||||||
|
STARTUPINFOW si = {
|
||||||
|
sizeof(si), nullptr, nullptr, nullptr, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, nullptr, nullptr, nullptr, nullptr
|
||||||
|
};
|
||||||
|
PROCESS_INFORMATION pi{
|
||||||
|
nullptr, nullptr, 0, 0
|
||||||
|
};
|
||||||
|
return CreateProcessW(nullptr, const_cast<wchar*>(cmdline.c_str()), nullptr, nullptr, 0, 0, nullptr, nullptr, &si, &pi);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline HRESULT RemoveDefaultCaption(const HWND hWnd, const MARGINS* p) noexcept { return DwmExtendFrameIntoClientArea(hWnd, p); }
|
||||||
|
|
||||||
|
inline void ShowConsoleIO() noexcept {
|
||||||
|
AllocConsole();
|
||||||
|
FILE* pCout;
|
||||||
|
freopen_s(&pCout, "CONOUT$", "w", stdout);
|
||||||
|
FILE* pCin;
|
||||||
|
freopen_s(&pCin, "CONIN$", "r", stdin);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline const String ApplicationName = L"Hyblud Presher";
|
||||||
|
inline HINSTANCE MainInstance;
|
||||||
|
inline HWND MainWindowHandle;
|
||||||
|
|
||||||
|
inline void Initialize() {}
|
||||||
|
|
||||||
|
inline void Finalize() {}
|
||||||
@@ -1,67 +1,45 @@
|
|||||||
|
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
#include <consoleapi.h>
|
|
||||||
#include <corecrt_wprocess.h>
|
|
||||||
#include <minwindef.h>
|
#include <minwindef.h>
|
||||||
#include <windef.h>
|
#include <windef.h>
|
||||||
#include <wingdi.h>
|
#include <wingdi.h>
|
||||||
#include <winuser.h>
|
#include <winuser.h>
|
||||||
#include <Uxtheme.h>
|
#include <Uxtheme.h>
|
||||||
#include <vssym32.h>
|
#include <iostream>
|
||||||
|
#include <dwmapi.h>
|
||||||
|
|
||||||
#include "../CarlbeksLib/iwindows.h"
|
#include "hbp.h"
|
||||||
|
#include "InteractManager.h"
|
||||||
#include "core.h"
|
|
||||||
|
|
||||||
LRESULT __stdcall WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
|
LRESULT __stdcall WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
|
||||||
switch (uMsg) {
|
switch (uMsg) {
|
||||||
[[likely]] case WM_PAINT: {
|
_LIKELY
|
||||||
|
case WM_PAINT: {
|
||||||
PAINTSTRUCT ps;
|
PAINTSTRUCT ps;
|
||||||
HDC hdc = BeginPaint(hwnd, &ps); // Paint caption
|
HDC hdc = BeginPaint(hwnd, &ps);// Paint caption
|
||||||
MainWindow.fireRender();
|
|
||||||
EndPaint(hwnd, &ps);
|
EndPaint(hwnd, &ps);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case WM_LBUTTONDOWN:
|
case WM_LBUTTONDOWN: interactManager.update(VK_LBUTTON, true);
|
||||||
MainWindow.fireMouseDown(Carlbeks::UI::MA_LEFT);
|
|
||||||
MainWindow.fireRender();
|
|
||||||
break;
|
break;
|
||||||
case WM_RBUTTONDOWN:
|
case WM_RBUTTONDOWN: interactManager.update(VK_RBUTTON, true);
|
||||||
MainWindow.fireMouseDown(Carlbeks::UI::MA_RIGHT);
|
|
||||||
MainWindow.fireRender();
|
|
||||||
break;
|
break;
|
||||||
case WM_LBUTTONUP:
|
case WM_LBUTTONUP: interactManager.update(VK_LBUTTON, false);
|
||||||
MainWindow.fireMouseUp(Carlbeks::UI::MA_LEFT);
|
|
||||||
MainWindow.fireRender();
|
|
||||||
break;
|
break;
|
||||||
case WM_RBUTTONUP:
|
case WM_RBUTTONUP: interactManager.update(VK_RBUTTON, false);
|
||||||
MainWindow.fireMouseUp(Carlbeks::UI::MA_RIGHT);
|
|
||||||
MainWindow.fireRender();
|
|
||||||
break;
|
break;
|
||||||
[[likely]] case WM_NCHITTEST: {
|
_LIKELY
|
||||||
Carlbeks::UI::UIReturn ret = MainWindow.fireMouseMove();
|
case WM_NCHITTEST: {
|
||||||
MainWindow.fireRender();
|
|
||||||
if (ret & 0x20) return ret ^ 0x20;
|
|
||||||
return HTCLIENT;
|
|
||||||
LRESULT lr = 0;
|
LRESULT lr = 0;
|
||||||
BOOL r = DwmDefWindowProc(hwnd, uMsg, wParam, lParam, &lr);
|
BOOL r = DwmDefWindowProc(hwnd, uMsg, wParam, lParam, &lr);
|
||||||
return lr;
|
return lr;
|
||||||
}
|
}
|
||||||
[[likely]] case WM_MOUSEMOVE: {
|
case WM_MOUSEMOVE: { break; }
|
||||||
MainWindow.fireMouseMove();
|
case WM_MBUTTONDOWN: interactManager.update(VK_MBUTTON, true);
|
||||||
// MainWindow.fireRender();
|
|
||||||
break;
|
break;
|
||||||
}
|
case WM_MBUTTONUP: interactManager.update(VK_MBUTTON, false);
|
||||||
[[unlikely]] case WM_MBUTTONDOWN:
|
|
||||||
MainWindow.fireMouseDown(Carlbeks::UI::MA_MID);
|
|
||||||
MainWindow.fireRender();
|
|
||||||
break;
|
break;
|
||||||
[[unlikely]] case WM_MBUTTONUP:
|
case WM_COMMAND: std::wcout << L"WM_COMMAND" << std::endl;
|
||||||
MainWindow.fireMouseUp(Carlbeks::UI::MA_MID);
|
|
||||||
MainWindow.fireRender();
|
|
||||||
break;
|
|
||||||
[[unlikely]] case WM_COMMAND:
|
|
||||||
std::wcout << L"WM_COMMAND" << std::endl;
|
|
||||||
break;
|
break;
|
||||||
case WM_DWMCOMPOSITIONCHANGED: {
|
case WM_DWMCOMPOSITIONCHANGED: {
|
||||||
MARGINS margins{
|
MARGINS margins{
|
||||||
@@ -70,11 +48,10 @@ LRESULT __stdcall WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
|
|||||||
.cyTopHeight = 0,
|
.cyTopHeight = 0,
|
||||||
.cyBottomHeight = 0
|
.cyBottomHeight = 0
|
||||||
};
|
};
|
||||||
HRESULT hr = Carlbeks::WindowsInterface::RemoveDefaultCaption(hwnd, &margins);
|
HRESULT hr = RemoveDefaultCaption(hwnd, &margins);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case WM_NCCALCSIZE:
|
case WM_NCCALCSIZE: if (wParam == 1) {
|
||||||
if (wParam == 1) {
|
|
||||||
NCCALCSIZE_PARAMS* pncsp = reinterpret_cast<NCCALCSIZE_PARAMS*>(lParam);
|
NCCALCSIZE_PARAMS* pncsp = reinterpret_cast<NCCALCSIZE_PARAMS*>(lParam);
|
||||||
pncsp->rgrc[0].left = pncsp->rgrc[0].left + 0;
|
pncsp->rgrc[0].left = pncsp->rgrc[0].left + 0;
|
||||||
pncsp->rgrc[0].top = pncsp->rgrc[0].top + 0;
|
pncsp->rgrc[0].top = pncsp->rgrc[0].top + 0;
|
||||||
@@ -82,9 +59,14 @@ LRESULT __stdcall WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
|
|||||||
pncsp->rgrc[0].bottom = pncsp->rgrc[0].bottom - 0;
|
pncsp->rgrc[0].bottom = pncsp->rgrc[0].bottom - 0;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
case WM_SIZE:
|
case WM_SIZE: switch (wParam) {
|
||||||
MainWindow.fireResize();
|
case SIZE_RESTORED: break;
|
||||||
MainWindow.fireRender();
|
case SIZE_MINIMIZED: break;
|
||||||
|
case SIZE_MAXIMIZED: break;
|
||||||
|
case SIZE_MAXSHOW:
|
||||||
|
case SIZE_MAXHIDE:
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case WM_ACTIVATE: {
|
case WM_ACTIVATE: {
|
||||||
MARGINS margins{
|
MARGINS margins{
|
||||||
@@ -93,21 +75,22 @@ LRESULT __stdcall WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
|
|||||||
.cyTopHeight = 0,
|
.cyTopHeight = 0,
|
||||||
.cyBottomHeight = 0
|
.cyBottomHeight = 0
|
||||||
};
|
};
|
||||||
HRESULT hr = Carlbeks::WindowsInterface::RemoveDefaultCaption(hwnd, &margins);
|
HRESULT hr = RemoveDefaultCaption(hwnd, &margins);
|
||||||
} break;
|
}
|
||||||
[[unlikely]] case WM_DESTROY:
|
|
||||||
PostQuitMessage(0);
|
|
||||||
return 0;
|
|
||||||
[[unlikely]] case WM_CREATE:
|
|
||||||
SetWindowPos(hwnd, NULL, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOOWNERZORDER); // Force post NCCALCSIZE
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
break;
|
||||||
|
_UNLIKELY
|
||||||
|
case WM_DESTROY: PostQuitMessage(0);
|
||||||
|
return 0;
|
||||||
|
_UNLIKELY
|
||||||
|
case WM_CREATE: SetWindowPos(hwnd, nullptr, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOOWNERZORDER);// Force post NCCALCSIZE
|
||||||
|
break;
|
||||||
|
default: break;
|
||||||
}
|
}
|
||||||
return DefWindowProc(hwnd, uMsg, wParam, lParam);
|
return DefWindowProc(hwnd, uMsg, wParam, lParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
int __stdcall wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow) {
|
int __stdcall wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nCmdShow) {
|
||||||
|
AllocConsole();
|
||||||
WNDCLASSEX wc = { 0 };
|
WNDCLASSEX wc = { 0 };
|
||||||
wc.cbSize = sizeof(WNDCLASSEX);
|
wc.cbSize = sizeof(WNDCLASSEX);
|
||||||
wc.style = CS_HREDRAW | CS_VREDRAW;
|
wc.style = CS_HREDRAW | CS_VREDRAW;
|
||||||
@@ -115,26 +98,24 @@ int __stdcall wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCm
|
|||||||
wc.cbClsExtra = 0;
|
wc.cbClsExtra = 0;
|
||||||
wc.cbWndExtra = 0;
|
wc.cbWndExtra = 0;
|
||||||
wc.hInstance = hInstance;
|
wc.hInstance = hInstance;
|
||||||
wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
|
wc.hIcon = LoadIcon(nullptr, IDI_APPLICATION);
|
||||||
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
|
wc.hCursor = LoadCursor(nullptr, IDC_ARROW);
|
||||||
wc.hbrBackground = (HBRUSH) GetStockObject(BLACK_BRUSH);
|
wc.hbrBackground = (HBRUSH) GetStockObject(BLACK_BRUSH);
|
||||||
wc.lpszMenuName = L"None";
|
wc.lpszMenuName = L"None";
|
||||||
wc.lpszClassName = ApplicationName.c_str();
|
wc.lpszClassName = ApplicationName.c_str();
|
||||||
if (!RegisterClassExW(&wc)) return FALSE;
|
if (!RegisterClassExW(&wc)) return FALSE;
|
||||||
MainInstance = hInstance;
|
MainInstance = hInstance;
|
||||||
MainWindowHandle = CreateWindowExW(0, wc.lpszClassName, wc.lpszClassName, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL);
|
MainWindowHandle = CreateWindowExW(0, wc.lpszClassName, wc.lpszClassName, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, nullptr, nullptr, hInstance, nullptr);
|
||||||
ShowWindow(MainWindowHandle, nCmdShow);
|
ShowWindow(MainWindowHandle, nCmdShow);
|
||||||
Initialize();
|
Initialize();
|
||||||
MainWindow.fireResize();
|
|
||||||
HACCEL hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(109));
|
HACCEL hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(109));
|
||||||
MSG msg = { 0 };
|
MSG msg = { nullptr };
|
||||||
while (GetMessageW(&msg, NULL, 0, 0)) {
|
while (GetMessageW(&msg, nullptr, 0, 0)) {
|
||||||
if (!TranslateAcceleratorW(msg.hwnd, hAccelTable, &msg)) {
|
if (!TranslateAcceleratorW(msg.hwnd, hAccelTable, &msg)) {
|
||||||
TranslateMessage(&msg);
|
TranslateMessage(&msg);
|
||||||
DispatchMessageW(&msg);
|
DispatchMessageW(&msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DestroyAcceleratorTable(hAccelTable);
|
DestroyAcceleratorTable(hAccelTable);
|
||||||
Finalize();
|
|
||||||
return (int) msg.wParam;
|
return (int) msg.wParam;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user