/** * input_state: * @port : user number. * @device : device identifier of user. * @idx : index value of user. * @id : identifier of key pressed by user. * * Input state callback function. * * Returns: Non-zero if the given key (identified by @id) was pressed by the user * (assigned to @port). **/ static int16_t input_state(unsigned port, unsigned device, unsigned idx, unsigned id) { size_t i; const struct retro_keybind *libretro_input_binds[MAX_USERS]; int16_t res = 0; settings_t *settings = config_get_ptr(); driver_t *driver = driver_get_ptr(); global_t *global = global_get_ptr(); const input_driver_t *input = driver ? (const input_driver_t*)driver->input : NULL; for (i = 0; i < MAX_USERS; i++) libretro_input_binds[i] = settings->input.binds[i]; device &= RETRO_DEVICE_MASK; if (global->bsv.movie && global->bsv.movie_playback) { int16_t ret; if (bsv_movie_get_input(global->bsv.movie, &ret)) return ret; global->bsv.movie_end = true; } if (settings->input.remap_binds_enable) input_remapping_state(port, &device, &idx, &id); if (!driver->block_libretro_input) { if (((id < RARCH_FIRST_META_KEY) || (device == RETRO_DEVICE_KEYBOARD))) res = input->input_state(driver->input_data, libretro_input_binds, port, device, idx, id); #ifdef HAVE_OVERLAY input_state_overlay(&res, port, device, idx, id); #endif } /* flushing_input will be cleared in rarch_main_iterate. */ if (driver->flushing_input) res = 0; /* Don't allow turbo for D-pad. */ if (device == RETRO_DEVICE_JOYPAD && (id < RETRO_DEVICE_ID_JOYPAD_UP || id > RETRO_DEVICE_ID_JOYPAD_RIGHT)) res = input_apply_turbo(port, id, res); if (global->bsv.movie && !global->bsv.movie_playback) bsv_movie_set_input(global->bsv.movie, res); return res; }
/** * input_state: * @port : user number. * @device : device identifier of user. * @idx : index value of user. * @id : identifier of key pressed by user. * * Input state callback function. * * Returns: Non-zero if the given key (identified by @id) was pressed by the user * (assigned to @port). **/ int16_t input_state(unsigned port, unsigned device, unsigned idx, unsigned id) { int16_t res = 0; settings_t *settings = config_get_ptr(); device &= RETRO_DEVICE_MASK; if (bsv_movie_ctl(BSV_MOVIE_CTL_PLAYBACK_ON, NULL)) { int16_t ret; if (bsv_movie_ctl(BSV_MOVIE_CTL_GET_INPUT, &ret)) return ret; bsv_movie_ctl(BSV_MOVIE_CTL_SET_END, NULL); } if (settings->input.remap_binds_enable) input_remapping_state(port, &device, &idx, &id); if (!input_driver_is_flushing_input() && !input_driver_is_libretro_input_blocked()) { if (((id < RARCH_FIRST_META_KEY) || (device == RETRO_DEVICE_KEYBOARD))) res = current_input->input_state( current_input_data, libretro_input_binds, port, device, idx, id); #ifdef HAVE_OVERLAY input_state_overlay(&res, port, device, idx, id); #endif #ifdef HAVE_NETWORKGAMEPAD input_remote_state(&res, port, device, idx, id); #endif } /* Don't allow turbo for D-pad. */ if (device == RETRO_DEVICE_JOYPAD && (id < RETRO_DEVICE_ID_JOYPAD_UP || id > RETRO_DEVICE_ID_JOYPAD_RIGHT)) { /* * Apply turbo button if activated. * * If turbo button is held, all buttons pressed except * for D-pad will go into a turbo mode. Until the button is * released again, the input state will be modulated by a * periodic pulse defined by the configured duty cycle. */ if (res && input_driver_turbo_btns.frame_enable[port]) input_driver_turbo_btns.enable[port] |= (1 << id); else if (!res) input_driver_turbo_btns.enable[port] &= ~(1 << id); if (input_driver_turbo_btns.enable[port] & (1 << id)) { /* if turbo button is enabled for this key ID */ res = res && ((input_driver_turbo_btns.count % settings->input.turbo_period) < settings->input.turbo_duty_cycle); } } if (bsv_movie_ctl(BSV_MOVIE_CTL_PLAYBACK_OFF, NULL)) bsv_movie_ctl(BSV_MOVIE_CTL_SET_INPUT, &res); return res; }
/** * input_state: * @port : user number. * @device : device identifier of user. * @idx : index value of user. * @id : identifier of key pressed by user. * * Input state callback function. * * Returns: Non-zero if the given key (identified by @id) was pressed by the user * (assigned to @port). **/ static int16_t input_state(unsigned port, unsigned device, unsigned idx, unsigned id) { int16_t res = 0; settings_t *settings = config_get_ptr(); driver_t *driver = driver_get_ptr(); global_t *global = global_get_ptr(); const struct retro_keybind *libretro_input_binds[MAX_USERS] = { settings->input.binds[0], settings->input.binds[1], settings->input.binds[2], settings->input.binds[3], settings->input.binds[4], settings->input.binds[5], settings->input.binds[6], settings->input.binds[7], settings->input.binds[8], settings->input.binds[9], settings->input.binds[10], settings->input.binds[11], settings->input.binds[12], settings->input.binds[13], settings->input.binds[14], settings->input.binds[15], }; device &= RETRO_DEVICE_MASK; if (global->bsv.movie && global->bsv.movie_playback) { int16_t ret; if (bsv_movie_get_input(global->bsv.movie, &ret)) return ret; global->bsv.movie_end = true; } if (settings->input.remap_binds_enable) input_remapping_state(port, &device, &idx, &id); if (!driver->block_libretro_input) { if (((id < RARCH_FIRST_META_KEY) || (device == RETRO_DEVICE_KEYBOARD))) res = input_driver_state(libretro_input_binds, port, device, idx, id); #ifdef HAVE_OVERLAY if (port == 0) { switch (device) { case RETRO_DEVICE_JOYPAD: if (driver->overlay_state.buttons & (UINT64_C(1) << id)) res |= 1; break; case RETRO_DEVICE_KEYBOARD: if (id < RETROK_LAST) { if (OVERLAY_GET_KEY(&driver->overlay_state, id)) res |= 1; } break; case RETRO_DEVICE_ANALOG: { unsigned base = 0; if (idx == RETRO_DEVICE_INDEX_ANALOG_RIGHT) base = 2; if (id == RETRO_DEVICE_ID_ANALOG_Y) base += 1; if (driver->overlay_state.analog[base]) res = driver->overlay_state.analog[base]; } break; } } #endif } /* flushing_input will be cleared in rarch_main_iterate. */ if (driver->flushing_input) res = 0; /* Don't allow turbo for D-pad. */ if (device == RETRO_DEVICE_JOYPAD && (id < RETRO_DEVICE_ID_JOYPAD_UP || id > RETRO_DEVICE_ID_JOYPAD_RIGHT)) res = input_apply_turbo(port, id, res); if (global->bsv.movie && !global->bsv.movie_playback) bsv_movie_set_input(global->bsv.movie, res); return res; }