Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Features for momentary and toggle layers, properly held keys, more combo triggers, etc #101

Open
wants to merge 47 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
d608a4c
add hold() function for momentary layer effect
Dregu Jan 26, 2024
4fb7e48
what happened to these
Dregu Jan 26, 2024
eba421d
fix replacing holdkeys twice, oops
Dregu Jan 26, 2024
a278164
support multiple keys in hold()
Dregu Jan 26, 2024
8d82c41
use combo() syntax instead of _ in hold()
Dregu Jan 27, 2024
6ce854d
block physical modifier up when included in hold, add moddedhold to r…
Dregu Jan 27, 2024
ff53a40
support modifier strings in hold functions
Dregu Jan 27, 2024
d2b0f0a
make most functions accept any key/combo format
Dregu Jan 27, 2024
1ed5982
fix .... modstrings breaking old behavior, silently ignore invalid ke…
Dregu Jan 27, 2024
997b19f
add option HoldRepeatsAllKeys and repeat only last key by default
Dregu Jan 27, 2024
c7f530c
fix hold with rewired keys
Dregu Jan 27, 2024
912b487
add more tap/hold modstrings
Dregu Jan 27, 2024
5bc79b3
add pretty labels for virtual keys
Dregu Jan 27, 2024
f88ffe8
add holdmods() to hold combo modifiers with physical mod and keys wit…
Dregu Jan 28, 2024
878f0a6
add type modifiers for key() function to clear the mess
Dregu Jan 28, 2024
839f7e5
support multiple functions per combo
Dregu Jan 28, 2024
7870942
some convenience functions
Dregu Jan 28, 2024
fa1f95a
add nop()
Dregu Jan 28, 2024
933c8bd
add up/tap combo triggers and toggleable modifiers
Dregu Jan 28, 2024
a460470
fixes
Dregu Jan 28, 2024
1e87ebf
rename combo to down
Dregu Jan 29, 2024
3d13037
add F24
Dregu Jan 29, 2024
3507b82
fix hold repeat
Dregu Jan 29, 2024
520862b
add exe() to run programs directly
Dregu Jan 29, 2024
cbc06b0
exe fixes, add kill() too
Dregu Jan 29, 2024
994a8b9
32 mods
Dregu Jan 29, 2024
0d35620
expand env variables in exe
Dregu Jan 29, 2024
b64b2da
fix modstring parser
Dregu Jan 30, 2024
0e5afa7
make modstring optional
Dregu Jan 30, 2024
ce1df40
add simple fallback function for combos
Dregu Jan 30, 2024
a40c9e7
add options to disable or forward Esc combos
Dregu Jan 30, 2024
605f7e5
fixes
Dregu Jan 30, 2024
aceacac
where did this go?
Dregu Jan 30, 2024
57e9591
support multiple keys in down etc
Dregu Jan 30, 2024
93efc4e
Load AutoHotkey_H as DLL, define and call functions directly in the ini
Dregu Jan 31, 2024
c4ed395
fix
Dregu Feb 1, 2024
e2fb5ae
hope that wasn't important
Dregu Feb 1, 2024
d8f1191
add deviceid filter to combos
Dregu Feb 1, 2024
65cfcd1
initial mouse support
Dregu Feb 1, 2024
2d68bb1
mouse fixes
Dregu Feb 1, 2024
970030b
add option to enable mouse support
Dregu Feb 1, 2024
08eb82b
device filter optimization, fixes
Dregu Feb 2, 2024
7c72b9e
fix the fixes
Dregu Feb 2, 2024
22bddba
add Esc+M to toggle mouse input support
Dregu Feb 3, 2024
bcc25d4
handle multiple mouse buttons per stroke
Dregu Feb 6, 2024
2e6f407
add REPEAT combo trigger
Dregu Feb 6, 2024
8d5c4ad
fix mouse wheel events getting stuck?
Dregu Feb 25, 2024
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
Prev Previous commit
Next Next commit
block physical modifier up when included in hold, add moddedhold to r…
…elease modifiers before hold
  • Loading branch information
