MCPcopy Create free account
hub / github.com/Panzerschrek/Chasm-Reverse / GetInputState

Method GetInputState

PanzerChasm/system_window.cpp:676–698  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

674}
675
676void SystemWindow::GetInputState( InputState& out_input_state )
677{
678 out_input_state.keyboard.reset();
679
680 int key_count;
681 const Uint8* const keyboard_state= SDL_GetKeyboardState( &key_count );
682
683 for( int i= 0; i < key_count; i++ )
684 {
685 SystemEvent::KeyEvent::KeyCode code= TranslateKey( SDL_Scancode(i) );
686 if( code < SystemEvent::KeyEvent::KeyCode::KeyCount && code != SystemEvent::KeyEvent::KeyCode::Unknown )
687 out_input_state.keyboard[ static_cast<unsigned int>(code) ]= keyboard_state[i] != 0;
688 }
689
690 out_input_state.mouse.reset();
691
692 const Uint32 mouse_state= SDL_GetMouseState( nullptr, nullptr );
693 for( unsigned int i= SDL_BUTTON_LEFT; i <= SDL_BUTTON_RIGHT; i++ )
694 {
695 out_input_state.mouse[ static_cast<unsigned int>(TranslateMouseButton(i)) ]=
696 ( SDL_BUTTON(i) & mouse_state )!= 0u;
697 }
698}
699
700void SystemWindow::CaptureMouse( const bool need_capture )
701{

Callers 1

LoopMethod · 0.80

Calls 2

TranslateKeyFunction · 0.85
TranslateMouseButtonFunction · 0.85

Tested by

no test coverage detected