Skip to content

Commit

Permalink
[ench] Changed touch scaling for easier touches on edges
Browse files Browse the repository at this point in the history
  • Loading branch information
MERLev committed Sep 17, 2020
1 parent 074c476 commit 59f0361
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 18 deletions.
6 changes: 1 addition & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# ds4touch v1.1
# ds4touch v1.1.1

Adds ds4 touchpad support (ds4vita way) to PS TV and Vita with MiniVitaTV.\
Based on [xerpi](https://github.com/xerpi "xerpi")'s [ds4vita code](https://github.com/xerpi/ds4vita "ds4vita code")
Expand All @@ -12,10 +12,6 @@ Based on [xerpi](https://github.com/xerpi "xerpi")'s [ds4vita code](https://gith
*KERNEL
ur0:tai/ds4touch.skprx
```
### Limitations
- If connected several controllers, only the one connected first would be able to use touchpad
- On **PS TV** touchpad is not working on LiveArea and in system apps.
- On **PS TV** all native touch pointer functionality is disabled.

### Limitations
- If connected several controllers, only the one connected first would be able to use touchpad
Expand Down
28 changes: 15 additions & 13 deletions kernel/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

#define DS4_TOUCHPAD_W 1920
#define DS4_TOUCHPAD_H 940
#define DS4_TOUCHPAD_W_DEAD 60
#define DS4_TOUCHPAD_H_DEAD 120

#define VITA_FRONT_TOUCHSCREEN_W 1920
#define VITA_FRONT_TOUCHSCREEN_H 1080
Expand All @@ -25,6 +27,8 @@
#define EVF_EXIT (1 << 0)

#define abs(x) (((x) < 0) ? -(x) : (x))
#define max(a,b) (((a)>(b))?(a):(b))
#define min(a,b) (((a)<(b))?(a):(b))

#define DECL_FUNC_HOOK(name, ...) \
static tai_hook_ref_t name##_ref; \
Expand Down Expand Up @@ -172,34 +176,32 @@ static void patch_touch_data(SceUInt32 port, SceTouchData *pData, SceUInt32 nBuf

// If finger1 present, add finger1 as report 0
if (!ds4->finger1_activelow) {
pData->report[0].id = ds4->finger1_id;
pData->report[0].x = (ds4->finger1_x * VITA_FRONT_TOUCHSCREEN_W) / DS4_TOUCHPAD_W;
pData->report[0].y = (ds4->finger1_y * VITA_FRONT_TOUCHSCREEN_H) / DS4_TOUCHPAD_H;
pData[i].report[0].id = ds4->finger1_id;
pData[i].report[0].x = clamp(((ds4->finger1_x - DS4_TOUCHPAD_W_DEAD) * VITA_FRONT_TOUCHSCREEN_W) / (DS4_TOUCHPAD_W - DS4_TOUCHPAD_W_DEAD * 2), 0, VITA_FRONT_TOUCHSCREEN_W);
pData[i].report[0].y = clamp(((ds4->finger1_y - DS4_TOUCHPAD_H_DEAD) * VITA_FRONT_TOUCHSCREEN_H) / (DS4_TOUCHPAD_H - DS4_TOUCHPAD_H_DEAD * 2), 0, VITA_FRONT_TOUCHSCREEN_H);
num_reports++;
}

// If only finger2 is present, add finger2 as report 0
if (!ds4->finger2_activelow && ds4->finger1_activelow) {
pData->report[0].id = ds4->finger2_id;
pData->report[0].x = (ds4->finger2_x * VITA_FRONT_TOUCHSCREEN_W) / DS4_TOUCHPAD_W;
pData->report[0].y = (ds4->finger2_y * VITA_FRONT_TOUCHSCREEN_H) / DS4_TOUCHPAD_H;
pData[i].report[0].id = ds4->finger2_id;
pData[i].report[0].x = (ds4->finger2_x * VITA_FRONT_TOUCHSCREEN_W) / DS4_TOUCHPAD_W;
pData[i].report[0].y = (ds4->finger2_y * VITA_FRONT_TOUCHSCREEN_H) / DS4_TOUCHPAD_H;
num_reports++;
}

// If both finger1 and finger2 present, add finger2 as report 1
if (!ds4->finger2_activelow && !ds4->finger1_activelow) {
pData->report[1].id = ds4->finger2_id;
pData->report[1].x = (ds4->finger2_x * VITA_FRONT_TOUCHSCREEN_W) / DS4_TOUCHPAD_W;
pData->report[1].y = (ds4->finger2_y * VITA_FRONT_TOUCHSCREEN_H) / DS4_TOUCHPAD_H;
pData[i].report[1].id = ds4->finger2_id;
pData[i].report[1].x = (ds4->finger2_x * VITA_FRONT_TOUCHSCREEN_W) / DS4_TOUCHPAD_W;
pData[i].report[1].y = (ds4->finger2_y * VITA_FRONT_TOUCHSCREEN_H) / DS4_TOUCHPAD_H;
num_reports++;
}

if (num_reports > 0) {
ksceKernelPowerTick(0);
pData->reportNum = num_reports;
pData[i].reportNum = num_reports;
}

pData++;
}
}

Expand Down Expand Up @@ -301,8 +303,8 @@ int module_start(SceSize argc, const void *args){
int module_stop(SceSize argc, const void *args)
{
UNBIND_FUNC_HOOK(SceTouch_ksceTouchPeek);
UNBIND_FUNC_HOOK(SceTouch_ksceTouchPeekRegion);
UNBIND_FUNC_HOOK(SceTouch_ksceTouchRead);
UNBIND_FUNC_HOOK(SceTouch_ksceTouchPeekRegion);
UNBIND_FUNC_HOOK(SceTouch_ksceTouchReadRegion);
UNBIND_FUNC_HOOK(SceTouch_ksceBtHidTransfer);

Expand Down

0 comments on commit 59f0361

Please sign in to comment.