Skip to content

Commit

Permalink
Merge both GUI/Console to one branch
Browse files Browse the repository at this point in the history
- Fixed PSID.
- Fixed Model detection.
- Fixed Unit detection.
  • Loading branch information
joel16 committed Jul 3, 2018
1 parent 12fa37e commit a7952f0
Show file tree
Hide file tree
Showing 36 changed files with 1,368 additions and 607 deletions.
78 changes: 9 additions & 69 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,73 +1,13 @@
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()
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()

set(SHORT_NAME VITAident)
project(${SHORT_NAME})
include("${VITASDK}/share/vita.cmake" REQUIRED)

set(VITA_APP_NAME "VITAident")
set(VITA_TITLEID "VID000016")
set(VITA_VERSION "00.74")

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -O3 -Wno-unused-variable -Wno-unused-but-set-variable -Wno-format-truncation -fno-lto")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fno-rtti -fno-exceptions")

include_directories(
include
)

add_executable(${SHORT_NAME}
source/app.c
source/fs.c
source/kernel.c
source/main.c
source/net.c
source/power.c
source/utils.c
)

target_link_libraries(${SHORT_NAME}
vita2d
png
jpeg
z
m
c
SceAppMgr_stub
SceAppUtil_stub
SceAVConfig_stub
SceBtForDriver_stub
SceCommonDialog_stub
SceCompat_stub
SceCtrl_stub
SceDisplay_stub
SceGxm_stub
SceIofilemgr_stub
SceLibKernel_stub
SceNet_stub
SceNetCtl_stub
ScePower_stub
ScePvf_stub
SceRegistryMgr_stub
SceSysmodule_stub
SceUdcd_stub
SceUsbstorVStorDriver_stub
SceVshBridge_stub
)

vita_create_self(eboot.bin ${SHORT_NAME} UNSAFE)
vita_create_vpk(${SHORT_NAME}.vpk ${VITA_TITLEID} eboot.bin
VERSION ${VITA_VERSION}
NAME ${VITA_APP_NAME}
FILE sce_sys/icon0.png sce_sys/icon0.png
sce_sys/livearea/contents/bg.png sce_sys/livearea/contents/bg.png
sce_sys/livearea/contents/startup.png sce_sys/livearea/contents/startup.png
sce_sys/livearea/contents/template.xml sce_sys/livearea/contents/template.xml
)
project(VITAident)
add_subdirectory(console)
add_subdirectory(gui)
15 changes: 15 additions & 0 deletions common/include/app.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#ifndef _VITAIDENT_APP_H_
#define _VITAIDENT_APP_H_

#include <vitasdk.h>

SceInt App_InitAppUtil(SceVoid);
SceInt App_TermAppUtil(SceVoid);
SceChar8 *App_GetUser(SceVoid);
const char *App_GetLanguage(SceVoid);
SceOff App_GetTotalCapacity(const char *device);
SceOff App_GetUsedCapacity(const char *device);
char *App_GetStorageInfo(const char *device, SceInt type);
SceBool App_GetEnterButton(SceVoid);

#endif
29 changes: 17 additions & 12 deletions include/kernel.h → common/include/kernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,26 @@
#include <string.h>

#define isPCHX000 ((vshSblAimgrIsCEX()) && (!vshSblAimgrIsTool()) && (!vshSblAimgrIsTest()) && (!vshSblAimgrIsDEX()) && (vshSblAimgrIsGenuineVITA()))
#define isVTE1000 ((vshSblAimgrIsCEX()) && (!vshSblAimgrIsTool()) && (!vshSblAimgrIsTest()) && (!vshSblAimgrIsDEX()) && (vshSblAimgrIsGenuineDolce()))
#define isVTE1000 ((vshSblAimgrIsCEX()) && (!vshSblAimgrIsTool()) && (!vshSblAimgrIsTest()) && (!vshSblAimgrIsDEX()) && (sceKernelIsPSVitaTV()))
#define isPDEL ((!vshSblAimgrIsCEX()) && (!vshSblAimgrIsTest()) && (!vshSblAimgrIsDEX()) && (vshSblAimgrIsGenuineVITA()) && (vshSblAimgrIsTool()))
#define isPTEL ((!vshSblAimgrIsCEX()) && (!vshSblAimgrIsTool()) && (!vshSblAimgrIsTest()) && (vshSblAimgrIsDEX()) && (vshSblAimgrIsGenuineVITA()))

