Minor Style Fixes

This commit is contained in:
Florian Märkl 2021-01-01 15:24:53 +01:00
commit 49d65ad14a
No known key found for this signature in database
GPG key ID: 125BC8A5A6A1E857
32 changed files with 248 additions and 304 deletions

View file

@ -109,7 +109,6 @@ static const float vert_pos[] = {
1.0f, 1.0f
};
QSurfaceFormat AVOpenGLWidget::CreateSurfaceFormat()
{
QSurfaceFormat format;
@ -129,7 +128,7 @@ AVOpenGLWidget::AVOpenGLWidget(StreamSession *session, QWidget *parent)
{
enum AVPixelFormat pixel_format = chiaki_ffmpeg_decoder_get_pixel_format(session->GetFfmpegDecoder());
conversion_config = nullptr;
for(auto &cc: conversion_configs)
for(auto &cc : conversion_configs)
{
if(pixel_format == cc.pixel_format)
{

View file

@ -68,7 +68,6 @@ static QSet<QString> chiaki_motion_controller_guids({
"030000008f0e00001431000000000000",
});
static ControllerManager *instance = nullptr;
#define UPDATE_INTERVAL_MS 4

View file

@ -88,10 +88,10 @@ uint32_t Settings::GetLogLevelMask()
}
static const QMap<ChiakiVideoResolutionPreset, QString> resolutions = {
{ CHIAKI_VIDEO_RESOLUTION_PRESET_360p, "360p"},
{ CHIAKI_VIDEO_RESOLUTION_PRESET_540p, "540p"},
{ CHIAKI_VIDEO_RESOLUTION_PRESET_720p, "720p"},
{ CHIAKI_VIDEO_RESOLUTION_PRESET_1080p, "1080p"}
{ CHIAKI_VIDEO_RESOLUTION_PRESET_360p, "360p" },
{ CHIAKI_VIDEO_RESOLUTION_PRESET_540p, "540p" },
{ CHIAKI_VIDEO_RESOLUTION_PRESET_720p, "720p" },
{ CHIAKI_VIDEO_RESOLUTION_PRESET_1080p, "1080p" }
};
static const ChiakiVideoResolutionPreset resolution_default = CHIAKI_VIDEO_RESOLUTION_PRESET_720p;
@ -136,8 +136,8 @@ void Settings::SetBitrate(unsigned int bitrate)
}
static const QMap<ChiakiCodec, QString> codecs = {
{ CHIAKI_CODEC_H264, "h264"},
{ CHIAKI_CODEC_H265, "h265"}
{ CHIAKI_CODEC_H264, "h264" },
{ CHIAKI_CODEC_H265, "h265" }
};
static const ChiakiCodec codec_default = CHIAKI_CODEC_H265;

View file

@ -112,7 +112,7 @@ SettingsDialog::SettingsDialog(Settings *settings, QWidget *parent) : QDialog(pa
auto available_devices = audio_devices_future_watcher->result();
while(audio_device_combo_box->count() > 1) // remove all but "Auto"
audio_device_combo_box->removeItem(1);
for (QAudioDeviceInfo di : available_devices)
for(QAudioDeviceInfo di : available_devices)
audio_device_combo_box->addItem(di.deviceName(), di.deviceName());
int audio_out_device_index = audio_device_combo_box->findData(settings->GetAudioOutDevice());
audio_device_combo_box->setCurrentIndex(audio_out_device_index < 0 ? 0 : audio_out_device_index);
@ -136,10 +136,10 @@ SettingsDialog::SettingsDialog(Settings *settings, QWidget *parent) : QDialog(pa
resolution_combo_box = new QComboBox(this);
static const QList<QPair<ChiakiVideoResolutionPreset, const char *>> resolution_strings = {
{ CHIAKI_VIDEO_RESOLUTION_PRESET_360p, "360p"},
{ CHIAKI_VIDEO_RESOLUTION_PRESET_540p, "540p"},
{ CHIAKI_VIDEO_RESOLUTION_PRESET_720p, "720p"},
{ CHIAKI_VIDEO_RESOLUTION_PRESET_1080p, "1080p (PS5 and PS4 Pro only)"}
{ CHIAKI_VIDEO_RESOLUTION_PRESET_360p, "360p" },
{ CHIAKI_VIDEO_RESOLUTION_PRESET_540p, "540p" },
{ CHIAKI_VIDEO_RESOLUTION_PRESET_720p, "720p" },
{ CHIAKI_VIDEO_RESOLUTION_PRESET_1080p, "1080p (PS5 and PS4 Pro only)" }
};
auto current_res = settings->GetResolution();
for(const auto &p : resolution_strings)

View file

@ -7,7 +7,7 @@
#include <QVBoxLayout>
#include <QKeyEvent>
SettingsKeyCaptureDialog::SettingsKeyCaptureDialog(QWidget* parent)
SettingsKeyCaptureDialog::SettingsKeyCaptureDialog(QWidget *parent)
{
setWindowTitle(tr("Key Capture"));
@ -23,7 +23,7 @@ SettingsKeyCaptureDialog::SettingsKeyCaptureDialog(QWidget* parent)
connect(button, &QPushButton::clicked, this, &QDialog::accept);
}
void SettingsKeyCaptureDialog::keyReleaseEvent(QKeyEvent* event)
void SettingsKeyCaptureDialog::keyReleaseEvent(QKeyEvent *event)
{
KeyCaptured(Qt::Key(event->key()));
accept();

View file

@ -23,7 +23,6 @@ CHIAKI_EXPORT ChiakiErrorCode chiaki_audio_receiver_init(ChiakiAudioReceiver *au
return CHIAKI_ERR_SUCCESS;
}
CHIAKI_EXPORT void chiaki_audio_receiver_fini(ChiakiAudioReceiver *audio_receiver)
{
#ifdef CHIAKI_LIB_ENABLE_OPUS
@ -32,7 +31,6 @@ CHIAKI_EXPORT void chiaki_audio_receiver_fini(ChiakiAudioReceiver *audio_receive
chiaki_mutex_fini(&audio_receiver->mutex);
}
CHIAKI_EXPORT void chiaki_audio_receiver_stream_info(ChiakiAudioReceiver *audio_receiver, ChiakiAudioHeader *audio_header)
{
chiaki_mutex_lock(&audio_receiver->mutex);
@ -87,7 +85,7 @@ CHIAKI_EXPORT void chiaki_audio_receiver_av_packet(ChiakiAudioReceiver *audio_re
if(packet->frame_index > (1 << 15))
audio_receiver->frame_index_startup = false;
for(size_t i=0; i<source_units_count+fec_units_count; i++)
for(size_t i = 0; i < source_units_count + fec_units_count; i++)
{
ChiakiSeqNum16 frame_index;
if(i < source_units_count)

View file

@ -7,7 +7,6 @@
// Implementations taken from
// https://en.wikibooks.org/wiki/Algorithm_Implementation/Miscellaneous/Base64
CHIAKI_EXPORT ChiakiErrorCode chiaki_base64_encode(const uint8_t *in, size_t in_size, char *out, size_t out_size)
{
const char base64chars[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
@ -23,11 +22,11 @@ CHIAKI_EXPORT ChiakiErrorCode chiaki_base64_encode(const uint8_t *in, size_t in_
// these three 8-bit (ASCII) characters become one 24-bit number
n = ((uint32_t)in[x]) << 16;
if((x+1) < in_size)
n += ((uint32_t)in[x+1]) << 8;
if((x + 1) < in_size)
n += ((uint32_t)in[x + 1]) << 8;
if((x+2) < in_size)
n += in[x+2];
if((x + 2) < in_size)
n += in[x + 2];
// this 24-bit number gets separated into four 6-bit numbers
n0 = (uint8_t)(n >> 18) & 63;
@ -46,7 +45,7 @@ CHIAKI_EXPORT ChiakiErrorCode chiaki_base64_encode(const uint8_t *in, size_t in_
// if we have only two bytes available, then their encoding is
// spread out over three chars
if((x+1) < in_size)
if((x + 1) < in_size)
{
if(result_index >= out_size)
return CHIAKI_ERR_BUF_TOO_SMALL;
@ -55,7 +54,7 @@ CHIAKI_EXPORT ChiakiErrorCode chiaki_base64_encode(const uint8_t *in, size_t in_
// if we have all three bytes available, then their encoding is spread
// out over four characters
if((x+2) < in_size)
if((x + 2) < in_size)
{
if(result_index >= out_size)
return CHIAKI_ERR_BUF_TOO_SMALL;
@ -65,9 +64,9 @@ CHIAKI_EXPORT ChiakiErrorCode chiaki_base64_encode(const uint8_t *in, size_t in_
// create and add padding that is required if we did not have a multiple of 3
// number of characters available
if (pad_count > 0)
if(pad_count > 0)
{
for (; pad_count < 3; pad_count++)
for(; pad_count < 3; pad_count++)
{
if(result_index >= out_size)
return CHIAKI_ERR_BUF_TOO_SMALL;
@ -80,25 +79,22 @@ CHIAKI_EXPORT ChiakiErrorCode chiaki_base64_encode(const uint8_t *in, size_t in_
return CHIAKI_ERR_SUCCESS;
}
#define WHITESPACE 64
#define EQUALS 65
#define INVALID 66
static const unsigned char d[] = {
66,66,66,66,66,66,66,66,66,66,64,66,66,66,66,66,66,66,66,66,66,66,66,66,66,
66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,62,66,66,66,63,52,53,
54,55,56,57,58,59,60,61,66,66,66,65,66,66,66, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,66,66,66,66,66,66,26,27,28,
29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,66,66,
66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,
66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,
66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,
66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,
66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,66,
66,66,66,66,66,66
66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 64, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66,
66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 62, 66, 66, 66, 63, 52, 53,
54, 55, 56, 57, 58, 59, 60, 61, 66, 66, 66, 65, 66, 66, 66, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 66, 66, 66, 66, 66, 66, 26, 27, 28,
29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 66, 66,
66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66,
66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66,
66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66,
66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66,
66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66, 66,
66, 66, 66, 66, 66, 66
};
CHIAKI_EXPORT ChiakiErrorCode chiaki_base64_decode(const char *in, size_t in_size, uint8_t *out, size_t *out_size)
@ -108,7 +104,7 @@ CHIAKI_EXPORT ChiakiErrorCode chiaki_base64_decode(const char *in, size_t in_siz
uint32_t buf = 0;
size_t len = 0;
while (in < end)
while(in < end)
{
unsigned char c = d[(size_t)(*in++)];
@ -132,7 +128,8 @@ CHIAKI_EXPORT ChiakiErrorCode chiaki_base64_decode(const char *in, size_t in_siz
*(out++) = (unsigned char)((buf >> 16) & 0xff);
*(out++) = (unsigned char)((buf >> 8) & 0xff);
*(out++) = (unsigned char)(buf & 0xff);
buf = 0; iter = 0;
buf = 0;
iter = 0;
}
}
}

View file

@ -1,14 +1,14 @@
// SPDX-License-Identifier: LicenseRef-AGPL-3.0-only-OpenSSL
#include <chiaki/common.h>
#include <chiaki/random.h>
#include <chiaki/fec.h>
#include <chiaki/random.h>
#include <galois.h>
#include <errno.h>
#include <stdlib.h>
#include <time.h>
#include <errno.h>
#ifdef _WIN32
#include <winsock2.h>
@ -98,7 +98,7 @@ CHIAKI_EXPORT ChiakiErrorCode chiaki_lib_init()
WORD wsa_version = MAKEWORD(2, 2);
WSADATA wsa_data;
int err = WSAStartup(wsa_version, &wsa_data);
if (err != 0)
if(err != 0)
return CHIAKI_ERR_NETWORK;
}
#endif

View file

@ -14,7 +14,7 @@ CHIAKI_EXPORT void chiaki_controller_state_set_idle(ChiakiControllerState *state
state->right_x = 0;
state->right_y = 0;
state->touch_id_next = 0;
for(size_t i=0; i<CHIAKI_CONTROLLER_TOUCHES_MAX; i++)
for(size_t i = 0; i < CHIAKI_CONTROLLER_TOUCHES_MAX; i++)
{
state->touches[i].id = -1;
state->touches[i].x = 0;
@ -24,7 +24,7 @@ CHIAKI_EXPORT void chiaki_controller_state_set_idle(ChiakiControllerState *state
CHIAKI_EXPORT int8_t chiaki_controller_state_start_touch(ChiakiControllerState *state, uint16_t x, uint16_t y)
{
for(size_t i=0; i<CHIAKI_CONTROLLER_TOUCHES_MAX; i++)
for(size_t i = 0; i < CHIAKI_CONTROLLER_TOUCHES_MAX; i++)
{
if(state->touches[i].id < 0)
{
@ -40,7 +40,7 @@ CHIAKI_EXPORT int8_t chiaki_controller_state_start_touch(ChiakiControllerState *
CHIAKI_EXPORT void chiaki_controller_state_stop_touch(ChiakiControllerState *state, uint8_t id)
{
for(size_t i=0; i<CHIAKI_CONTROLLER_TOUCHES_MAX; i++)
for(size_t i = 0; i < CHIAKI_CONTROLLER_TOUCHES_MAX; i++)
{
if(state->touches[i].id == id)
{
@ -53,7 +53,7 @@ CHIAKI_EXPORT void chiaki_controller_state_stop_touch(ChiakiControllerState *sta
CHIAKI_EXPORT void chiaki_controller_state_set_touch_pos(ChiakiControllerState *state, uint8_t id, uint16_t x, uint16_t y)
{
id &= TOUCH_ID_MASK;
for(size_t i=0; i<CHIAKI_CONTROLLER_TOUCHES_MAX; i++)
for(size_t i = 0; i < CHIAKI_CONTROLLER_TOUCHES_MAX; i++)
{
if(state->touches[i].id == id)
{
@ -79,7 +79,7 @@ CHIAKI_EXPORT void chiaki_controller_state_or(ChiakiControllerState *out, Chiaki
out->right_y = MAX_ABS(a->right_y, b->right_y);
out->touch_id_next = 0;
for(size_t i=0; i<CHIAKI_CONTROLLER_TOUCHES_MAX; i++)
for(size_t i = 0; i < CHIAKI_CONTROLLER_TOUCHES_MAX; i++)
{
ChiakiControllerTouch *touch = a->touches[i].id >= 0 ? &a->touches[i] : (b->touches[i].id >= 0 ? &b->touches[i] : NULL);
if(!touch)

View file

@ -501,7 +501,6 @@ static void ctrl_enable_optional_features(ChiakiCtrl *ctrl)
ctrl_message_send(ctrl, 0x36, pre_enable, 4);
}
static void ctrl_message_received_session_id(ChiakiCtrl *ctrl, uint8_t *payload, size_t payload_size)
{
if(ctrl->session->ctrl_session_id_received)
@ -652,7 +651,7 @@ static void ctrl_message_received_keyboard_close(ChiakiCtrl *ctrl, uint8_t *payl
chiaki_session_send_event(ctrl->session, &keyboard_event);
}
static void ctrl_message_received_keyboard_text_change(ChiakiCtrl* ctrl, uint8_t* payload, size_t payload_size)
static void ctrl_message_received_keyboard_text_change(ChiakiCtrl *ctrl, uint8_t *payload, size_t payload_size)
{
assert(payload_size >= sizeof(CtrlKeyboardTextResponseMessage));
@ -676,7 +675,8 @@ static void ctrl_message_received_keyboard_text_change(ChiakiCtrl* ctrl, uint8_t
free(buffer);
}
typedef struct ctrl_response_t {
typedef struct ctrl_response_t
{
bool server_type_valid;
uint8_t rp_server_type[0x10];
bool success;
@ -742,7 +742,6 @@ static ChiakiErrorCode ctrl_connect(ChiakiCtrl *ctrl)
if(err != CHIAKI_ERR_SUCCESS)
CHIAKI_LOGE(session->log, "Failed to set ctrl socket to non-blocking: %s", chiaki_error_string(err));
chiaki_mutex_unlock(&ctrl->notif_mutex);
err = chiaki_stop_pipe_connect(&ctrl->notif_pipe, sock, sa, addr->ai_addrlen);
chiaki_mutex_lock(&ctrl->notif_mutex);

View file

@ -79,7 +79,6 @@ CHIAKI_EXPORT void chiaki_ecdh_fini(ChiakiECDH *ecdh)
#endif
}
CHIAKI_EXPORT ChiakiErrorCode chiaki_ecdh_set_local_key(ChiakiECDH *ecdh, const uint8_t *private_key, size_t private_key_size, const uint8_t *public_key, size_t public_key_size)
{
#ifdef CHIAKI_LIB_ENABLE_MBEDTLS
@ -89,24 +88,19 @@ CHIAKI_EXPORT ChiakiErrorCode chiaki_ecdh_set_local_key(ChiakiECDH *ecdh, const
// public
int r = 0;
r = mbedtls_ecp_point_read_binary(&ecdh->ctx.grp, &ecdh->ctx.Q,
public_key, public_key_size);
if(r != 0 ){
r = mbedtls_ecp_point_read_binary(&ecdh->ctx.grp, &ecdh->ctx.Q, public_key, public_key_size);
if(r != 0)
return CHIAKI_ERR_UNKNOWN;
}
// secret
r = mbedtls_mpi_read_binary(&ecdh->ctx.d, private_key, private_key_size);
if(r != 0 ){
if(r != 0)
return CHIAKI_ERR_UNKNOWN;
}
// regen key
r = mbedtls_ecdh_gen_public(&ecdh->ctx.grp, &ecdh->ctx.d,
&ecdh->ctx.Q, mbedtls_ctr_drbg_random, &ecdh->drbg);
if(r != 0 ){
r = mbedtls_ecdh_gen_public(&ecdh->ctx.grp, &ecdh->ctx.d, &ecdh->ctx.Q, mbedtls_ctr_drbg_random, &ecdh->drbg);
if(r != 0)
return CHIAKI_ERR_UNKNOWN;
}
return CHIAKI_ERR_SUCCESS;
#else

View file

@ -19,10 +19,8 @@
#include "utils.h"
#define KEY_BUF_CHUNK_SIZE 0x1000
static ChiakiErrorCode gkcrypt_gen_key_iv(ChiakiGKCrypt *gkcrypt, uint8_t index, const uint8_t *handshake_key, const uint8_t *ecdh_secret);
static void *gkcrypt_thread_func(void *user);
@ -110,7 +108,6 @@ CHIAKI_EXPORT void chiaki_gkcrypt_fini(ChiakiGKCrypt *gkcrypt)
}
}
static ChiakiErrorCode gkcrypt_gen_key_iv(ChiakiGKCrypt *gkcrypt, uint8_t index, const uint8_t *handshake_key, const uint8_t *ecdh_secret)
{
uint8_t data[3 + CHIAKI_HANDSHAKE_KEY_SIZE + 2];
@ -123,37 +120,41 @@ static ChiakiErrorCode gkcrypt_gen_key_iv(ChiakiGKCrypt *gkcrypt, uint8_t index,
uint8_t hmac[CHIAKI_GKCRYPT_BLOCK_SIZE*2];
size_t hmac_size = sizeof(hmac);
#ifdef CHIAKI_LIB_ENABLE_MBEDTLS
#ifdef CHIAKI_LIB_ENABLE_MBEDTLS
mbedtls_md_context_t ctx;
mbedtls_md_init(&ctx);
if(mbedtls_md_setup(&ctx, mbedtls_md_info_from_type(MBEDTLS_MD_SHA256) , 1) != 0){
if(mbedtls_md_setup(&ctx, mbedtls_md_info_from_type(MBEDTLS_MD_SHA256), 1) != 0)
{
mbedtls_md_free(&ctx);
return CHIAKI_ERR_UNKNOWN;
}
if(mbedtls_md_hmac_starts(&ctx, ecdh_secret, CHIAKI_ECDH_SECRET_SIZE) != 0){
if(mbedtls_md_hmac_starts(&ctx, ecdh_secret, CHIAKI_ECDH_SECRET_SIZE) != 0)
{
mbedtls_md_free(&ctx);
return CHIAKI_ERR_UNKNOWN;
}
if(mbedtls_md_hmac_update(&ctx, data, sizeof(data)) != 0){
if(mbedtls_md_hmac_update(&ctx, data, sizeof(data)) != 0)
{
mbedtls_md_free(&ctx);
return CHIAKI_ERR_UNKNOWN;
}
if(mbedtls_md_hmac_finish(&ctx, hmac) != 0){
if(mbedtls_md_hmac_finish(&ctx, hmac) != 0)
{
mbedtls_md_free(&ctx);
return CHIAKI_ERR_UNKNOWN;
}
mbedtls_md_free(&ctx);
#else
#else
if(!HMAC(EVP_sha256(), ecdh_secret, CHIAKI_ECDH_SECRET_SIZE, data, sizeof(data), hmac, (unsigned int *)&hmac_size))
return CHIAKI_ERR_UNKNOWN;
#endif
#endif
assert(hmac_size == sizeof(hmac));
memcpy(gkcrypt->key_base, hmac, CHIAKI_GKCRYPT_BLOCK_SIZE);
@ -220,7 +221,8 @@ CHIAKI_EXPORT ChiakiErrorCode chiaki_gkcrypt_gen_key_stream(ChiakiGKCrypt *gkcry
mbedtls_aes_context ctx;
mbedtls_aes_init(&ctx);
if(mbedtls_aes_setkey_enc(&ctx, gkcrypt->key_base, 128) != 0){
if(mbedtls_aes_setkey_enc(&ctx, gkcrypt->key_base, 128) != 0)
{
mbedtls_aes_free(&ctx);
return CHIAKI_ERR_UNKNOWN;
}
@ -248,9 +250,11 @@ CHIAKI_EXPORT ChiakiErrorCode chiaki_gkcrypt_gen_key_stream(ChiakiGKCrypt *gkcry
counter_add(cur, gkcrypt->iv, counter_offset++);
#ifdef CHIAKI_LIB_ENABLE_MBEDTLS
for(int i=0; i<buf_size; i=i+16){
for(int i = 0; i < buf_size; i = i + 16)
{
// loop over all blocks of 16 bytes (128 bits)
if(mbedtls_aes_crypt_ecb(&ctx, MBEDTLS_AES_ENCRYPT, buf+i, buf+i) != 0){
if(mbedtls_aes_crypt_ecb(&ctx, MBEDTLS_AES_ENCRYPT, buf + i, buf + i) != 0)
{
mbedtls_aes_free(&ctx);
return CHIAKI_ERR_UNKNOWN;
}
@ -373,13 +377,15 @@ CHIAKI_EXPORT ChiakiErrorCode chiaki_gkcrypt_gmac(ChiakiGKCrypt *gkcrypt, uint64
mbedtls_gcm_context actx;
mbedtls_gcm_init(&actx);
// set gmac_key 128 bits key
if(mbedtls_gcm_setkey(&actx, MBEDTLS_CIPHER_ID_AES, gmac_key, CHIAKI_GKCRYPT_BLOCK_SIZE*8) != 0){
if(mbedtls_gcm_setkey(&actx, MBEDTLS_CIPHER_ID_AES, gmac_key, CHIAKI_GKCRYPT_BLOCK_SIZE * 8) != 0)
{
mbedtls_gcm_free(&actx);
return CHIAKI_ERR_UNKNOWN;
}
// encrypt without additional data
if(mbedtls_gcm_starts(&actx, MBEDTLS_GCM_ENCRYPT, iv, CHIAKI_GKCRYPT_BLOCK_SIZE, NULL, 0) != 0){
if(mbedtls_gcm_starts(&actx, MBEDTLS_GCM_ENCRYPT, iv, CHIAKI_GKCRYPT_BLOCK_SIZE, NULL, 0) != 0)
{
mbedtls_gcm_free(&actx);
return CHIAKI_ERR_UNKNOWN;
}
@ -389,7 +395,8 @@ CHIAKI_EXPORT ChiakiErrorCode chiaki_gkcrypt_gmac(ChiakiGKCrypt *gkcrypt, uint64
if(mbedtls_gcm_crypt_and_tag(&actx, MBEDTLS_GCM_ENCRYPT,
0, iv, CHIAKI_GKCRYPT_BLOCK_SIZE,
buf, buf_size, NULL, NULL,
CHIAKI_GKCRYPT_GMAC_SIZE, gmac_out) != 0){
CHIAKI_GKCRYPT_GMAC_SIZE, gmac_out) != 0)
{
mbedtls_gcm_free(&actx);
return CHIAKI_ERR_UNKNOWN;

View file

@ -11,7 +11,6 @@
#include <sys/socket.h>
#endif
CHIAKI_EXPORT void chiaki_http_header_free(ChiakiHttpHeader *header)
{
while(header)

View file

@ -74,4 +74,3 @@ CHIAKI_EXPORT void chiaki_packet_stats_get(ChiakiPacketStats *stats, bool reset,
reset_stats(stats);
chiaki_mutex_unlock(&stats->mutex);
}

View file

@ -28,10 +28,12 @@ CHIAKI_EXPORT ChiakiErrorCode chiaki_random_bytes_crypt(uint8_t *buf, size_t buf
mbedtls_entropy_init(&entropy);
mbedtls_ctr_drbg_set_prediction_resistance(&ctr_drbg, MBEDTLS_CTR_DRBG_PR_OFF);
if(mbedtls_ctr_drbg_seed(&ctr_drbg, mbedtls_entropy_func, &entropy, (const unsigned char *) "RANDOM_GEN", 10 ) != 0 ){
if(mbedtls_ctr_drbg_seed(&ctr_drbg, mbedtls_entropy_func, &entropy, (const unsigned char *)"RANDOM_GEN", 10) != 0)
{
return CHIAKI_ERR_UNKNOWN;
}
if(mbedtls_ctr_drbg_random(&ctr_drbg, buf, buf_size) != 0){
if(mbedtls_ctr_drbg_random(&ctr_drbg, buf, buf_size) != 0)
{
return CHIAKI_ERR_UNKNOWN;
}

View file

@ -160,7 +160,6 @@ static int request_header_format(char *buf, size_t buf_size, size_t payload_size
return cur;
}
CHIAKI_EXPORT ChiakiErrorCode chiaki_regist_request_payload_format(ChiakiTarget target, const uint8_t *ambassador, uint8_t *buf, size_t *buf_size, ChiakiRPCrypt *crypt, const char *psn_online_id, const uint8_t *psn_account_id, uint32_t pin)
{
size_t buf_size_val = *buf_size;

View file

@ -1865,7 +1865,6 @@ static const uint8_t *rpcrypt_hmac_key(ChiakiRPCrypt *rpcrypt)
}
}
#ifdef CHIAKI_LIB_ENABLE_MBEDTLS
CHIAKI_EXPORT ChiakiErrorCode chiaki_rpcrypt_generate_iv(ChiakiRPCrypt *rpcrypt, uint8_t *iv, uint64_t counter)
{
@ -1968,7 +1967,6 @@ CHIAKI_EXPORT ChiakiErrorCode chiaki_rpcrypt_generate_iv(ChiakiRPCrypt *rpcrypt,
buf[CHIAKI_RPCRYPT_KEY_SIZE + 6] = (uint8_t)((counter >> 0x08) & 0xff);
buf[CHIAKI_RPCRYPT_KEY_SIZE + 7] = (uint8_t)((counter >> 0x00) & 0xff);
uint8_t hmac[32];
unsigned int hmac_len = 0;
if(!HMAC(EVP_sha256(), hmac_key, CHIAKI_RPCRYPT_KEY_SIZE, buf, sizeof(buf), hmac, &hmac_len))

View file

@ -645,7 +645,6 @@ static void senkusha_takion_data(ChiakiSenkusha *senkusha, ChiakiTakionMessageDa
senkusha->state_finished = true;
chiaki_cond_signal(&senkusha->state_cond);
}
}
chiaki_mutex_unlock(&senkusha->state_mutex);
}
@ -878,4 +877,3 @@ static ChiakiErrorCode senkusha_send_data_wait_for_ack(ChiakiSenkusha *senkusha,
return err;
}

View file

@ -540,10 +540,8 @@ quit:
#undef QUIT
}
typedef struct session_response_t {
typedef struct session_response_t
{
uint32_t error_code;
const char *nonce;
const char *rp_version;
@ -652,7 +650,6 @@ static ChiakiErrorCode session_thread_request_session(ChiakiSession *session, Ch
break;
}
if(CHIAKI_SOCKET_IS_INVALID(session_sock))
{
CHIAKI_LOGE(session->log, "Session request connect failed eventually.");

View file

@ -27,9 +27,8 @@ CHIAKI_EXPORT ChiakiErrorCode chiaki_stop_pipe_init(ChiakiStopPipe *stop_pipe)
int addr_size = sizeof(stop_pipe->addr);
stop_pipe->fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
if(stop_pipe->fd < 0){
if(stop_pipe->fd < 0)
return CHIAKI_ERR_UNKNOWN;
}
stop_pipe->addr.sin_family = AF_INET;
// bind to localhost
stop_pipe->addr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);

View file

@ -56,7 +56,6 @@ static ChiakiErrorCode stream_connection_send_streaminfo_ack(ChiakiStreamConnect
static void stream_connection_takion_av(ChiakiStreamConnection *stream_connection, ChiakiTakionAVPacket *packet);
static ChiakiErrorCode stream_connection_send_heartbeat(ChiakiStreamConnection *stream_connection);
CHIAKI_EXPORT ChiakiErrorCode chiaki_stream_connection_init(ChiakiStreamConnection *stream_connection, ChiakiSession *session)
{
stream_connection->session = session;
@ -121,7 +120,6 @@ CHIAKI_EXPORT void chiaki_stream_connection_fini(ChiakiStreamConnection *stream_
chiaki_mutex_fini(&stream_connection->state_mutex);
}
static bool state_finished_cond_check(void *user)
{
ChiakiStreamConnection *stream_connection = user;
@ -399,7 +397,6 @@ static void stream_connection_takion_data_protobuf(ChiakiStreamConnection *strea
break;
}
chiaki_mutex_unlock(&stream_connection->state_mutex);
}
static void stream_connection_takion_data_rumble(ChiakiStreamConnection *stream_connection, uint8_t *buf, size_t buf_size)
@ -640,7 +637,6 @@ static bool pb_decode_resolution(pb_istream_t *stream, const pb_field_t *field,
return true;
}
static void stream_connection_takion_data_expect_streaminfo(ChiakiStreamConnection *stream_connection, uint8_t *buf, size_t buf_size)
{
tkproto_TakionMessage msg;
@ -709,11 +705,9 @@ error:
chiaki_cond_signal(&stream_connection->state_cond);
}
static bool chiaki_pb_encode_zero_encrypted_key(pb_ostream_t *stream, const pb_field_t *field, void *const *arg)
{
if (!pb_encode_tag_for_field(stream, field))
if(!pb_encode_tag_for_field(stream, field))
return false;
uint8_t data[] = { 0, 0, 0, 0 };
return pb_encode_string(stream, data, sizeof(data));
@ -867,7 +861,6 @@ static ChiakiErrorCode stream_connection_send_disconnect(ChiakiStreamConnection
return err;
}
static void stream_connection_takion_av(ChiakiStreamConnection *stream_connection, ChiakiTakionAVPacket *packet)
{
chiaki_gkcrypt_decrypt(stream_connection->gkcrypt_remote, packet->key_pos + CHIAKI_GKCRYPT_BLOCK_SIZE, packet->data, packet->data_size);
@ -878,7 +871,6 @@ static void stream_connection_takion_av(ChiakiStreamConnection *stream_connectio
chiaki_audio_receiver_av_packet(stream_connection->audio_receiver, packet);
}
static ChiakiErrorCode stream_connection_send_heartbeat(ChiakiStreamConnection *stream_connection)
{
tkproto_TakionMessage msg = { 0 };

View file

@ -107,7 +107,6 @@ typedef enum takion_chunk_type_t {
TAKION_CHUNK_TYPE_COOKIE_ACK = 0xb,
} TakionChunkType;
typedef struct takion_message_t
{
uint32_t tag;
@ -120,7 +119,6 @@ typedef struct takion_message_t
uint8_t *payload;
} TakionMessage;
typedef struct takion_message_payload_init_t
{
uint32_t tag;
@ -152,14 +150,12 @@ typedef struct
uint16_t channel;
} TakionDataPacketEntry;
typedef struct chiaki_takion_postponed_packet_t
{
uint8_t *buf;
size_t buf_size;
} ChiakiTakionPostponedPacket;
static void *takion_thread_func(void *user);
static void takion_handle_packet(ChiakiTakion *takion, uint8_t *buf, size_t buf_size);
static ChiakiErrorCode takion_handle_packet_mac(ChiakiTakion *takion, uint8_t base_type, uint8_t *buf, size_t buf_size);
@ -603,7 +599,6 @@ static ChiakiErrorCode takion_handshake(ChiakiTakion *takion, uint32_t *seq_num_
CHIAKI_LOGI(takion->log, "Takion sent init");
// INIT_ACK <-
TakionMessagePayloadInitAck init_ack_payload;
@ -626,15 +621,12 @@ static ChiakiErrorCode takion_handshake(ChiakiTakion *takion, uint32_t *seq_num_
takion->tag_remote = init_ack_payload.tag;
*seq_num_remote_initial = takion->tag_remote; //init_ack_payload.initial_seq_num;
if(init_ack_payload.outbound_streams == 0 || init_ack_payload.inbound_streams == 0
|| init_ack_payload.outbound_streams > TAKION_INBOUND_STREAMS
|| init_ack_payload.inbound_streams < TAKION_OUTBOUND_STREAMS)
if(init_ack_payload.outbound_streams == 0 || init_ack_payload.inbound_streams == 0 || init_ack_payload.outbound_streams > TAKION_INBOUND_STREAMS || init_ack_payload.inbound_streams < TAKION_OUTBOUND_STREAMS)
{
CHIAKI_LOGE(takion->log, "Takion min/max check failed");
return CHIAKI_ERR_INVALID_RESPONSE;
}
// COOKIE ->
err = takion_send_message_cookie(takion, init_ack_payload.cookie);
@ -780,7 +772,6 @@ beach:
return NULL;
}
static ChiakiErrorCode takion_recv(ChiakiTakion *takion, uint8_t *buf, size_t *buf_size, uint64_t timeout_ms)
{
ChiakiErrorCode err = chiaki_stop_pipe_select_single(&takion->stop_pipe, takion->sock, false, timeout_ms);
@ -805,7 +796,6 @@ static ChiakiErrorCode takion_recv(ChiakiTakion *takion, uint8_t *buf, size_t *b
return CHIAKI_ERR_SUCCESS;
}
static ChiakiErrorCode takion_handle_packet_mac(ChiakiTakion *takion, uint8_t base_type, uint8_t *buf, size_t buf_size)
{
if(!takion->gkcrypt_remote)
@ -866,7 +856,6 @@ static void takion_postpone_packet(ChiakiTakion *takion, uint8_t *buf, size_t bu
packet->buf_size = buf_size;
}
/**
* @param buf ownership of this buf is taken.
*/
@ -934,7 +923,6 @@ static void takion_handle_packet_message(ChiakiTakion *takion, uint8_t *buf, siz
}
}
static void takion_flush_data_queue(ChiakiTakion *takion)
{
uint64_t seq_num = 0;
@ -1104,7 +1092,6 @@ static ChiakiErrorCode takion_parse_message(ChiakiTakion *takion, uint8_t *buf,
return CHIAKI_ERR_SUCCESS;
}
static ChiakiErrorCode takion_send_message_init(ChiakiTakion *takion, TakionMessagePayloadInit *payload)
{
uint8_t message[1 + TAKION_MESSAGE_HEADER_SIZE + 0x10];
@ -1121,8 +1108,6 @@ static ChiakiErrorCode takion_send_message_init(ChiakiTakion *takion, TakionMess
return chiaki_takion_send_raw(takion, message, sizeof(message));
}
static ChiakiErrorCode takion_send_message_cookie(ChiakiTakion *takion, uint8_t *cookie)
{
uint8_t message[1 + TAKION_MESSAGE_HEADER_SIZE + TAKION_COOKIE_SIZE];
@ -1132,8 +1117,6 @@ static ChiakiErrorCode takion_send_message_cookie(ChiakiTakion *takion, uint8_t
return chiaki_takion_send_raw(takion, message, sizeof(message));
}
static ChiakiErrorCode takion_recv_message_init_ack(ChiakiTakion *takion, TakionMessagePayloadInitAck *payload)
{
uint8_t message[1 + TAKION_MESSAGE_HEADER_SIZE + 0x10 + TAKION_COOKIE_SIZE];
@ -1181,7 +1164,6 @@ static ChiakiErrorCode takion_recv_message_init_ack(ChiakiTakion *takion, Takion
return CHIAKI_ERR_SUCCESS;
}
static ChiakiErrorCode takion_recv_message_cookie_ack(ChiakiTakion *takion)
{
uint8_t message[1 + TAKION_MESSAGE_HEADER_SIZE];
@ -1221,7 +1203,6 @@ static ChiakiErrorCode takion_recv_message_cookie_ack(ChiakiTakion *takion)
return CHIAKI_ERR_SUCCESS;
}
static void takion_handle_packet_av(ChiakiTakion *takion, uint8_t base_type, uint8_t *buf, size_t buf_size)
{
// HHIxIIx
@ -1453,5 +1434,4 @@ CHIAKI_EXPORT ChiakiErrorCode chiaki_takion_v7_av_packet_parse(ChiakiTakionAVPac
packet->data_size = buf_size;
return CHIAKI_ERR_SUCCESS;
}

View file

@ -23,7 +23,8 @@ static DWORD WINAPI win32_thread_func(LPVOID param)
#endif
#ifdef __SWITCH__
int64_t get_thread_limit(){
int64_t get_thread_limit()
{
uint64_t resource_limit_handle_value = INVALID_HANDLE;
svcGetInfo(&resource_limit_handle_value, InfoType_ResourceLimit, INVALID_HANDLE, 0);
int64_t thread_cur_value = 0, thread_lim_value = 0;
@ -45,9 +46,8 @@ CHIAKI_EXPORT ChiakiErrorCode chiaki_thread_create(ChiakiThread *thread, ChiakiT
return CHIAKI_ERR_THREAD;
#else
#ifdef __SWITCH__
if(get_thread_limit() <= 1){
if(get_thread_limit() <= 1)
return CHIAKI_ERR_THREAD;
}
#endif
int r = pthread_create(&thread->thread, NULL, func, arg);
if(r != 0)
@ -90,13 +90,13 @@ CHIAKI_EXPORT ChiakiErrorCode chiaki_thread_set_name(ChiakiThread *thread, const
if(r != 0)
return CHIAKI_ERR_THREAD;
#else
(void)thread; (void)name;
(void)thread;
(void)name;
#endif
#endif
return CHIAKI_ERR_SUCCESS;
}
CHIAKI_EXPORT ChiakiErrorCode chiaki_mutex_init(ChiakiMutex *mutex, bool rec)
{
#if _WIN32
@ -172,9 +172,6 @@ CHIAKI_EXPORT ChiakiErrorCode chiaki_mutex_unlock(ChiakiMutex *mutex)
return CHIAKI_ERR_SUCCESS;
}
CHIAKI_EXPORT ChiakiErrorCode chiaki_cond_init(ChiakiCond *cond)
{
#if _WIN32
@ -214,8 +211,6 @@ CHIAKI_EXPORT ChiakiErrorCode chiaki_cond_fini(ChiakiCond *cond)
return CHIAKI_ERR_SUCCESS;
}
CHIAKI_EXPORT ChiakiErrorCode chiaki_cond_wait(ChiakiCond *cond, ChiakiMutex *mutex)
{
#if _WIN32
@ -323,7 +318,6 @@ CHIAKI_EXPORT ChiakiErrorCode chiaki_cond_timedwait_pred(ChiakiCond *cond, Chiak
#endif
}
return CHIAKI_ERR_SUCCESS;
}
CHIAKI_EXPORT ChiakiErrorCode chiaki_cond_signal(ChiakiCond *cond)
@ -350,9 +344,6 @@ CHIAKI_EXPORT ChiakiErrorCode chiaki_cond_broadcast(ChiakiCond *cond)
return CHIAKI_ERR_SUCCESS;
}
CHIAKI_EXPORT ChiakiErrorCode chiaki_bool_pred_cond_init(ChiakiBoolPredCond *cond)
{
cond->pred = false;
@ -384,7 +375,6 @@ CHIAKI_EXPORT ChiakiErrorCode chiaki_bool_pred_cond_fini(ChiakiBoolPredCond *con
return CHIAKI_ERR_SUCCESS;
}
CHIAKI_EXPORT ChiakiErrorCode chiaki_bool_pred_cond_lock(ChiakiBoolPredCond *cond)
{
return chiaki_mutex_lock(&cond->mutex);

View file

@ -16,9 +16,9 @@
#define HOSTS_MAX 16
#define DROP_PINGS 3
static void Discovery(ChiakiDiscoveryHost * discovered_hosts, size_t hosts_count, void * user)
static void Discovery(ChiakiDiscoveryHost *discovered_hosts, size_t hosts_count, void *user)
{
DiscoveryManager * dm = (DiscoveryManager *)user;
DiscoveryManager *dm = (DiscoveryManager *)user;
for(size_t i = 0; i < hosts_count; i++)
{
dm->DiscoveryCB(discovered_hosts + i);
@ -105,7 +105,7 @@ uint32_t DiscoveryManager::GetIPv4BroadcastAddr()
#endif
}
int DiscoveryManager::Send(struct sockaddr * host_addr, size_t host_addr_len)
int DiscoveryManager::Send(struct sockaddr *host_addr, size_t host_addr_len)
{
if(!host_addr)
{
@ -120,9 +120,9 @@ int DiscoveryManager::Send(struct sockaddr * host_addr, size_t host_addr_len)
return 0;
}
int DiscoveryManager::Send(const char * discover_ip_dest)
int DiscoveryManager::Send(const char *discover_ip_dest)
{
struct addrinfo * host_addrinfos;
struct addrinfo *host_addrinfos;
int r = getaddrinfo(discover_ip_dest, NULL, NULL, &host_addrinfos);
if(r != 0)
{
@ -130,10 +130,10 @@ int DiscoveryManager::Send(const char * discover_ip_dest)
return 1;
}
struct sockaddr * host_addr = nullptr;
struct sockaddr *host_addr = nullptr;
socklen_t host_addr_len = 0;
for(struct addrinfo * ai = host_addrinfos; ai; ai = ai->ai_next)
for(struct addrinfo *ai = host_addrinfos; ai; ai = ai->ai_next)
{
if(ai->ai_protocol != IPPROTO_UDP)
continue;
@ -170,13 +170,13 @@ int DiscoveryManager::Send()
return DiscoveryManager::Send(this->host_addr, this->host_addr_len);
}
void DiscoveryManager::DiscoveryCB(ChiakiDiscoveryHost * discovered_host)
void DiscoveryManager::DiscoveryCB(ChiakiDiscoveryHost *discovered_host)
{
// the user ptr is passed as
// chiaki_discovery_thread_start arg
std::string key = discovered_host->host_name;
Host * host = this->settings->GetOrCreateHost(&key);
Host *host = this->settings->GetOrCreateHost(&key);
CHIAKI_LOGI(this->log, "--");
CHIAKI_LOGI(this->log, "Discovered Host:");

View file

@ -100,7 +100,7 @@ void HostInterface::Register(Host *host, std::function<void()> success_cb)
brls::Dialog *peprpc = new brls::Dialog("Please enter your PlayStation registration PIN code");
brls::GenericEvent::Callback cb_peprpc = [host, io, peprpc](brls::View *view) {
bool pin_provided = false;
char pin_input[9] = {0};
char pin_input[9] = { 0 };
std::string error_message;
// use callback to ensure that the message is showed on screen
@ -330,7 +330,7 @@ bool MainApplication::BuildConfigurationMenu(brls::List *ls, Host *host)
brls::ListItem *psn_account_id = new brls::ListItem("PSN Account ID", "PS5 or PS4 v7.0 and greater (base64 account_id)");
psn_account_id->setValue(psn_account_id_string.c_str());
auto psn_account_id_cb = [this, host, psn_account_id](brls::View *view) {
char account_id[CHIAKI_PSN_ACCOUNT_ID_SIZE * 2] = {0};
char account_id[CHIAKI_PSN_ACCOUNT_ID_SIZE * 2] = { 0 };
bool input = this->io->ReadUserKeyboard(account_id, sizeof(account_id));
if(input)
{
@ -349,7 +349,7 @@ bool MainApplication::BuildConfigurationMenu(brls::List *ls, Host *host)
brls::ListItem *psn_online_id = new brls::ListItem("PSN Online ID");
psn_online_id->setValue(psn_online_id_string.c_str());
auto psn_online_id_cb = [this, host, psn_online_id](brls::View *view) {
char online_id[256] = {0};
char online_id[256] = { 0 };
bool input = this->io->ReadUserKeyboard(online_id, sizeof(online_id));
if(input)
{
@ -380,7 +380,7 @@ bool MainApplication::BuildConfigurationMenu(brls::List *ls, Host *host)
}
brls::SelectListItem *resolution = new brls::SelectListItem(
"Resolution", {"720p", "540p", "360p"}, value);
"Resolution", { "720p", "540p", "360p" }, value);
auto resolution_cb = [this, host](int result) {
ChiakiVideoResolutionPreset value = CHIAKI_VIDEO_RESOLUTION_PRESET_720p;
@ -414,7 +414,7 @@ bool MainApplication::BuildConfigurationMenu(brls::List *ls, Host *host)
}
brls::SelectListItem *fps = new brls::SelectListItem(
"FPS", {"60", "30"}, value);
"FPS", { "60", "30" }, value);
auto fps_cb = [this, host](int result) {
ChiakiVideoFPSPreset value = CHIAKI_VIDEO_FPS_PRESET_60;
@ -467,7 +467,7 @@ void MainApplication::BuildAddHostConfigurationMenu(brls::List *add_host)
brls::ListItem *display_name = new brls::ListItem("Display name");
auto display_name_cb = [this, display_name](brls::View *view) {
char name[16] = {0};
char name[16] = { 0 };
bool input = this->io->ReadUserKeyboard(name, sizeof(name));
if(input)
{
@ -482,7 +482,7 @@ void MainApplication::BuildAddHostConfigurationMenu(brls::List *add_host)
brls::ListItem *address = new brls::ListItem("Remote IP/name");
auto address_cb = [this, address](brls::View *view) {
char addr[256] = {0};
char addr[256] = { 0 };
bool input = this->io->ReadUserKeyboard(addr, sizeof(addr));
if(input)
{
@ -500,7 +500,7 @@ void MainApplication::BuildAddHostConfigurationMenu(brls::List *add_host)
// brls::ListItem* port = new brls::ListItem("Remote stream port", "udp 9296");
// brls::ListItem* port = new brls::ListItem("Remote Senkusha port", "udp 9297");
brls::SelectListItem *ps_version = new brls::SelectListItem("PlayStation Version",
{"PS5", "PS4 > 8", "7 < PS4 < 8", "PS4 < 7"});
{ "PS5", "PS4 > 8", "7 < PS4 < 8", "PS4 < 7" });
auto ps_version_cb = [this, ps_version](int result) {
switch(result)
{

View file

@ -646,7 +646,7 @@ bool IO::InitOpenGlTextures()
D(glGenTextures(PLANES_COUNT, this->tex));
D(glGenBuffers(PLANES_COUNT, this->pbo));
uint8_t uv_default[] = {0x7f, 0x7f};
uint8_t uv_default[] = { 0x7f, 0x7f };
for(int i = 0; i < PLANES_COUNT; i++)
{
D(glBindTexture(GL_TEXTURE_2D, this->tex[i]));
@ -659,7 +659,7 @@ bool IO::InitOpenGlTextures()
D(glUseProgram(this->prog));
// bind only as many planes as we need
const char *plane_names[] = {"plane1", "plane2", "plane3"};
const char *plane_names[] = { "plane1", "plane2", "plane3" };
for(int i = 0; i < PLANES_COUNT; i++)
D(glUniform1i(glGetUniformLocation(this->prog, plane_names[i]), i));

View file

@ -111,11 +111,11 @@ extern "C" void userAppExit()
}
#endif // __SWITCH__
int main(int argc, char * argv[])
int main(int argc, char *argv[])
{
// load chiaki lib
Settings * settings = Settings::GetInstance();
ChiakiLog * log = settings->GetLogger();
Settings *settings = Settings::GetInstance();
ChiakiLog *log = settings->GetLogger();
CHIAKI_LOGI(log, "Loading chaki lib");

View file

@ -13,7 +13,7 @@ Settings::Settings()
#endif
}
Settings::ConfigurationItem Settings::ParseLine(std::string * line, std::string * value)
Settings::ConfigurationItem Settings::ParseLine(std::string *line, std::string *value)
{
Settings::ConfigurationItem ci;
std::smatch m;
@ -35,9 +35,9 @@ size_t Settings::GetB64encodeSize(size_t in)
return ((4 * in / 3) + 3) & ~3;
}
Settings * Settings::instance = nullptr;
Settings *Settings::instance = nullptr;
Settings * Settings::GetInstance()
Settings *Settings::GetInstance()
{
if(instance == nullptr)
{
@ -47,17 +47,17 @@ Settings * Settings::GetInstance()
return instance;
}
ChiakiLog * Settings::GetLogger()
ChiakiLog *Settings::GetLogger()
{
return &this->log;
}
std::map<std::string, Host> * Settings::GetHostsMap()
std::map<std::string, Host> *Settings::GetHostsMap()
{
return &this->hosts;
}
Host * Settings::GetOrCreateHost(std::string * host_name)
Host *Settings::GetOrCreateHost(std::string *host_name)
{
bool created = false;
// update of create Host instance
@ -69,7 +69,7 @@ Host * Settings::GetOrCreateHost(std::string * host_name)
created = true;
}
Host * host = &(this->hosts.at(*host_name));
Host *host = &(this->hosts.at(*host_name));
if(created)
{
// copy default settings
@ -90,7 +90,7 @@ void Settings::ParseFile()
std::string line;
std::string value;
bool rp_key_b = false, rp_regist_key_b = false, rp_key_type_b = false;
Host * current_host = nullptr;
Host *current_host = nullptr;
if(config_file.is_open())
{
CHIAKI_LOGV(&this->log, "Config file opened");
@ -231,7 +231,7 @@ int Settings::WriteFile()
if(it->second.rp_key_data || it->second.registered)
{
char rp_key_type[33] = {0};
char rp_key_type[33] = { 0 };
snprintf(rp_key_type, sizeof(rp_key_type), "%d", it->second.rp_key_type);
// save registered rp key for auto login
config_file << "rp_key = \"" << this->GetHostRPKey(&it->second) << "\"\n"
@ -334,7 +334,7 @@ ChiakiVideoFPSPreset Settings::StringToFPSPreset(std::string value)
return CHIAKI_VIDEO_FPS_PRESET_30;
}
std::string Settings::GetHostName(Host * host)
std::string Settings::GetHostName(Host *host)
{
if(host != nullptr)
return host->GetHostName();
@ -343,7 +343,7 @@ std::string Settings::GetHostName(Host * host)
return "";
}
std::string Settings::GetHostAddr(Host * host)
std::string Settings::GetHostAddr(Host *host)
{
if(host != nullptr)
return host->GetHostAddr();
@ -352,7 +352,7 @@ std::string Settings::GetHostAddr(Host * host)
return "";
}
std::string Settings::GetPSNOnlineID(Host * host)
std::string Settings::GetPSNOnlineID(Host *host)
{
if(host == nullptr || host->psn_online_id.length() == 0)
return this->global_psn_online_id;
@ -360,7 +360,7 @@ std::string Settings::GetPSNOnlineID(Host * host)
return host->psn_online_id;
}
void Settings::SetPSNOnlineID(Host * host, std::string psn_online_id)
void Settings::SetPSNOnlineID(Host *host, std::string psn_online_id)
{
if(host == nullptr)
this->global_psn_online_id = psn_online_id;
@ -368,7 +368,7 @@ void Settings::SetPSNOnlineID(Host * host, std::string psn_online_id)
host->psn_online_id = psn_online_id;
}
std::string Settings::GetPSNAccountID(Host * host)
std::string Settings::GetPSNAccountID(Host *host)
{
if(host == nullptr || host->psn_account_id.length() == 0)
return this->global_psn_account_id;
@ -376,7 +376,7 @@ std::string Settings::GetPSNAccountID(Host * host)
return host->psn_account_id;
}
void Settings::SetPSNAccountID(Host * host, std::string psn_account_id)
void Settings::SetPSNAccountID(Host *host, std::string psn_account_id)
{
if(host == nullptr)
this->global_psn_account_id = psn_account_id;
@ -384,7 +384,7 @@ void Settings::SetPSNAccountID(Host * host, std::string psn_account_id)
host->psn_account_id = psn_account_id;
}
ChiakiVideoResolutionPreset Settings::GetVideoResolution(Host * host)
ChiakiVideoResolutionPreset Settings::GetVideoResolution(Host *host)
{
if(host == nullptr)
return this->global_video_resolution;
@ -392,7 +392,7 @@ ChiakiVideoResolutionPreset Settings::GetVideoResolution(Host * host)
return host->video_resolution;
}
void Settings::SetVideoResolution(Host * host, ChiakiVideoResolutionPreset value)
void Settings::SetVideoResolution(Host *host, ChiakiVideoResolutionPreset value)
{
if(host == nullptr)
this->global_video_resolution = value;
@ -400,13 +400,13 @@ void Settings::SetVideoResolution(Host * host, ChiakiVideoResolutionPreset value
host->video_resolution = value;
}
void Settings::SetVideoResolution(Host * host, std::string value)
void Settings::SetVideoResolution(Host *host, std::string value)
{
ChiakiVideoResolutionPreset p = StringToResolutionPreset(value);
this->SetVideoResolution(host, p);
}
ChiakiVideoFPSPreset Settings::GetVideoFPS(Host * host)
ChiakiVideoFPSPreset Settings::GetVideoFPS(Host *host)
{
if(host == nullptr)
return this->global_video_fps;
@ -414,7 +414,7 @@ ChiakiVideoFPSPreset Settings::GetVideoFPS(Host * host)
return host->video_fps;
}
void Settings::SetVideoFPS(Host * host, ChiakiVideoFPSPreset value)
void Settings::SetVideoFPS(Host *host, ChiakiVideoFPSPreset value)
{
if(host == nullptr)
this->global_video_fps = value;
@ -422,18 +422,18 @@ void Settings::SetVideoFPS(Host * host, ChiakiVideoFPSPreset value)
host->video_fps = value;
}
void Settings::SetVideoFPS(Host * host, std::string value)
void Settings::SetVideoFPS(Host *host, std::string value)
{
ChiakiVideoFPSPreset p = StringToFPSPreset(value);
this->SetVideoFPS(host, p);
}
ChiakiTarget Settings::GetChiakiTarget(Host * host)
ChiakiTarget Settings::GetChiakiTarget(Host *host)
{
return host->GetChiakiTarget();
}
bool Settings::SetChiakiTarget(Host * host, ChiakiTarget target)
bool Settings::SetChiakiTarget(Host *host, ChiakiTarget target)
{
if(host != nullptr)
{
@ -447,20 +447,20 @@ bool Settings::SetChiakiTarget(Host * host, ChiakiTarget target)
}
}
bool Settings::SetChiakiTarget(Host * host, std::string value)
bool Settings::SetChiakiTarget(Host *host, std::string value)
{
// TODO Check possible target values
return this->SetChiakiTarget(host, static_cast<ChiakiTarget>(std::atoi(value.c_str())));
}
std::string Settings::GetHostRPKey(Host * host)
std::string Settings::GetHostRPKey(Host *host)
{
if(host != nullptr)
{
if(host->rp_key_data || host->registered)
{
size_t rp_key_b64_sz = this->GetB64encodeSize(0x10);
char rp_key_b64[rp_key_b64_sz + 1] = {0};
char rp_key_b64[rp_key_b64_sz + 1] = { 0 };
ChiakiErrorCode err;
err = chiaki_base64_encode(
host->rp_key, 0x10,
@ -478,7 +478,7 @@ std::string Settings::GetHostRPKey(Host * host)
return "";
}
bool Settings::SetHostRPKey(Host * host, std::string rp_key_b64)
bool Settings::SetHostRPKey(Host *host, std::string rp_key_b64)
{
if(host != nullptr)
{
@ -497,14 +497,14 @@ bool Settings::SetHostRPKey(Host * host, std::string rp_key_b64)
return false;
}
std::string Settings::GetHostRPRegistKey(Host * host)
std::string Settings::GetHostRPRegistKey(Host *host)
{
if(host != nullptr)
{
if(host->rp_key_data || host->registered)
{
size_t rp_regist_key_b64_sz = this->GetB64encodeSize(CHIAKI_SESSION_AUTH_SIZE);
char rp_regist_key_b64[rp_regist_key_b64_sz + 1] = {0};
char rp_regist_key_b64[rp_regist_key_b64_sz + 1] = { 0 };
ChiakiErrorCode err;
err = chiaki_base64_encode(
(uint8_t *)host->rp_regist_key, CHIAKI_SESSION_AUTH_SIZE,
@ -522,7 +522,7 @@ std::string Settings::GetHostRPRegistKey(Host * host)
return "";
}
bool Settings::SetHostRPRegistKey(Host * host, std::string rp_regist_key_b64)
bool Settings::SetHostRPRegistKey(Host *host, std::string rp_regist_key_b64)
{
if(host != nullptr)
{
@ -541,7 +541,7 @@ bool Settings::SetHostRPRegistKey(Host * host, std::string rp_regist_key_b64)
return false;
}
int Settings::GetHostRPKeyType(Host * host)
int Settings::GetHostRPKeyType(Host *host)
{
if(host != nullptr)
return host->rp_key_type;
@ -550,7 +550,7 @@ int Settings::GetHostRPKeyType(Host * host)
return 0;
}
bool Settings::SetHostRPKeyType(Host * host, std::string value)
bool Settings::SetHostRPKeyType(Host *host, std::string value)
{
if(host != nullptr)
{
@ -562,7 +562,7 @@ bool Settings::SetHostRPKeyType(Host * host, std::string value)
}
#ifdef CHIAKI_ENABLE_SWITCH_OVERCLOCK
int Settings::GetCPUOverclock(Host * host)
int Settings::GetCPUOverclock(Host *host)
{
if(host == nullptr)
return this->global_cpu_overclock;
@ -570,7 +570,7 @@ int Settings::GetCPUOverclock(Host * host)
return host->cpu_overclock;
}
void Settings::SetCPUOverclock(Host * host, int value)
void Settings::SetCPUOverclock(Host *host, int value)
{
int oc = OC_1326;
if(value > OC_1580)
@ -592,11 +592,9 @@ void Settings::SetCPUOverclock(Host * host, int value)
host->cpu_overclock = oc;
}
void Settings::SetCPUOverclock(Host * host, std::string value)
void Settings::SetCPUOverclock(Host *host, std::string value)
{
int v = atoi(value.c_str());
this->SetCPUOverclock(host, v);
}
#endif