From a2ebf7e40816778c982d49b2566e413db83f8fdb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=A4rkl?= Date: Wed, 11 Nov 2020 14:03:56 +0100 Subject: [PATCH] Disable Keyboard by default --- android/app/src/main/cpp/chiaki-jni.c | 2 +- gui/include/streamsession.h | 1 + gui/src/streamsession.cpp | 1 + lib/include/chiaki/session.h | 2 ++ lib/src/ctrl.c | 3 ++- lib/src/session.c | 1 + switch/src/host.cpp | 2 +- 7 files changed, 9 insertions(+), 3 deletions(-) diff --git a/android/app/src/main/cpp/chiaki-jni.c b/android/app/src/main/cpp/chiaki-jni.c index 195dfe5..b970ddc 100644 --- a/android/app/src/main/cpp/chiaki-jni.c +++ b/android/app/src/main/cpp/chiaki-jni.c @@ -204,7 +204,7 @@ JNIEXPORT void JNICALL JNI_FCN(sessionCreate)(JNIEnv *env, jobject obj, jobject jobject connect_video_profile_obj = E->GetObjectField(env, connect_info_obj, E->GetFieldID(env, connect_info_class, "videoProfile", "L"BASE_PACKAGE"/ConnectVideoProfile;")); jclass connect_video_profile_class = E->GetObjectClass(env, connect_video_profile_obj); - ChiakiConnectInfo connect_info; + ChiakiConnectInfo connect_info = { 0 }; const char *str_borrow = E->GetStringUTFChars(env, host_string, NULL); connect_info.host = host_str = strdup(str_borrow); E->ReleaseStringUTFChars(env, host_string, str_borrow); diff --git a/gui/include/streamsession.h b/gui/include/streamsession.h index 295998c..82acf86 100644 --- a/gui/include/streamsession.h +++ b/gui/include/streamsession.h @@ -44,6 +44,7 @@ struct StreamSessionConnectInfo ChiakiConnectVideoProfile video_profile; unsigned int audio_buffer_size; bool fullscreen; + bool enable_keyboard; StreamSessionConnectInfo(Settings *settings, QString host, QByteArray regist_key, QByteArray morning, bool fullscreen); }; diff --git a/gui/src/streamsession.cpp b/gui/src/streamsession.cpp index a6745ef..f26f9a2 100644 --- a/gui/src/streamsession.cpp +++ b/gui/src/streamsession.cpp @@ -27,6 +27,7 @@ StreamSessionConnectInfo::StreamSessionConnectInfo(Settings *settings, QString h this->morning = morning; audio_buffer_size = settings->GetAudioBufferSize(); this->fullscreen = fullscreen; + this->enable_keyboard = false; // TODO: from settings } static void AudioSettingsCb(uint32_t channels, uint32_t rate, void *user); diff --git a/lib/include/chiaki/session.h b/lib/include/chiaki/session.h index 558d045..80c89d3 100644 --- a/lib/include/chiaki/session.h +++ b/lib/include/chiaki/session.h @@ -76,6 +76,7 @@ typedef struct chiaki_connect_info_t char regist_key[CHIAKI_SESSION_AUTH_SIZE]; // must be completely filled (pad with \0) uint8_t morning[0x10]; ChiakiConnectVideoProfile video_profile; + bool enable_keyboard; } ChiakiConnectInfo; @@ -157,6 +158,7 @@ typedef struct chiaki_session_t uint8_t morning[CHIAKI_RPCRYPT_KEY_SIZE]; uint8_t did[CHIAKI_RP_DID_SIZE]; ChiakiConnectVideoProfile video_profile; + bool enable_keyboard; } connect_info; ChiakiTarget target; diff --git a/lib/src/ctrl.c b/lib/src/ctrl.c index 0f5e4a1..1c83568 100644 --- a/lib/src/ctrl.c +++ b/lib/src/ctrl.c @@ -488,7 +488,8 @@ static void ctrl_message_received(ChiakiCtrl *ctrl, uint16_t msg_type, uint8_t * static void ctrl_enable_optional_features(ChiakiCtrl *ctrl) { - // TODO: Make this optional. + if(!ctrl->session->connect_info.enable_keyboard) + return; // TODO: Last byte of pre_enable request is random (?) // TODO: Signature ?! uint8_t enable = 1; diff --git a/lib/src/session.c b/lib/src/session.c index 58f528c..496893d 100644 --- a/lib/src/session.c +++ b/lib/src/session.c @@ -215,6 +215,7 @@ CHIAKI_EXPORT ChiakiErrorCode chiaki_session_init(ChiakiSession *session, Chiaki memcpy(session->connect_info.did + sizeof(session->connect_info.did) - sizeof(did_suffix), did_suffix, sizeof(did_suffix)); session->connect_info.video_profile = connect_info->video_profile; + session->connect_info.enable_keyboard = connect_info->enable_keyboard; return CHIAKI_ERR_SUCCESS; error_stop_pipe: diff --git a/switch/src/host.cpp b/switch/src/host.cpp index e0d161a..200f74d 100644 --- a/switch/src/host.cpp +++ b/switch/src/host.cpp @@ -136,7 +136,7 @@ int Host::InitSession(IO * user) // Build chiaki ps4 stream session chiaki_opus_decoder_init(&(this->opus_decoder), this->log); ChiakiAudioSink audio_sink; - ChiakiConnectInfo chiaki_connect_info; + ChiakiConnectInfo chiaki_connect_info = { 0 }; chiaki_connect_info.host = this->host_addr.c_str(); chiaki_connect_info.video_profile = this->video_profile;