move reverse_bits into util.c

This commit is contained in:
itsmattkc 2024-11-13 17:39:08 -08:00
parent 31afc359a1
commit 4ecf7c07f1
4 changed files with 12 additions and 12 deletions

View file

@ -31,17 +31,6 @@ uint16_t PORT_AUD;
uint16_t PORT_HID; uint16_t PORT_HID;
uint16_t PORT_CMD; uint16_t PORT_CMD;
unsigned int reverse_bits(unsigned int b, int bit_count)
{
unsigned int result = 0;
for (int i = 0; i < bit_count; i++) {
result |= ((b >> i) & 1) << (bit_count - 1 -i );
}
return result;
}
void send_to_console(int fd, const void *data, size_t data_size, int port) void send_to_console(int fd, const void *data, size_t data_size, int port)
{ {
struct sockaddr_in address; struct sockaddr_in address;

View file

@ -37,7 +37,6 @@ typedef struct
int sync_internal(uint16_t code, uint32_t server_address); int sync_internal(uint16_t code, uint32_t server_address);
int connect_as_gamepad_internal(event_loop_t *ctx, uint32_t server_address); int connect_as_gamepad_internal(event_loop_t *ctx, uint32_t server_address);
unsigned int reverse_bits(unsigned int b, int bit_count);
void send_to_console(int fd, const void *data, size_t data_size, int port); void send_to_console(int fd, const void *data, size_t data_size, int port);
int is_stop_code(const char *data, size_t data_length); int is_stop_code(const char *data, size_t data_length);
int push_event(event_loop_t *loop, int type, const void *data, size_t size); int push_event(event_loop_t *loop, int type, const void *data, size_t size);

View file

@ -82,3 +82,14 @@ size_t get_millis()
return (s * 1000) + ms; return (s * 1000) + ms;
} }
unsigned int reverse_bits(unsigned int b, int bit_count)
{
unsigned int result = 0;
for (int i = 0; i < bit_count; i++) {
result |= ((b >> i) & 1) << (bit_count - 1 -i );
}
return result;
}

View file

@ -20,6 +20,7 @@ void force_interrupt();
void install_interrupt_handler(); void install_interrupt_handler();
void uninstall_interrupt_handler(); void uninstall_interrupt_handler();
size_t get_millis(); size_t get_millis();
unsigned int reverse_bits(unsigned int b, int bit_count);
uint16_t crc16(const void* data, size_t len); uint16_t crc16(const void* data, size_t len);