WiP
This commit is contained in:
parent
fdf7714d11
commit
b2b12b64ab
4 changed files with 73 additions and 51 deletions
|
@ -18,7 +18,8 @@ void script_system::load(sol::table &ns)
|
|||
"new", sol::no_constructor,
|
||||
"get",&input::get,
|
||||
"mouse_position",sol::readonly_property(&input::mouse_position),
|
||||
"mouse_button",sol::readonly_property(&input::mouse_button)
|
||||
"mouse_button",sol::readonly_property(&input::mouse_button),
|
||||
"input_string",sol::readonly_property(&input::input_string)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -76,7 +76,7 @@ w.size = pw.size.new(1200,800)
|
|||
while w:update()
|
||||
do
|
||||
|
||||
if (pw.input:get().mouse_button > 0) then
|
||||
if (pw.input:get().mouse_button == 1) then
|
||||
print(pw.input:get().mouse_position.x,pw.input:get().mouse_position.y)
|
||||
end
|
||||
|
||||
|
|
|
@ -13,9 +13,16 @@ public:
|
|||
|
||||
point mouse_position() const { return _mouse_position; }
|
||||
int mouse_button() const { return _mouse_button; }
|
||||
std::string input_string() const { return _input_string; }
|
||||
|
||||
|
||||
~input() = default;
|
||||
|
||||
enum mouse_button_state {
|
||||
pressed,
|
||||
released
|
||||
};
|
||||
|
||||
protected:
|
||||
|
||||
friend class window;
|
||||
|
@ -27,6 +34,9 @@ private:
|
|||
point _mouse_position;
|
||||
int _mouse_button;
|
||||
|
||||
std::string _input_string;
|
||||
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
#include "pw/system/input.hpp"
|
||||
|
||||
#include <cmath>
|
||||
#include <locale>
|
||||
#include <codecvt>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
|
@ -68,14 +70,18 @@ struct window::impl {
|
|||
std::cout << __FUNCTION__ << std::endl;
|
||||
}
|
||||
|
||||
static void character_callback(GLFWwindow* window, unsigned int codepoint)
|
||||
{
|
||||
std::cout << __FUNCTION__ << std::endl;
|
||||
}
|
||||
// static void character_callback(GLFWwindow* window, unsigned int codepoint)
|
||||
// {
|
||||
// std::cout << __FUNCTION__ << std::endl;
|
||||
// }
|
||||
|
||||
static void charmods_callback(GLFWwindow* window, unsigned int codepoint, int mods)
|
||||
{
|
||||
std::cout << __FUNCTION__ << std::endl;
|
||||
// build the string from a Unicode code point
|
||||
std::wstring_convert<std::codecvt_utf8<char32_t>, char32_t> converter;
|
||||
std::string u8str = converter.to_bytes(codepoint);
|
||||
|
||||
input::get()._input_string = u8str;
|
||||
}
|
||||
|
||||
static void framebuffer_size_callback(GLFWwindow* window, int width, int height)
|
||||
|
@ -97,7 +103,7 @@ struct window::impl {
|
|||
|
||||
glfwSetFramebufferSizeCallback(_window, window::impl::framebuffer_size_callback);
|
||||
glfwSetKeyCallback(_window, window::impl::key_callback);
|
||||
glfwSetCharCallback(_window, character_callback);
|
||||
// glfwSetCharCallback(_window, character_callback);
|
||||
glfwSetCharModsCallback(_window, charmods_callback);
|
||||
glfwSetScrollCallback(_window, scroll_callback);
|
||||
|
||||
|
@ -172,6 +178,11 @@ struct window::impl {
|
|||
{
|
||||
glfwSetWindowPos(_window,x,y);
|
||||
}
|
||||
|
||||
void set_fullscreen()
|
||||
{
|
||||
// glfwSetWindow
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue