diff --git a/src/guest/rom/boot.c b/src/guest/rom/boot.c index 3346a6a3..313f82fe 100644 --- a/src/guest/rom/boot.c +++ b/src/guest/rom/boot.c @@ -88,7 +88,8 @@ static int boot_init(struct device *dev) { return 1; } -void boot_rom_write(struct boot *boot, uint32_t addr, uint32_t data, uint32_t mask) { +void boot_rom_write(struct boot *boot, uint32_t addr, uint32_t data, + uint32_t mask) { WRITE_DATA(&boot->rom[addr]); } diff --git a/src/guest/rom/boot.h b/src/guest/rom/boot.h index 3960c77e..dee42d17 100644 --- a/src/guest/rom/boot.h +++ b/src/guest/rom/boot.h @@ -10,6 +10,7 @@ struct boot *boot_create(struct dreamcast *dc); void boot_destroy(struct boot *boot); uint32_t boot_rom_read(struct boot *boot, uint32_t addr, uint32_t mask); -void boot_rom_write(struct boot *boot, uint32_t addr, uint32_t data, uint32_t mask); +void boot_rom_write(struct boot *boot, uint32_t addr, uint32_t data, + uint32_t mask); #endif diff --git a/src/imgui.cc b/src/imgui.cc index 38e0e6e8..e98c4d27 100644 --- a/src/imgui.cc +++ b/src/imgui.cc @@ -22,7 +22,7 @@ struct imgui { int alt[2]; int ctrl[2]; int shift[2]; - int16_t keys[K_NUM_KEYS]; + int keys[K_NUM_KEYS]; }; /* maintain global pointer for ig* functions */ @@ -385,23 +385,36 @@ void imgui_begin_frame(struct imgui *imgui) { io.DisplaySize = ImVec2((float)width, (float)height); /* update navigation inputs */ - io.NavInputs[ImGuiNavInput_PadActivate] = imgui->keys[K_CONT_A]; - io.NavInputs[ImGuiNavInput_PadCancel] = imgui->keys[K_CONT_B]; + io.NavInputs[ImGuiNavInput_PadActivate] = (imgui->keys[K_CONT_A] != 0); + io.NavInputs[ImGuiNavInput_PadCancel] = (imgui->keys[K_CONT_B] != 0); io.NavInputs[ImGuiNavInput_PadUp] = - imgui->keys[K_CONT_DPAD_UP] || (imgui->keys[K_CONT_JOYY] < 0); + (imgui->keys[K_CONT_DPAD_UP] != 0) || (imgui->keys[K_CONT_JOYY] < 0); io.NavInputs[ImGuiNavInput_PadDown] = - imgui->keys[K_CONT_DPAD_DOWN] || (imgui->keys[K_CONT_JOYY] > 0); + (imgui->keys[K_CONT_DPAD_DOWN] != 0) || (imgui->keys[K_CONT_JOYY] > 0); io.NavInputs[ImGuiNavInput_PadLeft] = - imgui->keys[K_CONT_DPAD_LEFT] || (imgui->keys[K_CONT_JOYX] < 0); + (imgui->keys[K_CONT_DPAD_LEFT] != 0) || (imgui->keys[K_CONT_JOYX] < 0); io.NavInputs[ImGuiNavInput_PadRight] = - imgui->keys[K_CONT_DPAD_RIGHT] || (imgui->keys[K_CONT_JOYX] > 0); + (imgui->keys[K_CONT_DPAD_RIGHT] != 0) || (imgui->keys[K_CONT_JOYX] > 0); ImGui::NewFrame(); } int imgui_keydown(struct imgui *imgui, int key, int16_t value) { ImGuiIO &io = ImGui::GetIO(); - int down = value != 0; + + /* digital inputs will always be either 0 or INT_MAX, but analog inputs will + range from INT16_MIN to INT16_MAX. filter small values to require very + intentional actions when using these analog inputs for navigation */ + const int16_t min = 16384; + if (value > min) { + value = 1; + } else if (value < -min) { + value = -1; + } else { + value = 0; + } + + bool down = value != 0; if (key == K_MWHEELUP) { io.MouseWheel = 1.0f; @@ -426,6 +439,7 @@ int imgui_keydown(struct imgui *imgui, int key, int16_t value) { imgui->keys[key] = value; io.KeysDown[key] = down; } + return 0; } diff --git a/src/jit/ir/ir.c b/src/jit/ir/ir.c index 7f9d118b..bfa1afeb 100644 --- a/src/jit/ir/ir.c +++ b/src/jit/ir/ir.c @@ -1005,7 +1005,8 @@ void ir_debug_break(struct ir *ir) { ir_append_instr(ir, OP_DEBUG_BREAK, VALUE_V); } -void ir_debug_log(struct ir *ir, struct ir_value *a, struct ir_value *b, struct ir_value *c) { +void ir_debug_log(struct ir *ir, struct ir_value *a, struct ir_value *b, + struct ir_value *c) { struct ir_instr *instr = ir_append_instr(ir, OP_DEBUG_LOG, VALUE_V); ir_set_arg0(ir, instr, a); ir_set_arg1(ir, instr, b); diff --git a/src/jit/ir/ir.h b/src/jit/ir/ir.h index d1fbdb28..e9daa531 100644 --- a/src/jit/ir/ir.h +++ b/src/jit/ir/ir.h @@ -418,7 +418,8 @@ void ir_call_cond_2(struct ir *ir, struct ir_value *fn, struct ir_value *arg0, /* debug */ void ir_debug_break(struct ir *ir); -void ir_debug_log(struct ir *ir, struct ir_value *a, struct ir_value *b, struct ir_value *c); +void ir_debug_log(struct ir *ir, struct ir_value *a, struct ir_value *b, + struct ir_value *c); void ir_assert_eq(struct ir *ir, struct ir_value *a, struct ir_value *b); void ir_assert_lt(struct ir *ir, struct ir_value *a, struct ir_value *b);