bool vsx_widget_desktop::key_down(signed long key, bool n_alt, bool n_ctrl, bool n_shift) { this->alt = n_alt; this->ctrl = n_ctrl; this->shift = n_shift; char test[2]; test[0] = (char)key; test[1] = 0; //printf("key as char: %s\n", test); //printf("got key: %d\n", key); if (k_focus) { if (k_focus->event_key_down(key,alt,ctrl,shift)) { if (ctrl) { #ifdef _WIN32 switch (tolower(abs(key))) { #else switch (tolower(key)) { #endif case ' ': ((vsx_window_texture_viewer*)tv)->run = !((vsx_window_texture_viewer*)tv)->run; break; // fullwindow case 'F': case 'f': // F //printf("going fullwindow\n"); ((vsx_window_texture_viewer*)tv)->fullwindow = !((vsx_window_texture_viewer*)tv)->fullwindow; if (((vsx_window_texture_viewer*)tv)->fullwindow) mouse.hide_cursor(); else mouse.show_cursor(); if (!((vsx_window_texture_viewer*)tv)->fullwindow) this->performance_mode = false; //if (alt) this->performance_mode = !this->performance_mode; break; // close all controllers case 'c': delete_all_by_type(VSX_WIDGET_TYPE_CONTROLLER); break; // close all open anchors case 'd': for (std::map<int, vsx_widget*>::iterator it = ilist.begin(); it != ilist.end(); ++it) { if ((*it).second->widget_type == VSX_WIDGET_TYPE_ANCHOR) { if ((*it).second->parent) if ((*it).second->parent->widget_type == VSX_WIDGET_TYPE_COMPONENT) { ((vsx_widget_anchor*)(*it).second)->toggle(1); } } } break; } } if (alt) { #ifdef _WIN32 switch (tolower(abs(key))) { #else switch (tolower(key)) { #endif case 'F': case 'f': // F if (((vsx_window_texture_viewer*)tv)->fullwindow) { mouse.show_cursor(); this->performance_mode = !this->performance_mode; } default: break; } } if (!ctrl && !alt) #ifdef _WIN32 switch (tolower(abs(key))) { #else switch (abs(key)) { #endif case 0x08: case ' ': { //if (a_focus->type >= 100) { if (a_focus->widget_type != VSX_WIDGET_TYPE_SERVER) { vsx_vector a = a_focus->get_pos_p(); move_camera(vsx_vector(a.x,a.y,2.0f)); } else move_camera(vsx_vector(xp,yp,2.0f)); /*zp = 2; xp = a.x; yp = a.y; xps = 0; yps = 0; zps = 0;*/ } } break; case 'E': case 'e':{ interpolating = false;ypd=1.0;} break; case 'D': case 'd':{ interpolating = false;ypd=-1.0;} break; case 's': case 'S':{ interpolating = false;xpd=-1.0;} break; case 'F': case 'f':{ interpolating = false;xpd=1.0;} break; case 'R': case 'r':{ interpolating = false;zpd=-1.0;} break; case 'W': case 'w':{ interpolating = false;zpd=1.0;} break; } // switch } else { return true; } } else return true; return false; } bool vsx_widget_desktop::key_up(signed long key, bool alt, bool ctrl, bool shift) { this->ctrl = ctrl; if (k_focus) { if (k_focus->event_key_up(key,alt,ctrl,shift)) { //if (!ctrl) switch (key) { case 'E': case 'e': ypd=0.0; break; case 'D': case 'd': ypd=0.0; break; case 'S': case 's': xpd=0.0; break; case 'F': case 'f': xpd=0.0; break; case 'R': case 'r': zpd=0.0; break; case 'W': case 'w': zpd=0.0; break; #ifndef VSXU_PLAYER #ifndef _WIN32 case GLFW_KEY_TAB: #else case 0x09: #endif { ((vsxu_assistant*)assistant)->toggle_size(); } break; #endif //case 'c': tcp_main_client.connect(578); break; } } else { return false; } } else return true; return false; } void vsx_widget_desktop::event_mouse_wheel(float y) { //if (y > 0) zps += -y; if (zps > 2.0f) zps = 2.0f; if (zps < -2.0f) zps = -2.0f; //else //zps += ; } void vsx_widget_desktop::move_camera(vsx_vector world) { camera_target = world; interpolating = true; }
bool vsx_widget_desktop::key_down(signed long key, bool n_alt, bool n_ctrl, bool n_shift) { this->alt = n_alt; this->ctrl = n_ctrl; this->shift = n_shift; if (!k_focus) return true; bool k_focus_result = k_focus->event_key_down(key,alt,ctrl,shift); if (!k_focus_result) return true; if (ctrl) { switch (key) { case -GLFW_KEY_SPACE: ((vsx_window_texture_viewer*)tv)->toggle_run(); break; // fullwindow case 'F': case 'f': // F ((vsx_window_texture_viewer*)tv)->toggle_fullwindow(); if (((vsx_window_texture_viewer*)tv)->get_fullwindow()) { mouse.hide_cursor(); } else { mouse.show_cursor(); } if (!((vsx_window_texture_viewer*)tv)->get_fullwindow()) this->performance_mode = false; break; // close all controllers case -'C': case -'c': delete_all_by_type(VSX_WIDGET_TYPE_CONTROLLER); break; // close all open anchors case -'D': case -'d': for (std::map<int, vsx_widget*>::iterator it = global_index_list.begin(); it != global_index_list.end(); ++it) { if ((*it).second->widget_type == VSX_WIDGET_TYPE_ANCHOR) { if ((*it).second->parent) if ((*it).second->parent->widget_type == VSX_WIDGET_TYPE_COMPONENT) { ((vsx_widget_anchor*)(*it).second)->toggle(1); } } } break; } } if (alt) { switch (key) { case -'F': case -'f': // F if (((vsx_window_texture_viewer*)tv)->get_fullwindow()) { this->performance_mode = !this->performance_mode; } if (this->performance_mode) { mouse.show_cursor(); } else { mouse.hide_cursor(); } default: break; } } if (!ctrl && !alt) switch (key) { case -GLFW_KEY_SPACE: { { if (a_focus->widget_type != VSX_WIDGET_TYPE_SERVER) { vsx_vector3<> a = a_focus->get_pos_p(); camera.move_camera(vsx_vector3<>(a.x,a.y,2.0f)); } else camera.set_distance(2.0f);; } } break; case -GLFW_KEY_UP: case -'E': case -'e': camera.set_movement_y( 1.0 ); break; case -GLFW_KEY_DOWN: case -'D': case -'d': camera.set_movement_y( -1.0 ); break; case -GLFW_KEY_LEFT: case -'s': case -'S': camera.set_movement_x( -1.0 ); break; case -GLFW_KEY_RIGHT: case -'F': case -'f': camera.set_movement_x( 1.0 ); break; case -GLFW_KEY_PAGEUP: case -'R': case -'r': camera.set_movement_z( -1.0 ); break; case -GLFW_KEY_PAGEDOWN: case -'W': case -'w': camera.set_movement_z( 1.0 ); break; } // switch return false; }
bool vsx_widget_desktop::key_down(signed long key, bool n_alt, bool n_ctrl, bool n_shift) { this->alt = n_alt; this->ctrl = n_ctrl; this->shift = n_shift; if (k_focus) { if (k_focus->event_key_down(key,alt,ctrl,shift)) { if (ctrl) { #ifdef VSXU_DEBUG printf("desktop key: %d\n",key); printf("f: %d",'f'); printf("F: %d",'F'); printf("res: %d", tolower(abs(key))); #endif switch (key) { case -GLFW_KEY_SPACE: ((vsx_window_texture_viewer*)tv)->run = !((vsx_window_texture_viewer*)tv)->run; break; // fullwindow case -'F': case -'f': // F //printf("going fullwindow\n"); ((vsx_window_texture_viewer*)tv)->fullwindow = !((vsx_window_texture_viewer*)tv)->fullwindow; if (((vsx_window_texture_viewer*)tv)->fullwindow) mouse.hide_cursor(); else mouse.show_cursor(); if (!((vsx_window_texture_viewer*)tv)->fullwindow) this->performance_mode = false; //if (alt) this->performance_mode = !this->performance_mode; break; // close all controllers case -'C': case -'c': delete_all_by_type(VSX_WIDGET_TYPE_CONTROLLER); break; // close all open anchors case -'D': case -'d': for (std::map<int, vsx_widget*>::iterator it = ilist.begin(); it != ilist.end(); ++it) { if ((*it).second->widget_type == VSX_WIDGET_TYPE_ANCHOR) { if ((*it).second->parent) if ((*it).second->parent->widget_type == VSX_WIDGET_TYPE_COMPONENT) { ((vsx_widget_anchor*)(*it).second)->toggle(1); } } } break; } } if (alt) { switch (key) { case -'F': case -'f': // F if (((vsx_window_texture_viewer*)tv)->fullwindow) { mouse.show_cursor(); this->performance_mode = !this->performance_mode; } default: break; } } if (!ctrl && !alt) switch (key) { case -GLFW_KEY_SPACE: { { if (a_focus->widget_type != VSX_WIDGET_TYPE_SERVER) { vsx_vector a = a_focus->get_pos_p(); move_camera(vsx_vector(a.x,a.y,2.0f)); } else move_camera(vsx_vector(xp,yp,2.0f)); } } break; case -GLFW_KEY_UP: case -'E': case -'e':{ interpolating = false;ypd=1.0;} break; case -GLFW_KEY_DOWN: case -'D': case -'d':{ interpolating = false;ypd=-1.0;} break; case -GLFW_KEY_LEFT: case -'s': case -'S':{ interpolating = false;xpd=-1.0;} break; case -GLFW_KEY_RIGHT: case -'F': case -'f':{ interpolating = false;xpd=1.0;} break; case -GLFW_KEY_PAGEUP: case -'R': case -'r':{ interpolating = false;zpd=-1.0;} break; case -GLFW_KEY_PAGEDOWN: case -'W': case -'w':{ interpolating = false;zpd=1.0;} break; } // switch } else { return true; } } else return true; return false; }