Skip to content

Commit cf74c6b

Browse files
Add autoinstall
Enable optional replace control image on test failure Add Icon to app
1 parent 35c1e46 commit cf74c6b

26 files changed

+661
-378
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
*~
2+
deploy_app.sh
23
debug_dir
34
AppDir/*
45
bin

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ add_executable(
101101
src/light_image_panel.cpp
102102
src/keyboard_configuration.cpp
103103
src/configurator.cpp
104+
src/utf8_text.cpp
104105
)
105106

106107
target_link_libraries(

README.md

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,14 @@ user input.
1010
- [Dependencies](#dependencies)
1111
- [Features](#features)
1212
- [AppImage](#appimage)
13+
- [Desktop Integration](#desktop-integration)
1314
- [Examples](#examples)
1415
- [Interface Method](#interface-method)
1516
- [TinyUSB](#TinyUSB)
1617
- [uinput](#uinput)
1718
- [vm](#vm)
1819
- [Control Command](#control-command)
19-
- [Things to be Considered](things-to-be-considered)
20+
- [Things to be Considered](#things-to-be-considered)
2021
- [License](#license)
2122

2223
## Overview
@@ -87,6 +88,32 @@ openSUSE, Red Hat, Ubuntu, and other common desktop distributions running with x
8788
Some functionalities of kmRecorderAndPlayer relay on x11 (input on specific window,
8889
window screenshot), therefore it is not working under Wayland.
8990

91+
### Desktop Integration
92+
93+
This is totally optional.
94+
95+
Creating desktop entries for kmRecorderPlayer ensures quick access
96+
from the Application menu. For this, kmRecorderAndPlayer's autoinstallation
97+
will create desktop file with the following content
98+
99+
```
100+
[Desktop Entry]
101+
Name=HID Recorder and Player
102+
Comment=Graphical tool for recording and playing keyboard and mouse input
103+
Terminal=false
104+
Type=Application
105+
Exec=~/bin/kmRecPlayer/kmRecorderAndPlayer-x86_64.AppImage
106+
Icon=~/bin/kmRecPlayer/kmRecPlayerIcon.png
107+
Categories=Development;
108+
```
109+
110+
and save it in ~/.local/share/applications/ It also will create the directory
111+
~/bin/kmRecPlayert and move the appimage there. After this you will be able
112+
to see kmRecorderAndPlayer listed in the Application menu under Development.
113+
114+
To uninstall it, delete the directory ~/bin/kmRecPlayer and the file
115+
~/.local/share/applications/kmRecorderPlayer.desktop
116+
90117
## Examples
91118

92119
The following examples are here only to illustrate the functionality of

documentation.txt

Lines changed: 0 additions & 90 deletions
This file was deleted.

include/cstr_split.h

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
#include "debug_utils.h"
2222
#include <cstring>
23+
#include <optional>
2324

2425
#define SEPARATOR "#+{35sdfh4}|{7gkjf29}+#"
2526

@@ -306,19 +307,41 @@ class SimpleUnserialization
306307
template<typename T>
307308
T get(const char* key)
308309
{
309-
size_t keySize=std::strlen(key);
310-
for(size_t i=0; i<m_cstrSplit.dataSize(); i+=2){
311-
if(std::memcmp(m_cstrSplit[i], key, keySize*sizeof(char))==0){
312-
return FromString<T>::getFrom(m_cstrSplit[i+1], m_cstrSplit.chunkSize(i+1));
313-
}
310+
std::optional<T> value=getValue<T>(key);
311+
if(value){
312+
return *value;
314313
}
315-
std::string excp="Not conversion rule for type of key: ";
314+
315+
std::string excp="Key: ";
316316
excp+=key;
317+
excp+=" not foundy.";
317318
throw excp.c_str();
318319
}
319320

321+
template<typename T>
322+
T get(const char* key, T&& defaultValue)
323+
{
324+
std::optional<T> value=getValue<T>(key);
325+
if(value){
326+
return *value;
327+
}
328+
return std::forward<T>(defaultValue);
329+
}
330+
320331
private:
321332
CstrSplit<2*N> m_cstrSplit;
333+
334+
template<typename T>
335+
std::optional<T> getValue(const char* key)
336+
{
337+
size_t keySize=std::strlen(key);
338+
for(size_t i=0; i<m_cstrSplit.dataSize(); i+=2){
339+
if(std::memcmp(m_cstrSplit[i], key, keySize*sizeof(char))==0){
340+
return FromString<T>::getFrom(m_cstrSplit[i+1], m_cstrSplit.chunkSize(i+1));
341+
}
342+
}
343+
return std::nullopt;
344+
}
322345
};
323346

324347
//====================================================================

include/dedicated_popups.h

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,24 +209,37 @@ class FileListPopup : public WX_Popup
209209
};
210210

211211
//====================================================================
212+
class cmdPtr;
212213

213214
class ResultPopup : public ExtendedPopup
214215
{
215216
public:
216-
ResultPopup(wxWindow* parent, const char* title, const std::string& baseImg);
217+
ResultPopup(wxWindow* parent, const char* title, CtrlCommand* cmdPtr);
217218
virtual ~ResultPopup()=default;
218219

219220
void loadBaseImg(const std::string& baseImg);
220221

221222
protected:
222223
std::string m_baseImg;
223224
std::string m_sampleImg;
225+
CtrlCommand* m_ctrlCmdPtr;
224226
wxRadioBox* m_swapScreenshotRadio;
225227
ImagePanel* m_previewPanel;
226228
wxBoxSizer* m_bodySizer;
227229
wxBoxSizer* m_row;
230+
wxBoxSizer* m_ctrlRow;
231+
wxButton* m_replaceBtn;
232+
ExtendedPopup* m_replaceImagePopup;
228233
uint m_perc;
229234

235+
enum Target
236+
{
237+
ONE=0,
238+
ALL,
239+
};
240+
241+
void replaceImagePopupDialog();
242+
void replaceImage(Target target);
230243
void setLayout();
231244
};
232245

include/enumerations.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ namespace WX
3737
SUBMIT_INPUT,
3838
SET_CHOICE,
3939
TIMER,
40+
INTERFACE_TIMER,
4041
CONFIG_TIMER,
4142
ROI_RADIO,
4243
DISPLAY_KBOARD,
@@ -159,6 +160,15 @@ enum class HID_TARGET
159160
TINYUSB,
160161
};
161162

163+
164+
enum class InstallationStatus
165+
{
166+
INITIAL,
167+
NOT_INSTALLED,
168+
INSTALLED,
169+
170+
};
171+
162172
//====================================================================
163173

164174
#endif

include/input_command.h

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -83,17 +83,17 @@ class ExitCode
8383
public:
8484
enum
8585
{
86-
OK=0,
87-
FAILED=1<<1,
88-
TIMEOUT=1<<2,
89-
BASE_IMAGE_MISSING=1<<3,
90-
TARGET_WINDOW_CLOSED=1<<4,
91-
CV_EXCEPTION=1<<5,
92-
OUT_OF_BOUND=1<<6,// when mouse pointer is trying to get to a position outside of the screen
93-
SYSTEM_FAILED=1<<7,
94-
UNKNOWN=1<<8,
95-
MISSING_SYMBOL=1<<9,
96-
LAST=1<<10
86+
OK =0,
87+
FAILED =1<<0,
88+
TIMEOUT =1<<1,
89+
BASE_IMAGE_MISSING =1<<2,
90+
TARGET_WINDOW_CLOSED=1<<3,
91+
CV_EXCEPTION =1<<4,
92+
OUT_OF_BOUND =1<<5,// when mouse pointer is trying to get to a position outside of the screen
93+
SYSTEM_FAILED =1<<6,
94+
MISSING_SYMBOL =1<<7,
95+
UNKNOWN =1<<8,
96+
LAST =1<<9
9797
};
9898

9999
static const char* getExitCodeMsg(int exitCode)
@@ -625,7 +625,7 @@ class CtrlCommand : public BaseCommand, public WindowOffset
625625

626626
virtual int getExitCode() const override
627627
{
628-
return m_statusCode | 1 * static_cast<int>(m_strictRun && m_statusCode>0);
628+
return m_statusCode | static_cast<int>(m_strictRun && m_statusCode!=ExitCode::OK);
629629
}
630630

631631
virtual uint wait() const override
@@ -673,7 +673,17 @@ class CtrlCommand : public BaseCommand, public WindowOffset
673673

674674
virtual void setCtrlCallback();
675675

676-
virtual void updateBaseImg(const char* baseImg, const char* roiStr);
676+
/*
677+
* Replace the current image with the newBaseImg, and a new ROI newRoiStr
678+
*
679+
* */
680+
virtual void updateBaseImg(const char* newBaseImg, const char* newRoiStr);
681+
682+
/*
683+
* Replace only the base image, it assumes that the new image is taken
684+
* using the same ROI as the current one.
685+
* */
686+
virtual void updateBaseImg(const char* baseImg);
677687

