praetp / rustysnake

Snake game in Rust on raspberry pi with unicorn hat hd
MIT License
4 stars 0 forks source link

Non-rpi Linux? #1

Open davidde opened 6 years ago

davidde commented 6 years ago

Does this also work on non-rpi Linux? I just tried it on Debian, and I got:

cargo run -- /dev/input/event0 
    Finished dev [unoptimized + debuginfo] target(s) in 0.0 secs
     Running `target/debug/rustysnake /dev/input/event0`
Hello, world!
thread 'main' panicked at 'file not found: Error { repr: Os { code: 13, message: "Permission denied" } }', /checkout/src/libcore/result.rs:916:5
note: Run with `RUST_BACKTRACE=1` for a backtrace.

But maybe this has to do with the controller used? (I don't have a SNES one, so I tried a steam controller and keyboard ...)

praetp commented 6 years ago

There is no hard dependency on Raspberry PI in the game logic but you must specify the device file of the input device as sole argument and it must support certain events. If you are using a different kind of device with different kinds of events, you can send me a PR if you manage to get it working.

But here you are getting a permission denied, so I think there's still something else at play...

EDIT: Also, you will have to find an alternative for the display which is now hardcoded to be the unicorn hat hd. We could make this configurable.

davidde commented 6 years ago

Ok, thanks. Will let you know if I happen to find something.

davidde commented 6 years ago

Yes, the display seems to be the problem now. UnicornHatHd::default() on line 67 of unicornhd.rs unwraps on an err value:

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Error { repr: Os { code: 2, message: "No such file or directory" } }

But I wouldn't know how to fix this ...

praetp commented 6 years ago

The easy workaround is to uncomment the bottom lines in Cargo.toml. It will 'fake' the unicorn hat hd. This is probably not something you want as the final display but it will allow you to run the game in your PC. Not sure what you have in mind as a long term solution... Interested to hear..