diff --git a/src/driver/Makefile.am b/src/driver/Makefile.am index 75deffa31..3286ff101 100644 --- a/src/driver/Makefile.am +++ b/src/driver/Makefile.am @@ -48,6 +48,7 @@ libneutrino_driver_a_SOURCES = \ screen_max.cpp \ screenshot.cpp \ shutdown_count.cpp \ + slide.cpp \ streamts.cpp \ volume.cpp diff --git a/src/driver/slide.cpp b/src/driver/slide.cpp new file mode 100644 index 000000000..548a50818 --- /dev/null +++ b/src/driver/slide.cpp @@ -0,0 +1,178 @@ +/* + Neutrino-GUI - DBoxII-Project + + Copyright (C) 2022 TangoCash + + License: GPLv2 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#ifdef HAVE_CONFIG_H +#include +#endif + +#include +#include +#include +#include +#include + +#include +#include +#include + +#define MAX_HEIGHT 576 +#define MAX_WIDTH 720 +#define MIN_HEIGHT 0 +#define STEPSIZE 10 +#define SLIDETIME 2*5000 + +COSDSlider::COSDSlider(int percent, int mode) +{ + slideTimer = 0; + slideIn = false; + slideOut = false; + slideMode = mode; + if (mode == MID2SIDE) + slideMax = MAX_WIDTH; + else + slideMax = MAX_HEIGHT * percent / 100; +} + +COSDSlider::~COSDSlider() +{ + StopSlide(); +} + +int COSDSlider::proc_put(const char *path, char *value, int len) +{ + int ret, ret2; + int pfd = open(path, O_WRONLY); + + if (pfd < 0) + return pfd; + + ret = write(pfd, value, len); + ret2 = close(pfd); + + if (ret2 < 0) + return ret2; + + return ret; +} + +void COSDSlider::setValue(int val) +{ + //printf("setvalue: %d\n",val); + char buffer[10]; + if (slideMode == MID2SIDE) + { + int w = MAX_WIDTH - val; + int l = (MAX_WIDTH - w) / 2; + sprintf(buffer, "%x\n", w); + proc_put("/proc/stb/fb/dst_width", buffer, strlen(buffer)); + sprintf(buffer, "%x\n", l); + proc_put("/proc/stb/fb/dst_left", buffer, strlen(buffer)); + } + else + { + sprintf(buffer, "%x\n", val); + proc_put("/proc/stb/fb/dst_top", buffer, strlen(buffer)); + } + sprintf(buffer, "%x\n", 1); + proc_put("/proc/stb/fb/dst_apply", buffer, strlen(buffer)); +} + +void COSDSlider::StartSlideIn() +{ + slideIn = true; + slideOut = false; + slideValue = slideMax; + setValue(slideMax); + slideTimer = g_RCInput->addTimer(SLIDETIME, false); +} + +/* return true if slide out started */ +bool COSDSlider::StartSlideOut() +{ + bool ret = false; + + if (slideIn) + { + g_RCInput->killTimer(slideTimer); + slideIn = false; + } + + if (!slideOut) + { + slideOut = true; + g_RCInput->postMsg(NeutrinoMessages::EVT_SLIDER, BEFORE_SLIDEOUT); + setValue(MIN_HEIGHT); + slideTimer = g_RCInput->addTimer(SLIDETIME, false); + ret = true; + } + + return ret; +} + +void COSDSlider::StopSlide() +{ + if (slideIn || slideOut) + { + g_RCInput->killTimer(slideTimer); + //usleep(SLIDETIME * 3); + setValue(MIN_HEIGHT); + slideIn = slideOut = false; + } +} + +/* return true, if slide out done */ +bool COSDSlider::SlideDone() +{ + bool ret = false; + + if (slideOut) // disappear + { + slideValue += STEPSIZE; + + if (slideValue >= slideMax) + { + slideValue = slideMax; + g_RCInput->killTimer(slideTimer); + ret = true; + } + else + setValue(slideValue); + } + else // appears + { + slideValue -= STEPSIZE; + + if (slideValue <= MIN_HEIGHT) + { + slideValue = MIN_HEIGHT; + g_RCInput->killTimer(slideTimer); + slideIn = false; + g_RCInput->postMsg(NeutrinoMessages::EVT_SLIDER, AFTER_SLIDEIN); + } + else + setValue(slideValue); + } + + + + return ret; +} + diff --git a/src/driver/slide.h b/src/driver/slide.h new file mode 100644 index 000000000..020bb0c1d --- /dev/null +++ b/src/driver/slide.h @@ -0,0 +1,62 @@ +/* + Neutrino-GUI - DBoxII-Project + + Copyright (C) 2022 TangoCash + + License: GPLv2 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#ifndef __slide_f__ +#define __slide_f__ + +#include + +class COSDSlider +{ + private: + uint32_t slideTimer; + int slideValue; + bool slideIn; + bool slideOut; + int proc_put(const char *path, char *value, int len); + void setValue(int val); + int slideMax; + int slideMode; + + public: + COSDSlider(int percent = 100, int mode = BOTTOM2TOP); + virtual ~COSDSlider(); + + void StartSlideIn(); + bool StartSlideOut(); + void StopSlide(); + bool SlideDone(); + bool SlideInDone() { return !slideIn && !slideOut; }; + uint32_t GetSlideTimer() { return slideTimer; }; + enum + { + BEFORE_SLIDEIN = 1, + AFTER_SLIDEIN = 2, + BEFORE_SLIDEOUT = 3, + AFTER_SLIDEOUT = 4 + }; + enum + { + MID2SIDE, + BOTTOM2TOP + }; +}; +#endif diff --git a/src/neutrinoMessages.h b/src/neutrinoMessages.h index e86d87218..ac1701baf 100644 --- a/src/neutrinoMessages.h +++ b/src/neutrinoMessages.h @@ -176,7 +176,8 @@ struct NeutrinoMessages EVT_HOTPLUG = CRCInput::RC_WithData + 26, /* data: char */ EVT_FORMAT_DRIVE = CRCInput::RC_WithData + 27, /* data: char */ EVT_WEBTV_ZAP_COMPLETE = CRCInput::RC_WithData + 28, /* data: (t_channel_id *) */ - EVT_SCAN_REPORT_FREQUENCYP = CRCInput::RC_WithData + 29 + EVT_SCAN_REPORT_FREQUENCYP = CRCInput::RC_WithData + 29, + EVT_SLIDER = CRCInput::RC_WithData + 30 /* data: int */ }; };