3 #ifndef __MOUSE_CURSOR_TRACKER_H__
4 #define __MOUSE_CURSOR_TRACKER_H__
7 Copyright (c) 2020 Adrian I. Lam
9 Permission is hereby granted, free of charge, to any person obtaining a copy
10 of this software and associated documentation files (the "Software"), to deal
11 in the Software without restriction, including without limitation the rights
12 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 copies of the Software, and to permit persons to whom the Software is
14 furnished to do so, subject to the following conditions:
16 The above copyright notice and this permission notice shall be included in all
17 copies or substantial portions of the Software.
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
34 #include <gtkmm/application.h>
35 #include <gtkmm/builder.h>
36 #include <gtkmm/scale.h>
37 #include <gtkmm/checkbutton.h>
38 #include <gtkmm/button.h>
39 #include <gtkmm/window.h>
44 #include <pulse/simple.h>
47 class MouseCursorTracker
50 MouseCursorTracker(std
::string cfgPath
,
51 std
::vector
<std
::pair
<std
::string
, int> > motions
= {},
52 std
::vector
<std
::string
> expressions
= {});
53 ~MouseCursorTracker();
55 enum class MotionPriority
57 // See LAppDefine.cpp in Demo
66 std
::map
<std
::string
, double> live2d
;
70 bool randomIdleMotion
;
74 MotionPriority motionPriority
;
75 std
::string motionGroup
;
78 std
::string expression
;
81 Params
getParams(void);
99 bool randomIdleMotion
;
102 double lipSyncCutOff
;
103 unsigned int audioBufSize
;
113 std
::map
<std
::string
, double> m_overrideMap
;
121 std
::thread m_getVolumeThread
;
122 std
::thread m_parseCommandThread
;
123 std
::thread m_guiThread
;
124 void audioLoop(void);
127 void processCommand(std
::string
);
131 MotionPriority m_motionPriority
;
132 std
::string m_motionGroup
;
134 std
::mutex m_motionMutex
;
135 std
::string m_expression
;
137 void populateDefaultConfig(void);
138 void parseConfig(std
::string cfgPath
);
140 Glib
::RefPtr
<Gtk
::Application
> m_gtkapp
;
141 Glib
::RefPtr
<Gtk
::Builder
> m_builder
;
143 std
::vector
<std
::string
> m_onClearResettingParams
;
145 // GUI signal handlers
146 void onMotionStartButton(void);
147 void onExpressionStartButton(void);
148 void onParamUpdateButton(Gtk
::Scale
*scale
, bool isInc
);
149 void onParamValChanged(Glib
::RefPtr
<Gtk
::Adjustment
> adj
, std
::string paramName
);
150 void onAutoToggle(Gtk
::CheckButton
*check
, Gtk
::Scale
*scale
,
151 Gtk
::Button
*buttonDec
, Gtk
::Button
*buttonInc
,
152 std
::string paramName
);
153 void onClearButton(Glib
::RefPtr
<Gtk
::Button
> button
, std
::string paramName
, Glib
::RefPtr
<Gtk
::Adjustment
> adj
);
154 void onExpanderChange(Gtk
::Window
*window
);