#include <msp/core/application.h>
#include <msp/graphics/simplewindow.h>
+#include <msp/input/gesturedetector.h>
#include <msp/input/keyboard.h>
#include <msp/input/mouse.h>
+#include <msp/input/touchscreen.h>
#include <msp/io/print.h>
#include <msp/stringcodec/codec.h>
#include <msp/stringcodec/utf8.h>
Graphics::SimpleWindow window;
Input::Keyboard keyboard;
Input::Mouse mouse;
+ Input::Touchscreen *touch;
+ Input::GestureDetector *gesture;
public:
Ev(int, char **);
+ ~Ev();
private:
virtual void tick();
void button_press(unsigned);
void button_release(unsigned);
void axis_motion(unsigned, float, float);
+ void touch_press(unsigned);
+ void touch_release(unsigned);
+ void touch_motion(unsigned, float, float);
+ void gesture_started(unsigned);
+ void gesture_ended(unsigned);
+ void gesture_axis(unsigned, float, float);
};
Ev::Ev(int, char **):
window(200, 200),
keyboard(window),
- mouse(window)
+ mouse(window),
+ touch(0),
+ gesture(0)
{
window.get_display().signal_got_focus.connect(sigc::mem_fun(this, &Ev::got_focus));
window.get_display().signal_lost_focus.connect(sigc::mem_fun(this, &Ev::lost_focus));
mouse.signal_button_press.connect(sigc::bind_return(sigc::mem_fun(this, &Ev::button_press), false));
mouse.signal_button_release.connect(sigc::bind_return(sigc::mem_fun(this, &Ev::button_release), false));
mouse.signal_axis_motion.connect(sigc::bind_return(sigc::mem_fun(this, &Ev::axis_motion), false));
+ if(Input::Touchscreen::is_available())
+ {
+ touch = new Input::Touchscreen(window);
+ gesture = new Input::GestureDetector(*touch);
+ touch->signal_button_press.connect(sigc::bind_return(sigc::mem_fun(this, &Ev::touch_press), false));
+ touch->signal_button_release.connect(sigc::bind_return(sigc::mem_fun(this, &Ev::touch_release), false));
+ touch->signal_axis_motion.connect(sigc::bind_return(sigc::mem_fun(this, &Ev::touch_motion), false));
+ gesture->signal_button_press.connect(sigc::bind_return(sigc::mem_fun(this, &Ev::gesture_started), false));
+ gesture->signal_button_release.connect(sigc::bind_return(sigc::mem_fun(this, &Ev::gesture_ended), false));
+ gesture->signal_axis_motion.connect(sigc::bind_return(sigc::mem_fun(this, &Ev::gesture_axis), false));
+ }
window.set_title("Event tester");
window.show();
}
+Ev::~Ev()
+{
+ delete gesture;
+ delete touch;
+}
+
void Ev::tick()
{
window.tick();
{
IO::print("axis_motion: %s %.3f %+.3f\n", mouse.get_axis_name(axis), value, rel);
}
+
+void Ev::touch_press(unsigned btn)
+{
+ IO::print("touch_press: %s\n", touch->get_button_name(btn));
+}
+
+void Ev::touch_release(unsigned btn)
+{
+ IO::print("touch_release: %s\n", touch->get_button_name(btn));
+}
+
+void Ev::touch_motion(unsigned axis, float value, float rel)
+{
+ IO::print("touch_motion: %s %.3f %+.3f\n", touch->get_axis_name(axis), value, rel);
+}
+
+void Ev::gesture_started(unsigned type)
+{
+ IO::print("gesture_started: %s\n", gesture->get_button_name(type));
+}
+
+void Ev::gesture_ended(unsigned type)
+{
+ IO::print("gesture_ended: %s\n", gesture->get_button_name(type));
+}
+
+void Ev::gesture_axis(unsigned axis, float value, float rel)
+{
+ IO::print("gesture_axis: %s %.3f %.3f\n", gesture->get_axis_name(axis), value, rel);
+}