Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
Carlos committed Sep 28, 2022
0 parents commit 032f93d
Show file tree
Hide file tree
Showing 28 changed files with 1,515 additions and 0 deletions.
25 changes: 25 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
.idea
skprx/CMakeFiles
skprx/stubs
skprx/cmake_install.cmake
skprx/CMakeCache.txt
skprx/libvitapad_stub.a
skprx/libvitapad_stub_weak.a
skprx/Makefile
skprx/vitapad
skprx/vitapad.skprx
skprx/vitapad.skprx.out
skprx/vitapad.velf
vpk/CMakeFiles
vpk/resources/logo_active.png.o
vpk/resources/logo_inactive.png.o
vpk/cmake_install.cmake
vpk/CMakeCache.txt
vpk/Makefile
vpk/vitapad
vpk/vitapad.self
vpk/vitapad.self.out
vpk/vitapad.velf
vpk/vitapad.vpk
vpk/vitapad.vpk.out
vpk/vitapad.vpk_param.sfo
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# 🎮 VitaPad
Use your PlayStation Vita as USB gamepad with rear touchpad controls.

## Features
This is an improved version of the [vitastick plugin by xerpi](https://github.com/xerpi/vitastick) with added functionality, improved code readability, and some major changes that increase reliability and usability.
- Simple and elegant interface
- Ability to use rear touchpad controls (L2/R2 & L3/R3)
- Reduces clock frequencies when active to reduce power consumption
- Disables use of power and PS buttons while gamepad functionality is active (this allows the gamepad to continue working as necessary)
- Automatically disconnects after 2 minutes of inactivity

## 🚀 Installation
1. Download the plugin and VPK from the [releases page](https://github.com/carlelieser/vitapad/releases).
2. Copy `vitapad.skprx` to `ur0:/tai/`.
3. Add `vitapad.skprx` to your `config.txt` under the kernel section.
```
*KERNEL
ur0:tai/vitapad.skprx
```
4. Install `vitapad.vpk`.
## 🐈 Usage
Open the VPK and connect your Vita via USB. Press X to initialize the gamepad functionality. Hold SELECT + START to disconnect. Enjoy!
## Screenshots
<div style="width: 100%;">
<img style="border-radius: 1rem;" title="Initial screen" src="screenshots/disconnected.png" alt="Initial screen" width="960"/>
<img style="border-radius: 1rem; margin-top: 1rem;" title="Connected screen" src="screenshots/connected.png" width="960" alt="Connected screen"/>
</div>
4 changes: 4 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
cd ./skprx
./build.sh
cd ../vpk
./build.sh
2 changes: 2 additions & 0 deletions clean-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
./clean.sh
./build.sh
4 changes: 4 additions & 0 deletions clean.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
cd ./skprx
./clean.sh
cd ../vpk
./clean.sh
Binary file added screenshots/connected.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added screenshots/disconnected.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
46 changes: 46 additions & 0 deletions skprx/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
cmake_minimum_required(VERSION 2.8)

if(NOT DEFINED CMAKE_TOOLCHAIN_FILE)
if(DEFINED ENV{VITASDK})
set(CMAKE_TOOLCHAIN_FILE "$ENV{VITASDK}/share/vita.toolchain.cmake" CACHE PATH "toolchain file")
else()
message(FATAL_ERROR "Please define VITASDK to point to your SDK path!")
endif()
endif()

project(vitapad)
include("$ENV{VITASDK}/share/vita.cmake" REQUIRED)

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wl,-q -Wall -O2 -nostdlib")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti -fno-exceptions")

option(RELEASE "Release build" OFF)

if (RELEASE)
add_definitions(-DRELEASE)
endif(RELEASE)


add_executable(${PROJECT_NAME}
main.c
log.c
)

target_link_libraries(${PROJECT_NAME}
SceSysclibForDriver_stub
SceThreadmgrForDriver_stub
SceCpuForDriver_stub
SceCtrlForDriver_stub
SceTouchForDriver_stub
SceUdcdForDriver_stub
SceIofilemgrForDriver_stub
)

vita_create_self(${PROJECT_NAME}.skprx ${PROJECT_NAME} CONFIG ${PROJECT_NAME}.yml UNSAFE)

vita_create_stubs(stubs ${PROJECT_NAME} ${CMAKE_SOURCE_DIR}/${PROJECT_NAME}.yml KERNEL)

add_custom_target(send
COMMAND curl -T ${PROJECT_NAME}.skprx ftp://$(PSVITAIP):1337/ux0:/tai/
DEPENDS ${PROJECT_NAME}.skprx
)
3 changes: 3 additions & 0 deletions skprx/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export VITASDK=/usr/local/vitasdk
cmake ./
make
1 change: 1 addition & 0 deletions skprx/clean.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sudo rm -rf ./stubs ./libvitapad_stub.a ./libvitapad_stub_weak.a ./Makefile ./stubs.yml ./CMakeFiles ./cmake_install.cmake ./CMakeCache.txt ./vitapad ./vitapad.skprx ./vitapad.skprx.out ./vitapad.velf
39 changes: 39 additions & 0 deletions skprx/log.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#include <psp2kern/io/fcntl.h>
#include <psp2kern/io/stat.h>
#include "log.h"

#ifndef RELEASE
static unsigned int log_buf_ptr = 0;
static char log_buf[16 * 1024];

void log_reset()
{
memset(log_buf, 0, sizeof(log_buf));
log_buf_ptr = 0;
}

void log_write(const char *buffer, size_t length)
{
if ((log_buf_ptr + length) >= sizeof(log_buf))
return;

memcpy(log_buf + log_buf_ptr, buffer, length);

log_buf_ptr += length;

log_flush();
}

void log_flush()
{
ksceIoMkdir(LOG_PATH, 6);

SceUID fd = ksceIoOpen(LOG_FILE,
SCE_O_WRONLY | SCE_O_CREAT | SCE_O_TRUNC, 6);
if (fd < 0)
return;

ksceIoWrite(fd, log_buf, strlen(log_buf));
ksceIoClose(fd);
}
#endif
38 changes: 38 additions & 0 deletions skprx/log.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#ifndef LOG_H
#define LOG_H

#include <stdio.h>
#include <string.h>

#define LOG_PATH "ux0:VitaPad/"
#define LOG_FILE LOG_PATH "log.txt"

#ifndef RELEASE

void log_reset();
void log_write(const char *buffer, size_t length);
void log_flush();

#define LOG(...) \
do { \
char buffer[256]; \
snprintf(buffer, sizeof(buffer), ##__VA_ARGS__); \
log_write(buffer, strlen(buffer)); \
} while (0)
#else

static inline void log_reset() {}
static inline void log_write(const char *buffer, size_t length) {}
static inline void log_flush() {}

#define LOG(...) (void)0

#endif

#define TEST_CALL(f, ...) ({ \
int ret = f(__VA_ARGS__); \
LOG(# f " returned 0x%08X\n", ret); \
ret; \
})

#endif
Loading

0 comments on commit 032f93d

Please sign in to comment.