@@ -10,7 +10,7 @@ use bevy_controls::{
Action , ActionInner , GameState , GameStateInner , InputsContainer , InputsContainerInner ,
} ,
plugin ::ControlsPlugin ,
resource ::{ Binding , ButtonCombination , Controls , InputType , InputValue , PlayerInputs } ,
resource ::{ Binding , ButtonCombination , Controls , InputType , InputValue , Keyboard , PlayerInputs } ,
} ;
use strum_macros ::EnumIter ;
@@ -58,7 +58,8 @@ impl InputsContainerInner<MyAction> for MyInputsContainer {
#[ derive(Resource, Default, Deref, DerefMut) ]
struct JumpsCount ( i32 ) ;
fn main ( ) { App ::new ( )
fn main ( ) {
App ::new ( )
. add_plugins ( (
DefaultPlugins ,
ControlsPlugin ::< MyAction , MyInputsContainer , MyGameState > ::default ( ) ,
@@ -71,94 +72,67 @@ fn main() { App::new()
// TODO: default bingings...
fn add_bindings ( mut controls : ResMut < Controls < MyAction , MyGameState > > ) {
< < < < < < < HEAD
controls . force_push (
MyAction ::Left ,
Binding ::new ( ButtonCombination ::Single ( InputType ::Keyboard ( KeyCode ::A ) ) ) ,
) ;
controls . force_push (
MyAction ::Left ,
Binding ::new ( ButtonCombination ::Single ( InputType ::Keyboard ( KeyCode ::H ) ) ) ,
) ;
controls . force_push (
MyAction ::Back ,
Binding ::new ( ButtonCombination ::Single ( InputType ::Keyboard ( KeyCode ::S ) ) ) ,
) ;
controls . force_push (
MyAction ::Back ,
Binding ::new ( ButtonCombination ::Single ( InputType ::Keyboard ( KeyCode ::J ) ) ) ,
) ;
controls . force_push (
MyAction ::Forward ,
Binding ::new ( ButtonCombination ::Single ( InputType ::Keyboard ( KeyCode ::W ) ) ) ,
) ;
controls . force_push (
MyAction ::Forward ,
Binding ::new ( ButtonCombination ::Single ( InputType ::Keyboard ( KeyCode ::K ) ) ) ,
) ;
controls . force_push (
MyAction ::Right ,
Binding ::new ( ButtonCombination ::Single ( InputType ::Keyboard ( KeyCode ::D ) ) ) ,
) ;
controls . force_push (
MyAction ::Right ,
Binding ::new ( ButtonCombination ::Single ( InputType ::Keyboard ( KeyCode ::L ) ) ) ,
) ;
controls . force_push (
MyAction ::Up ,
Binding ::new ( ButtonCombination ::Single ( InputType ::Keyboard (
KeyCode ::Space ,
) ) ) ,
) ;
= = = = = = =
controls . force_push (
MyAction ::Left ,
// this way input will work only on latin layout only on `A`
Binding ::new ( ButtonCombination ::Single ( InputType ::Keyboard ( Keyboard ::KeyCode ( KeyCode ::A ) ) ) ) ,
Binding ::new ( ButtonCombination ::Single ( InputType ::Keyboard (
Keyboard ::KeyCode ( KeyCode ::A ) ,
) ) ) ,
) ;
controls . force_push (
MyAction ::Left ,
// this way input will work only on any layout on same button, 35 is `H` for `us` layout or
// `О ` for `ru` layout
Binding ::new ( ButtonCombination ::Single ( InputType ::Keyboard ( Keyboard ::ScanCode ( ScanCode ( 35 ) ) ) ) ) ,
Binding ::new ( ButtonCombination ::Single ( InputType ::Keyboard (
Keyboard ::ScanCode ( ScanCode ( 35 ) ) ,
) ) ) ,
) ;
controls . force_push (
MyAction ::Back ,
Binding ::new ( ButtonCombination ::Single ( InputType ::Keyboard ( Keyboard ::KeyCode ( KeyCode ::S ) ) ) ) ,
Binding ::new ( ButtonCombination ::Single ( InputType ::Keyboard (
Keyboard ::KeyCode ( KeyCode ::S ) ,
) ) ) ,
) ;
controls . force_push (
MyAction ::Back ,
Binding ::new ( ButtonCombination ::Single ( InputType ::Keyboard ( Keyboard ::ScanCode ( ScanCode ( 36 ) ) ) ) ) ,
Binding ::new ( ButtonCombination ::Single ( InputType ::Keyboard (
Keyboard ::ScanCode ( ScanCode ( 36 ) ) ,
) ) ) ,
) ;
controls . force_push (
MyAction ::Forward ,
Binding ::new ( ButtonCombination ::Single ( InputType ::Keyboard ( Keyboard ::KeyCode ( KeyCode ::W ) ) ) ) ,
Binding ::new ( ButtonCombination ::Single ( InputType ::Keyboard (
Keyboard ::KeyCode ( KeyCode ::W ) ,
) ) ) ,
) ;
controls . force_push (
MyAction ::Forward ,
Binding ::new ( ButtonCombination ::Single ( InputType ::Keyboard ( Keyboard ::ScanCode ( ScanCode ( 37 ) ) ) ) ) ,
Binding ::new ( ButtonCombination ::Single ( InputType ::Keyboard (
Keyboard ::ScanCode ( ScanCode ( 37 ) ) ,
) ) ) ,
) ;
controls . force_push (
MyAction ::Right ,
Binding ::new ( ButtonCombination ::Single ( InputType ::Keyboard ( Keyboard ::KeyCode ( KeyCode ::D ) ) ) ) ,
Binding ::new ( ButtonCombination ::Single ( InputType ::Keyboard (
Keyboard ::KeyCode ( KeyCode ::D ) ,
) ) ) ,
) ;
controls . force_push (
MyAction ::Right ,
Binding ::new ( ButtonCombination ::Single ( InputType ::Keyboard ( Keyboard ::ScanCode ( ScanCode ( 38 ) ) ) ) ) ,
Binding ::new ( ButtonCombination ::Single ( InputType ::Keyboard (
Keyboard ::ScanCode ( ScanCode ( 38 ) ) ,
) ) ) ,
) ;
controls . force_push (
MyAction ::Up ,
Binding ::new ( ButtonCombination ::Single ( InputType ::Keyboard ( Keyboard ::KeyCode ( KeyCode ::Space ) ) ) ) ,
Binding ::new ( ButtonCombination ::Single ( InputType ::Keyboard (
Keyboard ::KeyCode ( KeyCode ::Space ) ,
) ) ) ,
) ;
> > > > > > > b2e0bd2 ( feat : scancode support )
}
#[ derive(Component) ]