mirror of
https://github.com/pumpitupdev/pumptools.git
synced 2024-11-27 16:10:55 +01:00
Code format
This commit is contained in:
parent
e25d52c293
commit
94529e1e04
@ -202,7 +202,7 @@ enum cnh_result cnh_iobuf_write_be16(struct cnh_iobuf *dest, uint16_t value)
|
|||||||
return CNH_RESULT_ERROR_INSUFFICIENT_BUFFER;
|
return CNH_RESULT_ERROR_INSUFFICIENT_BUFFER;
|
||||||
}
|
}
|
||||||
|
|
||||||
dest->bytes[dest->pos++] = (uint8_t)(value >> 8);
|
dest->bytes[dest->pos++] = (uint8_t) (value >> 8);
|
||||||
dest->bytes[dest->pos++] = (uint8_t) value;
|
dest->bytes[dest->pos++] = (uint8_t) value;
|
||||||
|
|
||||||
return CNH_RESULT_SUCCESS;
|
return CNH_RESULT_SUCCESS;
|
||||||
@ -216,9 +216,9 @@ enum cnh_result cnh_iobuf_write_be32(struct cnh_iobuf *dest, uint32_t value)
|
|||||||
return CNH_RESULT_ERROR_INSUFFICIENT_BUFFER;
|
return CNH_RESULT_ERROR_INSUFFICIENT_BUFFER;
|
||||||
}
|
}
|
||||||
|
|
||||||
dest->bytes[dest->pos++] = (uint8_t)(value >> 24);
|
dest->bytes[dest->pos++] = (uint8_t) (value >> 24);
|
||||||
dest->bytes[dest->pos++] = (uint8_t)(value >> 16);
|
dest->bytes[dest->pos++] = (uint8_t) (value >> 16);
|
||||||
dest->bytes[dest->pos++] = (uint8_t)(value >> 8);
|
dest->bytes[dest->pos++] = (uint8_t) (value >> 8);
|
||||||
dest->bytes[dest->pos++] = (uint8_t) value;
|
dest->bytes[dest->pos++] = (uint8_t) value;
|
||||||
|
|
||||||
return CNH_RESULT_SUCCESS;
|
return CNH_RESULT_SUCCESS;
|
||||||
@ -233,7 +233,7 @@ enum cnh_result cnh_iobuf_write_le16(struct cnh_iobuf *dest, uint16_t value)
|
|||||||
}
|
}
|
||||||
|
|
||||||
dest->bytes[dest->pos++] = (uint8_t) value;
|
dest->bytes[dest->pos++] = (uint8_t) value;
|
||||||
dest->bytes[dest->pos++] = (uint8_t)(value >> 8);
|
dest->bytes[dest->pos++] = (uint8_t) (value >> 8);
|
||||||
|
|
||||||
return CNH_RESULT_SUCCESS;
|
return CNH_RESULT_SUCCESS;
|
||||||
}
|
}
|
||||||
@ -247,9 +247,9 @@ enum cnh_result cnh_iobuf_write_le32(struct cnh_iobuf *dest, uint32_t value)
|
|||||||
}
|
}
|
||||||
|
|
||||||
dest->bytes[dest->pos++] = (uint8_t) value;
|
dest->bytes[dest->pos++] = (uint8_t) value;
|
||||||
dest->bytes[dest->pos++] = (uint8_t)(value >> 8);
|
dest->bytes[dest->pos++] = (uint8_t) (value >> 8);
|
||||||
dest->bytes[dest->pos++] = (uint8_t)(value >> 16);
|
dest->bytes[dest->pos++] = (uint8_t) (value >> 16);
|
||||||
dest->bytes[dest->pos++] = (uint8_t)(value >> 24);
|
dest->bytes[dest->pos++] = (uint8_t) (value >> 24);
|
||||||
|
|
||||||
return CNH_RESULT_SUCCESS;
|
return CNH_RESULT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
|
|
||||||
#define LIB_MAIN_TRAP_MAIN(func_before_main, func_after_main) \
|
#define LIB_MAIN_TRAP_MAIN(func_before_main, func_after_main) \
|
||||||
typedef int (*func_libc_start_main_t)( \
|
typedef int (*func_libc_start_main_t)( \
|
||||||
int *(main)(int, char **, char **), \
|
int *(main) (int, char **, char **), \
|
||||||
int argc, \
|
int argc, \
|
||||||
char **ubp_av, \
|
char **ubp_av, \
|
||||||
void (*init)(void), \
|
void (*init)(void), \
|
||||||
@ -58,7 +58,7 @@
|
|||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
int __libc_start_main( \
|
int __libc_start_main( \
|
||||||
int *(main)(int, char **, char **), \
|
int *(main) (int, char **, char **), \
|
||||||
int argc, \
|
int argc, \
|
||||||
char **ubp_av, \
|
char **ubp_av, \
|
||||||
void (*init)(void), \
|
void (*init)(void), \
|
||||||
|
@ -67,29 +67,29 @@ static unsigned char PADDING[64] = {
|
|||||||
/* FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4.
|
/* FF, GG, HH, and II transformations for rounds 1, 2, 3, and 4.
|
||||||
Rotation is separate from addition to prevent recomputation.
|
Rotation is separate from addition to prevent recomputation.
|
||||||
*/
|
*/
|
||||||
#define FF(a, b, c, d, x, s, ac) \
|
#define FF(a, b, c, d, x, s, ac) \
|
||||||
{ \
|
{ \
|
||||||
(a) += F((b), (c), (d)) + (x) + (uint32_t)(ac); \
|
(a) += F((b), (c), (d)) + (x) + (uint32_t) (ac); \
|
||||||
(a) = ROTATE_LEFT((a), (s)); \
|
(a) = ROTATE_LEFT((a), (s)); \
|
||||||
(a) += (b); \
|
(a) += (b); \
|
||||||
}
|
}
|
||||||
#define GG(a, b, c, d, x, s, ac) \
|
#define GG(a, b, c, d, x, s, ac) \
|
||||||
{ \
|
{ \
|
||||||
(a) += G((b), (c), (d)) + (x) + (uint32_t)(ac); \
|
(a) += G((b), (c), (d)) + (x) + (uint32_t) (ac); \
|
||||||
(a) = ROTATE_LEFT((a), (s)); \
|
(a) = ROTATE_LEFT((a), (s)); \
|
||||||
(a) += (b); \
|
(a) += (b); \
|
||||||
}
|
}
|
||||||
#define HH(a, b, c, d, x, s, ac) \
|
#define HH(a, b, c, d, x, s, ac) \
|
||||||
{ \
|
{ \
|
||||||
(a) += H((b), (c), (d)) + (x) + (uint32_t)(ac); \
|
(a) += H((b), (c), (d)) + (x) + (uint32_t) (ac); \
|
||||||
(a) = ROTATE_LEFT((a), (s)); \
|
(a) = ROTATE_LEFT((a), (s)); \
|
||||||
(a) += (b); \
|
(a) += (b); \
|
||||||
}
|
}
|
||||||
#define II(a, b, c, d, x, s, ac) \
|
#define II(a, b, c, d, x, s, ac) \
|
||||||
{ \
|
{ \
|
||||||
(a) += I((b), (c), (d)) + (x) + (uint32_t)(ac); \
|
(a) += I((b), (c), (d)) + (x) + (uint32_t) (ac); \
|
||||||
(a) = ROTATE_LEFT((a), (s)); \
|
(a) = ROTATE_LEFT((a), (s)); \
|
||||||
(a) += (b); \
|
(a) += (b); \
|
||||||
}
|
}
|
||||||
|
|
||||||
/* MD5 initialization. Begins an MD5 operation, writing a new context.
|
/* MD5 initialization. Begins an MD5 operation, writing a new context.
|
||||||
|
@ -569,16 +569,16 @@ static const u32 rcon[] = {
|
|||||||
/* for 128-bit blocks, Rijndael never uses more than 10 rcon values */
|
/* for 128-bit blocks, Rijndael never uses more than 10 rcon values */
|
||||||
};
|
};
|
||||||
|
|
||||||
#define GETU32(plaintext) \
|
#define GETU32(plaintext) \
|
||||||
(((u32)(plaintext)[0] << 24) ^ ((u32)(plaintext)[1] << 16) ^ \
|
(((u32) (plaintext)[0] << 24) ^ ((u32) (plaintext)[1] << 16) ^ \
|
||||||
((u32)(plaintext)[2] << 8) ^ ((u32)(plaintext)[3]))
|
((u32) (plaintext)[2] << 8) ^ ((u32) (plaintext)[3]))
|
||||||
|
|
||||||
#define PUTU32(ciphertext, st) \
|
#define PUTU32(ciphertext, st) \
|
||||||
{ \
|
{ \
|
||||||
(ciphertext)[0] = (u8)((st) >> 24); \
|
(ciphertext)[0] = (u8) ((st) >> 24); \
|
||||||
(ciphertext)[1] = (u8)((st) >> 16); \
|
(ciphertext)[1] = (u8) ((st) >> 16); \
|
||||||
(ciphertext)[2] = (u8)((st) >> 8); \
|
(ciphertext)[2] = (u8) ((st) >> 8); \
|
||||||
(ciphertext)[3] = (u8)(st); \
|
(ciphertext)[3] = (u8) (st); \
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -34,10 +34,10 @@ exchook_lockchip_dec_chunk(uint8_t len, const uint8_t *src, uint8_t *dest)
|
|||||||
|
|
||||||
for (size_t i = 1; i < len; i++) {
|
for (size_t i = 1; i < len; i++) {
|
||||||
uint8_t result = sec_lockchip_step(src[i] ^ 0xFF);
|
uint8_t result = sec_lockchip_step(src[i] ^ 0xFF);
|
||||||
dest[i - 1] = (uint8_t)((last_res >> 3) ^ (result << 5));
|
dest[i - 1] = (uint8_t) ((last_res >> 3) ^ (result << 5));
|
||||||
last_res = result;
|
last_res = result;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t last_byte = sec_lockchip_step(0);
|
uint8_t last_byte = sec_lockchip_step(0);
|
||||||
dest[len - 1] = (uint8_t)((last_res >> 3) ^ (last_byte << 5));
|
dest[len - 1] = (uint8_t) ((last_res >> 3) ^ (last_byte << 5));
|
||||||
}
|
}
|
@ -45,7 +45,10 @@ static const struct util_options_def exchook_options_def[] = {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
.name = EXCHOOK_OPTIONS_STR_PATCH_GFX_SCALING_MODE,
|
.name = EXCHOOK_OPTIONS_STR_PATCH_GFX_SCALING_MODE,
|
||||||
.description = "Set a scaling mode for the rendered output. Available modes: 0 = disabled, 1 = SD 480 to pillarbox HD 720, 2 = SD 480 to pillarbox HD 1080, 3 = SD 480 to SD 960, 4 = HD 720 to HD 1080",
|
.description =
|
||||||
|
"Set a scaling mode for the rendered output. Available modes: 0 = "
|
||||||
|
"disabled, 1 = SD 480 to pillarbox HD 720, 2 = SD 480 to pillarbox "
|
||||||
|
"HD 1080, 3 = SD 480 to SD 960, 4 = HD 720 to HD 1080",
|
||||||
.param = 'z',
|
.param = 'z',
|
||||||
.type = UTIL_OPTIONS_TYPE_INT,
|
.type = UTIL_OPTIONS_TYPE_INT,
|
||||||
.is_secret_data = false,
|
.is_secret_data = false,
|
||||||
|
@ -36,7 +36,10 @@ const struct util_options_def f2hook_options_def[] = {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
.name = F2HOOK_OPTIONS_STR_PATCH_GFX_SCALING_MODE,
|
.name = F2HOOK_OPTIONS_STR_PATCH_GFX_SCALING_MODE,
|
||||||
.description = "Set a scaling mode for the rendered output. Available modes: 0 = disabled, 1 = SD 480 to pillarbox HD 720, 2 = SD 480 to pillarbox HD 1080, 3 = SD 480 to SD 960, 4 = HD 720 to HD 1080",
|
.description =
|
||||||
|
"Set a scaling mode for the rendered output. Available modes: 0 = "
|
||||||
|
"disabled, 1 = SD 480 to pillarbox HD 720, 2 = SD 480 to pillarbox "
|
||||||
|
"HD 1080, 3 = SD 480 to SD 960, 4 = HD 720 to HD 1080",
|
||||||
.param = 'z',
|
.param = 'z',
|
||||||
.type = UTIL_OPTIONS_TYPE_INT,
|
.type = UTIL_OPTIONS_TYPE_INT,
|
||||||
.is_secret_data = false,
|
.is_secret_data = false,
|
||||||
|
@ -36,7 +36,10 @@ const struct util_options_def fexhook_options_def[] = {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
.name = FEXHOOK_OPTIONS_STR_PATCH_GFX_SCALING_MODE,
|
.name = FEXHOOK_OPTIONS_STR_PATCH_GFX_SCALING_MODE,
|
||||||
.description = "Set a scaling mode for the rendered output. Available modes: 0 = disabled, 1 = SD 480 to pillarbox HD 720, 2 = SD 480 to pillarbox HD 1080, 3 = SD 480 to SD 960, 4 = HD 720 to HD 1080",
|
.description =
|
||||||
|
"Set a scaling mode for the rendered output. Available modes: 0 = "
|
||||||
|
"disabled, 1 = SD 480 to pillarbox HD 720, 2 = SD 480 to pillarbox "
|
||||||
|
"HD 1080, 3 = SD 480 to SD 960, 4 = HD 720 to HD 1080",
|
||||||
.param = 'z',
|
.param = 'z',
|
||||||
.type = UTIL_OPTIONS_TYPE_INT,
|
.type = UTIL_OPTIONS_TYPE_INT,
|
||||||
.is_secret_data = false,
|
.is_secret_data = false,
|
||||||
|
@ -36,7 +36,10 @@ const struct util_options_def fsthook_options_def[] = {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
.name = FSTHOOK_OPTIONS_STR_PATCH_GFX_SCALING_MODE,
|
.name = FSTHOOK_OPTIONS_STR_PATCH_GFX_SCALING_MODE,
|
||||||
.description = "Set a scaling mode for the rendered output. Available modes: 0 = disabled, 1 = SD 480 to pillarbox HD 720, 2 = SD 480 to pillarbox HD 1080, 3 = SD 480 to SD 960, 4 = HD 720 to HD 1080",
|
.description =
|
||||||
|
"Set a scaling mode for the rendered output. Available modes: 0 = "
|
||||||
|
"disabled, 1 = SD 480 to pillarbox HD 720, 2 = SD 480 to pillarbox "
|
||||||
|
"HD 1080, 3 = SD 480 to SD 960, 4 = HD 720 to HD 1080",
|
||||||
.param = 'z',
|
.param = 'z',
|
||||||
.type = UTIL_OPTIONS_TYPE_INT,
|
.type = UTIL_OPTIONS_TYPE_INT,
|
||||||
.is_secret_data = false,
|
.is_secret_data = false,
|
||||||
|
@ -35,7 +35,10 @@ static const struct util_options_def nxhook_options_def[] = {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
.name = NXHOOK_OPTIONS_STR_PATCH_GFX_SCALING_MODE,
|
.name = NXHOOK_OPTIONS_STR_PATCH_GFX_SCALING_MODE,
|
||||||
.description = "Set a scaling mode for the rendered output. Available modes: 0 = disabled, 1 = SD 480 to pillarbox HD 720, 2 = SD 480 to pillarbox HD 1080, 3 = SD 480 to SD 960, 4 = HD 720 to HD 1080",
|
.description =
|
||||||
|
"Set a scaling mode for the rendered output. Available modes: 0 = "
|
||||||
|
"disabled, 1 = SD 480 to pillarbox HD 720, 2 = SD 480 to pillarbox "
|
||||||
|
"HD 1080, 3 = SD 480 to SD 960, 4 = HD 720 to HD 1080",
|
||||||
.param = 'z',
|
.param = 'z',
|
||||||
.type = UTIL_OPTIONS_TYPE_INT,
|
.type = UTIL_OPTIONS_TYPE_INT,
|
||||||
.is_secret_data = false,
|
.is_secret_data = false,
|
||||||
|
@ -40,7 +40,10 @@ const struct util_options_def nx2hook_options_def[] = {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
.name = NX2HOOK_OPTIONS_STR_PATCH_GFX_SCALING_MODE,
|
.name = NX2HOOK_OPTIONS_STR_PATCH_GFX_SCALING_MODE,
|
||||||
.description = "Set a scaling mode for the rendered output. Available modes: 0 = disabled, 1 = SD 480 to pillarbox HD 720, 2 = SD 480 to pillarbox HD 1080, 3 = SD 480 to SD 960, 4 = HD 720 to HD 1080",
|
.description =
|
||||||
|
"Set a scaling mode for the rendered output. Available modes: 0 = "
|
||||||
|
"disabled, 1 = SD 480 to pillarbox HD 720, 2 = SD 480 to pillarbox "
|
||||||
|
"HD 1080, 3 = SD 480 to SD 960, 4 = HD 720 to HD 1080",
|
||||||
.param = 'z',
|
.param = 'z',
|
||||||
.type = UTIL_OPTIONS_TYPE_INT,
|
.type = UTIL_OPTIONS_TYPE_INT,
|
||||||
.is_secret_data = false,
|
.is_secret_data = false,
|
||||||
|
@ -40,7 +40,10 @@ const struct util_options_def nxahook_options_def[] = {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
.name = NXAHOOK_OPTIONS_STR_PATCH_GFX_SCALING_MODE,
|
.name = NXAHOOK_OPTIONS_STR_PATCH_GFX_SCALING_MODE,
|
||||||
.description = "Set a scaling mode for the rendered output. Available modes: 0 = disabled, 1 = SD 480 to pillarbox HD 720, 2 = SD 480 to pillarbox HD 1080, 3 = SD 480 to SD 960, 4 = HD 720 to HD 1080",
|
.description =
|
||||||
|
"Set a scaling mode for the rendered output. Available modes: 0 = "
|
||||||
|
"disabled, 1 = SD 480 to pillarbox HD 720, 2 = SD 480 to pillarbox "
|
||||||
|
"HD 1080, 3 = SD 480 to SD 960, 4 = HD 720 to HD 1080",
|
||||||
.param = 'z',
|
.param = 'z',
|
||||||
.type = UTIL_OPTIONS_TYPE_INT,
|
.type = UTIL_OPTIONS_TYPE_INT,
|
||||||
.is_secret_data = false,
|
.is_secret_data = false,
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
#define LOG_MODULE "patch-gfx"
|
#define LOG_MODULE "patch-gfx"
|
||||||
|
|
||||||
|
#include <GL/gl.h>
|
||||||
#include <X11/Xutil.h>
|
#include <X11/Xutil.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <GL/gl.h>
|
|
||||||
|
|
||||||
// OpenGL 3.x+
|
// OpenGL 3.x+
|
||||||
#include <GL/glx.h>
|
#include <GL/glx.h>
|
||||||
@ -165,8 +165,11 @@ void patch_gfx_init()
|
|||||||
log_info("Initialized");
|
log_info("Initialized");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Note, consider improving scaling, see http://www.david-amador.com/2013/04/opengl-2d-independent-resolution-rendering/
|
// Note, consider improving scaling, see
|
||||||
|
// http://www.david-amador.com/2013/04/opengl-2d-independent-resolution-rendering/
|
||||||
void patch_gfx_scale(enum patch_gfx_scale_mode scale_mode)
|
void patch_gfx_scale(enum patch_gfx_scale_mode scale_mode)
|
||||||
{
|
{
|
||||||
log_error("GFX scaling enabled but will not work. Temporarily removed due to issues with loading libGL.so");
|
log_error(
|
||||||
|
"GFX scaling enabled but will not work. Temporarily removed due to "
|
||||||
|
"issues with loading libGL.so");
|
||||||
}
|
}
|
||||||
|
@ -5,11 +5,11 @@
|
|||||||
* resolutions including keeping the aspect ratio
|
* resolutions including keeping the aspect ratio
|
||||||
*/
|
*/
|
||||||
enum patch_gfx_scale_mode {
|
enum patch_gfx_scale_mode {
|
||||||
PATCH_GFX_SCALE_MODE_INVALID = 0,
|
PATCH_GFX_SCALE_MODE_INVALID = 0,
|
||||||
PATCH_GFX_SCALE_MODE_SD_480_TO_PILLARBOX_HD_720 = 1,
|
PATCH_GFX_SCALE_MODE_SD_480_TO_PILLARBOX_HD_720 = 1,
|
||||||
PATCH_GFX_SCALE_MODE_SD_480_TO_PILLARBOX_HD_1080 = 2,
|
PATCH_GFX_SCALE_MODE_SD_480_TO_PILLARBOX_HD_1080 = 2,
|
||||||
PATCH_GFX_SCALE_MODE_SD_480_TO_SD_960 = 3,
|
PATCH_GFX_SCALE_MODE_SD_480_TO_SD_960 = 3,
|
||||||
PATCH_GFX_SCALE_MODE_HD_720_TO_HD_1080 = 4,
|
PATCH_GFX_SCALE_MODE_HD_720_TO_HD_1080 = 4,
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -468,9 +468,7 @@ static bool _patch_net_profile_download_profile_file(
|
|||||||
virtual_file->buffer,
|
virtual_file->buffer,
|
||||||
virtual_file->file_info->file_size)) {
|
virtual_file->file_info->file_size)) {
|
||||||
log_error(
|
log_error(
|
||||||
"Downloading file player %d, file_type %d, failed",
|
"Downloading file player %d, file_type %d, failed", player, file_type);
|
||||||
player,
|
|
||||||
file_type);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -536,16 +534,12 @@ static bool _patch_net_profile_upload_profile_file(
|
|||||||
virtual_file->buffer,
|
virtual_file->buffer,
|
||||||
virtual_file->file_info->file_size)) {
|
virtual_file->file_info->file_size)) {
|
||||||
log_error(
|
log_error(
|
||||||
"Uploading file player %d, file_type %d, failed",
|
"Uploading file player %d, file_type %d, failed", player, file_type);
|
||||||
player,
|
|
||||||
file_type);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
log_info(
|
log_info(
|
||||||
"Uploading file player %d, file_type %d, successful",
|
"Uploading file player %d, file_type %d, successful", player, file_type);
|
||||||
player,
|
|
||||||
file_type);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -641,10 +635,7 @@ void patch_net_profile_init(
|
|||||||
|
|
||||||
pthread_mutex_init(&_patch_net_profile_mutex, NULL);
|
pthread_mutex_init(&_patch_net_profile_mutex, NULL);
|
||||||
|
|
||||||
log_info(
|
log_info("Initialized: game %d, server %s", game, pumpnet_server_addr);
|
||||||
"Initialized: game %d, server %s",
|
|
||||||
game,
|
|
||||||
pumpnet_server_addr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void patch_net_profile_shutdown()
|
void patch_net_profile_shutdown()
|
||||||
|
@ -34,7 +34,10 @@ const struct util_options_def prihook_options_def[] = {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
.name = PRIHOOK_OPTIONS_STR_PATCH_GFX_SCALING_MODE,
|
.name = PRIHOOK_OPTIONS_STR_PATCH_GFX_SCALING_MODE,
|
||||||
.description = "Set a scaling mode for the rendered output. Available modes: 0 = disabled, 1 = SD 480 to pillarbox HD 720, 2 = SD 480 to pillarbox HD 1080, 3 = SD 480 to SD 960, 4 = HD 720 to HD 1080",
|
.description =
|
||||||
|
"Set a scaling mode for the rendered output. Available modes: 0 = "
|
||||||
|
"disabled, 1 = SD 480 to pillarbox HD 720, 2 = SD 480 to pillarbox "
|
||||||
|
"HD 1080, 3 = SD 480 to SD 960, 4 = HD 720 to HD 1080",
|
||||||
.param = 'z',
|
.param = 'z',
|
||||||
.type = UTIL_OPTIONS_TYPE_INT,
|
.type = UTIL_OPTIONS_TYPE_INT,
|
||||||
.is_secret_data = false,
|
.is_secret_data = false,
|
||||||
|
@ -43,7 +43,10 @@ static const struct util_options_def x2hook_options_def[] = {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
.name = X2HOOK_OPTIONS_STR_PATCH_GFX_SCALING_MODE,
|
.name = X2HOOK_OPTIONS_STR_PATCH_GFX_SCALING_MODE,
|
||||||
.description = "Set a scaling mode for the rendered output. Available modes: 0 = disabled, 1 = SD 480 to pillarbox HD 720, 2 = SD 480 to pillarbox HD 1080, 3 = SD 480 to SD 960, 4 = HD 720 to HD 1080",
|
.description =
|
||||||
|
"Set a scaling mode for the rendered output. Available modes: 0 = "
|
||||||
|
"disabled, 1 = SD 480 to pillarbox HD 720, 2 = SD 480 to pillarbox "
|
||||||
|
"HD 1080, 3 = SD 480 to SD 960, 4 = HD 720 to HD 1080",
|
||||||
.param = 'z',
|
.param = 'z',
|
||||||
.type = UTIL_OPTIONS_TYPE_INT,
|
.type = UTIL_OPTIONS_TYPE_INT,
|
||||||
.is_secret_data = false,
|
.is_secret_data = false,
|
||||||
|
@ -43,7 +43,10 @@ static const struct util_options_def zerohook_options_def[] = {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
.name = ZEROHOOK_OPTIONS_STR_PATCH_GFX_SCALING_MODE,
|
.name = ZEROHOOK_OPTIONS_STR_PATCH_GFX_SCALING_MODE,
|
||||||
.description = "Set a scaling mode for the rendered output. Available modes: 0 = disabled, 1 = SD 480 to pillarbox HD 720, 2 = SD 480 to pillarbox HD 1080, 3 = SD 480 to SD 960, 4 = HD 720 to HD 1080",
|
.description =
|
||||||
|
"Set a scaling mode for the rendered output. Available modes: 0 = "
|
||||||
|
"disabled, 1 = SD 480 to pillarbox HD 720, 2 = SD 480 to pillarbox "
|
||||||
|
"HD 1080, 3 = SD 480 to SD 960, 4 = HD 720 to HD 1080",
|
||||||
.param = 'z',
|
.param = 'z',
|
||||||
.type = UTIL_OPTIONS_TYPE_INT,
|
.type = UTIL_OPTIONS_TYPE_INT,
|
||||||
.is_secret_data = false,
|
.is_secret_data = false,
|
||||||
|
@ -182,18 +182,13 @@ int32_t io_usb_control_transfer(
|
|||||||
}
|
}
|
||||||
|
|
||||||
int32_t io_usb_interrupt_transfer(
|
int32_t io_usb_interrupt_transfer(
|
||||||
void *handle,
|
void *handle, int ep, uint8_t *data, uint16_t len, uint32_t timeout)
|
||||||
int ep,
|
|
||||||
uint8_t *data,
|
|
||||||
uint16_t len,
|
|
||||||
uint32_t timeout)
|
|
||||||
{
|
{
|
||||||
struct usb_io_ctx *dev = (struct usb_io_ctx *) handle;
|
struct usb_io_ctx *dev = (struct usb_io_ctx *) handle;
|
||||||
int32_t ret, transferred;
|
int32_t ret, transferred;
|
||||||
|
|
||||||
ret =
|
ret =
|
||||||
libusb_interrupt_transfer(
|
libusb_interrupt_transfer(dev->dev, ep, data, len, &transferred, timeout);
|
||||||
dev->dev, ep, data, len, &transferred, timeout);
|
|
||||||
|
|
||||||
if (transferred != len) {
|
if (transferred != len) {
|
||||||
log_error(
|
log_error(
|
||||||
|
@ -54,11 +54,7 @@ int32_t io_usb_control_transfer(
|
|||||||
* @return Number of bytes read/written or -1 on error
|
* @return Number of bytes read/written or -1 on error
|
||||||
*/
|
*/
|
||||||
int32_t io_usb_interrupt_transfer(
|
int32_t io_usb_interrupt_transfer(
|
||||||
void *handle,
|
void *handle, int ep, uint8_t *data, uint16_t len, uint32_t timeout);
|
||||||
int ep,
|
|
||||||
uint8_t *data,
|
|
||||||
uint16_t len,
|
|
||||||
uint32_t timeout);
|
|
||||||
/**
|
/**
|
||||||
* Close a opened usb device
|
* Close a opened usb device
|
||||||
*
|
*
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
/**
|
/**
|
||||||
* Communicate with the Andamiro "lxio" or ATMEGAPUMP or PIU HID.
|
* Communicate with the Andamiro "lxio" or ATMEGAPUMP or PIU HID.
|
||||||
* This device hosts all data in two address, and interrupt in and out.
|
* This device hosts all data in two address, and interrupt in and out.
|
||||||
* Device needs to be written then read in that order. Every read needs a preceding write.
|
* Device needs to be written then read in that order. Every read needs a
|
||||||
|
* preceding write.
|
||||||
*/
|
*/
|
||||||
#define LOG_MODULE "ptapi-io-piuio-lxio"
|
#define LOG_MODULE "ptapi-io-piuio-lxio"
|
||||||
|
|
||||||
@ -13,8 +14,8 @@
|
|||||||
|
|
||||||
#include "util/log.h"
|
#include "util/log.h"
|
||||||
|
|
||||||
#include "ptapi/io/piuio.h"
|
|
||||||
#include "ptapi/io/piubtn.h"
|
#include "ptapi/io/piubtn.h"
|
||||||
|
#include "ptapi/io/piuio.h"
|
||||||
|
|
||||||
// Data going to/from lxio
|
// Data going to/from lxio
|
||||||
uint8_t lxio_btn_state_buffer[LXIO_MSG_SIZE];
|
uint8_t lxio_btn_state_buffer[LXIO_MSG_SIZE];
|
||||||
@ -95,19 +96,19 @@ void convert_output_to_lxio()
|
|||||||
/* Menu Buttons */
|
/* Menu Buttons */
|
||||||
|
|
||||||
for (uint8_t i = 0; i < 2; i++) {
|
for (uint8_t i = 0; i < 2; i++) {
|
||||||
//both UR and UL are mapped to "back"
|
// both UR and UL are mapped to "back"
|
||||||
if (ptapi_piubtn_out[i].back) {
|
if (ptapi_piubtn_out[i].back) {
|
||||||
lxio_light_state_buffer[i+4] |= (1 << 0);
|
lxio_light_state_buffer[i + 4] |= (1 << 0);
|
||||||
lxio_light_state_buffer[i+4] |= (1 << 1);
|
lxio_light_state_buffer[i + 4] |= (1 << 1);
|
||||||
}
|
}
|
||||||
if (ptapi_piubtn_out[i].start) {
|
if (ptapi_piubtn_out[i].start) {
|
||||||
lxio_light_state_buffer[i+4] |= (1 << 2);
|
lxio_light_state_buffer[i + 4] |= (1 << 2);
|
||||||
}
|
}
|
||||||
if (ptapi_piubtn_out[i].left) {
|
if (ptapi_piubtn_out[i].left) {
|
||||||
lxio_light_state_buffer[i+4] |= (1 << 3);
|
lxio_light_state_buffer[i + 4] |= (1 << 3);
|
||||||
}
|
}
|
||||||
if (ptapi_piubtn_out[i].right) {
|
if (ptapi_piubtn_out[i].right) {
|
||||||
lxio_light_state_buffer[i+4] |= (1 << 4);
|
lxio_light_state_buffer[i + 4] |= (1 << 4);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -135,7 +136,6 @@ static void convert_input_to_piuio()
|
|||||||
ptapi_piuio_sys.clear = lxio_btn_state_buffer[8] & (1 << 7);
|
ptapi_piuio_sys.clear = lxio_btn_state_buffer[8] & (1 << 7);
|
||||||
ptapi_piuio_sys.coin = lxio_btn_state_buffer[8] & (1 << 2);
|
ptapi_piuio_sys.coin = lxio_btn_state_buffer[8] & (1 << 2);
|
||||||
ptapi_piuio_sys.coin2 = lxio_btn_state_buffer[9] & (1 << 2);
|
ptapi_piuio_sys.coin2 = lxio_btn_state_buffer[9] & (1 << 2);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ptapi_io_piuio_recv(void)
|
bool ptapi_io_piuio_recv(void)
|
||||||
@ -208,20 +208,20 @@ void ptapi_io_piuio_set_output_cab(
|
|||||||
&ptapi_piuio_cab_out, outputs, sizeof(struct ptapi_io_piuio_cab_outputs));
|
&ptapi_piuio_cab_out, outputs, sizeof(struct ptapi_io_piuio_cab_outputs));
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* ptapi_io_piubtn_ident(void)
|
const char *ptapi_io_piubtn_ident(void)
|
||||||
{
|
{
|
||||||
return "lxio";
|
return "lxio";
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ptapi_io_piubtn_open(void)
|
bool ptapi_io_piubtn_open(void)
|
||||||
{
|
{
|
||||||
//taken care of by piuio_open
|
// taken care of by piuio_open
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ptapi_io_piubtn_close(void)
|
void ptapi_io_piubtn_close(void)
|
||||||
{
|
{
|
||||||
//handled by piuio_close
|
// handled by piuio_close
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ptapi_io_piubtn_recv(void)
|
bool ptapi_io_piubtn_recv(void)
|
||||||
@ -236,33 +236,38 @@ bool ptapi_io_piubtn_send(void)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ptapi_io_piubtn_get_input(uint8_t player, struct ptapi_io_piubtn_inputs* inputs)
|
void ptapi_io_piubtn_get_input(
|
||||||
|
uint8_t player, struct ptapi_io_piubtn_inputs *inputs)
|
||||||
{
|
{
|
||||||
// Note: There could be consistancy issues if the two IOs are threaded by seperate threads
|
// Note: There could be consistancy issues if the two IOs are threaded by
|
||||||
// Decided to take the risk of potentially lost button inputs. Testing has yielded
|
// seperate threads Decided to take the risk of potentially lost button
|
||||||
// good results.
|
// inputs. Testing has yielded good results.
|
||||||
|
|
||||||
// Set all inputs to off
|
// Set all inputs to off
|
||||||
if (player == 0) {
|
if (player == 0) {
|
||||||
inputs->left = lxio_btn_state_buffer[10] & (1 << 3);
|
inputs->left = lxio_btn_state_buffer[10] & (1 << 3);
|
||||||
inputs->right = lxio_btn_state_buffer[10] & (1 << 4);
|
inputs->right = lxio_btn_state_buffer[10] & (1 << 4);
|
||||||
inputs->start = lxio_btn_state_buffer[10] & (1 << 2);
|
inputs->start = lxio_btn_state_buffer[10] & (1 << 2);
|
||||||
|
|
||||||
//map both UR and UL to "back" as this is how kpump maps it.
|
// map both UR and UL to "back" as this is how kpump maps it.
|
||||||
inputs->back = (lxio_btn_state_buffer[10] & (1 << 0)) |
|
inputs->back = (lxio_btn_state_buffer[10] & (1 << 0)) |
|
||||||
(lxio_btn_state_buffer[10] & (1 << 1));
|
(lxio_btn_state_buffer[10] & (1 << 1));
|
||||||
} else {
|
} else {
|
||||||
inputs->left = lxio_btn_state_buffer[11] & (1 << 3);
|
inputs->left = lxio_btn_state_buffer[11] & (1 << 3);
|
||||||
inputs->right = lxio_btn_state_buffer[11] & (1 << 4);
|
inputs->right = lxio_btn_state_buffer[11] & (1 << 4);
|
||||||
inputs->start = lxio_btn_state_buffer[11] & (1 << 2);
|
inputs->start = lxio_btn_state_buffer[11] & (1 << 2);
|
||||||
|
|
||||||
//map both UR and UL to "back" as this is how kpump maps it.
|
// map both UR and UL to "back" as this is how kpump maps it.
|
||||||
inputs->back = (lxio_btn_state_buffer[11] & (1 << 0)) |
|
inputs->back = (lxio_btn_state_buffer[11] & (1 << 0)) |
|
||||||
(lxio_btn_state_buffer[11] & (1 << 1));
|
(lxio_btn_state_buffer[11] & (1 << 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ptapi_io_piubtn_set_output(uint8_t player, const struct ptapi_io_piubtn_outputs* outputs)
|
void ptapi_io_piubtn_set_output(
|
||||||
|
uint8_t player, const struct ptapi_io_piubtn_outputs *outputs)
|
||||||
{
|
{
|
||||||
memcpy(&ptapi_piubtn_out[player], outputs, sizeof(struct ptapi_io_piubtn_outputs));
|
memcpy(
|
||||||
|
&ptapi_piubtn_out[player],
|
||||||
|
outputs,
|
||||||
|
sizeof(struct ptapi_io_piubtn_outputs));
|
||||||
}
|
}
|
||||||
|
@ -472,18 +472,18 @@ sec_hasp_asn1_encode_int(uint32_t val, uint8_t *buffer, size_t *offset)
|
|||||||
tmp[tmp_pos++] = (uint8_t) val;
|
tmp[tmp_pos++] = (uint8_t) val;
|
||||||
} else if (val <= 0xFFFF) {
|
} else if (val <= 0xFFFF) {
|
||||||
/* Big endian */
|
/* Big endian */
|
||||||
tmp[tmp_pos++] = (uint8_t)(val >> 8);
|
tmp[tmp_pos++] = (uint8_t) (val >> 8);
|
||||||
tmp[tmp_pos++] = (uint8_t) val;
|
tmp[tmp_pos++] = (uint8_t) val;
|
||||||
} else if (val <= 0xFFFFFF) {
|
} else if (val <= 0xFFFFFF) {
|
||||||
/* Big endian */
|
/* Big endian */
|
||||||
tmp[tmp_pos++] = (uint8_t)(val >> 16);
|
tmp[tmp_pos++] = (uint8_t) (val >> 16);
|
||||||
tmp[tmp_pos++] = (uint8_t)(val >> 8);
|
tmp[tmp_pos++] = (uint8_t) (val >> 8);
|
||||||
tmp[tmp_pos++] = (uint8_t) val;
|
tmp[tmp_pos++] = (uint8_t) val;
|
||||||
} else if (val <= 0xFFFFFFFF) {
|
} else if (val <= 0xFFFFFFFF) {
|
||||||
/* Big endian */
|
/* Big endian */
|
||||||
tmp[tmp_pos++] = (uint8_t)(val >> 24);
|
tmp[tmp_pos++] = (uint8_t) (val >> 24);
|
||||||
tmp[tmp_pos++] = (uint8_t)(val >> 16);
|
tmp[tmp_pos++] = (uint8_t) (val >> 16);
|
||||||
tmp[tmp_pos++] = (uint8_t)(val >> 8);
|
tmp[tmp_pos++] = (uint8_t) (val >> 8);
|
||||||
tmp[tmp_pos++] = (uint8_t) val;
|
tmp[tmp_pos++] = (uint8_t) val;
|
||||||
} else if (val <= 0xFFFFFFFFFFFFFFFF) {
|
} else if (val <= 0xFFFFFFFFFFFFFFFF) {
|
||||||
// TODO quad words not supported in decode?
|
// TODO quad words not supported in decode?
|
||||||
@ -528,20 +528,20 @@ sec_hasp_asn1_encode_length(uint32_t len, uint8_t *buffer, size_t *offset)
|
|||||||
} else if (len <= 0xFFFF) {
|
} else if (len <= 0xFFFF) {
|
||||||
buffer[(*offset)++] = 0x82;
|
buffer[(*offset)++] = 0x82;
|
||||||
/* Big endian */
|
/* Big endian */
|
||||||
buffer[(*offset)++] = (uint8_t)(len >> 8);
|
buffer[(*offset)++] = (uint8_t) (len >> 8);
|
||||||
buffer[(*offset)++] = (uint8_t) len;
|
buffer[(*offset)++] = (uint8_t) len;
|
||||||
} else if (len <= 0xFFFF) {
|
} else if (len <= 0xFFFF) {
|
||||||
buffer[(*offset)++] = 0x82;
|
buffer[(*offset)++] = 0x82;
|
||||||
/* Big endian */
|
/* Big endian */
|
||||||
buffer[(*offset)++] = (uint8_t)(len >> 16);
|
buffer[(*offset)++] = (uint8_t) (len >> 16);
|
||||||
buffer[(*offset)++] = (uint8_t)(len >> 8);
|
buffer[(*offset)++] = (uint8_t) (len >> 8);
|
||||||
buffer[(*offset)++] = (uint8_t) len;
|
buffer[(*offset)++] = (uint8_t) len;
|
||||||
} else if (len <= 0xFFFFFFFF) {
|
} else if (len <= 0xFFFFFFFF) {
|
||||||
buffer[(*offset)++] = 0x84;
|
buffer[(*offset)++] = 0x84;
|
||||||
/* Big endian */
|
/* Big endian */
|
||||||
buffer[(*offset)++] = (uint8_t)(len >> 24);
|
buffer[(*offset)++] = (uint8_t) (len >> 24);
|
||||||
buffer[(*offset)++] = (uint8_t)(len >> 16);
|
buffer[(*offset)++] = (uint8_t) (len >> 16);
|
||||||
buffer[(*offset)++] = (uint8_t)(len >> 8);
|
buffer[(*offset)++] = (uint8_t) (len >> 8);
|
||||||
buffer[(*offset)++] = (uint8_t) len;
|
buffer[(*offset)++] = (uint8_t) len;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -551,9 +551,9 @@ sec_hasp_asn1_encode_tag(uint16_t tag, uint8_t *buffer, size_t *offset)
|
|||||||
{
|
{
|
||||||
if (tag > 0xFF) {
|
if (tag > 0xFF) {
|
||||||
/* Big endian */
|
/* Big endian */
|
||||||
buffer[(*offset)++] = (uint8_t)(tag >> 8);
|
buffer[(*offset)++] = (uint8_t) (tag >> 8);
|
||||||
buffer[(*offset)++] = (uint8_t)(tag);
|
buffer[(*offset)++] = (uint8_t) (tag);
|
||||||
} else {
|
} else {
|
||||||
buffer[(*offset)++] = (uint8_t)(tag);
|
buffer[(*offset)++] = (uint8_t) (tag);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -648,7 +648,10 @@ static bool util_options_init_from_file(
|
|||||||
options->defs->defs[j].param,
|
options->defs->defs[j].param,
|
||||||
options->defs->defs[j].name,
|
options->defs->defs[j].name,
|
||||||
options->defs->defs[j].type,
|
options->defs->defs[j].type,
|
||||||
val ? (options->defs->defs[j].is_secret_data ? "[REDACTED-SECRET]" : val) : "NULL");
|
val ?
|
||||||
|
(options->defs->defs[j].is_secret_data ? "[REDACTED-SECRET]" :
|
||||||
|
val) :
|
||||||
|
"NULL");
|
||||||
|
|
||||||
options->values[j].avail = true;
|
options->values[j].avail = true;
|
||||||
break;
|
break;
|
||||||
|
@ -36,7 +36,7 @@ void util_patch_function(uintptr_t func_addr, void *detour_func)
|
|||||||
offset += 4;
|
offset += 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
uintptr_t call = (uintptr_t)(((uintptr_t) detour_func) - func_addr - offset);
|
uintptr_t call = (uintptr_t) (((uintptr_t) detour_func) - func_addr - offset);
|
||||||
|
|
||||||
if (UNPROTECT(func_addr, 4096) != 0) {
|
if (UNPROTECT(func_addr, 4096) != 0) {
|
||||||
log_die("Unprotecting memory %p, len %d failed", func_addr);
|
log_die("Unprotecting memory %p, len %d failed", func_addr);
|
||||||
|
@ -63,8 +63,8 @@ bool util_sock_tcp_is_connectable3(
|
|||||||
|
|
||||||
FD_ZERO(&fdset);
|
FD_ZERO(&fdset);
|
||||||
FD_SET(handle, &fdset);
|
FD_SET(handle, &fdset);
|
||||||
tv.tv_sec = (__time_t)(timeout_ms / 1000);
|
tv.tv_sec = (__time_t) (timeout_ms / 1000);
|
||||||
tv.tv_usec = (__suseconds_t)((timeout_ms % 1000) * 1000);
|
tv.tv_usec = (__suseconds_t) ((timeout_ms % 1000) * 1000);
|
||||||
|
|
||||||
if (select(handle + 1, NULL, &fdset, NULL, &tv) == 1) {
|
if (select(handle + 1, NULL, &fdset, NULL, &tv) == 1) {
|
||||||
int so_error;
|
int so_error;
|
||||||
@ -142,8 +142,8 @@ ssize_t
|
|||||||
util_sock_tcp_send(int handle, void *buffer, size_t size, uint32_t timeout_ms)
|
util_sock_tcp_send(int handle, void *buffer, size_t size, uint32_t timeout_ms)
|
||||||
{
|
{
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
tv.tv_sec = (__time_t)(timeout_ms / 1000);
|
tv.tv_sec = (__time_t) (timeout_ms / 1000);
|
||||||
tv.tv_usec = (__suseconds_t)((timeout_ms % 1000) * 1000);
|
tv.tv_usec = (__suseconds_t) ((timeout_ms % 1000) * 1000);
|
||||||
|
|
||||||
setsockopt(handle, SOL_SOCKET, SO_SNDTIMEO, (const char *) &tv, sizeof(tv));
|
setsockopt(handle, SOL_SOCKET, SO_SNDTIMEO, (const char *) &tv, sizeof(tv));
|
||||||
|
|
||||||
@ -166,8 +166,8 @@ ssize_t
|
|||||||
util_sock_tcp_recv(int handle, void *buffer, size_t size, uint32_t timeout_ms)
|
util_sock_tcp_recv(int handle, void *buffer, size_t size, uint32_t timeout_ms)
|
||||||
{
|
{
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
tv.tv_sec = (__time_t)(timeout_ms / 1000);
|
tv.tv_sec = (__time_t) (timeout_ms / 1000);
|
||||||
tv.tv_usec = (__suseconds_t)((timeout_ms % 1000) * 1000);
|
tv.tv_usec = (__suseconds_t) ((timeout_ms % 1000) * 1000);
|
||||||
|
|
||||||
setsockopt(handle, SOL_SOCKET, SO_RCVTIMEO, (const char *) &tv, sizeof(tv));
|
setsockopt(handle, SOL_SOCKET, SO_RCVTIMEO, (const char *) &tv, sizeof(tv));
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
void util_time_sleep_ns(uint64_t time_ns)
|
void util_time_sleep_ns(uint64_t time_ns)
|
||||||
{
|
{
|
||||||
struct timespec t;
|
struct timespec t;
|
||||||
t.tv_sec = (__time_t)(time_ns / (1000 * 1000 * 1000));
|
t.tv_sec = (__time_t) (time_ns / (1000 * 1000 * 1000));
|
||||||
t.tv_nsec = (__syscall_slong_t) time_ns % (1000 * 1000 * 1000);
|
t.tv_nsec = (__syscall_slong_t) time_ns % (1000 * 1000 * 1000);
|
||||||
|
|
||||||
nanosleep(&t, NULL);
|
nanosleep(&t, NULL);
|
||||||
@ -21,8 +21,8 @@ void util_time_sleep_ns(uint64_t time_ns)
|
|||||||
void util_time_sleep_us(uint64_t time_us)
|
void util_time_sleep_us(uint64_t time_us)
|
||||||
{
|
{
|
||||||
struct timespec t;
|
struct timespec t;
|
||||||
t.tv_sec = (__time_t)(time_us / (1000 * 1000));
|
t.tv_sec = (__time_t) (time_us / (1000 * 1000));
|
||||||
t.tv_nsec = (__syscall_slong_t)(time_us % (1000 * 1000)) * 1000;
|
t.tv_nsec = (__syscall_slong_t) (time_us % (1000 * 1000)) * 1000;
|
||||||
|
|
||||||
nanosleep(&t, NULL);
|
nanosleep(&t, NULL);
|
||||||
}
|
}
|
||||||
@ -30,8 +30,8 @@ void util_time_sleep_us(uint64_t time_us)
|
|||||||
void util_time_sleep_ms(uint64_t time_ms)
|
void util_time_sleep_ms(uint64_t time_ms)
|
||||||
{
|
{
|
||||||
struct timespec t;
|
struct timespec t;
|
||||||
t.tv_sec = (__time_t)(time_ms / 1000);
|
t.tv_sec = (__time_t) (time_ms / 1000);
|
||||||
t.tv_nsec = (__syscall_slong_t)(time_ms % 1000) * 1000 * 1000;
|
t.tv_nsec = (__syscall_slong_t) (time_ms % 1000) * 1000 * 1000;
|
||||||
|
|
||||||
nanosleep(&t, NULL);
|
nanosleep(&t, NULL);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user