git.y1.nz

SameBoy

Accurate GB/GBC emulator
download: https://git.y1.nz/archives/sameboy.tar.gz
README | Files | Log | Refs | LICENSE

commit 197a475fab5e083c21b70995ffb3ef1ddd9b6721
parent 4f91b19a9469214afe4fcbe77800a5ef6f8c6ec8
Author: Lior Halphon <LIJI32@gmail.com>
Date:   Fri, 10 Jun 2022 14:37:28 +0300

SDL Joypad controls for MBC7 games

Diffstat:
MSDL/main.c13+++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/SDL/main.c b/SDL/main.c @@ -272,9 +272,14 @@ static void handle_events(GB_gameboy_t *gb) case SDL_JOYAXISMOTION: { static bool axis_active[2] = {false, false}; + static double accel_values[2] = {0, 0}; joypad_axis_t axis = get_joypad_axis(event.jaxis.axis); if (axis == JOYPAD_AXISES_X) { - if (event.jaxis.value > JOYSTICK_HIGH) { + if (GB_has_accelerometer(gb)) { + accel_values[0] = event.jaxis.value / (double)32768.0; + GB_set_accelerometer_values(gb, -accel_values[0], -accel_values[1]); + } + else if (event.jaxis.value > JOYSTICK_HIGH) { axis_active[0] = true; GB_set_key_state(gb, GB_KEY_RIGHT, true); GB_set_key_state(gb, GB_KEY_LEFT, false); @@ -291,7 +296,11 @@ static void handle_events(GB_gameboy_t *gb) } } else if (axis == JOYPAD_AXISES_Y) { - if (event.jaxis.value > JOYSTICK_HIGH) { + if (GB_has_accelerometer(gb)) { + accel_values[1] = event.jaxis.value / (double)32768.0; + GB_set_accelerometer_values(gb, -accel_values[0], -accel_values[1]); + } + else if (event.jaxis.value > JOYSTICK_HIGH) { axis_active[1] = true; GB_set_key_state(gb, GB_KEY_DOWN, true); GB_set_key_state(gb, GB_KEY_UP, false);

This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.