Refactor and reformat
parent
33fa1c362a
commit
59ce0565e5
|
@ -53,10 +53,7 @@ HRESULT aime_io_nfc_poll(uint8_t unit_no);
|
|||
|
||||
Minimum API version: 0x0100
|
||||
*/
|
||||
HRESULT aime_io_nfc_get_aime_id(
|
||||
uint8_t unit_no,
|
||||
uint8_t *luid,
|
||||
size_t luid_size);
|
||||
HRESULT aime_io_nfc_get_aime_id(uint8_t unit_no, uint8_t *luid, size_t luid_size);
|
||||
|
||||
/*
|
||||
Attempt to read out a FeliCa card ID ("IDm"). The following are examples
|
||||
|
|
|
@ -10,8 +10,8 @@ add_library(chuniio_brokenithm SHARED src/chuniio.c
|
|||
src/chuniio.h
|
||||
src/config.c
|
||||
src/config.h
|
||||
src/socket.h
|
||||
src/struct.h
|
||||
src/servers/socket.h
|
||||
src/ipc_memory_info.h
|
||||
src/servers/android.c
|
||||
src/servers/android.h
|
||||
src/servers/common.h
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
#include "arch.h"
|
||||
#include "config.h"
|
||||
#include "struct.h"
|
||||
#include "ipc_memory_info.h"
|
||||
|
||||
#define MEM_FILE_NAME "Local\\BROKENITHM_SHARED_BUFFER"
|
||||
|
||||
|
|
|
@ -70,7 +70,6 @@ void __declspec(dllexport) chuni_io_jvs_poll(uint8_t *opbtn, uint8_t *beams);
|
|||
|
||||
void __declspec(dllexport) chuni_io_jvs_read_coin_counter(uint16_t *total);
|
||||
|
||||
|
||||
/* Initialize touch slider emulation. This function will be called before any
|
||||
other chuni_io_slider_*() function calls.
|
||||
|
||||
|
@ -155,11 +154,13 @@ HRESULT __declspec(dllexport) chuni_io_led_init(void);
|
|||
|
||||
/* Update the RGB LEDs. rgb is a pointer to an array of up to 63 * 3 = 189 bytes.
|
||||
|
||||
Chunithm uses two chains/boards with WS2811 protocol (each logical led corresponds to 3 physical leds).
|
||||
board 0 is on the left side and board 1 on the right side of the cab
|
||||
Chunithm uses two chains/boards with WS2811 protocol (each logical led corresponds to
|
||||
3 physical leds). board 0 is on the left side and board 1 on the right side of the
|
||||
cab
|
||||
|
||||
left side has 5*10 rgb values for the billboard, followed by 3 rgb values for the air tower
|
||||
right side has 6*10 rgb values for the billboard, followed by 3 rgb values for the air tower
|
||||
left side has 5*10 rgb values for the billboard, followed by 3 rgb values for the air
|
||||
tower right side has 6*10 rgb values for the billboard, followed by 3 rgb values for
|
||||
the air tower
|
||||
|
||||
Each rgb value is comprised of 3 bytes in R,G,B order
|
||||
|
||||
|
|
|
@ -8,24 +8,13 @@
|
|||
#include "config.h"
|
||||
|
||||
static const int chuni_io_default_cells[] = {
|
||||
'L', 'L', 'L', 'L',
|
||||
'K', 'K', 'K', 'K',
|
||||
'J', 'J', 'J', 'J',
|
||||
'H', 'H', 'H', 'H',
|
||||
'G', 'G', 'G', 'G',
|
||||
'F', 'F', 'F', 'F',
|
||||
'D', 'D', 'D', 'D',
|
||||
'S', 'S', 'S', 'S',
|
||||
'L', 'L', 'L', 'L', 'K', 'K', 'K', 'K', 'J', 'J', 'J', 'J', 'H', 'H', 'H', 'H',
|
||||
'G', 'G', 'G', 'G', 'F', 'F', 'F', 'F', 'D', 'D', 'D', 'D', 'S', 'S', 'S', 'S',
|
||||
};
|
||||
|
||||
static const int chuni_io_default_ir[] = {
|
||||
'4', '5', '6', '7', '8', '9'
|
||||
};
|
||||
static const int chuni_io_default_ir[] = {'4', '5', '6', '7', '8', '9'};
|
||||
|
||||
void chuni_io_config_load(
|
||||
struct chuni_io_config *cfg,
|
||||
const wchar_t *filename)
|
||||
{
|
||||
void chuni_io_config_load(struct chuni_io_config *cfg, const wchar_t *filename) {
|
||||
wchar_t key[16];
|
||||
int i;
|
||||
wchar_t port_input[6];
|
||||
|
@ -41,37 +30,30 @@ void chuni_io_config_load(
|
|||
|
||||
for (i = 0; i < 6; i++) {
|
||||
swprintf_s(key, _countof(key), L"ir%i", i + 1);
|
||||
cfg->vk_ir[i] = GetPrivateProfileIntW(
|
||||
L"ir",
|
||||
key,
|
||||
chuni_io_default_ir[i],
|
||||
filename);
|
||||
cfg->vk_ir[i] =
|
||||
GetPrivateProfileIntW(L"ir", key, chuni_io_default_ir[i], filename);
|
||||
}
|
||||
|
||||
for (i = 0; i < 32; i++) {
|
||||
swprintf_s(key, _countof(key), L"cell%i", i + 1);
|
||||
cfg->vk_cell[i] = GetPrivateProfileIntW(
|
||||
L"slider",
|
||||
key,
|
||||
chuni_io_default_cells[i],
|
||||
filename);
|
||||
cfg->vk_cell[i] =
|
||||
GetPrivateProfileIntW(L"slider", key, chuni_io_default_cells[i], filename);
|
||||
}
|
||||
|
||||
cfg->led_output_pipe = GetPrivateProfileIntW(L"led", L"cabLedOutputPipe", 1, filename);
|
||||
cfg->led_output_serial = GetPrivateProfileIntW(L"led", L"cabLedOutputSerial", 0, filename);
|
||||
cfg->led_output_pipe =
|
||||
GetPrivateProfileIntW(L"led", L"cabLedOutputPipe", 1, filename);
|
||||
cfg->led_output_serial =
|
||||
GetPrivateProfileIntW(L"led", L"cabLedOutputSerial", 0, filename);
|
||||
|
||||
cfg->slider_led_output_pipe = GetPrivateProfileIntW(L"led", L"controllerLedOutputPipe", 1, filename);
|
||||
cfg->slider_led_output_serial = GetPrivateProfileIntW(L"led", L"controllerLedOutputSerial", 0, filename);
|
||||
cfg->slider_led_output_pipe =
|
||||
GetPrivateProfileIntW(L"led", L"controllerLedOutputPipe", 1, filename);
|
||||
cfg->slider_led_output_serial =
|
||||
GetPrivateProfileIntW(L"led", L"controllerLedOutputSerial", 0, filename);
|
||||
|
||||
cfg->led_serial_baud = GetPrivateProfileIntW(L"led", L"serialBaud", 921600, filename);
|
||||
cfg->led_serial_baud =
|
||||
GetPrivateProfileIntW(L"led", L"serialBaud", 921600, filename);
|
||||
|
||||
GetPrivateProfileStringW(
|
||||
L"led",
|
||||
L"serialPort",
|
||||
L"COM5",
|
||||
port_input,
|
||||
6,
|
||||
filename);
|
||||
GetPrivateProfileStringW(L"led", L"serialPort", L"COM5", port_input, 6, filename);
|
||||
|
||||
// Sanitize the output path. If it's a serial COM port, it needs to be prefixed
|
||||
// with `\\.\`.
|
||||
|
|
|
@ -4,9 +4,9 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
struct chuni_io_config {
|
||||
uint8_t vk_test;
|
||||
|
@ -26,12 +26,9 @@ struct chuni_io_config {
|
|||
// The name of a COM port to output LED data on, in serial mode
|
||||
wchar_t led_serial_port[12];
|
||||
int32_t led_serial_baud;
|
||||
|
||||
};
|
||||
|
||||
void chuni_io_config_load(
|
||||
struct chuni_io_config *cfg,
|
||||
const wchar_t *filename);
|
||||
void chuni_io_config_load(struct chuni_io_config *cfg, const wchar_t *filename);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
//
|
||||
// Created by beerpsi on 12/29/2023.
|
||||
//
|
||||
|
||||
#ifndef CHUNIIO_BROKENITHM_STRUCT_H
|
||||
#define CHUNIIO_BROKENITHM_STRUCT_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
;
|
||||
#pragma pack(push)
|
||||
#pragma pack(1)
|
||||
struct IPCMemoryInfo {
|
||||
uint8_t airIoStatus[6];
|
||||
uint8_t sliderIoStatus[32];
|
||||
uint8_t ledRgbData[32 * 3];
|
||||
uint8_t testBtn;
|
||||
uint8_t serviceBtn;
|
||||
uint8_t coinInsertion;
|
||||
uint8_t cardRead;
|
||||
uint8_t remoteCardRead;
|
||||
uint8_t remoteCardType;
|
||||
uint8_t remoteCardId[10];
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
#endif // CHUNIIO_BROKENITHM_STRUCT_H
|
|
@ -13,7 +13,7 @@
|
|||
#include <stdint.h>
|
||||
|
||||
#include "servers/common.h"
|
||||
#include "socket.h"
|
||||
#include "servers/socket.h"
|
||||
|
||||
bool tcp_mode = true;
|
||||
uint16_t server_port = 52468;
|
||||
|
@ -155,7 +155,8 @@ unsigned int __stdcall led_broadcast_thread_proc(void *v) {
|
|||
memcpy(send_buffer + 4, current_led_status, 3 * 32);
|
||||
|
||||
if (socket_send_to(sock, &addr, send_buffer, 100) < 0) {
|
||||
print_err("[Android:ERROR] Cannot send packet: error %lu\n", WSAGetLastError());
|
||||
print_err("[Android:ERROR] Cannot send packet: error %lu\n",
|
||||
WSAGetLastError());
|
||||
|
||||
if (tcp_mode) {
|
||||
if (errno == EINTR || errno == EWOULDBLOCK || errno == EAGAIN) {
|
||||
|
@ -229,7 +230,8 @@ unsigned int __stdcall input_recv_thread_proc(void *v) {
|
|||
continue;
|
||||
}
|
||||
|
||||
print_err("[Android: INFO] Device disconnected (could not read data, errno "
|
||||
print_err("[Android: INFO] Device disconnected (could not read "
|
||||
"data, errno "
|
||||
"%d, os error %ld)\n",
|
||||
errno, error);
|
||||
atomic_store(&ctx->connected, false);
|
||||
|
@ -255,7 +257,8 @@ unsigned int __stdcall input_recv_thread_proc(void *v) {
|
|||
continue;
|
||||
}
|
||||
|
||||
print_err("[Android: INFO] Device disconnected (could not read data, errno "
|
||||
print_err("[Android: INFO] Device disconnected (could not read "
|
||||
"data, errno "
|
||||
"%d, os error %ld)\n",
|
||||
errno, error);
|
||||
atomic_store(&ctx->connected, false);
|
||||
|
@ -322,8 +325,8 @@ unsigned int __stdcall input_recv_thread_proc(void *v) {
|
|||
}
|
||||
|
||||
if (strlen(ctx->remote_address)) {
|
||||
print_err("[Android: INFO] Device %s:%d disconnected.\n", ctx->remote_address,
|
||||
ctx->remote_port);
|
||||
print_err("[Android: INFO] Device %s:%d disconnected.\n",
|
||||
ctx->remote_address, ctx->remote_port);
|
||||
memset(ctx->remote_address, 0, 40);
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,58 @@
|
|||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
|
||||
#include "struct.h"
|
||||
#include "ipc_memory_info.h"
|
||||
|
||||
;
|
||||
#pragma pack(push)
|
||||
#pragma pack(1)
|
||||
struct PacketInput {
|
||||
uint8_t packetSize;
|
||||
uint8_t packetName[3];
|
||||
uint32_t packetId;
|
||||
uint8_t airIoStatus[6];
|
||||
uint8_t sliderIoStatus[32];
|
||||
uint8_t testBtn;
|
||||
uint8_t serviceBtn;
|
||||
};
|
||||
|
||||
struct PacketInputNoAir {
|
||||
uint8_t packetSize;
|
||||
uint8_t packetName[3];
|
||||
uint32_t packetId;
|
||||
uint8_t sliderIoStatus[32];
|
||||
uint8_t testBtn;
|
||||
uint8_t serviceBtn;
|
||||
};
|
||||
|
||||
struct PacketConnect {
|
||||
uint8_t packetSize;
|
||||
uint8_t packetName[3];
|
||||
uint8_t addrType;
|
||||
uint16_t port;
|
||||
union {
|
||||
struct {
|
||||
uint8_t addr[4];
|
||||
uint8_t padding[12];
|
||||
} addr4;
|
||||
uint8_t addr6[16];
|
||||
} addr;
|
||||
};
|
||||
|
||||
struct PacketCard {
|
||||
uint8_t packetSize;
|
||||
uint8_t packetName[3];
|
||||
uint8_t remoteCardRead;
|
||||
uint8_t remoteCardType;
|
||||
uint8_t remoteCardId[10];
|
||||
};
|
||||
|
||||
struct PacketPing {
|
||||
uint8_t packetSize;
|
||||
uint8_t packetName[3];
|
||||
uint64_t remotePingTime;
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
HRESULT android_init_server(struct IPCMemoryInfo *memory);
|
||||
|
||||
|
|
|
@ -9,13 +9,22 @@
|
|||
#include <stdint.h>
|
||||
|
||||
enum FunctionButton {
|
||||
INVALID,
|
||||
INVALID __attribute__((unused)),
|
||||
FUNCTION_COIN,
|
||||
FUNCTION_CARD,
|
||||
};
|
||||
|
||||
#pragma pack(push)
|
||||
#pragma pack(1)
|
||||
struct PacketFunction {
|
||||
uint8_t packetSize;
|
||||
uint8_t packetName[3];
|
||||
uint8_t funcBtn;
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
void print_err(const char *fmt, ...);
|
||||
|
||||
void dump_bytes(const void *ptr, const size_t nbytes, const bool hex_string);
|
||||
void dump_bytes(const void *ptr, size_t nbytes, bool hex_string);
|
||||
|
||||
#endif // CHUNIIO_BROKENITHM_COMMON_H
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
#include "arch.h"
|
||||
|
||||
#ifdef ENV32BIT
|
||||
#include <libimobiledevice/libimobiledevice.h>
|
||||
#include <process.h>
|
||||
#include <stdatomic.h>
|
||||
#include <libimobiledevice/libimobiledevice.h>
|
||||
|
||||
#include "servers/common.h"
|
||||
|
||||
|
@ -56,7 +56,8 @@ unsigned int __stdcall ios_led_broadcast_thread_proc(void *v) {
|
|||
|
||||
int status;
|
||||
uint32_t sent;
|
||||
if ((status = idevice_connection_send(ctx->connection, send_buffer, 100, &sent))) {
|
||||
if ((status = idevice_connection_send(ctx->connection, send_buffer, 100,
|
||||
&sent))) {
|
||||
print_err("[iOS:ERROR] Cannot send LED packet: error %d\n", status);
|
||||
}
|
||||
|
||||
|
@ -79,7 +80,8 @@ unsigned int __stdcall ios_input_recv_thread_proc(void *v) {
|
|||
int status;
|
||||
uint32_t read;
|
||||
|
||||
if ((status = idevice_connection_receive_timeout(ctx->connection, buffer, 4, &read, 5))) {
|
||||
if ((status = idevice_connection_receive_timeout(ctx->connection, buffer, 4,
|
||||
&read, 5))) {
|
||||
if (status == IDEVICE_E_TIMEOUT) {
|
||||
continue;
|
||||
}
|
||||
|
@ -92,28 +94,34 @@ unsigned int __stdcall ios_input_recv_thread_proc(void *v) {
|
|||
|
||||
int len = (unsigned char)buffer[0];
|
||||
|
||||
if ((status = idevice_connection_receive_timeout(ctx->connection, buffer + 4, len - 3, &read, 5))) {
|
||||
if ((status = idevice_connection_receive_timeout(ctx->connection, buffer + 4,
|
||||
len - 3, &read, 5))) {
|
||||
print_err("[iOS:ERROR] Could not read data from device: %d\n", status);
|
||||
atomic_store(&ctx->exit_flag, true);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (len >= sizeof(struct iOSPacketInput) && memcmp(buffer + 1, "INP", 3) == 0) {
|
||||
struct iOSPacketInput* pkt = (struct iOSPacketInput*)buffer;
|
||||
if (len >= sizeof(struct PacketInput) && memcmp(buffer + 1, "INP", 3) == 0) {
|
||||
struct PacketInput *pkt = (struct PacketInput *)buffer;
|
||||
|
||||
if (air_enabled) {
|
||||
memcpy(ctx->memory->airIoStatus, pkt->airIoStatus, sizeof(pkt->airIoStatus));
|
||||
memcpy(ctx->memory->airIoStatus, pkt->airIoStatus,
|
||||
sizeof(pkt->airIoStatus));
|
||||
}
|
||||
|
||||
memcpy(ctx->memory->sliderIoStatus, pkt->sliderIoStatus, sizeof(pkt->sliderIoStatus));
|
||||
memcpy(ctx->memory->sliderIoStatus, pkt->sliderIoStatus,
|
||||
sizeof(pkt->sliderIoStatus));
|
||||
ctx->memory->testBtn = pkt->testBtn;
|
||||
ctx->memory->serviceBtn = pkt->serviceBtn;
|
||||
} else if (len >= 4 && memcmp(buffer + 1, "AIR", 3) == 0) {
|
||||
air_enabled = buffer[3] != 0;
|
||||
} else if (len >= sizeof(struct PacketAirStatus) && memcmp(buffer + 1, "AIR", 3) == 0) {
|
||||
struct PacketAirStatus *pkt = (struct PacketAirStatus *)buffer;
|
||||
|
||||
print_err("[iOS: INFO] Air input %s", air_enabled ? "enabled" : "disabled");
|
||||
} else if (len >= sizeof(struct PacketFunction) && memcmp(buffer + 1, "FNC", 3) == 0) {
|
||||
air_enabled = pkt->airEnabled != 0;
|
||||
|
||||
print_err("[iOS: INFO] Air input %s\n", air_enabled ? "enabled" : "disabled");
|
||||
} else if (len >= sizeof(struct PacketFunction) &&
|
||||
memcmp(buffer + 1, "FNC", 3) == 0) {
|
||||
const struct PacketFunction *pkt = (struct PacketFunction *)buffer;
|
||||
|
||||
switch (pkt->funcBtn) {
|
||||
|
@ -129,7 +137,7 @@ unsigned int __stdcall ios_input_recv_thread_proc(void *v) {
|
|||
}
|
||||
}
|
||||
|
||||
print_err("[iOS: INFO] Device disconnected.");
|
||||
print_err("[iOS: INFO] Device disconnected.\n");
|
||||
|
||||
idevice_disconnect(ctx->connection);
|
||||
ctx->connection = NULL;
|
||||
|
|
|
@ -8,7 +8,26 @@
|
|||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <windows.h>
|
||||
|
||||
#include "struct.h"
|
||||
#include "ipc_memory_info.h"
|
||||
|
||||
;
|
||||
#pragma pack(push)
|
||||
#pragma pack(1)
|
||||
struct PacketInput {
|
||||
uint8_t packetSize;
|
||||
uint8_t packetName[3];
|
||||
uint8_t airIoStatus[6];
|
||||
uint8_t sliderIoStatus[32];
|
||||
uint8_t testBtn;
|
||||
uint8_t serviceBtn;
|
||||
};
|
||||
|
||||
struct PacketAirStatus {
|
||||
uint8_t packetSize;
|
||||
uint8_t packetName[3];
|
||||
uint8_t airEnabled;
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
HRESULT ios_init_server(struct IPCMemoryInfo *memory);
|
||||
|
||||
|
|
|
@ -9,12 +9,12 @@
|
|||
#ifndef WINVER
|
||||
#define WINVER 0x0501
|
||||
#endif // WINVER
|
||||
#include <ws2tcpip.h>
|
||||
#include <winsock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
#else
|
||||
// translate windows functions to linux functions
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#define SOCKET int
|
||||
#define INVALID_SOCKET (SOCKET)(~0)
|
||||
#define SOCKET_ERROR (-1)
|
||||
|
@ -29,14 +29,14 @@
|
|||
#ifndef __hpux
|
||||
#include <sys/select.h>
|
||||
#endif /* __hpux */
|
||||
#include <arpa/inet.h>
|
||||
#include <netdb.h>
|
||||
#include <netinet/in.h>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <stdio.h>
|
||||
#include <netdb.h>
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
typedef sockaddr *LPSOCKADDR;
|
||||
#endif // _WIN32
|
|
@ -1,100 +0,0 @@
|
|||
//
|
||||
// Created by beerpsi on 12/29/2023.
|
||||
//
|
||||
|
||||
#ifndef CHUNIIO_BROKENITHM_STRUCT_H
|
||||
#define CHUNIIO_BROKENITHM_STRUCT_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
;
|
||||
#pragma pack(push)
|
||||
#pragma pack(1)
|
||||
|
||||
struct IPCMemoryInfo
|
||||
{
|
||||
uint8_t airIoStatus[6];
|
||||
uint8_t sliderIoStatus[32];
|
||||
uint8_t ledRgbData[32 * 3];
|
||||
uint8_t testBtn;
|
||||
uint8_t serviceBtn;
|
||||
uint8_t coinInsertion;
|
||||
uint8_t cardRead;
|
||||
uint8_t remoteCardRead;
|
||||
uint8_t remoteCardType;
|
||||
uint8_t remoteCardId[10];
|
||||
};
|
||||
|
||||
struct iOSPacketInput {
|
||||
uint8_t packetSize;
|
||||
uint8_t packetName[3];
|
||||
uint8_t airIoStatus[6];
|
||||
uint8_t sliderIoStatus[32];
|
||||
uint8_t testBtn;
|
||||
uint8_t serviceBtn;
|
||||
};
|
||||
|
||||
struct PacketInput
|
||||
{
|
||||
uint8_t packetSize;
|
||||
uint8_t packetName[3];
|
||||
uint32_t packetId;
|
||||
uint8_t airIoStatus[6];
|
||||
uint8_t sliderIoStatus[32];
|
||||
uint8_t testBtn;
|
||||
uint8_t serviceBtn;
|
||||
};
|
||||
|
||||
struct PacketInputNoAir
|
||||
{
|
||||
uint8_t packetSize;
|
||||
uint8_t packetName[3];
|
||||
uint32_t packetId;
|
||||
uint8_t sliderIoStatus[32];
|
||||
uint8_t testBtn;
|
||||
uint8_t serviceBtn;
|
||||
};
|
||||
|
||||
struct PacketFunction
|
||||
{
|
||||
uint8_t packetSize;
|
||||
uint8_t packetName[3];
|
||||
uint8_t funcBtn;
|
||||
};
|
||||
|
||||
struct PacketConnect
|
||||
{
|
||||
uint8_t packetSize;
|
||||
uint8_t packetName[3];
|
||||
uint8_t addrType;
|
||||
uint16_t port;
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
uint8_t addr[4];
|
||||
uint8_t padding[12];
|
||||
} addr4;
|
||||
uint8_t addr6[16];
|
||||
} addr;
|
||||
};
|
||||
|
||||
struct PacketCard
|
||||
{
|
||||
uint8_t packetSize;
|
||||
uint8_t packetName[3];
|
||||
uint8_t remoteCardRead;
|
||||
uint8_t remoteCardType;
|
||||
uint8_t remoteCardId[10];
|
||||
};
|
||||
|
||||
struct PacketPing
|
||||
{
|
||||
uint8_t packetSize;
|
||||
uint8_t packetName[3];
|
||||
uint64_t remotePingTime;
|
||||
};
|
||||
|
||||
#pragma pack(pop)
|
||||
|
||||
#endif //CHUNIIO_BROKENITHM_STRUCT_H
|
|
@ -14,8 +14,7 @@ static CRITICAL_SECTION dbg_buf_lock;
|
|||
static char dbg_buf[16384];
|
||||
static size_t dbg_buf_pos;
|
||||
|
||||
void dprintf(const char *fmt, ...)
|
||||
{
|
||||
void dprintf(const char *fmt, ...) {
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
|
@ -23,8 +22,7 @@ void dprintf(const char *fmt, ...)
|
|||
va_end(ap);
|
||||
}
|
||||
|
||||
void dprintfv(const char *fmt, va_list ap)
|
||||
{
|
||||
void dprintfv(const char *fmt, va_list ap) {
|
||||
long init;
|
||||
|
||||
/* Static constructors in C are difficult to do in a way that works under
|
||||
|
@ -45,12 +43,8 @@ void dprintfv(const char *fmt, va_list ap)
|
|||
|
||||
EnterCriticalSection(&dbg_buf_lock);
|
||||
|
||||
dbg_buf_pos += vsnprintf_s(
|
||||
dbg_buf + dbg_buf_pos,
|
||||
sizeof(dbg_buf) - dbg_buf_pos,
|
||||
sizeof(dbg_buf) - dbg_buf_pos - 1,
|
||||
fmt,
|
||||
ap);
|
||||
dbg_buf_pos += vsnprintf_s(dbg_buf + dbg_buf_pos, sizeof(dbg_buf) - dbg_buf_pos,
|
||||
sizeof(dbg_buf) - dbg_buf_pos - 1, fmt, ap);
|
||||
|
||||
if (dbg_buf_pos + 1 > sizeof(dbg_buf)) {
|
||||
abort();
|
||||
|
@ -65,8 +59,7 @@ void dprintfv(const char *fmt, va_list ap)
|
|||
LeaveCriticalSection(&dbg_buf_lock);
|
||||
}
|
||||
|
||||
void dwprintf(const wchar_t *fmt, ...)
|
||||
{
|
||||
void dwprintf(const wchar_t *fmt, ...) {
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
|
@ -74,8 +67,7 @@ void dwprintf(const wchar_t *fmt, ...)
|
|||
va_end(ap);
|
||||
}
|
||||
|
||||
void dwprintfv(const wchar_t *fmt, va_list ap)
|
||||
{
|
||||
void dwprintfv(const wchar_t *fmt, va_list ap) {
|
||||
wchar_t msg[512];
|
||||
|
||||
_vsnwprintf_s(msg, _countof(msg), _countof(msg) - 1, fmt, ap);
|
||||
|
|
Loading…
Reference in New Issue