// SceInt32 ksceSysconGetBaryonVersion(SceInt32 * baryonVersion);
typedef struct PsCode
{
char magic[2];
char target_id[2];
char model_revision[2];
uint16_t chassis;
} PsCode;

char * getFwVersion(SceBool spoofed);
char getHenkakuVersion(SceVoid);
SceInt getModel(SceVoid);
char * getCID(SceVoid);
char * getmCID(SceVoid);
SceKernelOpenPsId getPSID(SceVoid);
char * getUnit(SceVoid);
const char * getDeviceModel(SceVoid);
const char * getBoard(SceVoid);
const char * getSysrootKernelModes(SceInt data);
SceInt _vshSblAimgrGetPscode(PsCode *code);

char *Kernel_GetFirmwareVersion(SceBool spoofed);
SceInt Kernel_GetModel(SceVoid);
char *Kernel_GetCID(SceVoid);
char *Kernel_GetPSID(SceVoid);
char *Kernel_GetDeviceModel(SceVoid);
char *Kernel_GetDeviceBoard(SceVoid);
char *Kernel_GetDeviceUnit(SceVoid);

#endif
11 changes: 11 additions & 0 deletions common/include/net.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#ifndef _VITAIDENT_NET_H_
#define _VITAIDENT_NET_H_

#include <vitasdk.h>

SceVoid Net_Init(SceVoid);
SceVoid Net_Term(SceVoid);
char *Net_GetMacAddr(SceVoid);
char *Net_GetIPAddr(SceVoid);

#endif
29 changes: 29 additions & 0 deletions common/include/power.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#ifndef _VITAIDENT_POWER_H_
#define _VITAIDENT_POWER_H_

#include <vitasdk.h>

typedef enum
{
clockFrequencyType_cpu,
clockFrequencyType_bus,
clockFrequencyType_gpu,
clockFrequencyType_gpuXbar
} clockFrequencyType;

//SceInt scePowerPower_GetBatteryElec(SceVoid); Crashes the VITA

SceInt Power_GetClockFrequency(clockFrequencyType type);
const char *Power_GetBatteryStatus(SceVoid);
const char *Power_GetBatteryPercentage(SceVoid);
const char *Power_GetUsingWireless(SceVoid);
const char *Power_GetBatterySOH(SceVoid);
const char *Power_GetBatteryCycleCount(SceVoid);
const char *Power_GetBatteryCapacity(SceVoid);
const char *Power_GetBatteryRemainCapacity(SceVoid);
const char *Power_GetBatteryTemp(SceInt type);
const char *Power_GetBatteryVoltage(SceVoid);
const char *Power_GetUdcdCableState(SceVoid);
const char *Power_GetUsbChargingState(SceVoid);

#endif
10 changes: 10 additions & 0 deletions common/include/regmgr.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#ifndef _VITAIDENT_REGMGR_H_
#define _VITAIDENT_REGMGR_H_

#include <vitasdk.h>

SceInt RegMgr_GetBrightness(SceVoid);
SceInt RegMgr_GetInt(const char *category, const char *name);
char *RegMgr_GetStr(const char *category, const char *name);

#endif
18 changes: 18 additions & 0 deletions common/include/utils.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#ifndef _VITAIDENT_UTILS_H_
#define _VITAIDENT_UTILS_H_

#include <vitasdk.h>

/// Checks whether a result code indicates success.
#define R_SUCCEEDED(res) ((res)>=0)
/// Checks whether a result code indicates failure.
#define R_FAILED(res) ((res)<0)
/// Returns the level of a result code.

