Fixed the held keys, now occasionally a key will stick though

master
MitchellHansen 8 years ago
parent 10e3ba43fa
commit 7d7ed5367c

@ -93,31 +93,31 @@ void Camera::recieve_event(VrEventPublisher* publisher, std::unique_ptr<vr::Even
vr::KeyHeld *held_event = static_cast<vr::KeyHeld*>(event.get());
float speed = 1.0f;
default_impulse = 1.0f;
if (held_event->code == sf::Keyboard::LShift) {
speed = 0.2f;
default_impulse = 0.2f;
}
else if (held_event->code == sf::Keyboard::C) {
look_at_center();
}
else if (held_event->code == sf::Keyboard::Q) {
add_relative_impulse(Camera::DIRECTION::DOWN, speed);
add_relative_impulse(Camera::DIRECTION::DOWN, default_impulse);
}
else if (held_event->code == sf::Keyboard::E) {
add_relative_impulse(Camera::DIRECTION::UP, speed);
add_relative_impulse(Camera::DIRECTION::UP, default_impulse);
}
else if (held_event->code == sf::Keyboard::W) {
add_relative_impulse(Camera::DIRECTION::FORWARD, speed);
add_relative_impulse(Camera::DIRECTION::FORWARD, default_impulse);
}
else if (held_event->code == sf::Keyboard::S) {
add_relative_impulse(Camera::DIRECTION::REARWARD, speed);
add_relative_impulse(Camera::DIRECTION::REARWARD, default_impulse);
}
else if (held_event->code == sf::Keyboard::A) {
add_relative_impulse(Camera::DIRECTION::LEFT, speed);
add_relative_impulse(Camera::DIRECTION::LEFT, default_impulse);
}
else if (held_event->code == sf::Keyboard::D) {
add_relative_impulse(Camera::DIRECTION::RIGHT, speed);
add_relative_impulse(Camera::DIRECTION::RIGHT, default_impulse);
}
else if (held_event->code == sf::Keyboard::T) {
set_position(sf::Vector3f(50, 50, 50));

@ -46,7 +46,7 @@ void Input::handle_held_keys() {
}
else if (event->type == vr::Event::KeyReleased) {
vr::KeyReleased *e = static_cast<vr::KeyReleased*>(event.get());
std::remove(held_keys.begin(), held_keys.end(), e->code);
held_keys.erase(std::remove(held_keys.begin(), held_keys.end(), e->code), held_keys.end());
}
else if (event->type == vr::Event::MouseButtonPressed) {
vr::MouseButtonPressed *e = static_cast<vr::MouseButtonPressed*>(event.get());
@ -54,7 +54,7 @@ void Input::handle_held_keys() {
}
else if (event->type == vr::Event::MouseButtonReleased) {
vr::MouseButtonReleased *e = static_cast<vr::MouseButtonReleased*>(event.get());
std::remove(held_mouse_buttons.begin(), held_mouse_buttons.end(), e->button);
held_keys.erase(std::remove(held_keys.begin(), held_keys.end(), e->button), held_keys.end());
}
}

@ -1,4 +1,7 @@
#include "GL_Testing.h"

// This has to be up here or else glew will complain
#include "GL_Testing.h"
#ifdef linux
#include <CL/cl.h>
#include <CL/opencl.h>
@ -17,28 +20,22 @@
# include <OpenCL/opencl.h>
#include <OpenCL/cl_gl_ext.h>
#include <OpenCL/cl_ext.h>
#endif
#pragma once
#include <iostream>
#include <chrono>
#include <fstream>
#include <sstream>
#include <SFML/Graphics.hpp>
#include "Old_Map.h"
#include "util.hpp"
#include "RayCaster.h"
#include "Hardware_Caster.h"
#include "Vector4.hpp"
#include <Camera.h>
#include "Camera.h"
#include "Software_Caster.h"
#include "Input.h"
#include "Pub_Sub.h"
const int WINDOW_X = 1920;
const int WINDOW_Y = 1080;
const int WORK_SIZE = WINDOW_X * WINDOW_Y;
@ -164,18 +161,6 @@ int main() {
sf::Event event;
while (window.pollEvent(event)) {
if (event.type == sf::Event::Closed)
window.close();
if (event.type == sf::Event::KeyPressed) {
std::cout << event.key.code << std::endl;
}
if (event.type == sf::Event::KeyReleased) {
std::cout << event.key.code << std::endl;
}
if (event.type == sf::Event::KeyPressed) {
if (event.key.code == sf::Keyboard::M) {
if (mouse_enabled)
@ -208,8 +193,8 @@ int main() {
sf::Mouse::setPosition(fixed);
prev_pos = sf::Mouse::getPosition();
camera->slew_camera(sf::Vector2f(
deltas.y / 300.0f,
deltas.x / 300.0f
deltas.y / 600.0f,
deltas.x / 600.0f
));
}
}

Loading…
Cancel
Save