isStandby = true;
Sleeptimer::getInstance()->shutdown();
#ifdef WIN32
- stop(); //different behavoiur on windows, we exit
+ stop(); //different behavoiur on windows, we exit // FIXME - stop() now called directly from winmain
#endif
}
}
// Enter pre-keys here
// handleCommand(Input::OK);
// handleCommand(Input::THREE);
- handleCommand(Input::SIX);
+// handleCommand(Input::SIX);
// handleCommand(Input::OK);
// handleCommand(Input::UP);
// handleCommand(Input::PLAY);
// handleCommand(Input::DOWN);
// handleCommand(Input::DOWN);
// handleCommand(Input::DOWN);
- handleCommand(Input::RIGHT);
+// handleCommand(Input::RIGHT);
// handleCommand(Input::RED);
}
}
#define VOMP_HAS_EXIT
+ #define FALLTHROUGH
+
#else
int max(int, int);
#define VOMP_LINUX_CLOCK CLOCK_MONOTONIC
+#define FALLTHROUGH [[fallthrough]];
+
#endif
#ifdef VOMP_PLATTFORM_MVP // FIXME OBSOLETE
#define Remote_TYPE RemoteMVP
tv.tv_usec = 0;
int allowed = 1;
+
+#ifdef WIN32
+ setsockopt(socketnum, SOL_SOCKET, SO_BROADCAST, reinterpret_cast<char*>(&allowed), sizeof(allowed));
+#else
setsockopt(socketnum, SOL_SOCKET, SO_BROADCAST, static_cast<void*>(&allowed), sizeof(allowed));
+#endif
initted = true;
initted = false;
}
+#ifdef WIN32
+unsigned char DatagramSocket::waitforMessage(unsigned char how, SOCKET quitPipe)
+#else
unsigned char DatagramSocket::waitforMessage(unsigned char how, int quitPipe)
+#endif
{
if (!initted) return 0;
~DatagramSocket();
int init();
void shutdown();
+#ifdef WIN32
+ unsigned char waitforMessage(unsigned char, SOCKET quitPipe = 0); // uchar =0-block =1-new wait =2-continue wait
+#else
unsigned char waitforMessage(unsigned char, int quitPipe = 0); // uchar =0-block =1-new wait =2-continue wait
+#endif
UINT getDataLength() const;
const void* getData() const; // returns a pointer to the data
const char* getFromIPA() const; // returns a pointer to from IP address
InitHWCListwithDefaults();
}
-UCHAR Input::TranslateHWC(int code)
+UCHAR Input::TranslateHWC(HWC_TYPE code)
{
UCHAR ret = TranslateHWCFixed(code);
return TranslateHWCList(code);
}
-UCHAR Input::TranslateHWCList(int code)
+UCHAR Input::TranslateHWCList(HWC_TYPE code)
{
if (learnMode != NOLEARNMODE)
{
#include "defines.h"
#include "abstractoption.h"
-// FIXME make common base class sendKey function
+#ifdef WIN32
+#define HWC_TYPE ULLONG
+#else
+#define HWC_TYPE int
+#endif
+
class VDR;
virtual bool loadOptionsFromServer(VDR* vdr);
virtual bool saveOptionstoServer();
- void setHWCtoCommand(ULLONG hcw, UCHAR command);
- void unsetHWC(ULLONG hcw);
+ void setHWCtoCommand(HWC_TYPE hcw, UCHAR command);
+ void unsetHWC(HWC_TYPE hcw);
void LoadKeysConfig(VDR* vdr, const char* keynum);
void SaveKeysConfig();
void EnterLearnMode(UCHAR /* command */ ) {}; // Override and set lernMode to command
void cancelLearnMode() { learnMode = NOLEARNMODE; }
void ResetToDefault();
- virtual std::string getHardwareKeyName(int hardwareKey)=0;
+ virtual std::string getHardwareKeyName(HWC_TYPE hardwareKey) = 0;
const static ULONG NOLEARNMODE = 256;
RemoteTranslationList translist;
int learnMode{NOLEARNMODE};
- virtual UCHAR TranslateHWCFixed(int code)=0;
- UCHAR TranslateHWCList(int code);
- UCHAR TranslateHWC(int code);
+ virtual UCHAR TranslateHWCFixed(HWC_TYPE code) = 0;
+ UCHAR TranslateHWCList(HWC_TYPE code);
+ UCHAR TranslateHWC(HWC_TYPE code);
void sendInputKey(int key);
};
#include "log.h"
#include "wremoteconfig.h"
#include "wtabbar.h"
+#ifdef VOMP_PLATFORM_RASPBERRY
#include "inputlinux.h"
#include "inputcec.h"
+#endif
#include "inputudp.h"
+#include "inputwin.h"
#include "i18n.h"
#include "input.h"
bool InputMan::init()
{
- bool i1{}, i2{}, i3{};
+ bool i1{}, i2{}, i3{}, i4{};
#ifdef VOMP_PLATFORM_RASPBERRY
inputLinux = new InputLinux();
i3 = inputUDP->init();
if (!i3) { delete inputUDP; inputUDP = NULL; }
+#ifdef WIN32
+ inputWin = new InputWin();
+ i4 = inputWin->init();
+ if (!i4) { delete inputWin; inputWin = NULL; }
+#endif
- if (!i1 && !i2 && !i3)
+ if (!i1 && !i2 && !i3 && !i4)
{
Log::getInstance()->log("InputMan", Log::CRIT, "InputMan could not init any input module");
return false;
bool i1{}, i3{};
+#ifdef VOMP_PLATFORM_RASPBERRY
if (inputLinux)
{
i1 = inputLinux->start();
}
+#endif
if (inputUDP)
{
void InputMan::stop()
{
+ Log::getInstance()->log("InputMan", Log::DEBUG, "Stop called");
+
+#ifdef VOMP_PLATFORM_RASPBERRY
if (inputLinux) inputLinux->stop();
+#endif
if (inputUDP) inputUDP->stop();
}
{
Log::getInstance()->log("InputMan", Log::DEBUG, "Shutdown start");
+#ifdef VOMP_PLATFORM_RASPBERRY
+
if (inputLinux)
{
Log::getInstance()->log("InputMan", Log::DEBUG, "Shutdown start - Linux");
inputCEC = NULL;
}
+#endif
+
if (inputUDP)
{
Log::getInstance()->log("InputMan", Log::DEBUG, "Shutdown start - UDP");
bool InputMan::handlesVolume()
{
+#ifdef VOMP_PLATFORM_RASPBERRY
if (!inputCEC) return false;
return inputCEC->handlesVolume();
+#else
+ return false;
+#endif
}
void InputMan::volumeUp()
{
- if (inputCEC) inputCEC->volumeUp();
+#ifdef VOMP_PLATFORM_RASPBERRY
+ if (inputCEC) inputCEC->volumeUp();
+#endif
}
void InputMan::volumeDown()
{
- if (inputCEC) inputCEC->volumeDown();
+#ifdef VOMP_PLATFORM_RASPBERRY
+ if (inputCEC) inputCEC->volumeDown();
+#endif
}
void InputMan::volumeMute()
{
+#ifdef VOMP_PLATFORM_RASPBERRY
if (inputCEC) inputCEC->volumeMute();
+#endif
}
void InputMan::changePowerState(bool powerOn)
{
+#ifdef VOMP_PLATFORM_RASPBERRY
if (inputCEC) inputCEC->changePowerState(powerOn);
+#endif
}
bool InputMan::addOptionsToPanes(int panenumber, Options* options, WOptionPane* pane)
{
+#ifdef VOMP_PLATFORM_RASPBERRY
if (inputLinux) inputLinux->addOptionsToPanes(panenumber, options, pane);
if (inputCEC) inputCEC->addOptionsToPanes(panenumber, options, pane);
+#endif
return true; // FIXME
}
bool InputMan::loadOptionsFromServer(VDR* vdr)
{
+#ifdef VOMP_PLATFORM_RASPBERRY
if (inputLinux) inputLinux->loadOptionsFromServer(vdr);
if (inputCEC) inputCEC->loadOptionsFromServer(vdr);
+#endif
return true; // FIXME
}
bool InputMan::saveOptionstoServer()
{
+#ifdef VOMP_PLATFORM_RASPBERRY
if (inputLinux) inputLinux->saveOptionstoServer();
if (inputCEC) inputCEC->saveOptionstoServer();
-
+#endif
return true; // FIXME
}
std::string keyNames;
+#ifdef VOMP_PLATFORM_RASPBERRY
if (inputLinux)
{
std::string k = inputLinux->getHardCodedHardwareKeyNamesForVompKey(vompKey);
std::string k = inputCEC->getHardCodedHardwareKeyNamesForVompKey(vompKey);
if (k.size()) { keyNames += ", "; keyNames += k; }
}
+#endif
if (inputUDP)
{
{
std::string keyNames;
+#ifdef VOMP_PLATFORM_RASPBERRY
if (inputLinux)
{
std::string k = inputLinux->getAllHardwareKeyNamesAssignedToVompKey(vompKey);
std::string k = inputCEC->getAllHardwareKeyNamesAssignedToVompKey(vompKey);
if (k.size()) { keyNames += ", "; keyNames += k; }
}
+#endif
if (inputUDP)
{
void InputMan::ResetToDefault()
{
+#ifdef VOMP_PLATFORM_RASPBERRY
+
if (inputLinux) inputLinux->ResetToDefault();
if (inputCEC) inputCEC->ResetToDefault();
+#endif
+
if (inputUDP) inputUDP->ResetToDefault();
}
void InputMan::EnterLearningMode(UCHAR vompKey)
{
+#ifdef VOMP_PLATFORM_RASPBERRY
if (inputLinux) inputLinux->EnterLearningMode(vompKey);
// if (inputCEC) inputCEC->EnterLearningMode(); FIXME - is there any such thing?
+#endif
}
void InputMan::cancelLearnMode()
{
+#ifdef VOMP_PLATFORM_RASPBERRY
if (inputLinux) inputLinux->cancelLearnMode();
if (inputCEC) inputCEC->cancelLearnMode();
+#endif
if (inputUDP) inputUDP->cancelLearnMode();
}
bool start(); // MessageQueue should be ready before this is called
void stop(); // Nothing should be sent to MQ after this
+ InputWin* getInputWin() { return inputWin; };
+
bool mayHaveFewButtons();
bool handlesVolume(); // Returns true if we have an InputCEC willing to handle volume
*/
#include <fcntl.h>
+#ifndef WIN32
#include <unistd.h>
+#endif
#include "dsock.h"
#include "log.h"
#include "inputudp.h"
+const char* InputUDP::myModName = "InputUDP";
+
bool InputUDP::init()
{
if (initted) return false;
return false;
}
+#ifdef WIN32
+ quitPipe = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
+ if (quitPipe == INVALID_SOCKET)
+ {
+ Log::getInstance()->log("InputUDP", Log::ERR, "Win32 socket fail");
+#else
if (pipe2(pfds, O_NONBLOCK) == -1)
{
Log::getInstance()->log("InputUDP", Log::ERR, "pipe2() fail");
+#endif
ds->shutdown();
delete ds;
initted = false;
void InputUDP::shutdown()
{
+#ifdef WIN32
+ CLOSESOCKET(quitPipe);
+#endif
+
+
ds->shutdown();
delete ds;
- close(pfds[1]);
- close(pfds[0]);
+#ifndef WIN32
+ CLOSESOCKET(pfds[1]);
+ CLOSESOCKET(pfds[0]);
+#endif
initted = false;
}
if (listenThread.joinable())
{
+#ifdef WIN32
+ Log::getInstance()->log("InputUDP", Log::DEBUG, "Calling CLOSESOCKET on WIN32 quitPipe");
+
+ CLOSESOCKET(quitPipe);
+#else
write(pfds[1], "1", 1); // break the select in listenLoop
+#endif
listenThread.join();
}
}
int retval;
while(1)
{
+#ifdef WIN32
+ retval = ds->waitforMessage(3, quitPipe);
+#else
retval = ds->waitforMessage(3, pfds[0]);
+#endif
+ Log::getInstance()->log("InputUDP", Log::DEBUG, "Back from waitForMessage");
if (retval == 2)
{
}
else if (retval == 3) // quit
{
+ Log::getInstance()->log("InputUDP", Log::DEBUG, "quit");
break;
}
else
return "";
}
-std::string InputUDP::getHardwareKeyName(int /* hardwareKey */)
+std::string InputUDP::getHardwareKeyName(HWC_TYPE /* hardwareKey */)
{
std::string retval;
return retval;
#include <thread>
#include <mutex>
+#ifdef WIN32
+#include <winsock2.h>
+#endif
+
#include "defines.h"
#include "input.h"
// InputUDP doesn't do any translation stuff so just keep everything happy here
void InitHWCListwithDefaults() {};
- UCHAR TranslateHWCFixed(int code) { return static_cast<UCHAR>(code); };
+ UCHAR TranslateHWCFixed(HWC_TYPE code) { return static_cast<UCHAR>(code); };
const char* getHardCodedHardwareKeyNamesForVompKey(UCHAR vompKey);
- std::string getHardwareKeyName(int hardwareKey);
+ std::string getHardwareKeyName(HWC_TYPE hardwareKey);
private:
- static constexpr const char* myModName = "InputUDP";
+ static const char* myModName;
const char* modName() { return myModName; }
bool initted{};
std::mutex threadStartProtect;
void listenLoop();
bool listenLoopStop{};
+
+#ifdef WIN32
+ SOCKET quitPipe;
+#else
int pfds[2];
+#endif
void processRequest(const void* data, UINT length);
};
--- /dev/null
+/*
+ Copyright 2004-2020 Chris Tallon
+
+ This file is part of VOMP.
+
+ VOMP 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; either version 2 of the License, or
+ (at your option) any later version.
+
+ VOMP 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 VOMP. If not, see <https://www.gnu.org/licenses/>.
+*/
+
+#include "vompreswin.h"
+#include "i18n.h"
+#include "log.h"
+#include "inputwin.h"
+
+#define W_G_HCW(type,code) ( (((ULLONG)(type))<<32) | code)
+
+#define W_HCW_VK 1 /* virtual key */
+#define W_HCW_AP 2 /* App command */
+#define W_HCW_RI 3 /* remote control */
+#define W_HCW_CH 4 /* char */
+
+const char* InputWin::myModName = "InputWin";
+
+InputWin::InputWin()
+{
+}
+
+InputWin::~InputWin()
+{
+}
+
+bool InputWin::init()
+{
+ if (initted) return false;
+ initted = true;
+ event = CreateEvent(NULL, /*FALSE*/TRUE, FALSE, NULL);
+ return true;
+}
+
+void InputWin::shutdown()
+{
+ if (!initted) return;
+ Log::getInstance()->log("InputWin", Log::DEBUG, "Shutdown called");
+ CloseHandle(event);
+ initted = false;
+}
+
+/*
+UCHAR RemoteWin::getButtonPress(int waitType)
+{
+ / * how = 0 - block
+ how = 1 - start new wait
+ how = 2 - continue wait
+ how = 3 - no wait
+ * /
+ DWORD wait;
+
+
+ if (hascurevent) {
+ UCHAR temp=curevent;
+ hascurevent=false;
+
+ return temp;
+ }
+ if (waitType==3) {
+ return NA_NONE;
+ }
+ if (waitType==0) {
+ wait=INFINITE;
+ } else { //We do not distingish between 2 and 3
+ wait=1000;
+
+ }
+ WaitForSingleObject(event,wait);
+ ResetEvent(event);
+ if (!hascurevent) {
+ if (signal) {
+ signal=false;
+ return NA_SIGNAL; //Since we have no signals on windows, we simulate this
+ } else {
+ return NA_NONE;
+ }
+ }
+ UCHAR temp2=curevent;
+ hascurevent=false;
+ return temp2;
+
+}
+*/
+
+UCHAR InputWin::TranslateHWCFixed(HWC_TYPE code)
+{
+ switch (code)
+ {
+ case W_G_HCW(W_HCW_VK,VK_DOWN):
+ return DOWN;
+ case W_G_HCW(W_HCW_VK,VK_UP):
+ return UP;
+ case W_G_HCW(W_HCW_VK,VK_LEFT):
+ return LEFT;
+ case W_G_HCW(W_HCW_VK,VK_RIGHT):
+ return RIGHT;
+ case W_G_HCW(W_HCW_CH,'m'):
+ return MENU;
+ case W_G_HCW(W_HCW_VK,VK_BACK):
+ return BACK;
+ case W_G_HCW(W_HCW_VK,VK_RETURN):
+ case W_G_HCW(W_HCW_VK,VK_SPACE):
+ return OK;
+ /* Menu IDs, no sense to make it user selectable */
+ case W_G_HCW(W_HCW_AP,APPCOMMAND_BROWSER_BACKWARD):
+ return BACK;
+ case W_G_HCW(W_HCW_AP,APPCOMMAND_MEDIA_CHANNEL_DOWN):
+ return CHANNELDOWN;
+ case W_G_HCW(W_HCW_AP,APPCOMMAND_MEDIA_CHANNEL_UP):
+ return CHANNELUP;
+ case W_G_HCW(W_HCW_AP,APPCOMMAND_MEDIA_FAST_FORWARD):
+ return FORWARD;
+ case W_G_HCW(W_HCW_AP,APPCOMMAND_VOLUME_MUTE):
+ return MUTE;
+ case W_G_HCW(W_HCW_AP,APPCOMMAND_MEDIA_PAUSE):
+ return PAUSE;
+ case W_G_HCW(W_HCW_AP,APPCOMMAND_MEDIA_PLAY):
+ return PLAY;
+ case W_G_HCW(W_HCW_AP,APPCOMMAND_MEDIA_RECORD):
+ return RECORD;
+ case W_G_HCW(W_HCW_AP,APPCOMMAND_MEDIA_PREVIOUSTRACK):
+ return SKIPBACK;
+ case W_G_HCW(W_HCW_AP,APPCOMMAND_MEDIA_REWIND):
+ return REVERSE;
+ case W_G_HCW(W_HCW_AP,APPCOMMAND_MEDIA_NEXTTRACK):
+ return SKIPFORWARD;
+ case W_G_HCW(W_HCW_AP,APPCOMMAND_MEDIA_STOP):
+ return STOP;
+ case W_G_HCW(W_HCW_AP,APPCOMMAND_VOLUME_DOWN):
+ return VOLUMEDOWN;
+ case W_G_HCW(W_HCW_AP,APPCOMMAND_VOLUME_UP):
+ return VOLUMEUP;
+ case W_G_HCW(W_HCW_AP,VOMP_YELLOW):
+ return YELLOW;
+ case W_G_HCW(W_HCW_AP,VOMP_BLUE):
+ return BLUE;
+ case W_G_HCW(W_HCW_AP,VOMP_RED):
+ return RED;
+ case W_G_HCW(W_HCW_AP,VOMP_GREEN):
+ return GREEN;
+ case W_G_HCW(W_HCW_AP,VOMP_ENTER):
+ return OK;
+ case W_G_HCW(W_HCW_AP,VOMP_CANCEL):
+ return BACK;
+ case W_G_HCW(W_HCW_AP,VOMP_UP):
+ return UP;
+ case W_G_HCW(W_HCW_AP,VOMP_DOWN):
+ return DOWN;
+ case W_G_HCW(W_HCW_AP,VOMP_LEFT):
+ return LEFT;
+ case W_G_HCW(W_HCW_AP,VOMP_RIGHT):
+ return RIGHT;
+ case POWER:
+ return POWER;
+ default:
+ return NA_UNKNOWN;
+ }
+}
+
+const char* InputWin::getHardCodedHardwareKeyNameForVompKey(UCHAR vompKey)
+{
+ switch (vompKey)
+ {
+ case DOWN:
+ return tr("Down");
+ case UP:
+ return tr("Up");
+ case LEFT:
+ return tr("Left");
+ case RIGHT:
+ return tr("Right");
+ case MENU:
+ return tr("M");
+ case BACK:
+ return tr("Backspace, Back");
+ case OK:
+ return tr("Return, Space");
+ case CHANNELDOWN:
+ return tr("Insrt, C+Insrt, Pg down");
+ case CHANNELUP:
+ return tr("+, C++, Pg up");
+ case VOLUMEUP:
+ return "F10";
+ case VOLUMEDOWN:
+ return "F9";
+ case POWER:
+ return "Esc, A+F4";
+ case MUTE:
+ return "F8";
+ case REVERSE:
+ return"S+C+B";
+ case FORWARD:
+ return "S+C+F";
+ case SKIPBACK:
+ return "C+B";
+ case SKIPFORWARD:
+ return "C+F";
+ case PLAY:
+ return "S+P";
+ case STOP:
+ return "C+S";
+ case PAUSE:
+ return "C+P";
+ default:
+ return NULL;
+ }
+}
+
+void InputWin::InitHWCListwithDefaults()
+{
+ //Processing VK_Messages
+ translist[W_G_HCW(W_HCW_CH,'9')] = NINE;
+ translist[W_G_HCW(W_HCW_CH,'8')] = EIGHT;
+ translist[W_G_HCW(W_HCW_CH,'7')] = SEVEN;
+ translist[W_G_HCW(W_HCW_CH,'6')] = SIX;
+ translist[W_G_HCW(W_HCW_CH,'5')] = FIVE;
+ translist[W_G_HCW(W_HCW_CH,'4')] = FOUR;
+ translist[W_G_HCW(W_HCW_CH,'3')] = THREE;
+ translist[W_G_HCW(W_HCW_CH,'2')] = TWO;
+ translist[W_G_HCW(W_HCW_CH,'1')] = ONE;
+ translist[W_G_HCW(W_HCW_CH,'0')] = ZERO;
+ translist[W_G_HCW(W_HCW_CH,'*')] = STAR;
+ translist[W_G_HCW(W_HCW_CH,'#')] = HASH;
+ translist[W_G_HCW(W_HCW_CH,'j')] = GO; //j for JUMP TO instead of go to
+ translist[W_G_HCW(W_HCW_CH,'r')] = RED;
+ translist[W_G_HCW(W_HCW_CH,'g')] = GREEN;
+ translist[W_G_HCW(W_HCW_CH,'y')] = YELLOW;
+ translist[W_G_HCW(W_HCW_CH,'b')] = BLUE;
+ //Processing RI Messages
+ translist[W_G_HCW(W_HCW_RI,0x35c)] = GREEN;
+ translist[W_G_HCW(W_HCW_RI,0x35b)] = RED;
+ translist[W_G_HCW(W_HCW_RI,0x35d)] = YELLOW;
+ translist[W_G_HCW(W_HCW_RI,0x35e)] = BLUE;
+ translist[W_G_HCW(W_HCW_RI,0x30d)] = MENU; //MCE Button, used for Menu
+ translist[W_G_HCW(W_HCW_RI,0x348)] = RECORD; //Record Television
+ translist[W_G_HCW(W_HCW_RI,0x325)] = PLAY; //Playback Televison
+ translist[W_G_HCW(W_HCW_RI,0x324)] = PLAY; //Playback DVD
+ translist[W_G_HCW(W_HCW_RI,0x209)] = OK; //Properties
+ translist[W_G_HCW(W_HCW_RI,0x35a)] = OK; //Teletext?
+}
+
+std::string InputWin::getHardwareKeyName(HWC_TYPE hardwareKey)
+{
+ //Determine type
+ ULONG type = hardwareKey >> 32;
+ char rt[10];
+
+ switch(type)
+ {
+ case W_HCW_VK:
+ {
+ ULONG vk = (ULONG)hardwareKey;
+ ULONG scancode = MapVirtualKey(vk,0);
+ GetKeyNameText(scancode << 16, rt, 10);
+ break;
+ }
+ case W_HCW_CH:
+ {
+ ULONG ch = (ULONG)hardwareKey;
+ ULONG scancode = OemKeyScan(ch);
+ GetKeyNameText(scancode << 16, rt, 10);
+ break;
+ }
+ case W_HCW_RI:
+ {
+ ULONG ri = (ULONG)hardwareKey;
+ sprintf(rt, "R: %X", ri);
+ break;
+ }
+ }
+
+ std::string retval = rt;
+ return retval;
+}
+
+int InputWin::ReceiveButtonVK(UINT button)
+{
+/* UCHAR pb=NA_NONE;
+ //should we use a translation table ? No APPCOMMAND iS DWORD!
+ switch (button) { //Processing VK_Messages
+ case VK_DOWN:
+ pb=DOWN; break;
+ case VK_RETURN:
+ case VK_SPACE:
+ pb=OK;break;
+ case VK_LEFT:
+ pb=LEFT;break;
+ case '9':
+ case VK_NUMPAD9:
+ pb=NINE;break;
+ case '8':
+ case VK_NUMPAD8:
+ pb=EIGHT;break;
+ case '7':
+ case VK_NUMPAD7:
+ pb=SEVEN;break;
+ case '6':
+ case VK_NUMPAD6:
+ pb=SIX;break;
+ case '5':
+ case VK_NUMPAD5:
+ pb=FIVE;break;
+ case '4':
+ case VK_NUMPAD4:
+ pb=FOUR;break;
+ case '3':
+ case VK_NUMPAD3:
+ pb=THREE;break;
+ case '2':
+ case VK_NUMPAD2:
+ pb=TWO;break;
+ case '1':
+ case VK_NUMPAD1:
+ pb=ONE;break;
+ case '0':
+ case VK_NUMPAD0:
+ pb=ZERO;break;
+ case VK_RIGHT:
+ pb=RIGHT;break;
+ case VK_UP:
+ pb=UP;break;
+ case VK_MULTIPLY:
+ pb=STAR;break;
+ case 'J'://j for JUMP TO instead of go to
+ pb=GO;break;
+ //case VK_ESCAPE:
+ // pb=POWER;break;
+ case VK_BACK:
+ pb=BACK;break;
+ case 'M':
+ pb=MENU;break;
+ case 'R':
+ pb=RED;break;
+ case 'G':
+ pb=GREEN;break;
+ case 'Y':
+ pb=YELLOW;break;
+ case 'B':
+ pb=BLUE; break;
+
+
+ }; //All other commands are process via APPCOMMAND_MESSAGES
+ if (pb==NA_NONE) return 0;*/
+
+ UCHAR pb = TranslateHWC(W_G_HCW(W_HCW_VK,button));
+ if (pb==NA_UNKNOWN || pb==NA_NONE) return 0;
+ sendInputKey(pb);
+ return 1;
+
+ /*
+ curevent=pb;
+ hascurevent=true;
+ //PulseEvent(event);
+ SetEvent(event);
+ return 1; */
+}
+
+int InputWin::ReceiveButtonCH(UINT button)
+{
+ UCHAR pb = TranslateHWC(W_G_HCW(W_HCW_CH,button));
+ if (pb==NA_UNKNOWN || pb==NA_NONE) return 0;
+ sendInputKey(pb);
+ return 1;
+
+
+ /*
+ curevent=pb;
+ hascurevent=true;
+ //PulseEvent(event);
+ SetEvent(event);
+ return 1; */
+}
+
+int InputWin::ReceiveButtonAP(UINT button)
+{
+/* UCHAR pb=NA_NONE;
+ //should we use a translation table ? No APPCOMMAND iS DWORD!
+ switch (button) { //Processing VK_Messages
+ case APPCOMMAND_BROWSER_BACKWARD:
+ pb=BACK;break;
+ case APPCOMMAND_MEDIA_CHANNEL_DOWN:
+ pb=CHANNELDOWN;break;
+ case APPCOMMAND_MEDIA_CHANNEL_UP:
+ pb=CHANNELUP;break;
+ case APPCOMMAND_MEDIA_FAST_FORWARD:
+ pb=FORWARD;break;
+ case APPCOMMAND_VOLUME_MUTE:
+ pb=MUTE;break;
+ case APPCOMMAND_MEDIA_PAUSE:
+ pb=PAUSE;break;
+ case APPCOMMAND_MEDIA_PLAY:
+ pb=PLAY;break;
+ case APPCOMMAND_MEDIA_RECORD:
+ pb=RECORD;break;
+ case APPCOMMAND_MEDIA_PREVIOUSTRACK:
+ pb=SKIPBACK;break;
+ case APPCOMMAND_MEDIA_REWIND:
+ pb=REVERSE;break;
+ case APPCOMMAND_MEDIA_NEXTTRACK:
+ pb=SKIPFORWARD;break;
+ case APPCOMMAND_MEDIA_STOP:
+ pb=STOP;break;
+ case APPCOMMAND_VOLUME_DOWN:
+ pb=VOLUMEDOWN;break;
+ case APPCOMMAND_VOLUME_UP:
+ pb=VOLUMEUP;break;
+ case VOMP_YELLOW:
+ pb=YELLOW; break;
+ case VOMP_BLUE:
+ pb=BLUE;break;
+ case VOMP_RED:
+ pb=RED;break;
+ case VOMP_GREEN:
+ pb=GREEN;break;
+ case VOMP_ENTER:
+ pb=OK;break;
+ case VOMP_CANCEL:
+ pb=BACK;break;
+ case VOMP_UP:
+ pb=UP;break;
+ case VOMP_DOWN:
+ pb=DOWN;break;
+ case VOMP_LEFT:
+ pb=LEFT;break;
+ case VOMP_RIGHT:
+ pb=RIGHT;break;
+ };*/
+
+ //if (pb==NA_NONE) return 0;
+
+
+ UCHAR pb = TranslateHWC(W_G_HCW(W_HCW_AP,button));
+ if (pb==NA_UNKNOWN || pb==NA_NONE) return 0;
+ sendInputKey(pb);
+ return 1;
+
+ /*
+ curevent=pb;
+ hascurevent=true;
+ //PulseEvent(event);
+ SetEvent(event);
+ return 1; */
+}
+
+int InputWin::ReceiveButtonRI(UINT button)
+{
+ //UCHAR pb=NA_NONE;
+ //Raw Input
+ /* Note Codes above 0x29c are not listed in the specs on usb.org
+ therefore they are used by try, they might be device dependent
+ thus please supply codes of your remote control */
+/* switch (button) { //Processing VK_Messages
+ case 0x35c: //Green
+ pb=GREEN;break;
+ case 0x35b: //Red
+ pb=RED;break;
+ case 0x35d: //Yellow
+ pb=YELLOW;break;
+ case 0x35e: //Blue
+ pb=BLUE;break;
+ case 0x30d: //MCE Button, used for Menu
+ pb=MENU;break;
+ case 0x348: //Record Television
+ pb=RECORD;break;
+ case 0x28d: //Attach File Mmh, how should we assign this
+ pb=NA_NONE;break;
+ case 0x325: //Playback Televison
+ pb=PLAY;break;
+ case 0x324: //Playback DVD
+ pb=PLAY;break;
+ case 0x209: //Properties
+ case 0x35a: //Teletext?
+ pb=OK;break;
+
+
+ };
+ if (pb==NA_NONE) return 0;*/
+
+ UCHAR pb = TranslateHWC(W_G_HCW(W_HCW_RI,button));
+ if (pb==NA_UNKNOWN || pb==NA_NONE) return 0;
+ sendInputKey(pb);
+ return 1;
+
+ /*
+ curevent=pb;
+ hascurevent=true;
+ //PulseEvent(event);
+ SetEvent(event);
+ return 1; */
+}
+
+/*
+void InputWin::Signal()
+{
+ signal = true;
+ //PulseEvent(event);
+ SetEvent(event);
+}
+*/
+
+void InputWin::SendPower()
+{
+ /*
+ curevent=POWER;
+ hascurevent=true;
+ SetEvent(event);
+ */
+ sendInputKey(POWER);
+}
--- /dev/null
+/*
+ Copyright 2004-2020 Chris Tallon
+
+ This file is part of VOMP.
+
+ VOMP 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; either version 2 of the License, or
+ (at your option) any later version.
+
+ VOMP 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 VOMP. If not, see <https://www.gnu.org/licenses/>.
+*/
+
+#ifndef INPUTWIN_H
+#define INPUTWIN_H
+
+#define _WIN32_WINNT 0x501
+#include <winsock2.h>
+#include <windowsx.h>
+
+#include "defines.h"
+#include "input.h"
+
+class InputWin : public Input
+{
+ public:
+ InputWin();
+ ~InputWin();
+
+ bool init();
+ void shutdown();
+ //int getDevice();
+ //UCHAR getButtonPress(int how);
+ // void Signal();
+ int ReceiveButtonVK(UINT button); //Windows Message from WND_PROC (Virtual Key)
+ int ReceiveButtonCH(UINT button); //Windows Message from WND_PROC (char)
+ int ReceiveButtonAP(UINT button); // (App command)
+ int ReceiveButtonRI(UINT button); // (Remote control)
+ void SendPower();
+ void InitHWCListwithDefaults();
+ const char* getHardCodedHardwareKeyNameForVompKey(UCHAR vompKey);
+ std::string getHardwareKeyName(HWC_TYPE hardwareKey);
+
+ private:
+ static const char* myModName;
+ const char* modName() { return myModName; }
+
+ bool initted{};
+ bool signal{};
+ UCHAR curevent{};
+ bool hascurevent{};
+ HANDLE event;
+ UCHAR TranslateHWCFixed(HWC_TYPE code);
+};
+
+#endif
initted = 1;
logLevel = startLogLevel;
enabled = tenabled;
-// logfile = fopen(fileName, "a");
+ logfile = fopen(fileName, "a");
// logfile = fopen(stdout, "a");
- logfile = stdout;
+ //logfile = stdout;
// logfile = fopen("/log", "a");
if (logfile) return 1;
+++ /dev/null
-/*
- Copyright 2004-2005 Chris Tallon
-
- This file is part of VOMP.
-
- VOMP 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; either version 2 of the License, or
- (at your option) any later version.
-
- VOMP 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 VOMP; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-*/
-
-#include "remotewin.h"
-#include "vompreswin.h"
-#include "i18n.h"
-
-#define W_G_HCW(type,code) ( (((ULLONG)(type))<<32) | code)
-
-#define W_HCW_VK 1 /* virtual key */
-#define W_HCW_AP 2 /* App command */
-#define W_HCW_RI 3 /* remote control */
-#define W_HCW_CH 4 /* char */
-
-RemoteWin::RemoteWin()
-{
- initted = 0;
- curevent=0;
- hascurevent=false;
- signal=false;
-}
-
-RemoteWin::~RemoteWin()
-{
-}
-
-int RemoteWin::init(const char* devName)
-{
- if (initted) return 0;
- initted = 1;
- event = CreateEvent(NULL,/*FALSE*/TRUE,FALSE,NULL);
-
-
- return 1;
-}
-
-int RemoteWin::shutdown()
-{
- if (!initted) return 0;
- CloseHandle(event);
- initted = 0;
- return 1;
-}
-
-UCHAR RemoteWin::getButtonPress(int waitType)
-{
- /* how = 0 - block
- how = 1 - start new wait
- how = 2 - continue wait
- how = 3 - no wait
- */
- DWORD wait;
-
-
- if (hascurevent) {
- UCHAR temp=curevent;
- hascurevent=false;
-
- return temp;
- }
- if (waitType==3) {
- return NA_NONE;
- }
- if (waitType==0) {
- wait=INFINITE;
- } else { //We do not distingish between 2 and 3
- wait=1000;
-
- }
- WaitForSingleObject(event,wait);
- ResetEvent(event);
- if (!hascurevent) {
- if (signal) {
- signal=false;
- return NA_SIGNAL; //Since we have no signals on windows, we simulate this
- } else {
- return NA_NONE;
- }
- }
- UCHAR temp2=curevent;
- hascurevent=false;
- return temp2;
-
-}
-
-UCHAR RemoteWin::TranslateHWCFixed(ULLONG code)
-{
- switch (code)
- {
- case W_G_HCW(W_HCW_VK,VK_DOWN):
- return DOWN;
- case W_G_HCW(W_HCW_VK,VK_UP):
- return UP;
- case W_G_HCW(W_HCW_VK,VK_LEFT):
- return LEFT;
- case W_G_HCW(W_HCW_VK,VK_RIGHT):
- return RIGHT;
- case W_G_HCW(W_HCW_CH,'m'):
- return MENU;
- case W_G_HCW(W_HCW_VK,VK_BACK):
- return BACK;
- case W_G_HCW(W_HCW_VK,VK_RETURN):
- case W_G_HCW(W_HCW_VK,VK_SPACE):
- return OK;
- /* Menu IDs, no sense to make it user selectable */
- case W_G_HCW(W_HCW_AP,APPCOMMAND_BROWSER_BACKWARD):
- return BACK;
- case W_G_HCW(W_HCW_AP,APPCOMMAND_MEDIA_CHANNEL_DOWN):
- return CHANNELDOWN;break;
- case W_G_HCW(W_HCW_AP,APPCOMMAND_MEDIA_CHANNEL_UP):
- return CHANNELUP;break;
- case W_G_HCW(W_HCW_AP,APPCOMMAND_MEDIA_FAST_FORWARD):
- return FORWARD;break;
- case W_G_HCW(W_HCW_AP,APPCOMMAND_VOLUME_MUTE):
- return MUTE;break;
- case W_G_HCW(W_HCW_AP,APPCOMMAND_MEDIA_PAUSE):
- return PAUSE;break;
- case W_G_HCW(W_HCW_AP,APPCOMMAND_MEDIA_PLAY):
- return PLAY;break;
- case W_G_HCW(W_HCW_AP,APPCOMMAND_MEDIA_RECORD):
- return RECORD;break;
- case W_G_HCW(W_HCW_AP,APPCOMMAND_MEDIA_PREVIOUSTRACK):
- return SKIPBACK;break;
- case W_G_HCW(W_HCW_AP,APPCOMMAND_MEDIA_REWIND):
- return REVERSE;break;
- case W_G_HCW(W_HCW_AP,APPCOMMAND_MEDIA_NEXTTRACK):
- return SKIPFORWARD;break;
- case W_G_HCW(W_HCW_AP,APPCOMMAND_MEDIA_STOP):
- return STOP;break;
- case W_G_HCW(W_HCW_AP,APPCOMMAND_VOLUME_DOWN):
- return VOLUMEDOWN;break;
- case W_G_HCW(W_HCW_AP,APPCOMMAND_VOLUME_UP):
- return VOLUMEUP;break;
- case W_G_HCW(W_HCW_AP,VOMP_YELLOW):
- return YELLOW; break;
- case W_G_HCW(W_HCW_AP,VOMP_BLUE):
- return BLUE;break;
- case W_G_HCW(W_HCW_AP,VOMP_RED):
- return RED;break;
- case W_G_HCW(W_HCW_AP,VOMP_GREEN):
- return GREEN;break;
- case W_G_HCW(W_HCW_AP,VOMP_ENTER):
- return OK;break;
- case W_G_HCW(W_HCW_AP,VOMP_CANCEL):
- return BACK;break;
- case W_G_HCW(W_HCW_AP,VOMP_UP):
- return UP;break;
- case W_G_HCW(W_HCW_AP,VOMP_DOWN):
- return DOWN;break;
- case W_G_HCW(W_HCW_AP,VOMP_LEFT):
- return LEFT;break;
- case W_G_HCW(W_HCW_AP,VOMP_RIGHT):
- return RIGHT;break;
- case POWER:
- return POWER;
- default:
- return NA_UNKNOWN;
- };
-}
-
-const char*RemoteWin::HardcodedTranslateStr(UCHAR command)
-{
- switch (command)
- {
- case DOWN:
- return tr("Down");
- case UP:
- return tr("Up");
- case LEFT:
- return tr("Left");
- case RIGHT:
- return tr("Right");
- case MENU:
- return tr("M");
- case BACK:
- return tr("Backspace, Back");
- case OK:
- return tr("Return, Space");
- case CHANNELDOWN:
- return tr("Insrt, C+Insrt, Pg down");
- case CHANNELUP:
- return tr("+, C++, Pg up");
- case VOLUMEUP:
- return "F10";
- case VOLUMEDOWN:
- return "F9";
- case POWER:
- return "Esc, A+F4";
- case MUTE:
- return "F8";
- case REVERSE:
- return"S+C+B";
- case FORWARD:
- return "S+C+F";
- case SKIPBACK:
- return "C+B";
- case SKIPFORWARD:
- return "C+F";
- case PLAY:
- return "S+P";
- case STOP:
- return "C+S";
- case PAUSE:
- return "C+P";
- default:
- return NULL;
- };
-
-}
-
-
-void RemoteWin::InitHWCListwithDefaults()
-{
- //Processing VK_Messages
- translist[W_G_HCW(W_HCW_CH,'9')] = NINE;
- translist[W_G_HCW(W_HCW_CH,'8')] = EIGHT;
- translist[W_G_HCW(W_HCW_CH,'7')] = SEVEN;
- translist[W_G_HCW(W_HCW_CH,'6')] = SIX;
- translist[W_G_HCW(W_HCW_CH,'5')] = FIVE;
- translist[W_G_HCW(W_HCW_CH,'4')] = FOUR;
- translist[W_G_HCW(W_HCW_CH,'3')] = THREE;
- translist[W_G_HCW(W_HCW_CH,'2')] = TWO;
- translist[W_G_HCW(W_HCW_CH,'1')] = ONE;
- translist[W_G_HCW(W_HCW_CH,'0')] = ZERO;
- translist[W_G_HCW(W_HCW_CH,'*')] = STAR;
- translist[W_G_HCW(W_HCW_CH,'#')] = HASH;
- translist[W_G_HCW(W_HCW_CH,'j')] = GO; //j for JUMP TO instead of go to
- translist[W_G_HCW(W_HCW_CH,'r')] = RED;
- translist[W_G_HCW(W_HCW_CH,'g')] = GREEN;
- translist[W_G_HCW(W_HCW_CH,'y')] = YELLOW;
- translist[W_G_HCW(W_HCW_CH,'b')] = BLUE;
- //Processing RI Messages
- translist[W_G_HCW(W_HCW_RI,0x35c)] = GREEN;
- translist[W_G_HCW(W_HCW_RI,0x35b)] = RED;
- translist[W_G_HCW(W_HCW_RI,0x35d)] = YELLOW;
- translist[W_G_HCW(W_HCW_RI,0x35e)] = BLUE;
- translist[W_G_HCW(W_HCW_RI,0x30d)] = MENU;//MCE Button, used for Menu
- translist[W_G_HCW(W_HCW_RI,0x348)] = RECORD; //Record Television
- translist[W_G_HCW(W_HCW_RI,0x325)] = PLAY; //Playback Televison
- translist[W_G_HCW(W_HCW_RI,0x324)] = PLAY; //Playback DVD
- translist[W_G_HCW(W_HCW_RI,0x209)] = OK;//Properties
- translist[W_G_HCW(W_HCW_RI,0x35a)] = OK;//Teletext?
-
-}
-
-char* RemoteWin::HCWDesc(ULLONG hcw)
-{
- //Determine type
- ULONG type = hcw >> 32;
- char *rt=NULL;
- switch(type)
- {
- case W_HCW_VK:{
- ULONG vk=(ULONG)hcw;
- ULONG scancode=MapVirtualKey(vk,0);
- rt=new char[10];
- GetKeyNameText(scancode << 16,rt,10);
- }break;
- case W_HCW_CH:{
- ULONG ch=(ULONG)hcw;
- ULONG scancode=OemKeyScan(ch);
-
- rt=new char[10];
- GetKeyNameText(scancode << 16,rt,10);
- }break;
- case W_HCW_RI:{
- ULONG ri=(ULONG)hcw;
- rt=new char[10];
- sprintf(rt,"R: %X",ri);
- }break;
-
- };
- return rt;
-}
-
-
-int RemoteWin::ReceiveButtonVK(UINT button) {
-/* UCHAR pb=NA_NONE;
- //should we use a translation table ? No APPCOMMAND iS DWORD!
- switch (button) { //Processing VK_Messages
- case VK_DOWN:
- pb=DOWN; break;
- case VK_RETURN:
- case VK_SPACE:
- pb=OK;break;
- case VK_LEFT:
- pb=LEFT;break;
- case '9':
- case VK_NUMPAD9:
- pb=NINE;break;
- case '8':
- case VK_NUMPAD8:
- pb=EIGHT;break;
- case '7':
- case VK_NUMPAD7:
- pb=SEVEN;break;
- case '6':
- case VK_NUMPAD6:
- pb=SIX;break;
- case '5':
- case VK_NUMPAD5:
- pb=FIVE;break;
- case '4':
- case VK_NUMPAD4:
- pb=FOUR;break;
- case '3':
- case VK_NUMPAD3:
- pb=THREE;break;
- case '2':
- case VK_NUMPAD2:
- pb=TWO;break;
- case '1':
- case VK_NUMPAD1:
- pb=ONE;break;
- case '0':
- case VK_NUMPAD0:
- pb=ZERO;break;
- case VK_RIGHT:
- pb=RIGHT;break;
- case VK_UP:
- pb=UP;break;
- case VK_MULTIPLY:
- pb=STAR;break;
- case 'J'://j for JUMP TO instead of go to
- pb=GO;break;
- //case VK_ESCAPE:
- // pb=POWER;break;
- case VK_BACK:
- pb=BACK;break;
- case 'M':
- pb=MENU;break;
- case 'R':
- pb=RED;break;
- case 'G':
- pb=GREEN;break;
- case 'Y':
- pb=YELLOW;break;
- case 'B':
- pb=BLUE; break;
-
-
- }; //All other commands are process via APPCOMMAND_MESSAGES
- if (pb==NA_NONE) return 0;*/
- UCHAR pb=NA_NONE;
- pb=TranslateHWC(W_G_HCW(W_HCW_VK,button));
- if (pb==NA_UNKNOWN || pb==NA_NONE) return 0;
- curevent=pb;
- hascurevent=true;
- //PulseEvent(event);
- SetEvent(event);
- return 1;
-}
-
-int RemoteWin::ReceiveButtonCH(UINT button) {
- UCHAR pb=NA_NONE;
- pb=TranslateHWC(W_G_HCW(W_HCW_CH,button));
- if (pb==NA_UNKNOWN || pb==NA_NONE) return 0;
- curevent=pb;
- hascurevent=true;
- //PulseEvent(event);
- SetEvent(event);
- return 1;
-}
-
-int RemoteWin::ReceiveButtonAP(UINT button) {
-/* UCHAR pb=NA_NONE;
- //should we use a translation table ? No APPCOMMAND iS DWORD!
- switch (button) { //Processing VK_Messages
- case APPCOMMAND_BROWSER_BACKWARD:
- pb=BACK;break;
- case APPCOMMAND_MEDIA_CHANNEL_DOWN:
- pb=CHANNELDOWN;break;
- case APPCOMMAND_MEDIA_CHANNEL_UP:
- pb=CHANNELUP;break;
- case APPCOMMAND_MEDIA_FAST_FORWARD:
- pb=FORWARD;break;
- case APPCOMMAND_VOLUME_MUTE:
- pb=MUTE;break;
- case APPCOMMAND_MEDIA_PAUSE:
- pb=PAUSE;break;
- case APPCOMMAND_MEDIA_PLAY:
- pb=PLAY;break;
- case APPCOMMAND_MEDIA_RECORD:
- pb=RECORD;break;
- case APPCOMMAND_MEDIA_PREVIOUSTRACK:
- pb=SKIPBACK;break;
- case APPCOMMAND_MEDIA_REWIND:
- pb=REVERSE;break;
- case APPCOMMAND_MEDIA_NEXTTRACK:
- pb=SKIPFORWARD;break;
- case APPCOMMAND_MEDIA_STOP:
- pb=STOP;break;
- case APPCOMMAND_VOLUME_DOWN:
- pb=VOLUMEDOWN;break;
- case APPCOMMAND_VOLUME_UP:
- pb=VOLUMEUP;break;
- case VOMP_YELLOW:
- pb=YELLOW; break;
- case VOMP_BLUE:
- pb=BLUE;break;
- case VOMP_RED:
- pb=RED;break;
- case VOMP_GREEN:
- pb=GREEN;break;
- case VOMP_ENTER:
- pb=OK;break;
- case VOMP_CANCEL:
- pb=BACK;break;
- case VOMP_UP:
- pb=UP;break;
- case VOMP_DOWN:
- pb=DOWN;break;
- case VOMP_LEFT:
- pb=LEFT;break;
- case VOMP_RIGHT:
- pb=RIGHT;break;
- };*/
-
- //if (pb==NA_NONE) return 0;
- UCHAR pb=NA_NONE;
- pb=TranslateHWC(W_G_HCW(W_HCW_AP,button));
- if (pb==NA_UNKNOWN || pb==NA_NONE) return 0;
- curevent=pb;
- hascurevent=true;
- //PulseEvent(event);
- SetEvent(event);
- return 1;
-}
-
-int RemoteWin::ReceiveButtonRI(UINT button) {
- //UCHAR pb=NA_NONE;
- //Raw Input
- /* Note Codes above 0x29c are not listed in the specs on usb.org
- therefore they are used by try, they might be device dependent
- thus please supply codes of your remote control */
-/* switch (button) { //Processing VK_Messages
- case 0x35c: //Green
- pb=GREEN;break;
- case 0x35b: //Red
- pb=RED;break;
- case 0x35d: //Yellow
- pb=YELLOW;break;
- case 0x35e: //Blue
- pb=BLUE;break;
- case 0x30d: //MCE Button, used for Menu
- pb=MENU;break;
- case 0x348: //Record Television
- pb=RECORD;break;
- case 0x28d: //Attach File Mmh, how should we assign this
- pb=NA_NONE;break;
- case 0x325: //Playback Televison
- pb=PLAY;break;
- case 0x324: //Playback DVD
- pb=PLAY;break;
- case 0x209: //Properties
- case 0x35a: //Teletext?
- pb=OK;break;
-
-
- };
- if (pb==NA_NONE) return 0;*/
-
- UCHAR pb=NA_NONE;
- pb=TranslateHWC(W_G_HCW(W_HCW_RI,button));
- if (pb==NA_UNKNOWN || pb==NA_NONE) return 0;
- curevent=pb;
- hascurevent=true;
- //PulseEvent(event);
- SetEvent(event);
- return 1;
-}
-
-void RemoteWin::Signal() {
- signal=true;
- //PulseEvent(event);
- SetEvent(event);
-}
-
-void RemoteWin::SendPower()
-{
-
- curevent=POWER;
- hascurevent=true;
- SetEvent(event);
-}
-
+++ /dev/null
-/*
- Copyright 2004-2005 Chris Tallon
-
- This file is part of VOMP.
-
- VOMP 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; either version 2 of the License, or
- (at your option) any later version.
-
- VOMP 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 VOMP; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-*/
-
-#ifndef REMOTEWIN_H
-#define REMOTEWIN_H
-
-#include <stdio.h>
-
-#include "defines.h"
-#include "log.h"
-#include "input.h"
-
-#define _WIN32_WINNT 0x501
-#include <winsock2.h>
-#include <windowsx.h>
-
-
-
-class RemoteWin : public Remote
-{
- public:
- RemoteWin();
- ~RemoteWin();
-
- int init(const char *devName);
- int shutdown();
- int getDevice();
- UCHAR getButtonPress(int how);
- void Signal();
- int ReceiveButtonVK(UINT button);//Windows Message from WND_PROC
- int ReceiveButtonCH(UINT button);//Windows Message from WND_PROC
- int ReceiveButtonAP(UINT button);
- int ReceiveButtonRI(UINT button);
- void SendPower();
- void InitHWCListwithDefaults();
- const char*HardcodedTranslateStr(UCHAR command);
- char* HCWDesc(ULLONG hcw);
-
-
- private:
- int initted;
- bool signal;
- UCHAR curevent;
- bool hascurevent;
- HANDLE event;
- UCHAR TranslateHWCFixed(ULLONG code);
-};
-
-#endif
-
int soError; // SO_ERROR optval is int
socklen_t soErrorSize = sizeof(soError);
+
+#ifdef WIN32
+ int gso = getsockopt(sock, SOL_SOCKET, SO_ERROR, reinterpret_cast<char*>(&soError), &soErrorSize);
+#else
int gso = getsockopt(sock, SOL_SOCKET, SO_ERROR, reinterpret_cast<void*>(&soError), &soErrorSize);
+#endif
if ((gso == 0) && (soError == 0))
{
// Set receive window
// According to docs, optval in setsockopt is a pointer to int unless otherwise noted
int rxSize = rxBufferSize;
+#ifdef WIN32
+ int r = setsockopt(sock, SOL_SOCKET, SO_RCVBUF, reinterpret_cast<char*>(&rxSize), sizeof(size_t));
+#else
int r = setsockopt(sock, SOL_SOCKET, SO_RCVBUF, reinterpret_cast<void*>(&rxSize), sizeof(size_t));
+#endif
Log::getInstance()->log("TCP", Log::DEBUG, "Set receive window to %i, success(=0): %i", rxBufferSize, r);
}
// Override this method in derived classes
virtual void threadMethod()=0;
- virtual void threadPostStopCleanup()=0;
+ virtual void threadPostStopCleanup() {};
ThreadWin();
~ThreadWin();
return 2;
}
- [[fallthrough]]; // it won't, as long as sl.getCurrentOptionData() is 1-5, but keep the compiler happy
+ FALLTHROUGH
+ // it won't, as long as sl.getCurrentOptionData() is 1-5, but keep the compiler happy
}
case Input::BACK:
{
}
// else drop through to stop
}
- [[fallthrough]];
+ FALLTHROUGH
case Input::STOP:
{
stop();
return 2;
}
}
- [[fallthrough]];
+ FALLTHROUGH
case Input::STOP:
case Input::MENU:
{
/*
Copyright 2004-2005 Chris Tallon
+ Copyright 2012 Marten Richter
This file is part of VOMP.
#include "defines.h"
#include "log.h"
-#include "remotewin.h"
+#include "inputman.h"
+#include "inputwin.h"
#include "ledwin.h"
#include "timers.h"
#include "videowin.h"
// Global variables --------------------------------------------------------------------------------------------------
int debugEnabled = 0;
Log* logger;
-Remote* remote;
+InputMan* remote;
+InputWin* inputWin;
Led* led;
Osd* osd;
Timers* timers;
// Init global vars ------------------------------------------------------------------------------------------------
logger = new Log();
- remote = new RemoteWin();
+ remote = new InputMan();
led = new LedWin();
timers = new Timers();
osd = new Osd_TYPE();
// Init modules ----------------------------------------------------------------------------------------------------
int success;
- success = remote->init("/dev/rawir");
+ success = remote->init();
if (success)
{
logger->log("Core", Log::INFO, "Remote module initialised");
return 0;
}
+ inputWin = remote->getInputWin();
+
success = led->init(0);
if (success)
{
//TODO: call command
logger->log("Core", Log::NOTICE, "Window closed, shutting down...");
- ((RemoteWin*)Input::getInstance())->SendPower();
+ //inputWin->SendPower(); // FIXME this could be the only call
+ command->stop();
+
PostQuitMessage(0);
}break;
case WM_SIZING: {
}
break;
case WM_KEYDOWN:
- if (((RemoteWin*)remote)->ReceiveButtonVK(wparam)) {
+ if (inputWin->ReceiveButtonVK(wparam)) {
return 0L; //We process that Key
} else {
return DefWindowProc(wind, msg, wparam, lparam);
break;
case WM_CHAR:
- if (((RemoteWin*)remote)->ReceiveButtonCH(wparam)) {
+ if (inputWin->ReceiveButtonCH(wparam)) {
return 0L; //We process that Key
} else {
return DefWindowProc(wind, msg, wparam, lparam);
break;
case WM_APPCOMMAND:
- if (((RemoteWin*)remote)->ReceiveButtonAP(GET_APPCOMMAND_LPARAM(lparam))){
+ if (inputWin->ReceiveButtonAP(GET_APPCOMMAND_LPARAM(lparam))){
return TRUE; //yes we process that message
} else {
return DefWindowProc(wind, msg, wparam, lparam);
if (lpit->header.dwType==RIM_TYPEHID && lpit->data.hid.dwSizeHid>=2) {
DWORD button=lpit->data.hid.bRawData[1] | (lpit->data.hid.bRawData[0]<< 8);
- if (((RemoteWin*)remote)->ReceiveButtonRI(button)){
+ if (inputWin->ReceiveButtonRI(button)){
free(lpit);
return 0; //yes we process that message
}
ToggleTopmost();
return 0;
}
- if (((RemoteWin*)remote)->ReceiveButtonAP(LOWORD(wparam))){
+ if (inputWin->ReceiveButtonAP(LOWORD(wparam))){
return 0; //yes we process that message
} else {
return DefWindowProc(wind, msg, wparam, lparam);
*ptr++ = ethaddr [i];
/* Send the packet out */
- if (sendto (packet, static_cast<void*>(buf), 102, 0, reinterpret_cast<struct sockaddr *>(&sap), sizeof (sap)) < 0)
+#ifdef WIN32
+ if (sendto(packet, reinterpret_cast<const char*>(buf), 102, 0, reinterpret_cast<struct sockaddr *>(&sap), sizeof (sap)) < 0)
+#else
+ if (sendto(packet, static_cast<void*>(buf), 102, 0, reinterpret_cast<struct sockaddr *>(&sap), sizeof(sap)) < 0)
+#endif
{
fprintf (stderr, " sendto failed, %s\n",
strerror(errno));
case Input::OK:
{
AudioWin*aw=(AudioWin*)Audio::getInstance();
- aw->selectAudioFilter(sl.getCurrentOptionData());
+ aw->selectAudioFilter(reinterpret_cast<ULONG>(sl.getCurrentOptionData()));
return 1;
}
{
char * desc=new char [strlen(name)+1];
strcpy(desc,name);
- sl.addOption(desc,i,0);
+ sl.addOption(desc, reinterpret_cast<void*>(i), 0);
}
}
case Input::OK:
{
AudioWin*aw=(AudioWin*)Audio::getInstance();
- aw->selectMp3AudioFilter(sl.getCurrentOptionData());
+ aw->selectMp3AudioFilter(reinterpret_cast<ULONG>(sl.getCurrentOptionData()));
return 1;
}
if (filselected!=-1) drawText((*list)[filselected].friendlyname,215,15,DrawStyle::LIGHTTEXT);
sl.draw();
- if (!(*list)[sl.getCurrentOptionData()].vmr9tested)
+ if (!(*list)[reinterpret_cast<ULONG>(sl.getCurrentOptionData())].vmr9tested)
{
rectangle(area.w - 220, 160, 200, 20, DrawStyle::YELLOW);
drawText(tr("VMR 9 support: ?"), area.w - 220, 160, DrawStyle::DARKTEXT);
}
- else if ((*list)[sl.getCurrentOptionData()].vmr9)
+ else if ((*list)[reinterpret_cast<ULONG>(sl.getCurrentOptionData())].vmr9)
{
rectangle(area.w - 220, 160, 200, 20, DrawStyle::GREEN);
drawText(tr("VMR 9 support: yes"), area.w - 220, 160, DrawStyle::DARKTEXT);
case Input::OK:
{
VideoWin*vw=(VideoWin*)Video::getInstance();
- vw->selectVideoFilter(sl.getCurrentOptionData());
+ vw->selectVideoFilter(reinterpret_cast<ULONG>(sl.getCurrentOptionData()));
return 1;
}
case Input::BACK:
{
char * desc=new char [strlen(name)+1];
strcpy(desc,name);
- sl.addOption(desc,i,0);
+ sl.addOption(desc, reinterpret_cast<void*>(i), 0);
}
}
if (filselected!=-1) drawText((*list)[filselected].friendlyname,215,15,DrawStyle::LIGHTTEXT);
sl.draw();
- if (!(*list)[sl.getCurrentOptionData()].vmr9tested)
+ if (!(*list)[reinterpret_cast<ULONG>(sl.getCurrentOptionData())].vmr9tested)
{
rectangle(area.w - 220, 160, 200, 20, DrawStyle::YELLOW);
drawText(tr("VMR 9 support: ?"), area.w - 220, 160, DrawStyle::DARKTEXT);
}
- else if ((*list)[sl.getCurrentOptionData()].vmr9)
+ else if ((*list)[reinterpret_cast<ULONG>(sl.getCurrentOptionData())].vmr9)
{
rectangle(area.w - 220, 160, 200, 20, DrawStyle::GREEN);
drawText(tr("VMR 9 support: yes"), area.w - 220, 160, DrawStyle::DARKTEXT);
case Input::OK:
{
VideoWin*vw=(VideoWin*)Video::getInstance();
- vw->selectVideoH264Filter(sl.getCurrentOptionData());
+ vw->selectVideoH264Filter(reinterpret_cast<ULONG>(sl.getCurrentOptionData()));
return 1;
}
case Input::BACK: