📄 real time input.cpp
字号:
// Real Time Input.cpp : Defines the entry point for the application.
//
#include "stdafx.h"
#include "Mouse.h"
#include "Keyboard.h"
#include "InputMgrSys_t.h"
#include "KeyboardMgr_t.h"
#include "resource.h"
class SampleKeyEvent : public Key_Event
{
public:
SampleKeyEvent(HWND inWindow, int inID, string inString)
{
m_Window = inWindow;
m_String = inString;
m_ID = inID;
}
virtual void ProcessEvent(void)
{
SetDlgItemText(m_Window, m_ID, m_String.c_str());
}
HWND m_Window;
string m_String;
int m_ID;
};
/* global objects (kids, dont try this at home) */
KeyboardMgr_t gHotKeyManager;
InputMgrSys_t gInputSystem;
BOOL DlgOnInitDialog(HWND hwnd, HWND hwndFocus, LPARAM lParam)
{
SetWindowText(hwnd,_T("Keyboard--test"));
return 0;
}
BOOL DlgOnCommand(HWND hwnd, int id, HWND hwndCtl, UINT codeNotify)
{
switch(id)
{
case IDCANCEL:
DestroyWindow(hwnd);
PostQuitMessage(0);break;
default:break;
}
return 0;
}
BOOL CALLBACK DlgProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam)
{
switch(uMsg)
{
HANDLE_MSG(hWnd,WM_INITDIALOG,DlgOnInitDialog);
HANDLE_MSG(hWnd,WM_COMMAND,DlgOnCommand);
}
return 0;
}
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
// TODO: Place code here.
HWND hWnd = CreateDialog(hInstance,MAKEINTRESOURCE(IDD_FORMVIEW),0,DlgProc);
if ( gInputSystem.Create() )
{
if ( gInputSystem.CreateKeyboardDevice() )
{
if ( gInputSystem.SetKeyboardBehavior((void*)hWnd,DISCL_BACKGROUND | DISCL_NONEXCLUSIVE) )
{
Hot_Key * Key_Ctrl_B = new Hot_Key("GoToBreak",
Key(DIK_B,kismsCtrl),
new SampleKeyEvent(hWnd, IDC_STATE, "Go To Break - Just Pressed"),
new SampleKeyEvent(hWnd, IDC_STATE, "Go To Break - Pressed"),
new SampleKeyEvent(hWnd, IDC_STATE, "Go To Break - Just Released"));
Hot_Key * Key_H = new Hot_Key("GoToHelp",
Key(DIK_H,kismsShift),
new SampleKeyEvent(hWnd, IDC_STATE, "Go To Help - Just Pressed"),
new SampleKeyEvent(hWnd, IDC_STATE, "Go To Help - Pressed"),
new SampleKeyEvent(hWnd, IDC_STATE, "Go To Help - Just Released"));
gHotKeyManager.SetKeyboardMap(Key_Ctrl_B);
gHotKeyManager.SetKeyboardMap(Key_H);
ShowWindow(hWnd,nCmdShow);
UpdateWindow(hWnd);
MSG theMessage = {0};
while (GetMessage(&theMessage, NULL, NULL, NULL))
{
if (!IsWindow(hWnd) || !IsDialogMessage(hWnd, &theMessage))
{
TranslateMessage(&theMessage);
DispatchMessage(&theMessage);
}
else
{
gInputSystem.UpdateKeyboard();
gHotKeyManager.FireEvent(gInputSystem.GetJustPressedKeys(), gInputSystem.GetPressedKeys(),
gInputSystem.GetJustUnPressedKeys());
}
}
}
}
}
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -