Skip to content

Commit

Permalink
Added input init and multitouch support.
Browse files Browse the repository at this point in the history
Added input init and multitouch support.
  • Loading branch information
Rinnegatamante committed Aug 1, 2016
1 parent b148107 commit f0a508f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
16 changes: 10 additions & 6 deletions source/luaControls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,19 +84,23 @@ static int lua_touchpad(lua_State *L)
if (lua_gettop(L) != 0) return luaL_error(L, "wrong number of arguments.");
SceTouchData touch;
sceTouchPeek(SCE_TOUCH_PORT_FRONT, &touch, 1);
lua_pushnumber(L, lerp(touch.report[0].x, 1919, 960));
lua_pushnumber(L, lerp(touch.report[0].y, 1087, 544));
return 2;
for (SceUInt32 i=0;i<touch.reportNum;i++){
lua_pushnumber(L, lerp(touch.report[i].x, 1919, 960));
lua_pushnumber(L, lerp(touch.report[i].y, 1087, 544));
}
return touch.reportNum<<1;
}

static int lua_touchpad2(lua_State *L)
{
if (lua_gettop(L) != 0) return luaL_error(L, "wrong number of arguments.");
SceTouchData touch;
sceTouchPeek(SCE_TOUCH_PORT_BACK, &touch, 1);
lua_pushnumber(L, lerp(touch.report[0].x, 1919, 960));
lua_pushnumber(L, lerp(touch.report[0].y, 1087, 544));
return 2;
for (SceUInt32 i=0;i<touch.reportNum;i++){
lua_pushnumber(L, lerp(touch.report[i].x, 1919, 960));
lua_pushnumber(L, lerp(touch.report[i].y, 1087, 544));
}
return touch.reportNum<<1;
}

//Register our Controls Functions
Expand Down
7 changes: 7 additions & 0 deletions source/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <string.h>
#include <malloc.h>
#include <psp2/ctrl.h>
#include <psp2/touch.h>
#include <psp2/types.h>
#include <psp2/moduleinfo.h>
#include <psp2/kernel/processmgr.h>
Expand All @@ -22,6 +23,12 @@ int clr_color;

int main()
{

// Initializing touch screens and analogs
sceCtrlSetSamplingMode(SCE_CTRL_MODE_ANALOG);
sceTouchSetSamplingState(SCE_TOUCH_PORT_FRONT, 1);
sceTouchSetSamplingState(SCE_TOUCH_PORT_BACK, 1);

char vita_ip[16];
unsigned short int vita_port = 0;
vita2d_init();
Expand Down

0 comments on commit f0a508f

Please sign in to comment.