本文整理汇总了C++中ci::app::KeyEvent::getCode方法的典型用法代码示例。如果您正苦于以下问题:C++ KeyEvent::getCode方法的具体用法?C++ KeyEvent::getCode怎么用?C++ KeyEvent::getCode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ci::app::KeyEvent
的用法示例。
在下文中一共展示了KeyEvent::getCode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: keyDown
void CircleCropExample::keyDown(ci::app::KeyEvent event){
using ci::app::KeyEvent;
inherited::keyDown(event);
if(event.getChar() == KeyEvent::KEY_r){ // R = reload all configs and start over without quitting app
setupServer();
} else if(event.getCode() == KeyEvent::KEY_d){
moveCamera(ci::vec3(1.0f, 0.0f, 0.0f));
} else if(event.getCode() == KeyEvent::KEY_a){
moveCamera(ci::vec3(-1.0f, 0.0f, 0.0f));
} else if(event.getCode() == KeyEvent::KEY_w){
moveCamera(ci::vec3(0.0f, -1.0f, 0.0f));
} else if(event.getCode() == KeyEvent::KEY_s){
moveCamera(ci::vec3(0.0f, 1.0f, 0.0f));
} else if(event.getCode() == KeyEvent::KEY_RIGHTBRACKET){
moveCamera(ci::vec3(0.0f, 0.0f, 1.0f));
} else if(event.getCode() == KeyEvent::KEY_LEFTBRACKET){
moveCamera(ci::vec3(0.0f, 0.0f, -1.0f));
} else if(event.getCode() == KeyEvent::KEY_EQUALS){
ds::PerspCameraParams p = mEngine.getPerspectiveCamera(1);
p.mFarPlane += 1.0f;
std::cout << "Clip Far camera: " << p.mFarPlane << std::endl;
mEngine.setPerspectiveCamera(1, p);
} else if(event.getCode() == KeyEvent::KEY_MINUS){
ds::PerspCameraParams p = mEngine.getPerspectiveCamera(1);
p.mFarPlane -= 1.0f;
std::cout << "Clip Far camera: " << p.mFarPlane << std::endl;
mEngine.setPerspectiveCamera(1, p);
} else if(event.getCode() == KeyEvent::KEY_c){
if(mShaderCircleCrop){
mShaderCircleCrop->setCircleCrop(!mShaderCircleCrop->getCircleCrop());
}
}
}
示例2: keyDown
void PanoramicVideo::keyDown(ci::app::KeyEvent event){
using ci::app::KeyEvent;
inherited::keyDown(event);
if(event.getChar() == KeyEvent::KEY_r){ // R = reload all configs and start over without quitting app
setupServer();
// Shows all enabled sprites with a label for class type
} else if(event.getCode() == KeyEvent::KEY_f){
const int numRoots = mEngine.getRootCount();
int numPlacemats = 0;
for(int i = 0; i < numRoots - 1; i++){
mEngine.getRootSprite(i).forEachChild([this](ds::ui::Sprite& sprite){
if(sprite.isEnabled()){
sprite.setTransparent(false);
sprite.setColor(ci::Color(ci::randFloat(), ci::randFloat(), ci::randFloat()));
sprite.setOpacity(0.95f);
ds::ui::Text* labelly = mGlobals.getText("media_viewer:title").create(mEngine, &sprite);
labelly->setText(typeid(sprite).name());
labelly->enable(false);
labelly->setColor(ci::Color::black());
} else {
ds::ui::Text* texty = dynamic_cast<ds::ui::Text*>(&sprite);
if(!texty || (texty && texty->getColor() != ci::Color::black())) sprite.setTransparent(true);
}
}, true);
}
}
}
示例3: keyDown
void EditorState::keyDown(ci::app::KeyEvent event)
{
// XXX duplicate raycast
Vec2f pos = GG.mouse.getPos();
Vec3f planeHit = GG.hexRender.raycastHexPlane(pos.x, pos.y);
HexCoord selectedHex = GG.hexGrid.WorldToHex(planeHit);
int keycode = event.getCode();
Vec3f& cameraTo = GG.hexRender.getCameraTo();
if (keycode == app::KeyEvent::KEY_ESCAPE) {
mManager.setActiveState("title");
}
else if (keycode == app::KeyEvent::KEY_UP) {
cameraTo += Vec3f(0, 2.0f, 0);
}
else if (keycode == app::KeyEvent::KEY_DOWN) {
cameraTo += Vec3f(0, -2.0f, 0);
}
else if (keycode == app::KeyEvent::KEY_LEFT) {
cameraTo += Vec3f(-2.0f, 0, 0);
}
else if (keycode == app::KeyEvent::KEY_RIGHT) {
cameraTo += Vec3f(2.0f, 0, 0);
}
else if (keycode == app::KeyEvent::KEY_g) {
// Generate hex colors
Vec2i mapSize = GG.hexMap.getSize();
for (int iy=0; iy < mapSize.y; ++iy) {
for (int ix=0; ix < mapSize.x; ++ix) {
HexCell& cell = GG.hexMap.at(HexCoord(ix, iy));
if (cell.getLand()) {
int playerID = random.nextInt(0, 5);
cell.setOwner(playerID);
cell.setColor(GG.warGame.getPlayers()[playerID].getColor());
}
}
}
}
else if (keycode == app::KeyEvent::KEY_DELETE) {
GG.hexMap.at(selectedHex).setLand(0);
}
else if (keycode == app::KeyEvent::KEY_SPACE) {
mManager.setActiveState(string("game"));
}
else if (keycode == app::KeyEvent::KEY_c) {
vector<HexCoord> connected = GG.hexMap.connected(selectedHex);
for (vector<HexCoord>::iterator it = connected.begin(); it != connected.end(); ++it) {
HexCell& cell = GG.hexMap.at(*it);
Color cellColor = cell.getColor();
cellColor.r = 0.5f * cellColor.r;
cellColor.g = 0.5f * cellColor.g;
cellColor.b = 0.5f * cellColor.b;
cell.setColor(cellColor);
}
}
}
示例4: ImGui_ImplCinder_KeyCallback
void ImGui_ImplCinder_KeyCallback(ci::app::KeyEvent e, bool isDown)
{
ImGuiIO& io = ImGui::GetIO();
io.KeysDown[e.getCode()] = isDown;
io.KeyCtrl = io.KeysDown[ci::app::KeyEvent::KEY_LCTRL] || io.KeysDown[ci::app::KeyEvent::KEY_RCTRL];
io.KeyShift = io.KeysDown[ci::app::KeyEvent::KEY_LSHIFT] || io.KeysDown[ci::app::KeyEvent::KEY_RSHIFT];
io.KeyAlt = io.KeysDown[ci::app::KeyEvent::KEY_LALT] || io.KeysDown[ci::app::KeyEvent::KEY_RALT];
}
示例5: keyDown
void https_example::keyDown(ci::app::KeyEvent event){
using ci::app::KeyEvent;
inherited::keyDown(event);
if(event.getChar() == KeyEvent::KEY_r){ // R = reload all configs and start over without quitting app
setupServer();
} else if(event.getCode() == KeyEvent::KEY_v && event.isControlDown()){
auto fileNameOrig = ds::Environment::getClipboard();
mHttpsRequest.makeGetRequest("https://example.com", false, false);
} else if(event.getCode() == KeyEvent::KEY_p){
std::string datay = "{ \"data\": { \"type\": \"collection_links\", \"attributes\": { \"story_type\": \"Achievement\", \"story_id\": \"13\" }}}";
std::vector<std::string> headers;
headers.push_back("Accept: application/json");
headers.push_back("Content-Type: application/json");
mHttpsRequest.makePostRequest("https://example.com", datay, true, true, "", headers);
// Shows all enabled sprites with a label for class type
} else if(event.getCode() == KeyEvent::KEY_f){
const int numRoots = mEngine.getRootCount();
int numPlacemats = 0;
for(int i = 0; i < numRoots - 1; i++){
mEngine.getRootSprite(i).forEachChild([this](ds::ui::Sprite& sprite){
if(sprite.isEnabled()){
sprite.setTransparent(false);
sprite.setColor(ci::Color(ci::randFloat(), ci::randFloat(), ci::randFloat()));
sprite.setOpacity(0.95f);
ds::ui::Text* labelly = mGlobals.getText("media_viewer:title").create(mEngine, &sprite);
labelly->setText(typeid(sprite).name());
labelly->enable(false);
labelly->setColor(ci::Color::black());
} else {
ds::ui::Text* texty = dynamic_cast<ds::ui::Text*>(&sprite);
if(!texty || (texty && texty->getColor() != ci::Color::black())) sprite.setTransparent(true);
}
}, true);
}
}
}
示例6: keyDown
void XmlSettingsSetting::keyDown(ci::app::KeyEvent event){
using ci::app::KeyEvent;
inherited::keyDown(event);
if(event.getChar() == KeyEvent::KEY_r){ // R = reload all configs and start over without quitting app
setupServer();
} else if(event.getCode() == KeyEvent::KEY_x){
if(mSettings){
mSettings->toggleVisibility();
}
}
}
示例7: onKeyDown
void PretzelRoot::onKeyDown(ci::app::KeyEvent &event)
{
mGuiList[0]->keyDown( event.getChar(), event.getCode() );
// for( auto it = mGuiList.begin(); it!=mGuiList.end(); ++it){
// PretzelGui *pg = *it;
//
// if( pg->getGlobalBounds().contains( event.getPos() ) ){
// (*it)->keyDown( event.getChar(), event.getCode() );
// }
// }
}
示例8: keyDown
void ClientState::keyDown(ci::app::KeyEvent event)
{
// Vec3f& cameraTo = GG.hexRender.getCameraTo();
int keycode = event.getCode();
if (keycode == app::KeyEvent::KEY_ESCAPE) {
mManager.setActiveState("title");
}
else if (keycode == app::KeyEvent::KEY_BACKQUOTE) {
// XXX should push console to the top of the gui widget list
GG.gui.attach(GG.console);
}
}
示例9: keyDown
// TODO: Fix this memory leak from new Link(...)
bool ChatNode::keyDown(ci::app::KeyEvent event) {
if (event.getCode() == ci::app::KeyEvent::KEY_RETURN) {
if (active_node_identity_ != NULL &&
active_node_identity_->object() != NULL) {
// Finish updating by sending finished flag and deactivate
ChatMessageNode::request_finish_update(*active_node_identity_,
text_buffer_);
active_node_ = NULL;
text_buffer_.clear();
active_node_identity_ = NULL;
}
} else {
text_buffer_ += event.getChar();
unsent_chars_ = true;
if (active_node_identity_ == NULL) {
// Request create a node, but make sure to update it
TeteManager::instance() += ObjectController::instance()[id()];
ID create_id_ = Utility::create_uuid();
active_node_identity_ = Identity::create_identity(create_id_, NULL);
LinkPtr user_link(new Link(&(Client::user_identity()),
LinkFlags(true, true, true)));
std::deque<LinkPtr> temp_links;
temp_links.push_back(user_link);
if (!chat_messages_.empty()) {
const Identity* last_ident = Identity::get_identity_from_id(
chat_messages_.back()->id());
LinkPtr last_msg_link(new Link(last_ident, LinkFlags(true, true)));
temp_links.push_back(last_msg_link);
}
ChatMessageNode::request_create(create_id_,
*identity(), text_buffer_, temp_links);
} else if (active_node_identity_ != NULL &&
active_node_identity_->object() != NULL) {
// Update the current node, and send an update request
ChatMessageNode::request_update_text(*active_node_identity_,
text_buffer_);
unsent_chars_ = false;
}
}
return false;
}
示例10: keyDown
void ServerState::keyDown(ci::app::KeyEvent event)
{
static int count = 0;
++count;
// Vec3f& cameraTo = GG.hexRender.getCameraTo();
io::stream<GuiConsoleStream> cout = GG.console->output();
int keycode = event.getCode();
if (keycode == app::KeyEvent::KEY_ESCAPE) {
mManager.setActiveState("title");
}
else if (keycode == app::KeyEvent::KEY_BACKQUOTE) {
// XXX should push console to the top of the gui widget list
GG.gui.attach(GG.console);
}
else if (keycode == app::KeyEvent::KEY_SPACE) {
cout << "That's what I said: " << count << std::endl;
}
}
示例11: isBindedToKeyEvent
bool Control::isBindedToKeyEvent( ci::app::KeyEvent &event )
{
bool useModifier = ( mKeyModifier != -1 ) ? true : false;
bool modDown = getIsModifierDown( event );
bool isBindedToMod = getIsBindedToModifier( event );
bool isBindedToKey = getIsBindedToKey( event.getCode() );
if( isBindedToKey )
{
if( isBindedToMod )
{
return true;
}
else if( !modDown && !useModifier )
{
return true;
}
}
return false;
}
示例12: keyDown
void redEyeApp::keyDown(ci::app::KeyEvent event) {
if(event.getChar()=='i') {
mHide= !mHide;
} else if(event.getCode()==KeyEvent::KEY_ESCAPE) {
setFullScreen(!isFullScreen());
} else if(event.getChar()=='f') {
fs::path path= getOpenFilePath(mPathFrag);
if(!path.empty()) {
mPathFrag= path;
loadShader();
}
} else if(event.getChar()=='v') {
fs::path path= getOpenFilePath(mPathVert);
if(!path.empty()) {
mPathVert= path;
loadShader();
}
} else if(event.getChar()=='m') {
mMode= (mMode+1)%9;
}
}
示例13: keyDown
void Game::keyDown(ci::app::KeyEvent e)
{
mEngine.keyEvent(true, e.getCode());
}
示例14: keyDown
void RibbonPaint::keyDown( ci::app::KeyEvent event )
{
if(_state != kStateNormal) return;
char keyPressed = event.getChar();
int colorMode;
switch (keyPressed)
{
case 's':
saveOutBrushImageAndParameters();
break;
case 'o':
_drawParams = !_drawParams;
_params.show( !_params.isVisible() );
break;
case 'r':
randomizeBrush();
break;
case 'm':
createBrush();
break;
case 'g':
_glitchSegment = !_glitchSegment;
break;
case 'l':
_useBezier = !_useBezier;
case 'p':
_drawPins = !_drawPins;
break;
case '1': // COLORMODE_HSV
case '2': // COLORMODE_RGB
case '3': // COLORMODE_RGBINVERSE
case '4': // COLORMODE_RGB_B
case '5': // COLORMODE_RGB_C
case '6': // COLORMODE_GRAYSCALE
case '7': // COLORMODE_ALPHABLEND_1
case '8': // COLORMODE_ALPHABLEND_2
colorMode = boost::lexical_cast<int>( keyPressed );
toggleAdditiveBlending( colorMode < COLORMODE_GRAYSCALE);
_colorMode = colorMode;
break;
default:
console() << keyPressed << std::endl;
break;
}
// slowdown or speed up how fast our object chases the mouse - clamp addition of speed (determined by ternary operator)
if(event.getCode() == ci::app::KeyEvent::KEY_LEFT || event.getCode() == ci::app::KeyEvent::KEY_RIGHT) {
if(event.getCode() == ci::app::KeyEvent::KEY_LEFT)
_mouseChaseDamping -= 0.02;
else if(event.getCode() == ci::app::KeyEvent::KEY_RIGHT)
_mouseChaseDamping += 0.02;
_mouseChaseDamping = ci::math<float>::clamp(_mouseChaseDamping, 0.02, 1.0);
updateParams();
}
if(event.getCode() == ci::app::KeyEvent::KEY_UP || event.getCode() == ci::app::KeyEvent::KEY_DOWN)
{
_alphaWhenDrawing = ci::math<double>::clamp(_alphaWhenDrawing + ((event.getCode() == ci::app::KeyEvent::KEY_UP) ? 0.005 : -0.005), 0.0, 1.0);
updateParams();
}
// exit fullscreen with escape, and toggle with F
if ( event.getChar() == 'f' || (isFullScreen() && event.getCode() == ci::app::KeyEvent::KEY_ESCAPE) )
{
ci::gl::clear(_clearColor);
setFullScreen( !isFullScreen() );
}
}
示例15: keyDown
// ------------------------------------------------------------------------------------------------
void VisualsApp::keyDown(ci::app::KeyEvent event) {
if (event.getCode() == 27) quit(); // quit on escape
}