Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 0 additions & 46 deletions .github/workflows/snapkey.yml

This file was deleted.

14 changes: 0 additions & 14 deletions Build SnapKey/CMAKE-Build/CMake-Build.bat

This file was deleted.

18 changes: 0 additions & 18 deletions Build SnapKey/CMAKE-Build/CMakeLists.txt

This file was deleted.

1 change: 0 additions & 1 deletion Build SnapKey/CMAKE-Build/resources.rc

This file was deleted.

20 changes: 0 additions & 20 deletions Build SnapKey/MSYS-Build/MSYS-Build.bat

This file was deleted.

17 changes: 0 additions & 17 deletions Build SnapKey/MSYS-Build/MSYS-Build.sh

This file was deleted.

32 changes: 0 additions & 32 deletions Build SnapKey/MSYS-Build/resources.rc

This file was deleted.

60 changes: 0 additions & 60 deletions Build SnapKey/Setup-Build/setup.iss

This file was deleted.

Binary file removed Build SnapKey/Setup-Build/wizard_large.bmp
Binary file not shown.
Binary file removed Build SnapKey/Setup-Build/wizard_large.xcf
Binary file not shown.
Binary file removed Build SnapKey/Setup-Build/wizard_small.bmp
Binary file not shown.
10 changes: 10 additions & 0 deletions Emitter.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#include <windows.h>
#include "InputState.h"

void SendKey(WORD vk, bool down) {
INPUT input = {};
input.type = INPUT_KEYBOARD;
input.ki.wVk = vk;
input.ki.dwFlags = down ? 0 : KEYEVENTF_KEYUP;
SendInput(1, &input, sizeof(INPUT));
}
99 changes: 99 additions & 0 deletions Hooks.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
#include <windows.h>
#include "InputState.h"

HHOOK keyboardHook = NULL;
HHOOK mouseHook = NULL;

/* =========================
KEYBOARD HOOK
========================= */
LRESULT CALLBACK KeyboardProc(int nCode, WPARAM wParam, LPARAM lParam) {
if (nCode == HC_ACTION) {
KBDLLHOOKSTRUCT* k = (KBDLLHOOKSTRUCT*)lParam;

// Ignore injected input
if (k->flags & LLKHF_INJECTED) {
return CallNextHookEx(NULL, nCode, wParam, lParam);
}

bool isKeyDown = (wParam == WM_KEYDOWN || wParam == WM_SYSKEYDOWN);
bool isKeyUp = (wParam == WM_KEYUP || wParam == WM_SYSKEYUP);

if (isKeyDown || isKeyUp) {

switch (k->vkCode) {

case 'A':
if (isKeyDown && !pA) { pA = true; lastH = 'A'; }
else if (isKeyUp) { pA = false; }
break;

case 'D':
if (isKeyDown && !pD) { pD = true; lastH = 'D'; }
else if (isKeyUp) { pD = false; }
break;

case 'W':
if (isKeyDown && !pW) { pW = true; lastV = 'W'; }
else if (isKeyUp) { pW = false; }
break;

case 'S':
if (isKeyDown && !pS) { pS = true; lastV = 'S'; }
else if (isKeyUp) { pS = false; }
break;

default:
break;
}

Update();

// Block raw WASD ONLY when enabled
if (g_enabled &&
(k->vkCode == 'W' || k->vkCode == 'A' ||
k->vkCode == 'S' || k->vkCode == 'D')) {
return 1;
}
}
}

return CallNextHookEx(NULL, nCode, wParam, lParam);
}

/* =========================
MOUSE HOOK
========================= */
LRESULT CALLBACK MouseProc(int nCode, WPARAM wParam, LPARAM lParam) {
if (nCode == HC_ACTION) {
if (wParam == WM_LBUTTONDOWN) {
pFire = true;
Update();
} else if (wParam == WM_LBUTTONUP) {
pFire = false;
Update();
}
}
return CallNextHookEx(NULL, nCode, wParam, lParam);
}

/* =========================
INSTALL
========================= */
void InstallKeyboardHook() {
keyboardHook = SetWindowsHookEx(
WH_KEYBOARD_LL,
KeyboardProc,
NULL,
0
);
}

void InstallMouseHook() {
mouseHook = SetWindowsHookEx(
WH_MOUSE_LL,
MouseProc,
NULL,
0
);
}
63 changes: 63 additions & 0 deletions InputState.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#pragma once
#include <windows.h>

// =========================
// PHYSICAL STATE
// =========================
extern bool pW, pA, pS, pD;
extern bool pFire;

// =========================
// FEATURE TOGGLES
// =========================
extern bool g_socd_enabled;
extern bool g_mouse_override_enabled;

// =========================
// AXIS-SPECIFIC SOCD TOGGLES
// =========================
extern bool g_socd_x_enabled; // A / D
extern bool g_socd_y_enabled; // W / S


// =========================
// SOCD-RESOLVED STATE
// =========================
extern bool sW, sA, sS, sD;

// =========================
// FINAL OUTPUT STATE
// =========================
extern bool lW, lA, lS, lD;

// =========================
// PREVIOUS OUTPUT STATE
// =========================
extern bool prevW, prevA, prevS, prevD;

// =========================
// LAST PRESSED (SOCD)
// =========================
extern char lastH;
extern char lastV;

// =========================
// APP STATE
// =========================
extern bool g_enabled;

// =========================
// CORE
// =========================
void Update();

// =========================
// HOOKS
// =========================
void InstallKeyboardHook();
void InstallMouseHook();

// =========================
// EMISSION
// =========================
void SendKey(WORD vk, bool down);
Loading