From bbf58d01042c5ff22510bb846aa13f3f50c0485d Mon Sep 17 00:00:00 2001 From: Lendemor Date: Mon, 30 Jan 2017 01:07:40 +0100 Subject: [PATCH] set version number and change return type of getPosition() --- CMakeLists.txt | 3 +++ src/input.cpp | 9 +++++---- src/input.h | 7 +++++-- src/main.cpp | 9 --------- 4 files changed, 13 insertions(+), 15 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 098f803..817a788 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,9 @@ project(SparrowInput) cmake_minimum_required(VERSION 2.8) +SET(VERSION_MAJOR 1) +SET(VERSION_MINOR 0) + # choose source file file(GLOB LIB_SRC_LIST src/input.cpp src/keybindings.cpp src/textbuffer.cpp) file(GLOB LIB_HEAD_LIST src/*.h) diff --git a/src/input.cpp b/src/input.cpp index e114cd4..4f0091c 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -162,14 +162,15 @@ void Input::releaseHeldKeys(sf::Keyboard::Key keycode){ /* mouse-related functions */ -sf::Vector2i Input::getPosition() const +glm::vec2 Input::getPosition() const { - return m_mouse_position; + return glm::vec2(m_mouse_position.x,m_mouse_position.y); } -sf::Vector2i Input::getDeltaPosition() const +glm::vec2 Input::getDeltaPosition() const { - return m_mouse_position - m_last_mouse_position; + sf::Vector2i delta = m_mouse_position - m_last_mouse_position; + return glm::vec2(delta.x,delta.y); } float Input::getDeltaVerticalScroll() const diff --git a/src/input.h b/src/input.h index 37b5acc..6627ed8 100644 --- a/src/input.h +++ b/src/input.h @@ -9,6 +9,7 @@ #include #include #include "textbuffer.h" +#include "glm/vec2.hpp" class Input{ private: @@ -62,8 +63,10 @@ public: bool isKeyPressed(int key) const; /* mouse-related function */ - sf::Vector2i getPosition() const; - sf::Vector2i getDeltaPosition() const; + //sf::Vector2i getPosition() const; + glm::vec2 getPosition() const; + //sf::Vector2i getDeltaPosition() const; + glm::vec2 getDeltaPosition() const; float getDeltaVerticalScroll() const; /* Mouse grabbing */ diff --git a/src/main.cpp b/src/main.cpp index aa2d456..3761319 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -55,12 +55,3 @@ int main() cerr << "Successfully ended" << endl; return 0; } - -/*class MyInput : public Input -{ - MyInput(sf::Window *w) : Input(w){ - - } - -}; -*/