mirror of https://github.com/AxioDL/metaforce.git
Add ability to set/get player index on SDL controllers
This commit is contained in:
parent
5a41dab870
commit
5add26b42e
|
@ -1443,7 +1443,7 @@ checksum = "96311ef4a16462c757bb6a39152c40f58f31cd2602a40fceb937e2bc34e6cbab"
|
|||
[[package]]
|
||||
name = "sdl2"
|
||||
version = "0.35.2"
|
||||
source = "git+https://github.com/encounter/rust-sdl2.git?rev=e282ef3acd7fcb4b2ba16863a7a0a7a8439f9335#e282ef3acd7fcb4b2ba16863a7a0a7a8439f9335"
|
||||
source = "git+https://github.com/encounter/rust-sdl2.git?rev=f39d7a7549fd59bebb1fb42ec12973200bb3080b#f39d7a7549fd59bebb1fb42ec12973200bb3080b"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"lazy_static",
|
||||
|
@ -1454,7 +1454,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "sdl2-sys"
|
||||
version = "0.35.2"
|
||||
source = "git+https://github.com/encounter/rust-sdl2.git?rev=e282ef3acd7fcb4b2ba16863a7a0a7a8439f9335#e282ef3acd7fcb4b2ba16863a7a0a7a8439f9335"
|
||||
source = "git+https://github.com/encounter/rust-sdl2.git?rev=f39d7a7549fd59bebb1fb42ec12973200bb3080b#f39d7a7549fd59bebb1fb42ec12973200bb3080b"
|
||||
dependencies = [
|
||||
"cfg-if 1.0.0",
|
||||
"libc",
|
||||
|
|
|
@ -30,7 +30,7 @@ scopeguard = "1.1.0"
|
|||
twox-hash = "1.6.2"
|
||||
winit = "0.26.1"
|
||||
# custom sdl2
|
||||
sdl2 = { git = "https://github.com/encounter/rust-sdl2.git", rev = "e282ef3acd7fcb4b2ba16863a7a0a7a8439f9335", features = ["no-link", "hidapi"] }
|
||||
sdl2 = { git = "https://github.com/encounter/rust-sdl2.git", rev = "f39d7a7549fd59bebb1fb42ec12973200bb3080b", features = ["no-link", "hidapi"] }
|
||||
|
||||
[dependencies.imgui]
|
||||
git = "https://github.com/imgui-rs/imgui-rs"
|
||||
|
|
|
@ -183,6 +183,8 @@ mod ffi {
|
|||
fn get_backend() -> Backend;
|
||||
fn get_backend_string() -> &'static str;
|
||||
fn set_fullscreen(v: bool);
|
||||
fn get_controller_player_index(which: u32) -> i32;
|
||||
fn set_controller_player_index(which: u32, index: i32);
|
||||
}
|
||||
}
|
||||
impl From<Button> for ffi::ControllerButton {
|
||||
|
@ -594,3 +596,19 @@ fn set_fullscreen(v: bool) {
|
|||
None
|
||||
});
|
||||
}
|
||||
|
||||
fn get_controller_player_index(which: u32) -> i32 {
|
||||
let has_controller = get_app().sdl_open_controllers.contains_key(&which);
|
||||
let result = if has_controller {
|
||||
get_app().sdl_open_controllers.get(&which).unwrap().player_index()
|
||||
} else {
|
||||
-1
|
||||
};
|
||||
result as i32
|
||||
}
|
||||
|
||||
fn set_controller_player_index(which: u32, index: i32) {
|
||||
if get_app().sdl_open_controllers.contains_key(&which) {
|
||||
get_app().sdl_open_controllers.get(&which).unwrap().set_player_index(index);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include "imgui.h"
|
||||
#include "misc/cpp/imgui_stdlib.h"
|
||||
#include <memory>
|
||||
|
||||
//#include <boo/IWindow.hpp>
|
||||
//#include <boo/graphicsdev/IGraphicsDataFactory.hpp>
|
||||
|
|
Loading…
Reference in New Issue