Skip to content

Commit

Permalink
Split ds3 support, add og xbox and some dinput support
Browse files Browse the repository at this point in the history
  • Loading branch information
isage committed Feb 26, 2023
1 parent ec77366 commit c7b161d
Show file tree
Hide file tree
Showing 14 changed files with 664 additions and 59 deletions.
40 changes: 40 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ add_executable(${PROJECT_NAME}
src/unpack.c
src/devicelist.c
src/controller.c
src/controllers/xbox_controller.c
src/controllers/xbox_360_controller.c
src/controllers/xbox_360w_controller.c
src/controllers/ds3_controller.c
src/controllers/dinput_controller.c
)

target_link_libraries(${PROJECT_NAME}
Expand All @@ -42,3 +44,41 @@ vita_create_self(${PROJECT_NAME}.skprx ${PROJECT_NAME}
CONFIG vixen.yml
UNSAFE
)

add_executable(${PROJECT_NAME}_ds3
src/main.c
src/unpack.c
src/devicelist.c
src/controller.c
src/controllers/xbox_controller.c
src/controllers/xbox_360_controller.c
src/controllers/xbox_360w_controller.c
src/controllers/ds3_controller.c
src/controllers/dinput_controller.c
)

target_link_libraries(${PROJECT_NAME}_ds3
SceDebugForDriver_stub
SceSblAIMgrForDriver_stub
SceCtrlForDriver_stub
SceKernelSuspendForDriver_stub
SceSysclibForDriver_stub
SceSysmemForDriver_stub
SceThreadmgrForDriver_stub
SceUsbdForDriver_stub
SceUsbServForDriver_stub
taihenForKernel_stub
)

set_target_properties(${PROJECT_NAME}_ds3
PROPERTIES LINK_FLAGS "-nostdlib"
)

target_compile_definitions(${PROJECT_NAME}_ds3
PRIVATE WITH_DS3
)

vita_create_self(${PROJECT_NAME}_ds3.skprx ${PROJECT_NAME}_ds3
CONFIG vixen.yml
UNSAFE
)
23 changes: 16 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,36 @@ PSVita kernel driver for x-input gamepads (e.g. xbox360)

## Features

* Support for up to 4 wired usb x-input devices.
* Support for up to 4 wired usb x-input, original xbox or ps3 devices, Logitech Rumblepad/DualAction and Playstation Classic controllers.
* Support for up to 4 wireless Xbox 360 gamepads via 1 wired usb receiver.
* Auto turn-off wireless controllers on suspend.

Note: xbox 360 wireless receiver takes over all 4 gamepad ports, so you can't use wired and wireless gamepads simultaniously.

For full list of supported devices see [here](src/devicelist.c)

## Read this carefully
There two versions of plugins: `vixen.skprx` and `vixen_ds3.skprx`. Second one supports wired ds3-alike pads.
If you use `vixen_ds3.skprx` you
1. need to make sure it's first plugin under `*KERNEL`
2. **will** lose ability to pair wireless ds3 on pstv. So if you need to - temporarily comment-out plugin.
3. ds3 support is very unstable atm.
Tl;dr if you don't use anything, that presents itself as ds3 (except wireless ds3 itself) - use `vixen.skprx`. Otherwise you may try `vixen_ds3.skprx`

## Installing
* Copy `vixen.skprx` into `ur0:tai` folder
* Add `ur0:tai/vixen.skprx` line under `*KERNEL` in tai config and reboot.
* Copy `vixen.skprx` or `vixen_ds3.skprx` into `ur0:tai` folder
* Add `ur0:tai/vixen.skprx` or `ur0:tai/vixen.skprx` line under `*KERNEL` in tai config and reboot.
* For vita you need usb Y-cable and external power. See [this](https://github.com/isage/vita-usb-ether#hardware) for example.

## FAQ
* **Does it support joycon, xbox one s, _insert another wireless controller here_?**
NO. It supports **wired USB** controllers only. Yes, Xbox 360 is also wired (because you need receiver)
For wireless (bluetooth) use [ds34vita](https://github.com/MERLev/ds34vita), [VitaControl](https://github.com/Hydr8gon/VitaControl) or [MiniVitaTV](https://github.com/TheOfficialFloW/MiniVitaTV)
* **Can i connect mu Xbox 360 pad via charge'n'play?**
* **Can i connect my Xbox 360 pad via charge'n'play?**
No. Because it's more charge than play. It doesn't support data. You need wireless receiver.
* **Does it support _insert controller name here_?**
Currently it supports plenty of x-input devices and wired ds3 (or ds3 compatible). See [here](src/devicelist.c)
If your device isn't in that list (or doesn't present itself as ds3 or xbox360 pad), see [that list](https://github.com/xboxdrv/xboxdrv/blob/stable/src/xpad_device.cpp#L29)
Currently it supports plenty of x-input devices, original xbox devices (via xbox->usb adapter) and wired ds3 (or ds3 compatible). See [here](src/devicelist.c)
If your device isn't in that list (or doesn't present itself as ds3 or xbox or xbox360 pad), see [that list](https://github.com/xboxdrv/xboxdrv/blob/stable/src/xpad_device.cpp#L29)
If it's in that list - i can add support. If it isn't - i, most likely, can't without having such device.
* **Can i install it alongside another input plugin?**
Generally that isn't recommended. Most input plugins (ds34vita/vitacontrol) hook same functions, conflicts will definitely arise.
Expand All @@ -46,4 +54,5 @@ MIT, see LICENSE.md
* [xerpi](https://github.com/xerpi) - for ds3vita
* **CBPS discord** - for support and stupid ideas
* **rem** - for being lazy/buzy to do the same :P
* [Graphene](https://github.com/GrapheneCt) - for testing and ideas
* [Graphene](https://github.com/GrapheneCt) - for testing and ideas
* [Paddel06](https://github.com/paddel06) - for testing og xbox support
38 changes: 24 additions & 14 deletions src/controller.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#include "controller.h"

#include "controllers/dinput_controller.h"
#include "controllers/ds3_controller.h"
#include "controllers/xbox_360_controller.h"
#include "controllers/xbox_360w_controller.h"
#include "controllers/xbox_controller.h"

#include <psp2kern/kernel/suspend.h>
#include <psp2kern/kernel/threadmgr.h>
Expand All @@ -11,26 +13,35 @@
void on_read_data(int32_t result, int32_t count, void *arg)
{
// process buffer

Controller *c = (Controller *)arg;
if (result == 0 && count > 0 && arg)
{
if (c->inited)
{
if (c->type == PAD_XBOX360)
{
if (Xbox360Controller_processReport(c, count))
ksceKernelPowerTick(0); // cancel sleep timers.
}
else if (c->type == PAD_DS3)
{
if (DS3Controller_processReport(c, count))
ksceKernelPowerTick(0); // cancel sleep timers.
}
else
int ret = 0;
switch (c->type)
{
if (Xbox360WController_processReport(c, count))
ksceKernelPowerTick(0); // cancel sleep timers.
case PAD_XBOX:
ret = XboxController_processReport(c, count);
break;
case PAD_XBOX360:
ret = Xbox360Controller_processReport(c, count);
break;
case PAD_XBOX360W:
ret = Xbox360WController_processReport(c, count);
break;
case PAD_DS3:
ret = DS3Controller_processReport(c, count);
break;
case PAD_DINPUT:
ret = DinputController_processReport(c, count);
break;
default:
break;
}
if (ret)
ksceKernelPowerTick(0); // cancel sleep timers.
}
}

Expand All @@ -39,7 +50,6 @@ void on_read_data(int32_t result, int32_t count, void *arg)

void on_write_data(int32_t result, int32_t count, void *arg)
{
// ksceDebugPrintf("write status: %d %d\n", result, count);
// check status
// do nothing?
}
Expand Down
2 changes: 2 additions & 0 deletions src/controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ typedef struct
SceUID pipe_control;
unsigned char buffer[64] __attribute__((aligned(64)));
size_t buffer_size;
int vendor;
int product;

} Controller;

Expand Down
Loading

0 comments on commit c7b161d

Please sign in to comment.