change timeings, reduced logging

This commit is contained in:
mrbesen 2022-04-20 21:03:11 +02:00
parent 7faf7dfc29
commit 0151c34bd2
Signed by: MrBesen
GPG Key ID: 596B2350DCD67504
1 changed files with 9 additions and 12 deletions

View File

@ -27,6 +27,8 @@
#include <cstring>
#include <thread>
XInputSimulatorImplLinux::XInputSimulatorImplLinux()
{
@ -156,44 +158,39 @@ void XInputSimulatorImplLinux::keyUp(int key)
void XInputSimulatorImplLinux::keyClick(int key)
{
std::cout << "key click: " << key << std::endl;
this->keyDown(key);
std::this_thread::sleep_for(std::chrono::milliseconds(25));
this->keyUp(key);
std::this_thread::sleep_for(std::chrono::milliseconds(36));
}
int XInputSimulatorImplLinux::charToKeyCode(char key_char)
{
std::cout << "cchar: " << (int)key_char << std::endl;
// std::cout << "cchar: " << (int)key_char << std::endl;
int keyCode = XKeysymToKeycode(display, key_char);
// int keyCode = XKeysymToKeycode(display, XStringToKeysym(&key_char));
std::cout << "ccode: " << keyCode << std::endl;
// std::cout << "ccode: " << keyCode << std::endl;
return keyCode;
}
void XInputSimulatorImplLinux::keySequence(const std::string &sequence)
{
std::cout << "key seq: " << sequence << std::endl;
for(const char c : sequence) {
std::cout << "cahr: " << c << std::endl;
int keyCode = this->charToKeyCode(c);
std::cout << "key code: " << keyCode << std::endl;
if (isupper(c)) {
std::cout << "upper " << c << std::endl;
this->keyDown(XKeysymToKeycode(display, XK_Shift_L));
std::this_thread::sleep_for(std::chrono::milliseconds(42));
this->keyClick(keyCode);
this->keyUp(XKeysymToKeycode(display, XK_Shift_L));
}
else {
this->keyClick(keyCode);
}
std::cout << std::endl;
std::this_thread::sleep_for(std::chrono::milliseconds(35));
}
}