alt_return to toggle fullscreen (#252)

* alt_return to toggle fullscreen

* more
This commit is contained in:
Logan McNaughton 2025-02-14 12:29:49 +01:00 committed by GitHub
parent df9ad377d3
commit b7d194e12d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 27 additions and 5 deletions

View File

@ -141,10 +141,17 @@ bool sdl_event_filter(void *userdata, SDL_Event *event)
{
wsi_platform->do_resize();
}
else if (event->type == SDL_EVENT_KEY_DOWN)
else if (event->type == SDL_EVENT_KEY_UP)
{
switch (event->key.scancode)
{
case SDL_SCANCODE_RETURN:
if (event->key.mod & SDL_KMOD_ALT)
{
fullscreen = !fullscreen;
SDL_SetWindowFullscreen(window, fullscreen);
}
break;
case SDL_SCANCODE_ESCAPE:
if (fullscreen)
callback.emu_running = false;

View File

@ -334,10 +334,20 @@ pub fn get(ui: &mut ui::Ui, channel: usize) -> (u32, bool) {
let mut keys = 0;
let controller = ui.controllers[channel].game_controller;
let joystick = ui.controllers[channel].joystick;
let alt_pressed = unsafe {
// ignore key presses if ALT is pressed
*ui.keyboard_state
.offset(i32::from(sdl3_sys::scancode::SDL_SCANCODE_LALT) as isize)
|| *ui
.keyboard_state
.offset(i32::from(sdl3_sys::scancode::SDL_SCANCODE_RALT) as isize)
};
for i in 0..14 {
if profile_name != "default" || channel == 0 {
let profile_key = profile.keys[i];
if profile_key.0 {
if profile_key.0 && !alt_pressed {
keys |= (unsafe { *ui.keyboard_state.offset(profile_key.1 as isize) } as u32) << i;
}
}
@ -513,9 +523,14 @@ pub fn configure_input_profile(ui: &mut ui::Ui, profile: String, dinput: bool) {
if event_type == u32::from(sdl3_sys::events::SDL_EVENT_WINDOW_CLOSE_REQUESTED) {
close_controllers(open_joysticks, open_controllers);
return;
} else if event_type == u32::from(sdl3_sys::events::SDL_EVENT_KEY_DOWN) {
new_keys[*value] = (true, i32::from(unsafe { event.key.scancode }));
key_set = true
} else if event_type == u32::from(sdl3_sys::events::SDL_EVENT_KEY_UP) {
if unsafe {
event.key.scancode != sdl3_sys::scancode::SDL_SCANCODE_LALT
&& event.key.scancode != sdl3_sys::scancode::SDL_SCANCODE_RALT
} {
new_keys[*value] = (true, i32::from(unsafe { event.key.scancode }));
key_set = true
}
} else if event_type == u32::from(sdl3_sys::events::SDL_EVENT_GAMEPAD_BUTTON_DOWN) {
if !open_controllers.is_empty() {
new_controller_buttons[*value] =