Formatting
This commit is contained in:
@@ -34,12 +34,12 @@ bool jb_io_init(
|
|||||||
thread_join_t thread_join,
|
thread_join_t thread_join,
|
||||||
thread_destroy_t thread_destroy)
|
thread_destroy_t thread_destroy)
|
||||||
{
|
{
|
||||||
if(CH341OpenDevice(0) < 0) {
|
if (CH341OpenDevice(0) < 0) {
|
||||||
jb_io_log_warning("jbio", "Can't open CH341 device.\n");
|
jb_io_log_warning("jbio", "Can't open CH341 device.\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
is_initialized = true;
|
is_initialized = true;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -76,8 +76,8 @@ static const uint32_t magic_sys_mappings[] = {
|
|||||||
|
|
||||||
bool jb_io_read_inputs(void)
|
bool jb_io_read_inputs(void)
|
||||||
{
|
{
|
||||||
// Read IO board
|
// Read IO board
|
||||||
unsigned long n;
|
unsigned long n;
|
||||||
union {
|
union {
|
||||||
uint32_t dword;
|
uint32_t dword;
|
||||||
uint8_t bytes[4];
|
uint8_t bytes[4];
|
||||||
@@ -87,29 +87,29 @@ bool jb_io_read_inputs(void)
|
|||||||
jb_io_panels = 0;
|
jb_io_panels = 0;
|
||||||
jb_io_sys_buttons = 0;
|
jb_io_sys_buttons = 0;
|
||||||
|
|
||||||
CH341EppSetAddr(0, 255);
|
CH341EppSetAddr(0, 255);
|
||||||
CH341EppSetAddr(0, 1);
|
CH341EppSetAddr(0, 1);
|
||||||
CH341EppSetAddr(0, 255);
|
CH341EppSetAddr(0, 255);
|
||||||
CH341EppSetAddr(0, 0);
|
CH341EppSetAddr(0, 0);
|
||||||
n = 1;
|
n = 1;
|
||||||
CH341EppReadData(0, &input.bytes[0], &n);
|
CH341EppReadData(0, &input.bytes[0], &n);
|
||||||
CH341EppSetAddr(0, 255);
|
CH341EppSetAddr(0, 255);
|
||||||
CH341EppSetAddr(0, 0);
|
CH341EppSetAddr(0, 0);
|
||||||
n = 1;
|
n = 1;
|
||||||
CH341EppReadData(0, &input.bytes[1], &n);
|
CH341EppReadData(0, &input.bytes[1], &n);
|
||||||
CH341EppSetAddr(0, 255);
|
CH341EppSetAddr(0, 255);
|
||||||
CH341EppSetAddr(0, 0);
|
CH341EppSetAddr(0, 0);
|
||||||
n = 1;
|
n = 1;
|
||||||
CH341EppReadData(0, &input.bytes[2], &n);
|
CH341EppReadData(0, &input.bytes[2], &n);
|
||||||
CH341EppSetAddr(0, 255);
|
CH341EppSetAddr(0, 255);
|
||||||
|
|
||||||
for (uint8_t i = 0; i < lengthof(magic_panel_mappings); i++) {
|
for (uint8_t i = 0; i < lengthof(magic_panel_mappings); i++) {
|
||||||
if((input.dword & magic_panel_mappings[i]) == 0) {
|
if ((input.dword & magic_panel_mappings[i]) == 0) {
|
||||||
jb_io_panels |= 1 << i;
|
jb_io_panels |= 1 << i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (uint8_t i = 0; i < lengthof(magic_sys_mappings); i++) {
|
for (uint8_t i = 0; i < lengthof(magic_sys_mappings); i++) {
|
||||||
if((input.dword & magic_sys_mappings[i]) == 0) {
|
if ((input.dword & magic_sys_mappings[i]) == 0) {
|
||||||
jb_io_sys_buttons |= 1 << i;
|
jb_io_sys_buttons |= 1 << i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user