678688
virtual void setSensitivity(uint sensitivity)
679689
{

include/km_recorder_player.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ class RecorderPlayerKM : public wxFrame
124124

125125
private:
126126
wxTimer m_timer;
127+
wxTimer m_checkInterfacetimer;
127128

128129
std::string m_baseImage;
129130
wxString m_roiStr;
@@ -202,7 +203,6 @@ class RecorderPlayerKM : public wxFrame
202203
WxWorker* m_connectionWorkerPtr;
203204

204205
CmdScrolledWindow::PlayMode m_mode;
205-
Cmd m_getFocusCmd;
206206

207207
CommandInputMode m_commandInputMode;
208208
State m_state;
@@ -217,8 +217,10 @@ class RecorderPlayerKM : public wxFrame
217217
bool m_fullMenu;
218218
bool m_indentation;
219219

220+
void autoInstall(bool install=false);
221+
220222
void dialogConfirm(const wxString& line1, const wxString& line2);
221-
void checkConnection();
223+
void checkConnection(wxTimerEvent& event);
222224
void UpdateConnection(bool isConnected);
223225
void initPopups();
224226
bool Pause();
@@ -232,8 +234,8 @@ class RecorderPlayerKM : public wxFrame
232234
bool SaveChangesData();
233235
void clearCommands();
234236

235-
const char* session(bool regenerate=false);
236-
std::string imageId();
237+
//const char* session(bool regenerate=false);
238+
//std::string imageId();
237239

238240
void windowLevelInput(const char* windowName);
239241
void takeScreenshotByWindow(const char* windowName);

0 commit comments

Comments
 (0)