Skip to content

Commit

Permalink
print trace output on device change
Browse files Browse the repository at this point in the history
  • Loading branch information
cajhin committed Nov 16, 2023
1 parent 13c81ee commit 23312cb
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
26 changes: 24 additions & 2 deletions capsicain/capsicain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
#include "scancodes.h"
#include "resource.h"
#include "led.h"
#include <chrono>

using namespace std;


//try out if we can play doom when we have a TMK style temp layer shift key
/*
int TESTING_LAYER_SHIFT_KEY = SC_APPS;
Expand Down Expand Up @@ -80,6 +80,7 @@ struct AllMaps

struct InterceptionState
{
int newKeyboardCounter = 0;
InterceptionContext interceptionContext = NULL;
InterceptionDevice interceptionDevice = NULL;
InterceptionDevice previousInterceptionDevice = NULL;
Expand Down Expand Up @@ -177,6 +178,16 @@ void error(string txt)
errorLog += "\r\n" + txt;
}

string getTimestamp()
{
auto start = std::chrono::system_clock::now();
auto legacyStart = std::chrono::system_clock::to_time_t(start);
char tmBuff[30];
ctime_s(tmBuff, sizeof(tmBuff), &legacyStart);
return tmBuff;
}


string getPrettyVKLabelPadded(int vcode, int resultLength)
{
string label = PRETTY_VK_LABELS[vcode];
Expand Down Expand Up @@ -310,7 +321,18 @@ int main()
|| interceptionState.previousInterceptionDevice != interceptionState.interceptionDevice) //keyboard changed
{
getHardwareId();
cout << endl << "new keyboard: " << (globalState.deviceIsAppleKeyboard ? "Apple keyboard" : "IBM keyboard") << endl;
//detail to debug the "new device after sleep, reboot after 10 new devices"
cout << endl
<< "<" << endl
<< "new keyboard: " << (globalState.deviceIsAppleKeyboard ? "Apple keyboard" : "IBM keyboard") << endl
<< "new keyboard count: " << interceptionState.newKeyboardCounter << endl
<< "keyboard device id: " << globalState.deviceIdKeyboard << endl
<< "interceptionDevice: " << interceptionState.interceptionDevice << endl
<< getTimestamp() << endl
<< ">" << endl;



interceptionState.previousInterceptionDevice = interceptionState.interceptionDevice;
}

Expand Down
2 changes: 1 addition & 1 deletion capsicain/constants.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#define VERSION "95"
#define VERSION "96"

//arbitray limits
#define MAX_VCODES 0x121 //biggest defined code in scancodes.h must be smaller than this
Expand Down
Binary file modified x64/Release/capsicain.exe
Binary file not shown.

0 comments on commit 23312cb

Please sign in to comment.