Skip to content

Commit

Permalink
implemented touchpad-style pointer controls
Browse files Browse the repository at this point in the history
Touch controls are configured under 'More Options/Touch'
Choices are 'Touch Off', 'Front only', or 'Front and Back.'

The default is to use only the front panel. Both panels
work the same, using relative touch mode.

How far a certain finger motion moves the pointer depends on
the Mouse Speed setting, which also affects how fast the analog
stick moves the mouse.

Touch gestures supported:
single short tap - left mouse click
single short tap while holding a second finger down - right mouse click
single finger drag - move the mouse pointer
dual finger drag - drag'n'drop (while left mouse button is held down)
  • Loading branch information
rsn8887 committed Feb 6, 2018
1 parent 34d945a commit 391bf2c
Show file tree
Hide file tree
Showing 11 changed files with 542 additions and 25 deletions.
3 changes: 2 additions & 1 deletion CMakeLists.txt
Expand Up @@ -27,6 +27,7 @@ set(SRC_FILES
src/psp2/psp2_shader.cpp
src/psp2/psp2_input.c
src/psp2/psp2-dirent.c
src/psp2/psp2_touch.c
src/vkbd/vkbd.cpp
src/neon_helper.s
src/gp2x/memset.s
Expand Down Expand Up @@ -120,7 +121,7 @@ set(LDFLAGS
${CMAKE_SOURCE_DIR}/src/psp2/vita-shader-collection/lib/libvitashaders.a
SceSysmodule_stub SceDisplay_stub SceGxm_stub
SceCtrl_stub ScePgf_stub ScePower_stub SceCommonDialog_stub
SceAudio_stub SceShellSvc_stub SceHid_stub png jpeg z m c
SceAudio_stub SceShellSvc_stub SceHid_stub SceTouch_stub png jpeg z m c
)

if (BUILD_DEBUG)
Expand Down
11 changes: 11 additions & 0 deletions Readme.txt
Expand Up @@ -50,6 +50,7 @@ VITA-EXCLUSIVE FEATURES:
- Adjustable stereo separation
- Bluetooth keyboard and mouse support
- Sticky virtual keyboard modifiers: allows keyboard combos like CTRL-C to be entered easily
- Touchpad style pointer controls using the front touch panel and, optional, the rear touch panel. Touch pointer speed can be adjusted with the Mouse Speed option.

NOTES:

Expand Down Expand Up @@ -117,7 +118,17 @@ Square = Backspace
Triangle = Toggle shift
Circle = Turn off all sticky keys (ctrl, alt, amiga, and shift)

Touch controls:
single short tap = left mouse click
single short tap while holding a second finger down = right mouse click
single finger drag = move the mouse pointer
dual finger drag = drag'n'drop (left mouse button is held down)

CHANGELOG:
1.59

- implemented touchpad-style pointer controls. Touch controls are configured under 'More Options/Touch.' Choices are 'Touch Off', 'Front only', or 'Front and Back.' The default is to use only the front panel. Both panels work the same, using relative touch mode. How far a certain finger motion moves the pointer depends on the Mouse Speed setting, which also affects how fast the analog stick moves the mouse.

1.58

- fix 'movec pcr,d0' not throwing exception on 68020 (fixes WHDload 18.3)
Expand Down
5 changes: 5 additions & 0 deletions src/gp2x/menu/menu_config.cpp
Expand Up @@ -141,6 +141,7 @@ int saveMenu_n_savestate = 0;
#ifdef __PSP2__
int mainMenu_shader = 5;
int mainMenu_leftStickMouse = 0;
int mainMenu_touchControls = 1;
int mainMenu_deadZone = 1000;
#endif

Expand Down Expand Up @@ -310,6 +311,7 @@ void SetDefaultMenuSettings(int general)
#ifdef __PSP2__
mainMenu_shader = 5;
mainMenu_leftStickMouse = 0;
mainMenu_touchControls = 1;
mainMenu_deadZone = 1000;
#endif

Expand Down Expand Up @@ -944,6 +946,8 @@ int saveconfig(int general)
fputs(buffer,f);
snprintf((char*)buffer, 255, "leftstickmouse=%d\n",mainMenu_leftStickMouse);
fputs(buffer,f);
snprintf((char*)buffer, 255, "touchcontrols=%d\n",mainMenu_touchControls);
fputs(buffer,f);
snprintf((char*)buffer, 255, "deadzone=%d\n",mainMenu_deadZone);
fputs(buffer,f);
#endif
Expand Down Expand Up @@ -1347,6 +1351,7 @@ void loadconfig(int general)
#ifdef __PSP2__
fscanf(f,"shader=%d\n",&mainMenu_shader);
fscanf(f,"leftstickmouse=%d\n",&mainMenu_leftStickMouse);
fscanf(f,"touchcontrols=%d\n",&mainMenu_touchControls);
fscanf(f,"deadzone=%d\n",&mainMenu_deadZone);
#endif
fscanf(f,"showstatus=%d\n",&mainMenu_showStatus);
Expand Down
1 change: 1 addition & 0 deletions src/gp2x/menu/menu_config.h
Expand Up @@ -115,6 +115,7 @@ extern char custom_kickrom[256];

#ifdef __PSP2__
extern int mainMenu_leftStickMouse;
extern int mainMenu_touchControls;
extern int mainMenu_shader;
extern int mainMenu_deadZone;
extern int mainMenu_custom_controlSet;
Expand Down
78 changes: 59 additions & 19 deletions src/gp2x/menu/menu_misc.cpp
Expand Up @@ -79,6 +79,7 @@ enum {
#endif
#ifdef __PSP2__
MENUMISC_DEADZONE,
MENUMISC_TOUCHCONTROLS,
#else
MENUMISC_TAPDELAY,
#endif
Expand Down Expand Up @@ -383,17 +384,17 @@ static void draw_miscMenu(int c)
write_text(tabstop3-8,menuLine,"On");
write_text(tabstop3-5,menuLine,"(can disturb 2nd player)");

// MENUMISC_LEFTSTICKMOUSE
menuLine+=2;
// MENUMISC_LEFTSTICKMOUSE
menuLine+=2;
write_text(leftMargin,menuLine,"Mouse Control");
if (mainMenu_leftStickMouse==0)
{
if ((menuMisc!=MENUMISC_LEFTSTICKMOUSE)||(bb))
write_text_inv(tabstop2,menuLine,"Right Stick");
else
write_text(tabstop2,menuLine,"Right Stick ");
}
else if (mainMenu_leftStickMouse==1)
}
else if (mainMenu_leftStickMouse==1)
{
if ((menuMisc!=MENUMISC_LEFTSTICKMOUSE)||(bb))
write_text_inv(tabstop2,menuLine,"Left Stick");
Expand Down Expand Up @@ -453,7 +454,31 @@ static void draw_miscMenu(int c)
write_text_inv(tabstop2,menuLine,cpuSpeed);
else
write_text(tabstop2,menuLine,cpuSpeed);


// MENUMISC_TOUCHCONTROLS
write_text(tabstop6-2,menuLine,"Touch");
if (mainMenu_touchControls==0)
{
if ((menuMisc!=MENUMISC_TOUCHCONTROLS)||(bb))
write_text_inv(tabstop9-1,menuLine,"Off");
else
write_text(tabstop9-1,menuLine,"Off ");
}
else if (mainMenu_touchControls==1)
{
if ((menuMisc!=MENUMISC_TOUCHCONTROLS)||(bb))
write_text_inv(tabstop9-1,menuLine,"Front");
else
write_text(tabstop9-1,menuLine,"Front ");
}
else if (mainMenu_touchControls==2)
{
if ((menuMisc!=MENUMISC_TOUCHCONTROLS)||(bb))
write_text_inv(tabstop9-1,menuLine,"Both");
else
write_text(tabstop9-1,menuLine,"Both ");
}

#else
// MENUMISC_TAPDELAY
menuLine+=2;
Expand Down Expand Up @@ -668,31 +693,46 @@ static int key_miscMenu(int *c)
mainMenu_CPU_speed=0;
}
break;

#ifndef __PSP2__
#ifdef PANDORA
case MENUMISC_PANDORASPEED:
case MENUMISC_PANDORASPEED:
if(left)
mainMenu_cpuSpeed-=10;
else if(right)
mainMenu_cpuSpeed+=10;
break;
break;
#endif
#endif //__PSP2__
#ifdef __PSP2__
case MENUMISC_LEFTSTICKMOUSE:
if ((left)||(right))
mainMenu_leftStickMouse = !mainMenu_leftStickMouse;
break;
case MENUMISC_LEFTSTICKMOUSE:
if (left || right)
mainMenu_leftStickMouse = !mainMenu_leftStickMouse;
break;
case MENUMISC_TOUCHCONTROLS:
if (left)
{
if (mainMenu_touchControls>0)
mainMenu_touchControls--;
else
mainMenu_touchControls=2;
}
else if (right)
{
if (mainMenu_touchControls<2)
mainMenu_touchControls++;
else
mainMenu_touchControls=0;
}
break;
#endif

#ifdef ANDROIDSDL
case MENUMISC_ONSCREEN:
if ((left)||(right))
mainMenu_onScreen = !mainMenu_onScreen;
break;
mainMenu_onScreen = !mainMenu_onScreen;
break;
#endif

case MENUMISC_CONTROLCFG:
if (left)
{
Expand Down Expand Up @@ -724,7 +764,7 @@ static int key_miscMenu(int *c)
else
mainMenu_joyPort=0;
}
break;
break;
case MENUMISC_AUTOFIRERATE:
if(left)
{
Expand Down Expand Up @@ -756,7 +796,7 @@ static int key_miscMenu(int *c)
}
else if (right)
{
if (mainMenu_customAutofireButton < 6)
if (mainMenu_customAutofireButton < 6)
mainMenu_customAutofireButton++;
else
mainMenu_customAutofireButton=6;
Expand Down Expand Up @@ -845,8 +885,8 @@ static int key_miscMenu(int *c)
break;
case MENUMISC_MOUSEEMULATION:
if ((left)||(right))
mainMenu_mouseEmulation = !mainMenu_mouseEmulation;
break;
mainMenu_mouseEmulation = !mainMenu_mouseEmulation;
break;
#else
case MENUMISC_TAPDELAY:
if (left)
Expand Down
4 changes: 2 additions & 2 deletions src/gui.cpp
Expand Up @@ -253,8 +253,8 @@ int gui_init (void)
init_kickstart();

#ifdef __PSP2__
//Lock PS Button to prevent file corruption
sceShellUtilLock(SCE_SHELL_UTIL_LOCK_TYPE_PS_BTN);
//Lock PS Button to prevent file corruption
sceShellUtilLock(SCE_SHELL_UTIL_LOCK_TYPE_PS_BTN);
#endif

#ifdef USE_UAE4ALL_VKBD
Expand Down
10 changes: 8 additions & 2 deletions src/main.cpp
Expand Up @@ -64,6 +64,8 @@ extern SDL_Surface *current_screenshot;
#ifdef __PSP2__
//Allow locking PS Button
#include <psp2/shellutil.h>
//Touch input
#include "psp2_touch.h"
#ifdef DEBUG_UAE4ALL
#include <psp2shell.h>
#endif
Expand Down Expand Up @@ -201,6 +203,8 @@ void do_leave_program (void)
#ifdef USE_UAE4ALL_VKBD
vkbd_quit();
#endif
//De-Initialize touch panels
psp2QuitTouch();
#endif
if(current_screenshot != NULL)
SDL_FreeSurface(current_screenshot);
Expand Down Expand Up @@ -239,8 +243,10 @@ void real_main (int argc, char **argv)
#endif

#ifdef __PSP2__
//Initialize ShellUtil to allow us to disable "PS" Button (corrupts hdf files)
sceShellUtilInitEvents(0);
//Initialize ShellUtil to allow us to disable "PS" Button (corrupts hdf files)
sceShellUtilInitEvents(0);
//Initialize touch panels
psp2InitTouch();
#endif

#ifdef USE_SDL
Expand Down
1 change: 1 addition & 0 deletions src/od-joy.cpp
Expand Up @@ -56,6 +56,7 @@ extern int rAnalogY;
extern int lAnalogX;
extern int lAnalogY;
extern int mainMenu_leftStickMouse;
extern int mainMenu_touchControls;
extern int mainMenu_deadZone;
int delay2=0; // for 2nd player non-custom autofire
#endif
Expand Down

0 comments on commit 391bf2c

Please sign in to comment.