Dregu committed Jan 27, 2024
commit 6ce854d631b43fbaf7fd91b33cbaefa935ffe6c5
27 changes: 26 additions & 1 deletion capsicain/capsicain.cpp
Original file line number Diff line number Diff line change
@@ -1998,6 +1998,12 @@ void playKeyEventSequence(vector<VKeyEvent> keyEventSequence)
}
}
}
else if (vc == VK_CPS_RELEASEKEYS) //release all keys that are physically down
{
for (int i = 0; i <= 255; i++)
if (globalState.keysDownSent[i])
sendVKeyEvent({ i, false }, false);
}
//func key with param; wait for next key which is the param
else if (vc == VK_CPS_SLEEP
|| vc == VK_CPS_DEADKEY
@@ -2029,6 +2035,15 @@ void playKeyEventSequence(vector<VKeyEvent> keyEventSequence)
error("BUG: func key with param: " + getPrettyVKLabel(expectParamForFuncKey) + "is unfinished");
}

int getKeyHolding(int vcode)
{
for (int i = 0; i <= 255; i++)
{
if (globalState.holdKeys[i].find(vcode) != globalState.holdKeys[i].end())
return i;
}
return 0;
}

void sendVKeyEvent(VKeyEvent keyEvent, bool hold)
{
@@ -2060,9 +2075,12 @@ void sendVKeyEvent(VKeyEvent keyEvent, bool hold)
}
else
{
vector<int> release;
for (auto it = globalState.holdKeys[code].rbegin(); it != globalState.holdKeys[code].rend(); ++it)
sendVKeyEvent({*it, false}, false);
release.push_back(*it);
globalState.holdKeys[code].clear();
for (auto key : release)
sendVKeyEvent({key, false}, false);
}
keyEvent.vcode = 0;
return;
@@ -2079,6 +2097,13 @@ void sendVKeyEvent(VKeyEvent keyEvent, bool hold)
return;
}

auto holdingkey = getKeyHolding(scancode);
if (!keyEvent.isDownstroke && holdingkey) //ignore up when other key is holding it
{
IFDEBUG cout << " {blocked " << PRETTY_VK_LABELS[scancode] << " UP: " << PRETTY_VK_LABELS[holdingkey] << " is holding}";
return;
}

//consistency check
if (globalState.keysDownSent[scancode] == 0 && keyEvent.isDownstroke)
globalState.keysDownSentCounter++;
6 changes: 6 additions & 0 deletions capsicain/configUtils.cpp
Original file line number Diff line number Diff line change
@@ -505,6 +505,12 @@ bool parseKeywordCombo(std::string line, int &key, unsigned short(&mods)[5], std
if (!parseFunctionHold(funcParams, scLabels, strokeSeq))
return false;
}
else if (funcName == "moddedhold")
{
strokeSeq.push_back({ VK_CPS_RELEASEKEYS, true });
if (!parseFunctionHold(funcParams, scLabels, strokeSeq))
return false;
}
else if (funcName == "combo")
{
if (!parseFunctionCombo(funcParams, scLabels, strokeSeq))
1 change: 1 addition & 0 deletions capsicain/scancodes.h
Original file line number Diff line number Diff line change
@@ -198,6 +198,7 @@ enum VirtualCode
VK_CPS_OBFUSCATED_SEQUENCE_START = 0x115,
VK_CPS_PAUSE = 0x116, // not a real scancode; Cherry Pause key sends an escaped key combo E1 LCTRL NUMLOCK
VK_CPS_HOLDKEY = 0x117,
VK_CPS_RELEASEKEYS = 0x118,
/* testing the VMK style config shift
VK_SHFCFG0 = 0x117, //shift config, i.e. shift back when the key is released
VK_SHFCFG1 = 0x118,
Binary file modified x64/Release/capsicain.exe
Binary file not shown.