Skip to content

Commit 5eb2452

Browse files
committed
Initial
0 parents  commit 5eb2452

File tree

17 files changed

+1710
-0
lines changed

17 files changed

+1710
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

CMakeLists.txt

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
cmake_minimum_required(VERSION 3.2)
2+
3+
if(NOT DEFINED CMAKE_TOOLCHAIN_FILE)
4+
if(DEFINED ENV{VITASDK})
5+
set(CMAKE_TOOLCHAIN_FILE "$ENV{VITASDK}/share/vita.toolchain.cmake" CACHE PATH "toolchain file")
6+
else()
7+
message(FATAL_ERROR "Please define VITASDK to point to your SDK path!")
8+
endif()
9+
endif()
10+
11+
project(vivid)
12+
include("${VITASDK}/share/vita.cmake" REQUIRED)
13+
14+
find_package(SDL2 CONFIG REQUIRED)
15+
16+
set(VITA_APP_NAME "ViViD")
17+
set(VITA_TITLEID "VVID00001")
18+
set(VITA_VERSION "01.00")
19+
20+
add_subdirectory(module)
21+
22+
include_directories(
23+
module/include
24+
)
25+
26+
link_directories(${CMAKE_CURRENT_BINARY_DIR}/module)
27+
28+
add_executable(${PROJECT_NAME}
29+
src/main.c
30+
)
31+
32+
#add_dependencies(${PROJECT_NAME} "vividk.skprx-self")
33+
add_dependencies(${PROJECT_NAME} "vividk_all")
34+
35+
target_link_libraries(${PROJECT_NAME}
36+
SDL2::SDL2-static
37+
vividk_stub_weak
38+
-Wl,--whole-archive pthread -Wl,--no-whole-archive
39+
taihen_stub
40+
SceVshBridge_stub
41+
SceAppMgr_stub
42+
SceShellSvc_stub
43+
)
44+
45+
vita_create_self(${PROJECT_NAME}.self ${PROJECT_NAME} UNSAFE)
46+
vita_create_vpk(${PROJECT_NAME}.vpk ${VITA_TITLEID} ${PROJECT_NAME}.self
47+
VERSION ${VITA_VERSION}
48+
NAME ${VITA_APP_NAME}
49+
FILE sce_sys sce_sys
50+
FILE data data
51+
FILE ${CMAKE_CURRENT_BINARY_DIR}/module/vividk.skprx module/vividk.skprx
52+
)

LICENSE.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Copyright 2022 Cat (Epifanov Ivan)
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4+
5+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6+
7+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# ViViD
2+
**Vi**ta **Vi**rtual **D**ualshock
3+
4+
PSVita app to turn your vita into DualShock™ 3, compatible with PS3, PSTV, PC.
5+
6+
## Installing
7+
* Install `vivid.vpk`
8+
* Run app, press X and connect your vita with usb cable to PS3, PSTV or PC.
9+
10+
## FAQ
11+
* **Does it support wireless (bluetooth) connection?**
12+
Not yet. Only wired for now.
13+
* **How do i use L2/R2/L3/R3?**
14+
L2 and R2 are mapped to upper "rectangles" of back touch, L3 and R3 to the lower. L2 and R2 are "analog", e.g. the lower you touch - the higher pressure value (e.g. swiping from top to bottom is like pressing them on real ds3)
15+
* **Can i set up touch points/use front touch?**
16+
No. Maybe in very distant future (read: probably never)
17+
18+
## License
19+
20+
MIT, see LICENSE.md
21+
22+
## Credits
23+
24+
* [xerpi](https://github.com/xerpi) - for vitapad and udcd work

data/active.bmp

1.99 MB
Binary file not shown.

data/inactive.bmp

1.99 MB
Binary file not shown.

module/CMakeLists.txt

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
cmake_minimum_required(VERSION 3.2)
2+
3+
if(NOT DEFINED CMAKE_TOOLCHAIN_FILE)
4+
if(DEFINED ENV{VITASDK})
5+
set(CMAKE_TOOLCHAIN_FILE "$ENV{VITASDK}/share/vita.toolchain.cmake" CACHE PATH "toolchain file")
6+
else()
7+
message(FATAL_ERROR "Please define VITASDK to point to your SDK path!")
8+
endif()
9+
endif()
10+
11+
project(vividk)
12+
include("${VITASDK}/share/vita.cmake" REQUIRED)
13+
14+
add_executable(${PROJECT_NAME}
15+
src/main.c
16+
)
17+
18+
target_link_libraries(${PROJECT_NAME}
19+
SceDebugForDriver_stub
20+
SceCtrlForDriver_stub
21+
SceCpuForDriver_stub
22+
SceKernelSuspendForDriver_stub
23+
SceModulemgrForDriver_stub
24+
SceSysclibForDriver_stub
25+
SceSysmemForDriver_stub
26+
SceSysconForDriver_stub
27+
SceThreadmgrForDriver_stub
28+
SceUdcdForDriver_stub
29+
SceBtForDriver_stub
30+
SceOledForDriver_stub_weak
31+
SceLcdForDriver_stub_weak
32+
taihenForKernel_stub
33+
)
34+
35+
target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include)
36+
37+
set_target_properties(${PROJECT_NAME}
38+
PROPERTIES LINK_FLAGS "-nostdlib"
39+
)
40+
41+
vita_create_self(${PROJECT_NAME}.skprx ${PROJECT_NAME}
42+
CONFIG vividk.yml
43+
UNSAFE
44+
)
45+
46+
vita_create_stubs(stubs vividk ${CMAKE_CURRENT_SOURCE_DIR}/vividk.yml KERNEL)
47+
48+
add_custom_target(vividk_all
49+
ALL
50+
DEPENDS vividk.skprx-self
51+
DEPENDS libvividk_stub.a
52+
DEPENDS libvividk_stub_weak.a
53+
)

