X-Git-Url: https://adrianiainlam.tk/git/?p=mouse-tracker-for-cubism.git;a=blobdiff_plain;f=include%2Fmouse_cursor_tracker.h;fp=include%2Fmouse_cursor_tracker.h;h=a53713f517e202d9f254ba469f3764b6f86b4ef1;hp=0000000000000000000000000000000000000000;hb=126d8fa4d0ea5d05ed56d2b318e747426317808d;hpb=2b1f0c7c63dc30d20c9d55fda5e99b208a9f82b3 diff --git a/include/mouse_cursor_tracker.h b/include/mouse_cursor_tracker.h new file mode 100644 index 0000000..a53713f --- /dev/null +++ b/include/mouse_cursor_tracker.h @@ -0,0 +1,108 @@ +// -*- mode: c++ -*- + +#ifndef __MOUSE_CURSOR_TRACKER_H__ +#define __MOUSE_CURSOR_TRACKER_H__ + +/**** +Copyright (c) 2020 Adrian I. Lam + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +****/ + +#include +#include +#include +extern "C" +{ +#include +#include +} + +class MouseCursorTracker +{ +public: + MouseCursorTracker(std::string cfgPath); + ~MouseCursorTracker(); + + struct Params + { + double leftEyeOpenness; + double rightEyeOpenness; + double leftEyeSmile; + double rightEyeSmile; + double mouthOpenness; + double mouthForm; + double faceXAngle; + double faceYAngle; + double faceZAngle; + bool autoBlink; + bool autoBreath; + bool randomMotion; + bool useLipSync; + double lipSyncParam; + }; + + Params getParams(void) const; + + void stop(void); + + void mainLoop(void); + +private: + struct Coord + { + int x; + int y; + }; + + struct Config + { + int sleepMs; + bool autoBlink; + bool autoBreath; + bool randomMotion; + bool useLipSync; + double lipSyncGain; + double lipSyncCutOff; + unsigned int audioBufSize; + double mouthForm; + int top; + int bottom; + int left; + int right; + int screen; + Coord middle; + } m_cfg; + + bool m_stop; + + Coord m_curPos; + + xdo_t *m_xdo; + + std::thread m_getVolumeThread; + void audioLoop(void); + double m_currentVol; + pa_simple *m_pulse; + + void populateDefaultConfig(void); + void parseConfig(std::string cfgPath); +}; + +#endif