Skip to content

Commit

Permalink
Key press duration added
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam777Z committed Aug 5, 2021
1 parent 85744c8 commit f86b1b9
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
10 changes: 10 additions & 0 deletions config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ longpress_duration = 1000
; Don't make it too long as other presses will not be detected during this wait.
delay = 0

; Wait this long before releasing a key (whether longpress or not).
; In milliseconds
; Ignored if hold_mode = 1
; In hold_mode = 2, wait this many ms before releasing the key (whether key or longpress_key).
; Don't make it too long as other presses will not be detected during this wait.
duration = 1

; End of player1.
; Settings for other players follow

Expand All @@ -55,6 +62,7 @@ hold_mode = 1
longpress_key = 1
longpress_duration = 1000
delay = 0
duration = 1

[player3]
button = 0
Expand All @@ -64,6 +72,7 @@ hold_mode = 1
longpress_key = 1
longpress_duration = 1000
delay = 0
duration = 1

[player4]
button = 0
Expand All @@ -73,6 +82,7 @@ hold_mode = 1
longpress_key = 1
longpress_duration = 1000
delay = 0
duration = 1



Expand Down
9 changes: 7 additions & 2 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ struct PlayerSettings
std::vector<int> longpress_key = { 1 };
int64_t longpress_duration = 1000;
int64_t delay = 0;
int64_t duration = 1;
};

void print(int8_t v)
Expand Down Expand Up @@ -347,6 +348,7 @@ struct GlobalData
settings[0].longpress_key = ini.getIntegers("player1", "longpress_key", { 1 });
settings[0].longpress_duration = ini.getInteger("player1", "longpress_duration", 1000);
settings[0].delay = ini.getInteger("player1", "delay", 0);
settings[0].duration = ini.getInteger("player1", "duration", 1);

settings[1].button = ini.getInteger("player2", "button", 0);
settings[1].xbox_game_bar = ini.getInteger("player2", "xbox_game_bar", 1);
Expand All @@ -355,6 +357,7 @@ struct GlobalData
settings[1].longpress_key = ini.getIntegers("player2", "longpress_key", { 1 });
settings[1].longpress_duration = ini.getInteger("player2", "longpress_duration", 1000);
settings[1].delay = ini.getInteger("player2", "delay", 0);
settings[1].duration = ini.getInteger("player2", "duration", 1);

settings[2].button = ini.getInteger("player3", "button", 0);
settings[2].xbox_game_bar = ini.getInteger("player3", "xbox_game_bar", 1);
Expand All @@ -363,6 +366,7 @@ struct GlobalData
settings[2].longpress_key = ini.getIntegers("player3", "longpress_key", { 1 });
settings[2].longpress_duration = ini.getInteger("player3", "longpress_duration", 1000);
settings[2].delay = ini.getInteger("player3", "delay", 0);
settings[2].duration = ini.getInteger("player3", "duration", 1);

settings[3].button = ini.getInteger("player4", "button", 0);
settings[3].xbox_game_bar = ini.getInteger("player4", "xbox_game_bar", 1);
Expand All @@ -371,6 +375,7 @@ struct GlobalData
settings[3].longpress_key = ini.getIntegers("player4", "longpress_key", { 1 });
settings[3].longpress_duration = ini.getInteger("player4", "longpress_duration", 1000);
settings[3].delay = ini.getInteger("player4", "delay", 0);
settings[3].duration = ini.getInteger("player4", "duration", 1);


}
Expand Down Expand Up @@ -466,7 +471,7 @@ int WINAPI WinMain(_In_ HINSTANCE hThisInstance, _In_opt_ HINSTANCE hPrevInstanc
if (d.settings[i].longpress_key.size() != 0)
{
for (std::size_t j = 0; j < d.settings[i].longpress_key.size(); ++j) {
key_tap(d.settings[i].longpress_key[j], d.settings[i].delay, 1);
key_tap(d.settings[i].longpress_key[j], d.settings[i].delay, d.settings[i].duration);
}
}
}
Expand All @@ -475,7 +480,7 @@ int WINAPI WinMain(_In_ HINSTANCE hThisInstance, _In_opt_ HINSTANCE hPrevInstanc
if (d.settings[i].key.size() != 0)
{
for (std::size_t j = 0; j < d.settings[i].key.size(); ++j) {
key_tap(d.settings[i].key[j], d.settings[i].delay, 1);
key_tap(d.settings[i].key[j], d.settings[i].delay, d.settings[i].duration);
}
}
}
Expand Down
Binary file modified resource.rc
Binary file not shown.

0 comments on commit f86b1b9

Please sign in to comment.