module/include/descriptors.h

Lines changed: 234 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,234 @@
1+
#ifndef __DESCRIPTORS_H__
2+
#define __DESCRIPTORS_H__
3+
4+
#include <psp2kern/udcd.h>
5+
static unsigned char hid_report_descriptor[] __attribute__((aligned(64))) = {
6+
0x05, 0x01, // Usage Page (Generic Desktop Ctrls)
7+
0x09, 0x04, // Usage (Joystick)
8+
0xA1, 0x01, // Collection (Application)
9+
0xA1, 0x02, // Collection (Logical)
10+
0x85, 0x01, // Report ID (1)
11+
0x75, 0x08, // Report Size (8)
12+
0x95, 0x01, // Report Count (1)
13+
0x15, 0x00, // Logical Minimum (0)
14+
0x26, 0xFF, // Logical Maximum (255)
15+
0x00, 0x81, 0x03, // Input (Constant, Variable),
16+
0x75, 0x01, // Report Size (1)
17+
0x95, 0x13, // Report Count (19)
18+
0x15, 0x00, // Logical Minimum (0)
19+
0x25, 0x01, // Logical Maximum (1)
20+
0x35, 0x00, // Physical Minimum (0)
21+
0x45, 0x01, // Physical Maximum (1)
22+
0x05, 0x09, // Usage Page (Button)
23+
0x19, 0x01, // Usage Minimum (0x01)
24+
0x29, 0x13, // Usage Maximum (0x13)
25+
0x81, 0x02, // Input (Variable)
26+
0x75, 0x01, // Report Size (1)
27+
0x95, 0x0D, // Report Count (19)
28+
0x06, 0x00, 0xFF, // Usage Page (FF00h), ; FF00h, vendor-defined
29+
0x81, 0x03, // Input (Constant, Variable)
30+
0x15, 0x00, // Logical Minimum (0)
31+
0x26, 0xFF, // Logical Maximum (255)
32+
0x00, 0x05, 0x01, // Usage Page (Desktop), ; Generic desktop controls (01h)
33+
0x09, 0x01, // Usage (Pointer), ; Pointer (01h, physical collection)
34+
0xA1, 0x00, // Collection (Physical),
35+
0x75, 0x08, // Report Size (8)
36+
0x95, 0x04, // Report Count (4)
37+
0x35, 0x00, // Physical Minimum (0)
38+
0x46, 0xFF, // Physical Maximum (255)
39+
0x00, 0x09, 0x30, // Usage (X)
40+
0x09, 0x31, // Usage (Y)
41+
0x09, 0x32, // Usage (Z)
42+
0x09, 0x35, // Usage (Rz)
43+
0x81, 0x02, // Input (Variable)
44+
0xC0, // End Collection
45+
46+
0x05, 0x01, // Usage Page (Generic Desktop Ctrls)
47+
0x75, 0x08, // Report Size (8)
48+
0x95, 0x27, // Report Count (39)
49+
0x09, 0x01, // Usage (Pointer)
50+
0x81, 0x02, // Input (Variable)
51+
52+
0x75, 0x08, // Report Size (8)
53+
0x95, 0x30, // Report Count (48)
54+
0x09, 0x01, // Usage (Pointer)
55+
0x91, 0x02, // Output (Variable)
56+
57+
0x75, 0x08, // Report Size (8)
58+
0x95, 0x30, // Report Count (48)
59+
0x09, 0x01, // Usage (Pointer)
60+
0xB1, 0x02, // Feature (Variable)
61+
0xC0, // End Collection
62+
63+
0xA1, 0x02, // Collection (Logical)
64+
0x85, 0x02, // Report ID (2)
65+
0x75, 0x08, // Report Size (8),
66+
0x95, 0x30, // Report Count (48),
67+
0x09, 0x01, // Usage (Pointer)
68+
0xB1, 0x02, // Feature (Variable)
69+
0xC0, // End Collection
70+
71+
0xA1, 0x02, // Collection (Logical)
72+
0x85, 0xEE, // Report ID (238)
73+
0x75, 0x08, // Report Size (8),
74+
0x95, 0x30, // Report Count (48),
75+
0x09, 0x01, // Usage (Pointer)
76+
0xB1, 0x02, // Feature (Variable)
77+
0xC0, // End Collection
78+
79+
0xA1, 0x02, // Collection (Logical)
80+
0x85, 0xEF, // Report ID (239)
81+
0x75, 0x08, // Report Size (8),
82+
0x95, 30, // Report Count (48),
83+
0x09, 0x01, // Usage (Pointer)
84+
0xB1, 0x02, // Feature (Variable)
85+
0xC0, // End Collection
86+
87+
0xC0, // End Collection
88+
};
89+
90+
/* HID descriptor */
91+
static unsigned char hiddesc[] = {
92+
0x09, /* bLength */
93+
HID_DESCRIPTOR_HID, /* bDescriptorType */
94+
0x11,
95+
0x01, /* bcdHID */
96+
0x00, /* bCountryCode */
97+
0x01, /* bNumDescriptors */
98+
HID_DESCRIPTOR_REPORT, /* bDescriptorType */
99+
sizeof(hid_report_descriptor),
100+
0x00 /* wDescriptorLength */
101+
};
102+
103+
/* Endpoint blocks */
104+
static struct SceUdcdEndpoint endpoints[2] = {{0x00, 0, 0, 0}, {0x80, 1, 0, 0}};
105+
106+
/* Interfaces */
107+
static struct SceUdcdInterface interfaces[1] = {{-1, 0, 1}};
108+
109+
/* String descriptor */
110+
static struct SceUdcdStringDescriptor string_descriptors[2]
111+
= {{12, USB_DT_STRING, {'V', 'i', 'V', 'i', 'D'}}, {0, USB_DT_STRING}};
112+
113+
/* HI-Speed device descriptor */
114+
static struct SceUdcdDeviceDescriptor devdesc_hi = {
115+
USB_DT_DEVICE_SIZE,
116+
USB_DT_DEVICE,
117+
0x200, /* bcdUSB */
118+
USB_CLASS_PER_INTERFACE, /* bDeviceClass */
119+
0, /* bDeviceSubClass */
120+
0, /* bDeviceProtocol */
121+
64, /* bMaxPacketSize0 */
122+
0x0268, /* idProduct */
123+
0x054c, /* idVendor */
124+
0x200, /* bcdDevice */
125+
0, /* iManufacturer */
126+
0, /* iProduct */
127+
0, /* iSerialNumber */
128+
1 /* bNumConfigurations */
129+
};
130+
131+
/* Hi-Speed endpoint descriptors */
132+
static struct SceUdcdEndpointDescriptor endpdesc_hi[2]
133+
= {{
134+
USB_DT_ENDPOINT_SIZE, USB_DT_ENDPOINT, 0x81, /* bEndpointAddress */
135+
0x03, /* bmAttributes */
136+
0x40, /* wMaxPacketSize */
137+
0x01 /* bInterval */
138+
},
139+
{
140+
0,
141+
}};
142+
143+
/* Hi-Speed interface descriptor */
144+
static struct SceUdcdInterfaceDescriptor interdesc_hi[2]
145+
= {{USB_DT_INTERFACE_SIZE, USB_DT_INTERFACE, 0, /* bInterfaceNumber */
146+
0, /* bAlternateSetting */
147+
1, /* bNumEndpoints */
148+
USB_CLASS_HID, /* bInterfaceClass */
149+
0x00, /* bInterfaceSubClass */
150+
0x00, /* bInterfaceProtocol */
151+
1, /* iInterface */
152+
&endpdesc_hi[0], /* endpoints */
153+
hiddesc, sizeof(hiddesc)},
154+
{0}};
155+
156+
/* Hi-Speed settings */
157+
static struct SceUdcdInterfaceSettings settings_hi[1] = {{&interdesc_hi[0], 0, 1}};
158+
159+
/* Hi-Speed configuration descriptor */
160+
static struct SceUdcdConfigDescriptor confdesc_hi
161+
= {USB_DT_CONFIG_SIZE,
162+
USB_DT_CONFIG,
163+
(USB_DT_INTERFACE_SIZE + USB_DT_CONFIG_SIZE + USB_DT_ENDPOINT_SIZE + sizeof(hiddesc)), /* wTotalLength */
164+
1, /* bNumInterfaces */
165+
1, /* bConfigurationValue */
166+
0, /* iConfiguration */
167+
0xC0, /* bmAttributes */
168+
0, /* bMaxPower */
169+
&settings_hi[0]};
170+
171+
/* Hi-Speed configuration */
172+
static struct SceUdcdConfiguration config_hi = {&confdesc_hi, &settings_hi[0], &interdesc_hi[0], &endpdesc_hi[0]};
173+
174+
/* Full-Speed device descriptor */
175+
static struct SceUdcdDeviceDescriptor devdesc_full = {
176+
USB_DT_DEVICE_SIZE,
177+
USB_DT_DEVICE,
178+
0x200, /* bcdUSB (should be 0x110 but the PSVita freezes otherwise) */
179+
USB_CLASS_PER_INTERFACE, /* bDeviceClass */
180+
0, /* bDeviceSubClass */
181+
0, /* bDeviceProtocol */
182+
64, /* bMaxPacketSize0 */
183+
0x0268, /* idProduct */
184+
0x054c, /* idVendor */
185+
0x200, /* bcdDevice */
186+
0, /* iManufacturer */
187+
0, /* iProduct */
188+
0, /* iSerialNumber */
189+
1 /* bNumConfigurations */
190+
};
191+
192+
/* Full-Speed endpoint descriptors */
193+
static struct SceUdcdEndpointDescriptor endpdesc_full[2]
194+
= {{
195+
USB_DT_ENDPOINT_SIZE, USB_DT_ENDPOINT, 0x81, /* bEndpointAddress */
196+
0x03, /* bmAttributes */
197+
0x40, /* wMaxPacketSize */
198+
0x01 /* bInterval */
199+
},
200+
{0}};
201+
202+
/* Full-Speed interface descriptor */
203+
static struct SceUdcdInterfaceDescriptor interdesc_full[2]
204+
= {{USB_DT_INTERFACE_SIZE, USB_DT_INTERFACE, 0, /* bInterfaceNumber */
205+
0, /* bAlternateSetting */
206+
1, /* bNumEndpoints */
207+
USB_CLASS_HID, /* bInterfaceClass */
208+
0x00, /* bInterfaceSubClass */
209+
0x00, /* bInterfaceProtocol */
210+
1, /* iInterface */
211+
&endpdesc_full[0], /* endpoints */
212+
hiddesc, sizeof(hiddesc)},
213+
{0}};
214+
215+
/* Full-Speed settings */
216+
static struct SceUdcdInterfaceSettings settings_full[1] = {{&interdesc_full[0], 0, 1}};
217+
218+
/* Full-Speed configuration descriptor */
219+
static struct SceUdcdConfigDescriptor confdesc_full
220+
= {USB_DT_CONFIG_SIZE,
221+
USB_DT_CONFIG,
222+
(USB_DT_INTERFACE_SIZE + USB_DT_CONFIG_SIZE + USB_DT_ENDPOINT_SIZE + sizeof(hiddesc)), /* wTotalLength */
223+
1, /* bNumInterfaces */
224+
1, /* bConfigurationValue */
225+
0, /* iConfiguration */
226+
0xC0, /* bmAttributes */
227+
0, /* bMaxPower */
228+
&settings_full[0]};
229+
230+
/* Full-Speed configuration */
231+
static struct SceUdcdConfiguration config_full
232+
= {&confdesc_full, &settings_full[0], &interdesc_full[0], &endpdesc_full[0]};
233+
234+
#endif // __DESCRIPTORS_H__

0 commit comments

Comments
 (0)