Skip to content

keymod not working #580

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
hoqhuuep opened this issue Dec 23, 2016 · 3 comments
Closed

keymod not working #580

hoqhuuep opened this issue Dec 23, 2016 · 3 comments

Comments

@hoqhuuep
Copy link

The keymod field of Event::KeyDown is always 0 (checked with keymod.bits()) regardless of CTRL/SHIFT/ALT state.

This was working for me recently, but after running rustup update and cargo update today I cannot get it to work again.

My OS is Windows 10.

> rustc --version
rustc 1.15.0-nightly (71c06a56a 2016-12-18)

I have tried:

[dependencies.sdl2]
version = "=0.27.0"

and

[dependencies.sdl2]
version = "=0.27.1"

Some example code which demostrates this issue:

src/main.rs

extern crate sdl2;
use sdl2::event::Event;

fn main() {
    let sdl2_context = sdl2::init().expect("failed to initialize sdl2");
    let video = sdl2_context.video().expect("failed to get sdl2 video context");
    let mut event_pump = sdl2_context.event_pump().expect("failed to get sdl2 event pump");

    let window = video.window("Keymod Test", 640, 480)
        .position_centered()
        .opengl()
        .build()
        .expect("failed to create window");

    let mut renderer = window.renderer()
        .present_vsync()
        .build()
        .expect("failed to create renderer");

    'event: loop {
        for event in event_pump.poll_iter() {
            match event {
                Event::Quit { .. } => break 'event,
                Event::KeyDown { keycode, keymod, .. } => {
                    println!("keycode: {:?}, keymod: {}", keycode, keymod.bits());
                }
                _ => {}
            }
        }

        renderer.clear();
        renderer.present();
    }
}

Cargo.toml

[package]
name = "keymod_test"
version = "0.1.0"

[dependencies]
sdl2="0.27"

Just hold CTRL/SHIFT/ALT and spam other keyboard keys. keymod is always 0.

@Cobrand
Copy link
Member

Cobrand commented Dec 23, 2016

Related to #579 and #575

Let me patch this real quick it should be fine by the end of the day

@Cobrand
Copy link
Member

Cobrand commented Dec 23, 2016

Up in sdl2 0.27.2

@Cobrand Cobrand closed this as completed Dec 23, 2016
@hoqhuuep
Copy link
Author

Fantastic, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants