2017-03-30 17:53:36 +02:00
|
|
|
/****************************************************************************
|
|
|
|
* Copyright (C) 2016,2017 Maschell
|
|
|
|
*
|
|
|
|
* 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, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* 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, see <http://www.gnu.org/licenses/>.
|
|
|
|
****************************************************************************/
|
2018-03-07 18:42:36 +01:00
|
|
|
#ifndef _CP_TCPSERVER_WINDOW_H_
|
|
|
|
#define _CP_TCPSERVER_WINDOW_H_
|
2017-03-30 17:53:36 +02:00
|
|
|
|
2017-10-29 09:34:47 +01:00
|
|
|
#include "../ControllerPatcherIncludes.hpp"
|
2017-05-07 14:44:09 +02:00
|
|
|
|
2018-03-07 18:42:36 +01:00
|
|
|
#include <utils/TCPServer.hpp>
|
2018-06-17 20:33:39 +02:00
|
|
|
#include <network/net.h>
|
|
|
|
#include <coreinit/title.h>
|
2017-03-30 17:53:36 +02:00
|
|
|
|
2017-04-13 15:30:40 +02:00
|
|
|
#define WIIU_CP_TCP_HANDSHAKE WIIU_CP_TCP_HANDSHAKE_VERSION_3
|
2017-04-10 15:39:58 +02:00
|
|
|
|
|
|
|
#define WIIU_CP_TCP_HANDSHAKE_VERSION_MIN WIIU_CP_TCP_HANDSHAKE_VERSION_1
|
2017-04-13 15:30:40 +02:00
|
|
|
#define WIIU_CP_TCP_HANDSHAKE_VERSION_MAX WIIU_CP_TCP_HANDSHAKE_VERSION_3
|
2017-04-10 15:39:58 +02:00
|
|
|
|
|
|
|
#define WIIU_CP_TCP_HANDSHAKE_VERSION_1 0x12
|
|
|
|
#define WIIU_CP_TCP_HANDSHAKE_VERSION_2 0x13
|
2017-04-13 15:30:40 +02:00
|
|
|
#define WIIU_CP_TCP_HANDSHAKE_VERSION_3 0x14
|
2017-04-10 15:39:58 +02:00
|
|
|
|
|
|
|
#define WIIU_CP_TCP_HANDSHAKE_ABORT 0x30
|
|
|
|
|
|
|
|
#define WIIU_CP_TCP_ATTACH 0x01
|
|
|
|
#define WIIU_CP_TCP_DETACH 0x02
|
|
|
|
#define WIIU_CP_TCP_PING 0xF0
|
|
|
|
#define WIIU_CP_TCP_PONG 0xF1
|
|
|
|
|
|
|
|
#define WIIU_CP_TCP_ATTACH_CONFIG_FOUND 0xE0
|
|
|
|
#define WIIU_CP_TCP_ATTACH_CONFIG_NOT_FOUND 0xE1
|
|
|
|
#define WIIU_CP_TCP_ATTACH_USER_DATA_OKAY 0xE8
|
|
|
|
#define WIIU_CP_TCP_ATTACH_USER_DATA_BAD 0xE9
|
|
|
|
|
2017-03-30 17:53:36 +02:00
|
|
|
#define DEFAULT_TCP_PORT 8112
|
|
|
|
|
2018-06-19 17:46:37 +02:00
|
|
|
class CPTCPServer: TCPServer {
|
2017-03-30 17:53:36 +02:00
|
|
|
friend class ControllerPatcher;
|
|
|
|
|
|
|
|
private:
|
2018-06-19 17:46:37 +02:00
|
|
|
static CPTCPServer *getInstance() {
|
|
|
|
if(!instance) {
|
2018-03-07 18:42:36 +01:00
|
|
|
|
|
|
|
instance = new CPTCPServer(DEFAULT_TCP_PORT);
|
|
|
|
}
|
2017-03-30 17:53:36 +02:00
|
|
|
return instance;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void destroyInstance() {
|
2018-06-19 17:46:37 +02:00
|
|
|
if(instance) {
|
2017-03-30 17:53:36 +02:00
|
|
|
delete instance;
|
|
|
|
instance = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-06-20 15:07:15 +02:00
|
|
|
static int32_t getPriority() {
|
|
|
|
int32_t priority = 28;
|
2018-03-07 18:42:36 +01:00
|
|
|
if(OSGetTitleID() == 0x00050000101c9300 || //The Legend of Zelda Breath of the Wild JPN
|
2018-06-19 17:46:37 +02:00
|
|
|
OSGetTitleID() == 0x00050000101c9400 || //The Legend of Zelda Breath of the Wild USA
|
|
|
|
OSGetTitleID() == 0x00050000101c9500 || //The Legend of Zelda Breath of the Wild EUR
|
|
|
|
OSGetTitleID() == 0x00050000101c9b00 || //The Binding of Isaac: Rebirth EUR
|
|
|
|
OSGetTitleID() == 0x00050000101a3c00) { //The Binding of Isaac: Rebirth USA
|
2018-03-07 18:42:36 +01:00
|
|
|
priority = 10;
|
|
|
|
DEBUG_FUNCTION_LINE("This game needs higher thread priority. We set it to %d\n",priority);
|
|
|
|
}
|
|
|
|
return priority;
|
|
|
|
}
|
|
|
|
|
2018-06-20 15:07:15 +02:00
|
|
|
CPTCPServer(int32_t port);
|
2017-03-30 17:53:36 +02:00
|
|
|
|
2018-03-07 18:42:36 +01:00
|
|
|
virtual ~CPTCPServer();
|
2017-03-30 17:53:36 +02:00
|
|
|
|
|
|
|
static void DetachConnectedNetworkController();
|
2018-03-07 18:42:36 +01:00
|
|
|
|
2018-06-19 17:40:02 +02:00
|
|
|
static void AttachDetach(HIDAttachEvent attach);
|
2017-03-30 17:53:36 +02:00
|
|
|
|
2018-03-07 18:42:36 +01:00
|
|
|
virtual void DetachAndDelete();
|
|
|
|
|
2018-06-20 15:07:15 +02:00
|
|
|
virtual BOOL whileLoop();
|
2018-03-07 18:42:36 +01:00
|
|
|
|
2018-06-20 15:07:15 +02:00
|
|
|
virtual BOOL acceptConnection();
|
2017-03-30 17:53:36 +02:00
|
|
|
|
2018-03-07 18:42:36 +01:00
|
|
|
virtual void onConnectionClosed();
|
2017-03-30 17:53:36 +02:00
|
|
|
|
2018-03-07 18:42:36 +01:00
|
|
|
static CPTCPServer * instance;
|
2017-03-30 17:53:36 +02:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif //_TCPSERVER_WINDOW_H_
|