载入中...
搜索中...
未找到
Touch.cpp
浏览该文件的文档.
1#include "touch/Touch.h"
2#include "touch/sdl/Touch.h"
3#include "common/Exception.h"
4#include <simplesquirrel/simplesquirrel.hpp>
5namespace eve::touch {
6
8
9double Touch::getTouchX(int index) const {
10 const auto &touches = getTouches();
11 if (index < 0 || index >= int(touches.size()))
12 throw Exception("Touch index out of range");
13 return touches[size_t(index)].x;
14}
15
16double Touch::getTouchY(int index) const {
17 const auto &touches = getTouches();
18 if (index < 0 || index >= int(touches.size()))
19 throw Exception("Touch index out of range");
20 return touches[size_t(index)].y;
21}
22
23void Touch::expose(ssq::Table& table) {
24 auto cls = table.addClass(name, Touch::create, false);
25 expose(cls);
26}
27
28void Touch::expose(ssq::Class& cls) {
29 cls.addFunc("getName", &Touch::getName);
30 cls.addFunc("getTouchCount", &Touch::getTouchCount);
31 cls.addFunc("getTouchX", [](Touch *t, int index) -> float {
32 return t ? float(t->getTouchX(index)) : 0.f;
33 });
34 cls.addFunc("getTouchY", [](Touch *t, int index) -> float {
35 return t ? float(t->getTouchY(index)) : 0.f;
36 });
37}
38
39}
HSQOBJECT cls
Definition ECS.cpp:21
#define Module_IMPL(ModuleName, newExpr)
Definition Module.h:24
const char * name
Definition RockMesh.cpp:21
virtual std::string getName() const =0
double getTouchY(int index) const
Definition Touch.cpp:16
double getTouchX(int index) const
Definition Touch.cpp:9
virtual const std::vector< TouchInfo > & getTouches() const =0
Gets all currently active touches.
int getTouchCount() const
Definition Touch.h:37
SDL 触摸后端实现(状态由事件驱动更新)。
Definition Touch.h:11