本文整理汇总了C++中KeyboardInput类的典型用法代码示例。如果您正苦于以下问题:C++ KeyboardInput类的具体用法?C++ KeyboardInput怎么用?C++ KeyboardInput使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了KeyboardInput类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HandleObjectTypeChange
//-----------------------------------------------------------------------------------------------------------------------------------
void LevelDesignScreen::HandleObjectTypeChange(const KeyboardInput& keyboard)
{
if (keyboard.IsKeyPressed(Keyboard::D1))
{
m_currentType = kNormalTile;
m_objectTypeLabel->SetText(L"Normal Tile");
}
else if (keyboard.IsKeyPressed(Keyboard::D2))
{
m_currentType = kCollisionTile;
m_objectTypeLabel->SetText(L"Collision Tile");
}
else if (keyboard.IsKeyPressed(Keyboard::D3))
{
m_currentType = kNormalDecal;
m_objectTypeLabel->SetText(L"Normal Decal");
}
else if (keyboard.IsKeyPressed(Keyboard::D4))
{
m_currentType = kCollisionDecal;
m_objectTypeLabel->SetText(L"Collision Decal");
}
else if (keyboard.IsKeyPressed(Keyboard::D5))
{
m_currentType = kStartingPosition;
m_objectTypeLabel->SetText(L"Starting Position");
}
}
示例2: KeyDown
void CurveEditTool::KeyDown( const KeyboardInput& e )
{
CurveEditMode mode = m_HotEditMode;
switch (e.GetKeyCode())
{
case TXT('M'):
m_HotEditMode = CurveEditModes::Modify;
break;
case TXT('I'):
m_HotEditMode = CurveEditModes::Insert;
break;
case TXT('R'):
m_HotEditMode = CurveEditModes::Remove;
break;
default:
Base::KeyDown( e );
break;
}
if ( mode != m_HotEditMode )
{
m_Generator->GetContainer()->Read();
}
}
示例3: KeyPress
void CreateTool::KeyPress( const KeyboardInput& e )
{
if (e.GetKeyCode() == KeyCodes::Return)
{
AddToScene();
// create new at position
Place(Matrix4::Identity);
// render
m_Scene->Execute(true);
}
else
{
e.Skip();
}
}
示例4: main_loop
void main_loop(KeyboardInput &keyboardInput)
{
bool quit = false;
AudioData audioData(cmdline_opt.audio_card);
while (!quit)
{
int ch = keyboardInput.ReadKey();
if (ch != ERR)
{
std::cout << "ch: " << ch << std::endl;
std::string state_str;
state_str = keyboardInput.KeyPressedAction(ch);
pthread_mutex_lock(&rvopt_mutex);
if (quit || rvopt.quit)
{
quit = true;
rvopt.quit = true;
}
//Volume change?
if (rvopt.volume != -1)
{
audioData.SetVolume(rvopt.volume);
}
pthread_mutex_unlock(&rvopt_mutex);
//Speak state_str?
if ((cmdline_opt.speak) && (state_str != ""))
{
if (!audioData.Speak(state_str))
{
std::cerr << "Error calling Speak(). Use verbose mode for more info." << std::endl;
}
}
}
}
}
示例5: KeyPress
void CurveCreateTool::KeyPress( const KeyboardInput& e )
{
const int keyCode = e.GetKeyCode();
switch( keyCode )
{
case WXK_RETURN:
{
AddToScene();
break;
}
}
__super::KeyPress( e );
}
示例6: KeyPress
void CurveEditTool::KeyPress( const KeyboardInput& e )
{
if ( !m_Scene->IsEditable() )
{
return;
}
int32_t keyCode = e.GetKeyCode();
if ( keyCode == KeyCodes::Left || keyCode == KeyCodes::Up || keyCode == KeyCodes::Right || keyCode == KeyCodes::Down )
{
OS_SceneNodeDumbPtr selection = m_Scene->GetSelection().GetItems();
if ( selection.Empty() )
{
return;
}
CurveControlPoint* point = Reflect::SafeCast<CurveControlPoint>( selection.Front() );
if ( !point )
{
return;
}
Curve* curve = Reflect::SafeCast<Curve>( point->GetParent() );
if ( !curve )
{
return;
}
int32_t index = curve->GetIndexForControlPoint( point );
if ( index == -1 )
{
return;
}
uint32_t countControlPoints = curve->GetNumberControlPoints();
if ( keyCode == KeyCodes::Left || keyCode == KeyCodes::Down )
{
index--;
index += countControlPoints;
index %= countControlPoints;
}
else if ( keyCode == KeyCodes::Right || keyCode == KeyCodes::Up )
{
index++;
index %= countControlPoints;
}
point = curve->GetControlPointByIndex( index );
selection.Clear();
selection.Append( point );
m_Scene->GetSelection().SetItems( selection );
}
Base::KeyPress( e );
}
示例7: main
int main(int argc, char** argv) {
options.setOptions(argc, argv);
checkOptions(options);
displayHeader(cout);
if (fileQ) {
displayHeader(outputfile);
}
KeyboardInput keyboard; // for typing comments into output file
char keych; // character from keyboard
MidiMessage message;
int lastTime = -1;
midi.open();
while (1) {
while (midi.getCount() > 0) {
message = midi.extract();
if (echoQ) {
midi.send(message);
}
if ((!activeSensingQ) && (message.p0() == 0xfe)) {
// don't display incoming active-sensing messages
continue;
}
// filter any specified message types
if (suppressOffQ && ((message.p0() & 0xf0) == 0x90) &&
(message.p2() == 0)) {
continue;
} else if (filter[(message.p0() >> 4) - 8]) {
continue;
} else if (cfilter[message.p0() & 0x0f]) {
continue;
}
// adjust message time to delta time if necessary
if (!absoluteQ) {
if (lastTime == -1) {
lastTime = message.time;
message.time = 0;
} else {
int temp = message.time;
message.time = message.time - lastTime;
lastTime = temp;
}
}
displayMessage(cout, message, style);
if (fileQ) {
displayMessage(outputfile, message, style);
}
}
if (keyboardQ && keyboard.hit()) {
keych = keyboard.getch();
switch (keych) {
case 27: // escape key
if (fileQ && bufferIndex != 0 && bufferIndex < MAX_KEY_BUFF) {
inputBuffer[bufferIndex] = '\0';
outputfile << inputBuffer;
}
keyboard.deinitialize();
exit(0);
break;
case 0x08: // backspace key
case 0x7f: // delete key
if (bufferIndex > 0) {
cout << "\b \b" << flush;
bufferIndex--;
}
break;
case 0x0a: // enter key only
#ifdef VISUAL
break;
#endif
case 13: // line feed
cout << endl;
if (bufferIndex < MAX_KEY_BUFF) {
inputBuffer[bufferIndex] = '\0';
if (fileQ) {
outputfile << inputBuffer << '\n';
}
examineInputForCommand(inputBuffer);
}
bufferIndex = 0;
break;
case 0x0c: // ^L key (redraw input)
cout << endl;
if (bufferIndex < MAX_KEY_BUFF) {
inputBuffer[bufferIndex] = '\0';
cout << inputBuffer << flush;
}
break;
default: // normal key
cout << keych << flush;
if (bufferIndex < MAX_KEY_BUFF) {
inputBuffer[bufferIndex++] = keych;
} else {
//.........这里部分代码省略.........
示例8: new
void Helium::ConvertEvent( wxKeyEvent& event, KeyboardInput& input )
{
new (&input) KeyboardInput ();
KeyCode code = (KeyCode)-1;
if ( event.m_controlDown && event.m_keyCode < 32 ) // key codes below 32 are the ascii special characters for ctrl-*
{
switch ( event.GetKeyCode() )
{
// weird ASCII ctrl-<key> codes
case 0: code = KeyCodes::At; break;
case 1: code = KeyCodes::a; break;
case 2: code = KeyCodes::b; break;
case 3: code = KeyCodes::c; break;
case 4: code = KeyCodes::d; break;
case 5: code = KeyCodes::e; break;
case 6: code = KeyCodes::f; break;
case 7: code = KeyCodes::g; break;
case 8: code = KeyCodes::h; break; // WXK_BACK
case 9: code = KeyCodes::i; break; // WXK_TAB
case 10: code = KeyCodes::j; break;
case 11: code = KeyCodes::k; break;
case 12: code = KeyCodes::l; break;
case 13: code = KeyCodes::m; break; // WXK_RETURN
case 14: code = KeyCodes::n; break;
case 15: code = KeyCodes::o; break;
case 16: code = KeyCodes::p; break;
case 17: code = KeyCodes::q; break;
case 18: code = KeyCodes::r; break;
case 19: code = KeyCodes::s; break;
case 20: code = KeyCodes::t; break;
case 21: code = KeyCodes::u; break;
case 22: code = KeyCodes::v; break;
case 23: code = KeyCodes::w; break;
case 24: code = KeyCodes::x; break;
case 25: code = KeyCodes::y; break;
case 26: code = KeyCodes::z; break;
case 27: code = KeyCodes::LeftBracket; break; // WXK_ESCAPE
case 28: code = KeyCodes::Backslash; break;
case 29: code = KeyCodes::LeftBracket; break;
case 30: code = KeyCodes::Caret; break;
case 31: code = KeyCodes::Underscore; break;
}
}
else
{
switch ( event.GetKeyCode() )
{
case WXK_ESCAPE: code = KeyCodes::Escape; break;
case WXK_TAB: code = KeyCodes::Tab; break;
case WXK_BACK: code = KeyCodes::Backspace; break;
case WXK_RETURN: code = KeyCodes::Return; break;
case WXK_INSERT: code = KeyCodes::Insert; break;
case WXK_DELETE: code = KeyCodes::Delete; break;
case WXK_HOME: code = KeyCodes::Home; break;
case WXK_END: code = KeyCodes::End; break;
case WXK_PAGEUP: code = KeyCodes::PageUp; break;
case WXK_PAGEDOWN: code = KeyCodes::PageDown; break;
case WXK_LEFT: code = KeyCodes::Left; break;
case WXK_RIGHT: code = KeyCodes::Right; break;
case WXK_UP: code = KeyCodes::Up; break;
case WXK_DOWN: code = KeyCodes::Down; break;
case WXK_ALT: code = KeyCodes::Alt; break;
case WXK_CONTROL: code = KeyCodes::Ctrl; break;
case WXK_SHIFT: code = KeyCodes::Shift; break;
case WXK_WINDOWS_LEFT: code = KeyCodes::System; break;
case WXK_WINDOWS_RIGHT: code = KeyCodes::System; break;
case WXK_WINDOWS_MENU: code = KeyCodes::Menu; break;
case WXK_F1: code = KeyCodes::F1; break;
case WXK_F2: code = KeyCodes::F2; break;
case WXK_F3: code = KeyCodes::F3; break;
case WXK_F4: code = KeyCodes::F4; break;
case WXK_F5: code = KeyCodes::F5; break;
case WXK_F6: code = KeyCodes::F6; break;
case WXK_F7: code = KeyCodes::F7; break;
case WXK_F8: code = KeyCodes::F8; break;
case WXK_F9: code = KeyCodes::F9; break;
case WXK_F10: code = KeyCodes::F10; break;
case WXK_F11: code = KeyCodes::F11; break;
case WXK_F12: code = KeyCodes::F12; break;
}
}
if ( event.GetKeyCode() >= KeyCodes::Space && event.GetKeyCode() <= KeyCodes::Box )
{
code = (KeyCode)event.GetKeyCode();
}
HELIUM_ASSERT_MSG( code >= 0, TXT("Unrecognized keycode %d"), code );
input.SetCtrlDown( event.m_controlDown );
input.SetAltDown( event.m_altDown );
input.SetShiftDown( event.m_shiftDown );
input.SetMetaDown( event.m_metaDown );
input.SetKeyCode( code );
}
示例9: main
int main(int argc, char *argv[])
{
if (!SetCommandLineOptions(argc, argv))
{
return -1;
}
cmdline_opt = GetCommandLineOptions();
if (cmdline_opt.daemon)
{
std::cout << "raspivoice daemon started." << std::endl;
daemon_startup();
}
pthread_mutex_init(&rvopt_mutex, NULL);
rvopt = cmdline_opt;
//Setup keyboard:
KeyboardInput keyboardInput;
keyboardInput.Verbose = cmdline_opt.verbose;
bool use_ncurses = true;
if (cmdline_opt.verbose || cmdline_opt.daemon)
{
use_ncurses = false;
}
if (cmdline_opt.use_rotary_encoder)
{
keyboardInput.SetInputType(KeyboardInput::InputType::RotaryEncoder);
}
else if (cmdline_opt.grab_keyboard != "")
{
if (!keyboardInput.SetInputType(KeyboardInput::InputType::Keyboard, cmdline_opt.grab_keyboard))
{
std::cerr << "Cannot grab keyboard device: " << cmdline_opt.grab_keyboard << "." << std::endl;
return -1;
}
}
else if (use_ncurses)
{
keyboardInput.SetInputType(KeyboardInput::InputType::NCurses);
}
else if (!cmdline_opt.daemon)
{
keyboardInput.SetInputType(KeyboardInput::InputType::Terminal);
}
//Start Program in worker thread:
//Warning: Do not read or write rvopt or quit_flag without locking after this.
pthread_t thr;
AudioData::Init();
if (pthread_create(&thr, NULL, run_worker_thread, NULL))
{
std::cerr << "Error setting up thread." << std::endl;
return -1;
}
//Setup UI:
if (use_ncurses)
{
//Show interactive screen:
if (setup_screen())
{
printw("%s", keyboardInput.GetInteractiveCommandList().c_str());
refresh();
main_loop(keyboardInput);
close_screen();
}
}
else if ((cmdline_opt.verbose) && (!cmdline_opt.daemon))
{
std::cout << "Verbose mode on, curses UI disabled." << std::endl;
std::cout << keyboardInput.GetInteractiveCommandList();
main_loop(keyboardInput);
}
else
{
main_loop(keyboardInput);
}
if (cmdline_opt.grab_keyboard != "")
{
keyboardInput.ReleaseKeyboard();
}
//Wait for worker thread:
pthread_join(thr, nullptr);
//Check for exception from worker thread:
if (exc_ptr != nullptr)
{
try
{
std::rethrow_exception(exc_ptr);
}
//.........这里部分代码省略.........
示例10: checkKeyboard
int checkKeyboard(void) {
int output = -1;
if (keyboard.hit()) {
output = keyboard.getch();
}
return output;
}
示例11: Update
//-----------------------------------------------------------------------------------------------------------------------------------
void ScreenManager::Update(float elapsedSeconds)
{
m_keyboard.Update();
m_camera.Update(elapsedSeconds);
m_gameMouse.Update(elapsedSeconds);
for (BaseScreen* screen : m_activeScreens)
{
// Screen updating
screen->Update(elapsedSeconds);
}
for (BaseScreen* screen : m_screensToDelete)
{
// Clean up dead screens
m_activeScreens.remove(screen);
delete screen;
}
m_screensToDelete.clear();
}