SceUInt32 pressed;

SceInt Utils_HandleControls(SceVoid);
SceVoid Utils_GetSizeString(char *string, SceOff size);
char*Utils_StringConcat(char *s1, char *s2);

#endif
32 changes: 16 additions & 16 deletions source/app.c → common/source/app.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#include "app.h"
#include "utils.h"

SceInt initAppUtil(SceVoid)
SceInt App_InitAppUtil(SceVoid)
{
SceAppUtilInitParam init;
SceAppUtilBootParam boot;
Expand All @@ -19,7 +19,7 @@ SceInt initAppUtil(SceVoid)
return 0;
}

SceInt termAppUtil(SceVoid)
SceInt App_TermAppUtil(SceVoid)
{
SceInt ret = 0;

Expand All @@ -29,7 +29,7 @@ SceInt termAppUtil(SceVoid)
return 0;
}

SceChar8 * getUser(SceVoid)
SceChar8 *App_GetUser(SceVoid)
{
static SceChar8 userName[SCE_SYSTEM_PARAM_USERNAME_MAXSIZE];

Expand All @@ -39,9 +39,9 @@ SceChar8 * getUser(SceVoid)
return NULL;
}

const char * getLang(SceVoid)
const char *App_GetLanguage(SceVoid)
{
const char * languages[] =
const char *languages[] =
{
"Japanese",
"English US",
Expand Down Expand Up @@ -77,59 +77,59 @@ const char * getLang(SceVoid)
return NULL;
}

SceOff getMaxSize(const char * dev)
SceOff App_GetTotalCapacity(const char *device)
{
SceIoDevInfo info;

if (R_SUCCEEDED(sceIoDevctl(dev, 0x3001, NULL, 0, &info, sizeof(SceIoDevInfo))))
if (R_SUCCEEDED(sceIoDevctl(device, 0x3001, NULL, 0, &info, sizeof(SceIoDevInfo))))
return info.max_size;

return 0;
}

SceOff getFreeSize(const char * dev)
static SceOff App_GetFreeCapacity(const char *device)
{
SceIoDevInfo info;

if (R_SUCCEEDED(sceIoDevctl(dev, 0x3001, NULL, 0, &info, sizeof(SceIoDevInfo))))
if (R_SUCCEEDED(sceIoDevctl(device, 0x3001, NULL, 0, &info, sizeof(SceIoDevInfo))))
return info.free_size;

return 0;
}

SceOff getUsedSize(const char * dev)
SceOff App_GetUsedCapacity(const char *device)
{
SceIoDevInfo info;

if (R_SUCCEEDED(sceIoDevctl(dev, 0x3001, NULL, 0, &info, sizeof(SceIoDevInfo))))
if (R_SUCCEEDED(sceIoDevctl(device, 0x3001, NULL, 0, &info, sizeof(SceIoDevInfo))))
return info.max_size - info.free_size;

return 0;
}

char * getStorageInfo(const char * dev, SceInt type)
char *App_GetStorageInfo(const char *device, SceInt type)
{
static char size_string[0x10];

switch (type)
{
case 0: // Max size
getSizeString(size_string, getMaxSize(dev));
Utils_GetSizeString(size_string, App_GetTotalCapacity(device));
break;

case 1: // Free size
getSizeString(size_string, getFreeSize(dev));
Utils_GetSizeString(size_string, App_GetFreeCapacity(device));
break;

case 2: // Used size
getSizeString(size_string, getUsedSize(dev));
Utils_GetSizeString(size_string, App_GetUsedCapacity(device));
break;
}

return size_string;
}

SceBool getEnterButton(SceVoid) // Circle = 0, cross = 1
SceBool App_GetEnterButton(SceVoid)
{
int enterButton = 0;
sceAppUtilSystemParamGetInt(SCE_SYSTEM_PARAM_ID_ENTER_BUTTON, &enterButton);
Expand Down
Loading

0 comments on commit a7952f0

Please sign in to comment.