Added initial support for PSVita/PSTV and Switch (WIP)

This commit is contained in:
midwan 2019-01-06 13:16:16 +01:00
parent d3fd42ab93
commit 8ff4e03863
96 changed files with 3685 additions and 3 deletions

417
CMakeLists.txt Normal file
View file

@ -0,0 +1,417 @@
cmake_minimum_required(VERSION 3.0)
set(CMAKE_VERBOSE_MAKEFILE OFF)
set(VERSION_MAJOR 2)
set(VERSION_MINOR 24)
if(BUILD_PSP2)
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 ()
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(BUILD_DEBUG true CACHE BOOL "Build with psp2shell support")
endif()
endif(BUILD_PSP2)
if(BUILD_NX)
set(CMAKE_SYSTEM_NAME "Generic")
set(DEVKITPRO $ENV{DEVKITPRO})
set(CMAKE_SYSTEM_PROCESSOR "armv8-a")
set(CMAKE_C_COMPILER "${DEVKITPRO}/devkitA64/bin/aarch64-none-elf-gcc")
set(CMAKE_CXX_COMPILER "${DEVKITPRO}/devkitA64/bin/aarch64-none-elf-g++")
set(CMAKE_ASM_COMPILER "${DEVKITPRO}/devkitA64/bin/aarch64-none-elf-as")
set(CMAKE_AR "${DEVKITPRO}/devkitA64/bin/aarch64-none-elf-gcc-ar" CACHE STRING "")
set(CMAKE_RANLIB "${DEVKITPRO}/devkitA64/bin/aarch64-none-elf-gcc-ranlib" CACHE STRING "")
set(CMAKE_FIND_ROOT_PATH ${DEVKITPRO} ${DEVKITPRO}/devkitA64 ${DEVKITPRO}/libnx ${DEVKITPRO}/portlibs/switch)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
set(BUILD_SHARED_LIBS OFF CACHE INTERNAL "Shared libs not available")
link_directories(${DEVKITPRO}/libnx/lib ${DEVKITPRO}/portlibs/switch/lib)
endif(BUILD_NX)
execute_process(COMMAND "date" "+%Y.%m.%d"
OUTPUT_VARIABLE BUILD_DATE OUTPUT_STRIP_TRAILING_WHITESPACE)
project(amiberry)
if(BUILD_PSP2)
enable_language(ASM)
include("${VITASDK}/share/vita.cmake" REQUIRED)
endif(BUILD_PSP2)
set(TITLEID "AMIBERRY00")
set(SRC_FILES
src/osdep/vkbd/vkbd.cpp
src/akiko.cpp
src/ar.cpp
src/aros.rom.cpp
src/audio.cpp
src/autoconf.cpp
src/blitfunc.cpp
src/blittable.cpp
src/blitter.cpp
src/blkdev.cpp
src/blkdev_cdimage.cpp
src/bsdsocket.cpp
src/calc.cpp
src/cd32_fmv.cpp
src/cd32_fmv_genlock.cpp
src/cdrom.cpp
src/cfgfile.cpp
src/cia.cpp
src/crc32.cpp
src/custom.cpp
src/def_icons.cpp
src/devices.cpp
src/disk.cpp
src/diskutil.cpp
src/dlopen.cpp
src/drawing.cpp
src/events.cpp
src/expansion.cpp
src/fdi2raw.cpp
src/filesys.cpp
src/flashrom.cpp
src/fpp.cpp
src/fsdb.cpp
src/fsdb_unix.cpp
src/fsusage.cpp
src/gayle.cpp
src/gfxboard.cpp
src/gfxutil.cpp
src/hardfile.cpp
src/hrtmon.rom.cpp
src/ide.cpp
src/inputdevice.cpp
src/keybuf.cpp
src/main.cpp
src/memory.cpp
src/native2amiga.cpp
src/rommgr.cpp
src/rtc.cpp
src/savestate.cpp
src/scsi.cpp
src/statusline.cpp
src/traps.cpp
src/uaelib.cpp
src/uaeresource.cpp
src/zfile.cpp
src/zfile_archive.cpp
src/archivers/7z/7zAlloc.cpp
src/archivers/7z/7zBuf.cpp
src/archivers/7z/7zCrc.cpp
src/archivers/7z/7zCrcOpt.cpp
src/archivers/7z/7zDec.cpp
src/archivers/7z/7zIn.cpp
src/archivers/7z/7zStream.cpp
src/archivers/7z/Bcj2.cpp
src/archivers/7z/Bra.cpp
src/archivers/7z/Bra86.cpp
src/archivers/7z/BraIA64.c
src/archivers/7z/Delta.c
src/archivers/7z/LzmaDec.cpp
src/archivers/7z/Lzma2Dec.cpp
src/archivers/7z/Sha256.c
src/archivers/7z/Xz.cpp
src/archivers/7z/XzCrc64.c
src/archivers/7z/XzDec.c
src/archivers/dms/crc_csum.cpp
src/archivers/dms/getbits.cpp
src/archivers/dms/maketbl.cpp
src/archivers/dms/pfile.cpp
src/archivers/dms/tables.cpp
src/archivers/dms/u_deep.cpp
src/archivers/dms/u_heavy.cpp
src/archivers/dms/u_init.cpp
src/archivers/dms/u_medium.cpp
src/archivers/dms/u_quick.cpp
src/archivers/dms/u_rle.cpp
src/archivers/lha/crcio.cpp
src/archivers/lha/dhuf.cpp
src/archivers/lha/header.cpp
src/archivers/lha/huf.cpp
src/archivers/lha/larc.cpp
src/archivers/lha/lhamaketbl.cpp
src/archivers/lha/lharc.cpp
src/archivers/lha/shuf.cpp
src/archivers/lha/shuf.cpp
src/archivers/lha/slide.cpp
src/archivers/lha/uae_lha.cpp
src/archivers/lha/util.cpp
src/archivers/lzx/unlzx.cpp
src/archivers/mp2/kjmp2.cpp
src/archivers/wrp/warp.cpp
src/archivers/zip/unzip.cpp
src/caps/caps_win32.cpp
src/machdep/support.cpp
src/osdep/bsdsocket_host.cpp
src/osdep/cda_play.cpp
src/osdep/charset.cpp
src/osdep/fsdb_host.cpp
src/osdep/amiberry_hardfile.cpp
src/osdep/keyboard.cpp
src/osdep/mp3decoder.cpp
src/osdep/picasso96.cpp
src/osdep/writelog.cpp
src/osdep/amiberry.cpp
src/osdep/amiberry_filesys.cpp
src/osdep/amiberry_input.cpp
src/osdep/amiberry_gfx.cpp
src/osdep/amiberry_gui.cpp
src/osdep/amiberry_rp9.cpp
src/osdep/amiberry_mem.cpp
src/osdep/amiberry_whdbooter.cpp
src/osdep/sigsegv_handler.cpp
src/sounddep/sound.cpp
src/osdep/gui/UaeRadioButton.cpp
src/osdep/gui/UaeDropDown.cpp
src/osdep/gui/UaeCheckBox.cpp
src/osdep/gui/UaeListBox.cpp
src/osdep/gui/InGameMessage.cpp
src/osdep/gui/SelectorEntry.cpp
src/osdep/gui/ShowHelp.cpp
src/osdep/gui/ShowMessage.cpp
src/osdep/gui/SelectFolder.cpp
src/osdep/gui/SelectFile.cpp
src/osdep/gui/CreateFilesysHardfile.cpp
src/osdep/gui/EditFilesysVirtual.cpp
src/osdep/gui/EditFilesysHardfile.cpp
src/osdep/gui/PanelAbout.cpp
src/osdep/gui/PanelPaths.cpp
src/osdep/gui/PanelQuickstart.cpp
src/osdep/gui/PanelConfig.cpp
src/osdep/gui/PanelCPU.cpp
src/osdep/gui/PanelChipset.cpp
src/osdep/gui/PanelCustom.cpp
src/osdep/gui/PanelROM.cpp
src/osdep/gui/PanelRAM.cpp
src/osdep/gui/PanelFloppy.cpp
src/osdep/gui/PanelHD.cpp
src/osdep/gui/PanelInput.cpp
src/osdep/gui/PanelDisplay.cpp
src/osdep/gui/PanelSound.cpp
src/osdep/gui/PanelMisc.cpp
src/osdep/gui/PanelSavestate.cpp
src/osdep/gui/main_window.cpp
src/osdep/gui/Navigation.cpp
src/newcpu.cpp
src/newcpu_common.cpp
src/readcpu.cpp
src/cpudefs.cpp
src/cpustbl.cpp
src/cpuemu_0.cpp
src/cpuemu_4.cpp
src/cpuemu_11.cpp
src/cpuemu_40.cpp
src/cpuemu_44.cpp
src/jit/compemu.cpp
src/jit/compstbl.cpp
src/jit/compemu_fpp.cpp
src/jit/compemu_support.cpp
)
include_directories(
../common/include
include
src
src/osdep
src/osdep/psp2
src/osdep/switch
src/osdep/vkbd
src/include
src/threaddep
src/archivers
)
if(BUILD_PSP2)
set(PSP2_SRC_FILES
src/osdep/psp2/psp2_shader.cpp
src/osdep/psp2/psp2-dirent.c
src/osdep/psp2/psp2_touch.c
src/osdep/neon_helper.s
)
set(SRC_FILES ${PSP2_SRC_FILES} ${SRC_FILES})
include_directories(
${VITASDK}/arm-vita-eabi/include/SDL2
)
set(FLAGS
-Wno-write-strings
-DVERSION=\"${BUILD_DATE}\"
-DAMIBERRY -D__PSP2__ -DUSE_SDL2
-DGCCCONSTFUNC="__attribute__\(\(const\)\)" -DUSE_UNDERSCORE
-DSHM_SUPPORT_LINKS=0 -DUNALIGNED_PROFITABLE -DOPTIMIZED_FLAGS -DOS_WITHOUT_MEMORY_MANAGEMENT
-DROM_PATH_PREFIX=\"ux0:/data/amiberry/roms/\" -DDATA_PREFIX=\"app0:/data/\" -DSAVE_PREFIX=\"ux0:/data/amiberry/saves/\"
-DUSE_AMIBERRY_VKBD
-DUSE_ARMV7
-DARMV6_ASSEMBLY
-DARMV6T2
-DUSE_ARMNEON
-DARM_HAS_DIV
-marm -mfpu=neon -mcpu=cortex-a9 -march=armv7-a -mfloat-abi=hard -ffast-math
-fno-asynchronous-unwind-tables -funroll-loops
-mword-relocations -fno-unwind-tables -fno-optimize-sibling-calls
-mvectorize-with-neon-quad -funsafe-math-optimizations
-mlittle-endian -munaligned-access
)
set(LDFLAGS
SDL2 SDL2_image SDL2_ttf guisan FLAC mpg123 dl mpeg2convert mpeg2
${CMAKE_SOURCE_DIR}/src/osdep/psp2/vita2d_fbo/lib/libvita2d.a
${CMAKE_SOURCE_DIR}/src/osdep/psp2/vita-shader-collection/lib/libvitashaders.a
${CMAKE_SOURCE_DIR}/guisan-dev/lib/libguisan.a
SceSysmodule_stub SceDisplay_stub SceGxm_stub
SceCtrl_stub ScePgf_stub ScePower_stub SceCommonDialog_stub
SceAudio_stub SceShellSvc_stub SceHid_stub SceTouch_stub png jpeg z m c
)
if (BUILD_DEBUG)
list(APPEND FLAGS -DDEBUG -DDEBUG_AMIBERRY -DUAE_CONSOLE)
list(APPEND LDFLAGS psp2shell SceSysmodule_stub SceNetCtl_stub
SceNet_stub SceAppUtil_stub SceAppMgr_stub
)
set(UNSAFE_FLAG UNSAFE)
else ()
list(APPEND FLAGS -O3)
endif (BUILD_DEBUG)
add_executable(${PROJECT_NAME} ${SRC_FILES})
target_compile_options(${PROJECT_NAME} PRIVATE ${FLAGS})
target_link_libraries(${PROJECT_NAME} ${LDFLAGS})
vita_create_self(${PROJECT_NAME}.self ${PROJECT_NAME} ${UNSAFE_FLAG})
add_custom_target(${PROJECT_NAME}.vpk
DEPENDS ${PROJECT_NAME}.self
COMMAND rm -rf vpk && mkdir -p vpk/sce_sys
COMMAND ${VITASDK}/bin/vita-mksfoex -s TITLE_ID=${TITLEID} "${PROJECT_NAME}" vpk/sce_sys/param.sfo
COMMAND cp ${PROJECT_NAME}.self vpk/eboot.bin
COMMAND cp -r ${CMAKE_SOURCE_DIR}/psp2data/* vpk
COMMAND cd vpk && zip -r ../amiberry_${VERSION_MAJOR}.${VERSION_MINOR}.vpk . && cd ..
)
endif(BUILD_PSP2)
if(BUILD_NX)
set(NX_SRC_FILES
src/osdep/switch/switch_touch.c
src/osdep/switch/sdl2_to_sdl1.cpp
)
set(SRC_FILES ${NX_SRC_FILES} ${SRC_FILES})
include_directories(
${DEVKITPRO}/portlibs/switch/include/SDL2
${DEVKITPRO}/libnx/include
${DEVKITPRO}/portlibs/switch/include
)
add_definitions(
-DVERSION=\"${BUILD_DATE}\"
-DGP2X
-DPANDORA
-D__SWITCH__
-D__64BIT__
-DUSE_AUTOCONFIG
-DUSE_ZFILE
-DUSE_FAME_CORE
-DWITH_TESTMODE
-DUSE_SDL
-DUSE_SDL2
-DGCCCONSTFUNC=\"__attribute__\(\(const\)\)\"
-DUSE_UNDERSCORE
-DSHM_SUPPORT_LINKS=0
-DUNALIGNED_PROFITABLE
-DOPTIMIZED_FLAGS
-DOS_WITHOUT_MEMORY_MANAGEMENT
-DROM_PATH_PREFIX=\"./roms/\"
-DDATA_PREFIX=\"./data/\"
-DSAVE_PREFIX=\"./saves/\"
-DUSE_AMIBERRY_VKBD
)
set(FLAGS
-Wno-write-strings
-march=armv8-a
-mtune=cortex-a57
-mtp=soft
#-fPIE is neccessary to prevent crash on startup
-fPIE
-O1
-ffast-math
-fno-asynchronous-unwind-tables
-funroll-loops
-fno-unwind-tables
-fno-optimize-sibling-calls
-funsafe-math-optimizations
-mlittle-endian
-ffunction-sections
-fno-rtti
-fno-exceptions
# -fomit-frame-pointer
# -fno-strict-aliasing
# -fexpensive-optimizations
# -fweb
# -frename-registers
# -fomit-frame-pointer
# -falign-functions=32
# -finline
# -finline-functions
# -fno-builtin
)
set(LIBS
SDL2
SDL2_image
EGL
GLESv2
glapi
drm_nouveau
nx
png
jpeg
z
m
c
stdc++
)
foreach(flag ${FLAGS})
set(FLAGS_GENERAL "${FLAGS_GENERAL} ${flag}")
endforeach(flag ${FLAGS})
#set(CMAKE_C_FLAGS "${FLAGS_GENERAL}" CACHE STRING "C Flags" FORCE)
#set(CMAKE_CXX_FLAGS "${FLAGS_GENERAL}" CACHE STRING "C++ Flags" FORCE)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${FLAGS_GENERAL} -specs=${DEVKITPRO}/libnx/switch.specs --verbose")
add_executable(${PROJECT_NAME}.elf ${SRC_FILES})
target_compile_options(${PROJECT_NAME}.elf PRIVATE ${FLAGS})
target_link_libraries(${PROJECT_NAME}.elf PRIVATE ${LIBS})
add_custom_target(${PROJECT_NAME}.nro
DEPENDS ${PROJECT_NAME}.elf
COMMAND ${DEVKITPRO}/tools/bin/nacptool --create "${PROJECT_NAME}" "midwan" "${VERSION_MAJOR}.${VERSION_MINOR}" ${PROJECT_NAME}.nacp
COMMAND ${DEVKITPRO}/tools/bin/elf2nro ${PROJECT_NAME}.elf ${PROJECT_NAME}.nro --icon=${CMAKE_SOURCE_DIR}/switchdata/icon0.jpg --nacp=${PROJECT_NAME}.nacp
)
add_custom_target(${PROJECT_NAME}_switch.zip
DEPENDS ${PROJECT_NAME}.nro
COMMAND rm -rf ${CMAKE_BINARY_DIR}/release/${PROJECT_NAME}
COMMAND mkdir -p ${CMAKE_BINARY_DIR}/release/${PROJECT_NAME}
COMMAND mkdir -p ${CMAKE_BINARY_DIR}/release/${PROJECT_NAME}/data
COMMAND mkdir -p ${CMAKE_BINARY_DIR}/release/${PROJECT_NAME}/roms
COMMAND mkdir -p ${CMAKE_BINARY_DIR}/release/${PROJECT_NAME}/kickstarts
COMMAND mkdir -p ${CMAKE_BINARY_DIR}/release/${PROJECT_NAME}/saves
COMMAND mkdir -p ${CMAKE_BINARY_DIR}/release/${PROJECT_NAME}/conf
COMMAND cp -f ${CMAKE_BINARY_DIR}/${PROJECT_NAME}.nro ${CMAKE_BINARY_DIR}/release/${PROJECT_NAME}/${PROJECT_NAME}.nro
COMMAND cp -r ${CMAKE_SOURCE_DIR}/switchdata/data/* ${CMAKE_BINARY_DIR}/release/${PROJECT_NAME}/data/
COMMAND cd ${CMAKE_BINARY_DIR}/release && zip -r ../${PROJECT_NAME}_${VERSION_MAJOR}.${VERSION_MINOR}_switch.zip ${PROJECT_NAME} && cd ${CMAKE_BINARY_DIR}
)
endif(BUILD_NX)

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 225 KiB

5
psp2data/data/colors.txt Normal file
View file

@ -0,0 +1,5 @@
menu_inv_color=0x9a,0x9a,0xaa
menu_win0_color=0x20,0x20,0x30
menu_win1_color=0x70,0x70,0x80
menu_barra0_color=0x40,0x40,0x50
menu_barra1_color=0x80,0x80,0x90

BIN
psp2data/data/text.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

BIN
psp2data/data/window.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

BIN
psp2data/sce_sys/icon0.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

View file

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<livearea style="a1" format-ver="01.00" content-rev="1">
<livearea-background>
<image>bg.png</image>
</livearea-background>
<gate>
<startup-image>startup.png</startup-image>
</gate>
</livearea>

View file

@ -27,7 +27,7 @@ extern long int version;
#define MAX_PATHS 8 #define MAX_PATHS 8
struct multipath { struct multipath {
TCHAR path[MAX_PATHS][PATH_MAX]; TCHAR path[MAX_PATHS][MAX_DPATH];
}; };
#define PATH_NONE -1 #define PATH_NONE -1

View file

@ -103,7 +103,11 @@ using namespace std;
#endif #endif
#if HAVE_DIRENT_H #if HAVE_DIRENT_H
#if defined(__PSP2__) // NOT __SWITCH__
# include "psp2-dirent.h"
#else
# include <dirent.h> # include <dirent.h>
#endif
#else #else
# define dirent direct # define dirent direct
# if HAVE_SYS_NDIR_H # if HAVE_SYS_NDIR_H
@ -154,8 +158,8 @@ typedef int uae_s16;
#endif #endif
#if SIZEOF_INT == 4 #if SIZEOF_INT == 4
typedef unsigned int uae_u32; //typedef unsigned int uae_u32;
typedef int uae_s32; //typedef int uae_s32;
#elif SIZEOF_LONG == 4 #elif SIZEOF_LONG == 4
typedef unsigned long uae_u32; typedef unsigned long uae_u32;
typedef long uae_s32; typedef long uae_s32;

View file

@ -9,6 +9,14 @@
#ifndef _RPT_H_ #ifndef _RPT_H_
#define _RPT_H_ #define _RPT_H_
#if defined(__PSP2__) // NOT __SWITCH__
#include <psp2/kernel/processmgr.h>
#endif
#if defined(__SWITCH__)
#include <switch.h>
#endif
typedef unsigned long frame_time_t; typedef unsigned long frame_time_t;
extern int64_t g_uae_epoch; extern int64_t g_uae_epoch;
@ -17,11 +25,17 @@ extern int64_t g_uae_epoch;
static __inline__ frame_time_t read_processor_time (void) static __inline__ frame_time_t read_processor_time (void)
{ {
int64_t time; int64_t time;
#if defined(__PSP2__) // NOT __SWITCH__
time = sceKernelGetProcessTimeWide();
#elif defined(__SWITCH__)
time = (int64_t) ((svcGetSystemTick() * 1000000) / 19200000);
#else
struct timespec ts; struct timespec ts;
clock_gettime (CLOCK_MONOTONIC, &ts); clock_gettime (CLOCK_MONOTONIC, &ts);
time = (((int64_t) ts.tv_sec) * 1000000) + (ts.tv_nsec / 1000); time = (((int64_t) ts.tv_sec) * 1000000) + (ts.tv_nsec / 1000);
#endif
return time - g_uae_epoch; return time - g_uae_epoch;
} }
@ -29,11 +43,17 @@ static __inline__ frame_time_t read_processor_time (void)
static __inline__ int64_t read_processor_time_ns (void) static __inline__ int64_t read_processor_time_ns (void)
{ {
int64_t time; int64_t time;
#if defined(__PSP2__) // NOT __SWITCH__
time = sceKernelGetProcessTimeWide();
#elif defined(__SWITCH__)
time = (int64_t) ((svcGetSystemTick() * 1000000) / 19200000);
#else
struct timespec ts; struct timespec ts;
clock_gettime (CLOCK_MONOTONIC, &ts); clock_gettime (CLOCK_MONOTONIC, &ts);
time = (((int64_t) ts.tv_sec) * 1000000 * 1000) + (ts.tv_nsec); time = (((int64_t) ts.tv_sec) * 1000000 * 1000) + (ts.tv_nsec);
#endif
return time; return time;
} }

View file

@ -0,0 +1,260 @@
/*
Copyright (C) 2016, David "Davee" Morgan
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:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
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.
*/
#include "psp2-dirent.h"
#include <errno.h>
#include <malloc.h>
#include <string.h>
#include <psp2/types.h>
#include <psp2/io/dirent.h>
#include <psp2/kernel/threadmgr.h>
#define SCE_ERRNO_MASK 0xFF
int mkdir(const char *path, mode_t mode)
{
return sceIoMkdir(path, 0777);
}
int rmdir(const char *path)
{
return sceIoRmdir(path);
}
struct DIR_
{
SceUID uid;
struct dirent dir;
int refcount;
char *dirname;
int index;
};
static inline void grab_dir(DIR *dirp)
{
__sync_add_and_fetch(&dirp->refcount, 1);
}
static inline void drop_dir(DIR *dirp)
{
if (__sync_add_and_fetch(&dirp->refcount, 1) == 0)
{
free(dirp->dirname);
free(dirp);
}
}
static inline void release_drop_dir(DIR *dirp)
{
if (__sync_add_and_fetch(&dirp->refcount, 2) == 0)
{
free(dirp->dirname);
free(dirp);
}
}
static inline void atomic_exchange(int *obj, int desired)
{
__sync_synchronize();
__sync_lock_test_and_set(obj, desired);
}
#ifdef F_closedir
int closedir(DIR *dirp)
{
if (!dirp)
{
errno = EBADF;
return -1;
}
grab_dir(dirp);
int res = sceIoDclose(dirp->uid);
if (res < 0)
{
errno = res & SCE_ERRNO_MASK;
drop_dir(dirp);
return -1;
}
release_drop_dir(dirp);
errno = 0;
return 0;
}
#endif
#if F_opendir
DIR *opendir(const char *dirname)
{
SceUID uid = sceIoDopen(dirname);
if (uid < 0)
{
errno = uid & SCE_ERRNO_MASK;
return NULL;
}
DIR *dirp = (DIR *)calloc(1, sizeof(DIR));
if (!dirp)
{
sceIoDclose(uid);
errno = ENOMEM;
return NULL;
}
dirp->refcount = 1;
dirp->uid = uid;
dirp->dirname = strdup(dirname);
dirp->index = 0;
errno = 0;
return dirp;
}
#endif
#ifdef F_readdir
struct dirent *readdir(DIR *dirp)
{
if (!dirp)
{
errno = EBADF;
return NULL;
}
grab_dir(dirp);
int res = sceIoDread(dirp->uid, (SceIoDirent *)&dirp->dir);
if (res < 0)
{
errno = res & SCE_ERRNO_MASK;
drop_dir(dirp);
return NULL;
}
if (res == 0)
{
errno = 0;
drop_dir(dirp);
return NULL;
}
__sync_add_and_fetch(&dirp->index, 1);
struct dirent *dir = &dirp->dir;
if(SCE_S_ISDIR(dirp->dir.d_stat.st_mode))
dir->d_type = DT_DIR;
else
dir->d_type = DT_REG;
drop_dir(dirp);
return dir;
}
#endif
#ifdef F_readdir_r
int readdir_r(DIR *dirp, struct dirent *x, struct dirent **y)
{
errno = ENOSYS;
return -1;
}
#endif
#ifdef F_rewinddir
void rewinddir(DIR *dirp)
{
if (!dirp)
{
errno = EBADF;
return;
}
grab_dir(dirp);
SceUID dirfd = sceIoDopen(dirp->dirname);
if (dirfd < 0)
{
errno = dirfd & SCE_ERRNO_MASK;
drop_dir(dirp);
return;
}
sceIoDclose(dirp->uid);
atomic_exchange(&dirp->uid, dirfd);
atomic_exchange(&dirp->index, 0);
drop_dir(dirp);
}
#endif
#ifdef F_seekdir
void seekdir(DIR *dirp, long int index)
{
if (!dirp)
{
errno = EBADF;
return;
}
grab_dir(dirp);
if (index < dirp->index)
rewinddir(dirp);
if (index < dirp->index)
{
drop_dir(dirp);
return;
}
while (index != dirp->index)
{
if (!readdir(dirp))
{
errno = ENOENT;
drop_dir(dirp);
return;
}
}
drop_dir(dirp);
}
#endif
#ifdef F_telldir
long int telldir(DIR *dirp)
{
if (!dirp)
{
errno = EBADF;
return -1;
}
return dirp->index;
}
#endif

View file

@ -0,0 +1,71 @@
/*
Copyright (C) 2016, David "Davee" Morgan
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:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
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.
*/
#ifndef _PSP2_DIRENT_H_
#define _PSP2_DIRENT_H_
#include <sys/types.h>
#include <sys/time.h>
#include <psp2/io/dirent.h>
#ifdef __cplusplus
extern "C" {
#endif
#define F_opendir 1
#define F_readdir 1
#define F_closedir 1
#define DT_DIR 0
#define DT_REG 1
struct dirent
{
/** File status. */
SceIoStat d_stat;
/** File name. */
char d_name[256];
/** Device-specific data. */
void *d_private;
int dummy;
int d_type;
};
struct DIR_;
typedef struct DIR_ DIR;
int closedir(DIR *);
DIR *opendir(const char *);
struct dirent *readdir(DIR *);
int readdir_r(DIR *, struct dirent *, struct dirent **);
void rewinddir(DIR *);
void seekdir(DIR *, long int);
long int telldir(DIR *);
#ifdef __cplusplus
}
#endif
#endif /* _PSP2_DIRENT_H_ */

111
src/osdep/psp2/psp2_input.c Normal file
View file

@ -0,0 +1,111 @@
#include "psp2_input.h"
#ifdef USE_SDL2
#include "sdl2_to_sdl1.h"
#endif
#ifdef __SWITCH__
extern int mainMenu_swapAB;
#endif
extern int inside_menu;
SDLKey getKey(Uint8 button) {
switch(button) {
case PAD_UP:
#ifdef __SWITCH__
case LSTICK_UP:
#endif
return SDLK_UP;
case PAD_DOWN:
#ifdef __SWITCH__
case LSTICK_DOWN:
#endif
return SDLK_DOWN;
case PAD_RIGHT:
#ifdef __SWITCH__
case LSTICK_RIGHT:
#endif
return SDLK_RIGHT;
case PAD_LEFT:
#ifdef __SWITCH__
case LSTICK_LEFT:
#endif
return SDLK_LEFT;
case PAD_START:
return SDLK_LALT;
case PAD_SELECT:
return SDLK_LCTRL;
case PAD_CROSS:
#ifdef __SWITCH__
if (mainMenu_swapAB) {
return SDLK_END;
}
#endif
return SDLK_PAGEDOWN;
case PAD_CIRCLE:
#ifdef __SWITCH__
if (mainMenu_swapAB) {
return SDLK_PAGEDOWN;
}
#endif
return SDLK_END;
case PAD_TRIANGLE:
return SDLK_PAGEUP;
case PAD_SQUARE:
return SDLK_HOME;
case PAD_L:
return SDLK_RSHIFT;
case PAD_R:
return SDLK_RCTRL;
default:
break;
}
return 0;
}
int PSP2_PollEvent(SDL_Event *event) {
int ret = SDL_PollEvent(event);
if(event != NULL && inside_menu) {
switch (event->type) {
case SDL_JOYAXISMOTION:
break;
case SDL_JOYBUTTONDOWN:
if (event->jbutton.which==0) // Only Joystick 0 controls the menu
{
event->type = SDL_KEYDOWN;
event->key.keysym.sym = getKey(event->jbutton.button);
}
break;
case SDL_JOYBUTTONUP:
if (event->jbutton.which==0)
{
event->type = SDL_KEYUP;
event->key.keysym.sym = getKey(event->jbutton.button);
}
break;
default:
break;
}
}
return ret;
}

View file

@ -0,0 +1,58 @@
#include <SDL.h>
#ifdef __cplusplus
extern "C" {
#endif
int PSP2_PollEvent(SDL_Event *event);
#ifdef __PSP2__ // NOT __SWITCH__
#define PAD_UP 8
#define PAD_DOWN 6
#define PAD_LEFT 7
#define PAD_RIGHT 9
#define PAD_TRIANGLE 0
#define PAD_SQUARE 3
#define PAD_CROSS 2
#define PAD_CIRCLE 1
#define PAD_SELECT 10
#define PAD_START 11
#define PAD_L 4
#define PAD_R 5
#endif
#ifdef __SWITCH__
#define PAD_LEFT 12
#define PAD_UP 13
#define PAD_RIGHT 14
#define PAD_DOWN 15
#define PAD_TRIANGLE 2
#define PAD_SQUARE 3
#define PAD_CROSS 1
#define PAD_CIRCLE 0
#define PAD_SELECT 11
#define PAD_START 10
#define PAD_L 6
#define PAD_R 7
#define PAD_L2 8
#define PAD_R2 9
#define PAD_L3 4
#define PAD_R3 5
#define LSTICK_LEFT 16
#define LSTICK_UP 17
#define LSTICK_RIGHT 18
#define LSTICK_DOWN 19
#define RSTICK_LEFT 20
#define RSTICK_UP 21
#define RSTICK_RIGHT 22
#define RSTICK_DOWN 23
#define PAD_SL_LEFT 24
#define PAD_SR_LEFT 25
#define PAD_SL_RIGHT 26
#define PAD_SR_RIGHT 27
#define BUTTON_NONE 254
#endif
#ifdef __cplusplus
}
#endif

View file

@ -0,0 +1,84 @@
//
// Created by cpasjuste on 18/12/16.
//
// use https://github.com/frangarcj/vita2dlib/tree/fbo
// and https://github.com/frangarcj/vita-shader-collection/releases
#include <sysconfig.h>
#include "psp2_shader.h"
#include "vita-shader-collection/includes/lcd3x_v.h"
#include "vita-shader-collection/includes/lcd3x_f.h"
#include "vita-shader-collection/includes/gtu_v.h"
#include "vita-shader-collection/includes/gtu_f.h"
#include "vita-shader-collection/includes/texture_v.h"
#include "vita-shader-collection/includes/texture_f.h"
#include "vita-shader-collection/includes/opaque_v.h"
#include "vita-shader-collection/includes/bicubic_f.h"
#include "vita-shader-collection/includes/xbr_2x_v.h"
#include "vita-shader-collection/includes/xbr_2x_f.h"
#include "vita-shader-collection/includes/xbr_2x_fast_v.h"
#include "vita-shader-collection/includes/xbr_2x_fast_f.h"
#include "vita-shader-collection/includes/advanced_aa_v.h"
#include "vita-shader-collection/includes/advanced_aa_f.h"
#include "vita-shader-collection/includes/scale2x_f.h"
#include "vita-shader-collection/includes/scale2x_v.h"
#include "vita-shader-collection/includes/sharp_bilinear_f.h"
#include "vita-shader-collection/includes/sharp_bilinear_v.h"
#include "vita-shader-collection/includes/sharp_bilinear_simple_f.h"
#include "vita-shader-collection/includes/sharp_bilinear_simple_v.h"
//#include "xbr_2x_noblend_f.h"
//#include "xbr_2x_noblend_v.h"
#include "vita-shader-collection/includes/fxaa_v.h"
#include "vita-shader-collection/includes/fxaa_f.h"
#include "vita-shader-collection/includes/crt_easymode_f.h"
PSP2Shader::PSP2Shader(Shader shaderType) {
//printf("PSP2Shader: %i\n", shaderType);
switch (shaderType) {
case Shader::LCD3X:
shader = vita2d_create_shader((SceGxmProgram *) lcd3x_v, (SceGxmProgram *) lcd3x_f);
break;
case Shader::SCALE2X:
shader = vita2d_create_shader((SceGxmProgram *) scale2x_v, (SceGxmProgram *) scale2x_f);
break;
case Shader::AAA:
shader = vita2d_create_shader((SceGxmProgram *) advanced_aa_v, (SceGxmProgram *) advanced_aa_f);
break;
case Shader::SHARP_BILINEAR:
shader = vita2d_create_shader((SceGxmProgram *) sharp_bilinear_v, (SceGxmProgram *) sharp_bilinear_f);
break;
case Shader::SHARP_BILINEAR_SIMPLE:
shader = vita2d_create_shader((SceGxmProgram *) sharp_bilinear_simple_v, (SceGxmProgram *) sharp_bilinear_simple_f);
break;
case Shader::FXAA:
shader = vita2d_create_shader((SceGxmProgram *) fxaa_v, (SceGxmProgram *) fxaa_f);
break;
default:
shader = vita2d_create_shader((SceGxmProgram *) texture_v, (SceGxmProgram *) texture_f);
break;
}
vita2d_texture_set_program(shader->vertexProgram, shader->fragmentProgram);
vita2d_texture_set_wvp(shader->wvpParam);
vita2d_texture_set_vertexInput(&shader->vertexInput);
vita2d_texture_set_fragmentInput(&shader->fragmentInput);
for(int i=0; i<3; i++) {
vita2d_start_drawing();
vita2d_clear_screen();
vita2d_wait_rendering_done();
vita2d_swap_buffers();
}
}
PSP2Shader::~PSP2Shader() {
if (shader != NULL) {
vita2d_wait_rendering_done();
vita2d_free_shader(shader);
}
}

View file

@ -0,0 +1,31 @@
//
// Created by cpasjuste on 18/12/16.
//
#ifndef UAE4ALL2_PSP2_SHADER_H
#define UAE4ALL2_PSP2_SHADER_H
#include "vita2d_fbo/includes/vita2d.h"
class PSP2Shader {
public:
enum Shader {
NONE = 0,
LCD3X,
SCALE2X,
AAA,
SHARP_BILINEAR,
SHARP_BILINEAR_SIMPLE,
FXAA,
};
PSP2Shader(Shader shaderType);
~PSP2Shader();
private:
vita2d_shader *shader = NULL;
};
#endif //UAE4ALL2_PSP2_SHADER_H

442
src/osdep/psp2/psp2_touch.c Normal file
View file

@ -0,0 +1,442 @@
//
// Created by rsn8887 on 02/05/18.
#include <SDL.h>
#include <psp2/kernel/processmgr.h>
#include <psp2/touch.h>
#include "psp2_touch.h"
//#include "math.h"
typedef int bool;
#define false 0;
#define true 1;
SceTouchData touch_old[SCE_TOUCH_PORT_MAX_NUM];
SceTouchData touch[SCE_TOUCH_PORT_MAX_NUM];
SceTouchPanelInfo panelinfo[SCE_TOUCH_PORT_MAX_NUM];
float aAWidth[SCE_TOUCH_PORT_MAX_NUM];
float aAHeight[SCE_TOUCH_PORT_MAX_NUM];
float dispWidth[SCE_TOUCH_PORT_MAX_NUM];
float dispHeight[SCE_TOUCH_PORT_MAX_NUM];
float forcerange[SCE_TOUCH_PORT_MAX_NUM];
extern int mainMenu_touchControls;
extern int lastmx;
extern int lastmy;
static int hiresdx = 0;
static int hiresdy = 0;
enum {
MAX_NUM_FINGERS = 3, // number of fingers to track per panel
MAX_TAP_TIME = 250, // taps longer than this will not result in mouse click events
MAX_TAP_MOTION_DISTANCE = 10, // max distance finger motion in Vita screen pixels to be considered a tap
SIMULATED_CLICK_DURATION = 50, // time in ms how long simulated mouse clicks should be
}; // track three fingers per panel
typedef struct {
int id; // -1: no touch
int timeLastDown;
float lastDownX;
float lastDownY;
} Touch;
Touch _finger[SCE_TOUCH_PORT_MAX_NUM][MAX_NUM_FINGERS]; // keep track of finger status
typedef enum DraggingType {
DRAG_NONE = 0,
DRAG_TWO_FINGER,
DRAG_THREE_FINGER,
} DraggingType;
DraggingType _multiFingerDragging[SCE_TOUCH_PORT_MAX_NUM]; // keep track whether we are currently drag-and-dropping
int _simulatedClickStartTime[SCE_TOUCH_PORT_MAX_NUM][2]; // initiation time of last simulated left or right click (zero if no click)
void psp2InitTouch(void) {
sceTouchSetSamplingState(SCE_TOUCH_PORT_FRONT, SCE_TOUCH_SAMPLING_STATE_START);
sceTouchSetSamplingState(SCE_TOUCH_PORT_BACK, SCE_TOUCH_SAMPLING_STATE_START);
sceTouchEnableTouchForce(SCE_TOUCH_PORT_FRONT);
sceTouchEnableTouchForce(SCE_TOUCH_PORT_BACK);
SceTouchPanelInfo panelinfo[SCE_TOUCH_PORT_MAX_NUM];
for(int port = 0; port < SCE_TOUCH_PORT_MAX_NUM; port++) {
sceTouchGetPanelInfo(port, &panelinfo[port]);
aAWidth[port] = (float)(panelinfo[port].maxAaX - panelinfo[port].minAaX);
aAHeight[port] = (float)(panelinfo[port].maxAaY - panelinfo[port].minAaY);
dispWidth[port] = (float)(panelinfo[port].maxDispX - panelinfo[port].minDispX);
dispHeight[port] = (float)(panelinfo[port].maxDispY - panelinfo[port].minDispY);
forcerange[port] = (float)(panelinfo[port].maxForce - panelinfo[port].minForce);
}
for (int port = 0; port < SCE_TOUCH_PORT_MAX_NUM; port++) {
for (int i = 0; i < MAX_NUM_FINGERS; i++) {
_finger[port][i].id = -1;
}
_multiFingerDragging[port] = DRAG_NONE;
}
for (int port = 0; port < SCE_TOUCH_PORT_MAX_NUM; port++) {
for (int i = 0; i < 2; i++) {
_simulatedClickStartTime[port][i] = 0;
}
}
}
void psp2QuitTouch(void) {
sceTouchDisableTouchForce(SCE_TOUCH_PORT_FRONT);
sceTouchDisableTouchForce(SCE_TOUCH_PORT_BACK);
}
void psp2PollTouch(void) {
int finger_id = 0;
memcpy(touch_old, touch, sizeof(touch_old));
for(int port = 0; port < SCE_TOUCH_PORT_MAX_NUM; port++) {
if ((port == SCE_TOUCH_PORT_FRONT) || (mainMenu_touchControls == 2 && port == SCE_TOUCH_PORT_BACK)) {
sceTouchPeek(port, &touch[port], 1);
psp2FinishSimulatedMouseClicks(port, touch[port].timeStamp / 1000);
if (touch[port].reportNum > 0) {
for (int i = 0; i < touch[port].reportNum; i++) {
// adjust coordinates and forces to return normalized values
// for the front, screen area is used as a reference (for direct touch)
// e.g. touch_x = 1.0 corresponds to screen_x = 960
// for the back panel, the active touch area is used as reference
float x = 0;
float y = 0;
psp2ConvertTouchXYToSDLXY(&x, &y, touch[port].report[i].x, touch[port].report[i].y, port);
finger_id = touch[port].report[i].id;
// Send an initial touch if finger hasn't been down
bool hasBeenDown = false;
int j = 0;
if (touch_old[port].reportNum > 0) {
for (j = 0; j < touch_old[port].reportNum; j++) {
if (touch_old[port].report[j].id == touch[port].report[i].id ) {
hasBeenDown = true;
break;
}
}
}
if (!hasBeenDown) {
TouchEvent ev;
ev.type = FINGERDOWN;
ev.tfinger.timestamp = touch[port].timeStamp / 1000;
ev.tfinger.touchId = port;
ev.tfinger.fingerId = finger_id;
ev.tfinger.x = x;
ev.tfinger.y = y;
psp2ProcessTouchEvent(&ev);
} else {
// If finger moved, send motion event instead
if (touch_old[port].report[j].x != touch[port].report[i].x ||
touch_old[port].report[j].y != touch[port].report[i].y) {
float oldx = 0;
float oldy = 0;
psp2ConvertTouchXYToSDLXY(&oldx, &oldy, touch_old[port].report[j].x, touch_old[port].report[j].y, port);
TouchEvent ev;
ev.type = FINGERMOTION;
ev.tfinger.timestamp = touch[port].timeStamp / 1000;
ev.tfinger.touchId = port;
ev.tfinger.fingerId = finger_id;
ev.tfinger.x = x;
ev.tfinger.y = y;
ev.tfinger.dx = x - oldx;
ev.tfinger.dy = y - oldy;
psp2ProcessTouchEvent(&ev);
}
}
}
}
// some fingers might have been let go
if (touch_old[port].reportNum > 0) {
for (int i = 0; i < touch_old[port].reportNum; i++) {
int finger_up = 1;
if (touch[port].reportNum > 0) {
for (int j = 0; j < touch[port].reportNum; j++) {
if (touch[port].report[j].id == touch_old[port].report[i].id ) {
finger_up = 0;
}
}
}
if (finger_up == 1) {
float x = 0;
float y = 0;
psp2ConvertTouchXYToSDLXY(&x, &y, touch_old[port].report[i].x, touch_old[port].report[i].y, port);
finger_id = touch_old[port].report[i].id;
// Finger released from screen
TouchEvent ev;
ev.type = FINGERUP;
ev.tfinger.timestamp = touch[port].timeStamp / 1000;
ev.tfinger.touchId = port;
ev.tfinger.fingerId = finger_id;
ev.tfinger.x = x;
ev.tfinger.y = y;
psp2ProcessTouchEvent(&ev);
}
}
}
}
}
}
void psp2ConvertTouchXYToSDLXY(float *sdl_x, float *sdl_y, int vita_x, int vita_y, int port) {
float x = 0;
float y = 0;
if (port == SCE_TOUCH_PORT_FRONT) {
x = (vita_x - panelinfo[port].minDispX) / dispWidth[port];
y = (vita_y - panelinfo[port].minDispY) / dispHeight[port];
} else {
x = (vita_x - panelinfo[port].minAaX) / aAWidth[port];
y = (vita_y - panelinfo[port].minAaY) / aAHeight[port];
}
if (x < 0.0) {
x = 0.0;
} else if (x > 1.0) {
x = 1.0;
}
if (y < 0.0) {
y = 0.0;
} else if (y > 1.0) {
y = 1.0;
}
*sdl_x = x;
*sdl_y = y;
}
void psp2ProcessTouchEvent(TouchEvent *event) {
// Supported touch gestures:
// left mouse click: single finger short tap
// right mouse click: second finger short tap while first finger is still down
// pointer motion: single finger drag
// drag and drop: dual finger drag
if (event->type == FINGERDOWN || event->type == FINGERUP || event->type == FINGERMOTION) {
// front (0) or back (1) panel
int port = event->tfinger.touchId;
if (port >= 0 && port < SCE_TOUCH_PORT_MAX_NUM) {
switch (event->type) {
case FINGERDOWN:
psp2ProcessFingerDown(event);
break;
case FINGERUP:
psp2ProcessFingerUp(event);
break;
case FINGERMOTION:
psp2ProcessFingerMotion(event);
break;
}
}
}
}
void psp2ProcessFingerDown(TouchEvent *event) {
// front (0) or back (1) panel
int port = event->tfinger.touchId;
// id (for multitouch)
int id = event->tfinger.fingerId;
int x = lastmx;
int y = lastmy;
// make sure each finger is not reported down multiple times
for (int i = 0; i < MAX_NUM_FINGERS; i++) {
if (_finger[port][i].id == id) {
_finger[port][i].id = -1;
}
}
// we need the timestamps to decide later if the user performed a short tap (click)
// or a long tap (drag)
// we also need the last coordinates for each finger to keep track of dragging
for (int i = 0; i < MAX_NUM_FINGERS; i++) {
if (_finger[port][i].id == -1) {
_finger[port][i].id = id;
_finger[port][i].timeLastDown = event->tfinger.timestamp;
_finger[port][i].lastDownX = event->tfinger.x;
_finger[port][i].lastDownY = event->tfinger.y;
break;
}
}
}
void psp2ProcessFingerUp(TouchEvent *event) {
// front (0) or back (1) panel
int port = event->tfinger.touchId;
// id (for multitouch)
int id = event->tfinger.fingerId;
// find out how many fingers were down before this event
int numFingersDown = 0;
for (int i = 0; i < MAX_NUM_FINGERS; i++) {
if (_finger[port][i].id >= 0) {
numFingersDown++;
}
}
int x = lastmx;
int y = lastmy;
for (int i = 0; i < MAX_NUM_FINGERS; i++) {
if (_finger[port][i].id == id) {
_finger[port][i].id = -1;
if (!_multiFingerDragging[port]) {
if ((event->tfinger.timestamp - _finger[port][i].timeLastDown) <= MAX_TAP_TIME) {
// short (<MAX_TAP_TIME ms) tap is interpreted as right/left mouse click depending on # fingers already down
// but only if the finger hasn't moved since it was pressed down by more than MAX_TAP_MOTION_DISTANCE pixels
float xrel = ((event->tfinger.x * 960.0) - (_finger[port][i].lastDownX * 960.0));
float yrel = ((event->tfinger.y * 544.0) - (_finger[port][i].lastDownY * 544.0));
float maxRSquared = (float) (MAX_TAP_MOTION_DISTANCE * MAX_TAP_MOTION_DISTANCE);
if ((xrel * xrel + yrel * yrel) < maxRSquared) {
if (numFingersDown == 2 || numFingersDown == 1) {
Uint8 simulatedButton = 0;
if (numFingersDown == 2) {
simulatedButton = SDL_BUTTON_RIGHT;
// need to raise the button later
_simulatedClickStartTime[port][1] = event->tfinger.timestamp;
} else if (numFingersDown == 1) {
simulatedButton = SDL_BUTTON_LEFT;
// need to raise the button later
_simulatedClickStartTime[port][0] = event->tfinger.timestamp;
}
SDL_Event ev0;
ev0.type = SDL_MOUSEBUTTONDOWN;
ev0.button.button = simulatedButton;
ev0.button.x = x;
ev0.button.y = y;
SDL_PushEvent(&ev0);
}
}
}
} else if (numFingersDown == 1) {
// when dragging, and the last finger is lifted, the drag is over
Uint8 simulatedButton = 0;
if (_multiFingerDragging[port] == DRAG_THREE_FINGER)
simulatedButton = SDL_BUTTON_RIGHT;
else {
simulatedButton = SDL_BUTTON_LEFT;
}
SDL_Event ev0;
ev0.type = SDL_MOUSEBUTTONUP;
ev0.button.button = simulatedButton;
ev0.button.x = x;
ev0.button.y = y;
_multiFingerDragging[port] = DRAG_NONE;
SDL_PushEvent(&ev0);
}
}
}
}
void psp2ProcessFingerMotion(TouchEvent *event) {
// front (0) or back (1) panel
int port = event->tfinger.touchId;
// id (for multitouch)
int id = event->tfinger.fingerId;
// find out how many fingers were down before this event
int numFingersDown = 0;
for (int i = 0; i < MAX_NUM_FINGERS; i++) {
if (_finger[port][i].id >= 0) {
numFingersDown++;
}
}
if (numFingersDown >= 1) {
// If we are starting a multi-finger drag, start holding down the mouse button
if (numFingersDown >= 2) {
if (!_multiFingerDragging[port]) {
// only start a multi-finger drag if at least two fingers have been down long enough
int numFingersDownLong = 0;
for (int i = 0; i < MAX_NUM_FINGERS; i++) {
if (_finger[port][i].id >= 0) {
if (event->tfinger.timestamp - _finger[port][i].timeLastDown > MAX_TAP_TIME) {
numFingersDownLong++;
}
}
}
if (numFingersDownLong >= 2) {
Uint8 simulatedButton = 0;
if (numFingersDownLong == 2) {
simulatedButton = SDL_BUTTON_LEFT;
_multiFingerDragging[port] = DRAG_TWO_FINGER;
} else {
simulatedButton = SDL_BUTTON_RIGHT;
_multiFingerDragging[port] = DRAG_THREE_FINGER;
}
int mouseDownX = lastmx;
int mouseDownY = lastmy;
SDL_Event ev;
ev.type = SDL_MOUSEBUTTONDOWN;
ev.button.button = simulatedButton;
ev.button.x = mouseDownX;
ev.button.y = mouseDownY;
SDL_PushEvent(&ev);
}
}
}
//check if this is the "oldest" finger down (or the only finger down), otherwise it will not affect mouse motion
bool updatePointer = true;
if (numFingersDown > 1) {
for (int i = 0; i < MAX_NUM_FINGERS; i++) {
if (_finger[port][i].id == id) {
for (int j = 0; j < MAX_NUM_FINGERS; j++) {
if (_finger[port][j].id >= 0 && (i != j) ) {
if (_finger[port][j].timeLastDown < _finger[port][i].timeLastDown) {
updatePointer = false;
}
}
}
}
}
}
if (updatePointer) {
const int slowdown = 16;
hiresdx += (int)(event->tfinger.dx * 960.0 * slowdown);
hiresdy += (int)(event->tfinger.dy * 544.0 * slowdown);
int xrel = hiresdx / slowdown;
int yrel = hiresdy / slowdown;
if (xrel || yrel) {
int x = lastmx + xrel;
int y = lastmy + yrel;
SDL_Event ev0;
ev0.type = SDL_MOUSEMOTION;
ev0.motion.x = x;
ev0.motion.y = y;
ev0.motion.xrel = xrel;
ev0.motion.yrel = yrel;
SDL_PushEvent(&ev0);
hiresdx %= slowdown;
hiresdy %= slowdown;
}
}
}
}
void psp2FinishSimulatedMouseClicks(int port, SceUInt64 currentTime) {
for (int i = 0; i < 2; i++) {
if (_simulatedClickStartTime[port][i] != 0) {
if (currentTime - _simulatedClickStartTime[port][i] >= SIMULATED_CLICK_DURATION) {
int simulatedButton;
if (i == 0) {
simulatedButton = SDL_BUTTON_LEFT;
} else {
simulatedButton = SDL_BUTTON_RIGHT;
}
SDL_Event ev;
ev.type = SDL_MOUSEBUTTONUP;
ev.button.button = simulatedButton;
ev.button.x = lastmx;
ev.button.y = lastmy;
SDL_PushEvent(&ev);
_simulatedClickStartTime[port][i] = 0;
}
}
}
}

View file

@ -0,0 +1,50 @@
//
// Created by rsn8887 on 02/05/18.
#ifndef UAE4ALL2_PSP2_TOUCH_H
#define UAE4ALL2_PSP2_TOUCH_H
#include <psp2/touch.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef enum TouchEventType {
FINGERDOWN,
FINGERUP,
FINGERMOTION,
} TouchEventType;
typedef struct {
TouchEventType type;
SceUInt64 timestamp;
int touchId;
int fingerId;
float x;
float y;
float dx;
float dy;
} FingerType;
typedef struct {
TouchEventType type;
FingerType tfinger;
} TouchEvent;
/* Touch functions */
void psp2InitTouch(void);
void psp2QuitTouch(void);
void psp2PollTouch(void);
void psp2ProcessTouchEvent(TouchEvent *event);
void psp2ProcessFingerDown(TouchEvent *event);
void psp2ProcessFingerUp(TouchEvent *event);
void psp2ProcessFingerMotion(TouchEvent *event);
void psp2ConvertTouchXYToSDLXY(float *sdl_x, float *sdl_y, int vita_x, int vita_y, int port);
void psp2FinishSimulatedMouseClicks(int port, SceUInt64 currentTime);
#ifdef __cplusplus
}
#endif
#endif

View file

@ -0,0 +1,14 @@
/*
This file was autogenerated by raw2c.
Visit http://www.devkitpro.org
*/
//---------------------------------------------------------------------------------
#ifndef _advanced_aa_f_h_
#define _advanced_aa_f_h_
//---------------------------------------------------------------------------------
extern const unsigned char advanced_aa_f[];
extern const int advanced_aa_f_size;
//---------------------------------------------------------------------------------
#endif //_advanced_aa_f_h_
//---------------------------------------------------------------------------------

View file

@ -0,0 +1,14 @@
/*
This file was autogenerated by raw2c.
Visit http://www.devkitpro.org
*/
//---------------------------------------------------------------------------------
#ifndef _advanced_aa_v_h_
#define _advanced_aa_v_h_
//---------------------------------------------------------------------------------
extern const unsigned char advanced_aa_v[];
extern const int advanced_aa_v_size;
//---------------------------------------------------------------------------------
#endif //_advanced_aa_v_h_
//---------------------------------------------------------------------------------

View file

@ -0,0 +1,14 @@
/*
This file was autogenerated by raw2c.
Visit http://www.devkitpro.org
*/
//---------------------------------------------------------------------------------
#ifndef _alpha_blend_f_h_
#define _alpha_blend_f_h_
//---------------------------------------------------------------------------------
extern const unsigned char alpha_blend_f[];
extern const int alpha_blend_f_size;
//---------------------------------------------------------------------------------
#endif //_alpha_blend_f_h_
//---------------------------------------------------------------------------------

View file

@ -0,0 +1,14 @@
/*
This file was autogenerated by raw2c.
Visit http://www.devkitpro.org
*/
//---------------------------------------------------------------------------------
#ifndef _alpha_blend_v_h_
#define _alpha_blend_v_h_
//---------------------------------------------------------------------------------
extern const unsigned char alpha_blend_v[];
extern const int alpha_blend_v_size;
//---------------------------------------------------------------------------------
#endif //_alpha_blend_v_h_
//---------------------------------------------------------------------------------

View file

@ -0,0 +1,14 @@
/*
This file was autogenerated by raw2c.
Visit http://www.devkitpro.org
*/
//---------------------------------------------------------------------------------
#ifndef _bicubic_f_h_
#define _bicubic_f_h_
//---------------------------------------------------------------------------------
extern const unsigned char bicubic_f[];
extern const int bicubic_f_size;
//---------------------------------------------------------------------------------
#endif //_bicubic_f_h_
//---------------------------------------------------------------------------------

View file

@ -0,0 +1,14 @@
/*
This file was autogenerated by raw2c.
Visit http://www.devkitpro.org
*/
//---------------------------------------------------------------------------------
#ifndef _clear_f_h_
#define _clear_f_h_
//---------------------------------------------------------------------------------
extern const unsigned char clear_f[];
extern const int clear_f_size;
//---------------------------------------------------------------------------------
#endif //_clear_f_h_
//---------------------------------------------------------------------------------

View file

@ -0,0 +1,14 @@
/*
This file was autogenerated by raw2c.
Visit http://www.devkitpro.org
*/
//---------------------------------------------------------------------------------
#ifndef _clear_v_h_
#define _clear_v_h_
//---------------------------------------------------------------------------------
extern const unsigned char clear_v[];
extern const int clear_v_size;
//---------------------------------------------------------------------------------
#endif //_clear_v_h_
//---------------------------------------------------------------------------------

View file

@ -0,0 +1,14 @@
/*
This file was autogenerated by raw2c.
Visit http://www.devkitpro.org
*/
//---------------------------------------------------------------------------------
#ifndef _color_f_h_
#define _color_f_h_
//---------------------------------------------------------------------------------
extern const unsigned char color_f[];
extern const int color_f_size;
//---------------------------------------------------------------------------------
#endif //_color_f_h_
//---------------------------------------------------------------------------------

View file

@ -0,0 +1,14 @@
/*
This file was autogenerated by raw2c.
Visit http://www.devkitpro.org
*/
//---------------------------------------------------------------------------------
#ifndef _color_v_h_
#define _color_v_h_
//---------------------------------------------------------------------------------
extern const unsigned char color_v[];
extern const int color_v_size;
//---------------------------------------------------------------------------------
#endif //_color_v_h_
//---------------------------------------------------------------------------------

View file

@ -0,0 +1,14 @@
/*
This file was autogenerated by raw2c.
Visit http://www.devkitpro.org
*/
//---------------------------------------------------------------------------------
#ifndef _crt_easymode_f_h_
#define _crt_easymode_f_h_
//---------------------------------------------------------------------------------
extern const unsigned char crt_easymode_f[];
extern const int crt_easymode_f_size;
//---------------------------------------------------------------------------------
#endif //_crt_easymode_f_h_
//---------------------------------------------------------------------------------

View file

@ -0,0 +1,14 @@
/*
This file was autogenerated by raw2c.
Visit http://www.devkitpro.org
*/
//---------------------------------------------------------------------------------
#ifndef _fxaa_f_h_
#define _fxaa_f_h_
//---------------------------------------------------------------------------------
extern const unsigned char fxaa_f[];
extern const int fxaa_f_size;
//---------------------------------------------------------------------------------
#endif //_fxaa_f_h_
//---------------------------------------------------------------------------------

View file

@ -0,0 +1,14 @@
/*
This file was autogenerated by raw2c.
Visit http://www.devkitpro.org
*/
//---------------------------------------------------------------------------------
#ifndef _fxaa_v_h_
#define _fxaa_v_h_
//---------------------------------------------------------------------------------
extern const unsigned char fxaa_v[];
extern const int fxaa_v_size;
//---------------------------------------------------------------------------------
#endif //_fxaa_v_h_
//---------------------------------------------------------------------------------

View file

@ -0,0 +1,14 @@
/*
This file was autogenerated by raw2c.
Visit http://www.devkitpro.org
*/
//---------------------------------------------------------------------------------
#ifndef _gtu_f_h_
#define _gtu_f_h_
//---------------------------------------------------------------------------------
extern const unsigned char gtu_f[];
extern const int gtu_f_size;
//---------------------------------------------------------------------------------
#endif //_gtu_f_h_
//---------------------------------------------------------------------------------

View file

@ -0,0 +1,14 @@
/*
This file was autogenerated by raw2c.
Visit http://www.devkitpro.org
*/
//---------------------------------------------------------------------------------
#ifndef _gtu_v_h_
#define _gtu_v_h_
//---------------------------------------------------------------------------------
extern const unsigned char gtu_v[];
extern const int gtu_v_size;
//---------------------------------------------------------------------------------
#endif //_gtu_v_h_
//---------------------------------------------------------------------------------

View file

@ -0,0 +1,14 @@
/*
This file was autogenerated by raw2c.
Visit http://www.devkitpro.org
*/
//---------------------------------------------------------------------------------
#ifndef _lcd3x_f_h_
#define _lcd3x_f_h_
//---------------------------------------------------------------------------------
extern const unsigned char lcd3x_f[];
extern const int lcd3x_f_size;
//---------------------------------------------------------------------------------
#endif //_lcd3x_f_h_
//---------------------------------------------------------------------------------

View file

@ -0,0 +1,14 @@
/*
This file was autogenerated by raw2c.
Visit http://www.devkitpro.org
*/
//---------------------------------------------------------------------------------
#ifndef _lcd3x_v_h_
#define _lcd3x_v_h_
//---------------------------------------------------------------------------------
extern const unsigned char lcd3x_v[];
extern const int lcd3x_v_size;
//---------------------------------------------------------------------------------
#endif //_lcd3x_v_h_
//---------------------------------------------------------------------------------

View file

@ -0,0 +1,14 @@
/*
This file was autogenerated by raw2c.
Visit http://www.devkitpro.org
*/
//---------------------------------------------------------------------------------
#ifndef _opaque_f_h_
#define _opaque_f_h_
//---------------------------------------------------------------------------------
extern const unsigned char opaque_f[];
extern const int opaque_f_size;
//---------------------------------------------------------------------------------
#endif //_opaque_f_h_
//---------------------------------------------------------------------------------

View file

@ -0,0 +1,14 @@
/*
This file was autogenerated by raw2c.
Visit http://www.devkitpro.org
*/
//---------------------------------------------------------------------------------
#ifndef _opaque_v_h_
#define _opaque_v_h_
//---------------------------------------------------------------------------------
extern const unsigned char opaque_v[];
extern const int opaque_v_size;
//---------------------------------------------------------------------------------
#endif //_opaque_v_h_
//---------------------------------------------------------------------------------

View file

@ -0,0 +1,14 @@
/*
This file was autogenerated by raw2c.
Visit http://www.devkitpro.org
*/
//---------------------------------------------------------------------------------
#ifndef _ribbon_f_h_
#define _ribbon_f_h_
//---------------------------------------------------------------------------------
extern const unsigned char ribbon_f[];
extern const int ribbon_f_size;
//---------------------------------------------------------------------------------
#endif //_ribbon_f_h_
//---------------------------------------------------------------------------------

View file

@ -0,0 +1,14 @@
/*
This file was autogenerated by raw2c.
Visit http://www.devkitpro.org
*/
//---------------------------------------------------------------------------------
#ifndef _ribbon_simple_f_h_
#define _ribbon_simple_f_h_
//---------------------------------------------------------------------------------
extern const unsigned char ribbon_simple_f[];
extern const int ribbon_simple_f_size;
//---------------------------------------------------------------------------------
#endif //_ribbon_simple_f_h_
//---------------------------------------------------------------------------------

View file

@ -0,0 +1,14 @@
/*
This file was autogenerated by raw2c.
Visit http://www.devkitpro.org
*/
//---------------------------------------------------------------------------------
#ifndef _ribbon_simple_v_h_
#define _ribbon_simple_v_h_
//---------------------------------------------------------------------------------
extern const unsigned char ribbon_simple_v[];
extern const int ribbon_simple_v_size;
//---------------------------------------------------------------------------------
#endif //_ribbon_simple_v_h_
//---------------------------------------------------------------------------------

View file

@ -0,0 +1,14 @@
/*
This file was autogenerated by raw2c.
Visit http://www.devkitpro.org
*/
//---------------------------------------------------------------------------------
#ifndef _ribbon_v_h_
#define _ribbon_v_h_
//---------------------------------------------------------------------------------
extern const unsigned char ribbon_v[];
extern const int ribbon_v_size;
//---------------------------------------------------------------------------------
#endif //_ribbon_v_h_
//---------------------------------------------------------------------------------

View file

@ -0,0 +1,14 @@
/*
This file was autogenerated by raw2c.
Visit http://www.devkitpro.org
*/
//---------------------------------------------------------------------------------
#ifndef _scale2x_f_h_
#define _scale2x_f_h_
//---------------------------------------------------------------------------------
extern const unsigned char scale2x_f[];
extern const int scale2x_f_size;
//---------------------------------------------------------------------------------
#endif //_scale2x_f_h_
//---------------------------------------------------------------------------------

View file

@ -0,0 +1,14 @@
/*
This file was autogenerated by raw2c.
Visit http://www.devkitpro.org
*/
//---------------------------------------------------------------------------------
#ifndef _scale2x_v_h_
#define _scale2x_v_h_
//---------------------------------------------------------------------------------
extern const unsigned char scale2x_v[];
extern const int scale2x_v_size;
//---------------------------------------------------------------------------------
#endif //_scale2x_v_h_
//---------------------------------------------------------------------------------

View file

@ -0,0 +1,14 @@
/*
This file was autogenerated by raw2c.
Visit http://www.devkitpro.org
*/
//---------------------------------------------------------------------------------
#ifndef _sharp_bilinear_f_h_
#define _sharp_bilinear_f_h_
//---------------------------------------------------------------------------------
extern const unsigned char sharp_bilinear_f[];
extern const int sharp_bilinear_f_size;
//---------------------------------------------------------------------------------
#endif //_sharp_bilinear_f_h_
//---------------------------------------------------------------------------------

View file

@ -0,0 +1,14 @@
/*
This file was autogenerated by raw2c.
Visit http://www.devkitpro.org
*/
//---------------------------------------------------------------------------------
#ifndef _sharp_bilinear_simple_f_h_
#define _sharp_bilinear_simple_f_h_
//---------------------------------------------------------------------------------
extern const unsigned char sharp_bilinear_simple_f[];
extern const int sharp_bilinear_simple_f_size;
//---------------------------------------------------------------------------------
#endif //_sharp_bilinear_simple_f_h_
//---------------------------------------------------------------------------------

View file

@ -0,0 +1,14 @@
/*
This file was autogenerated by raw2c.
Visit http://www.devkitpro.org
*/
//---------------------------------------------------------------------------------
#ifndef _sharp_bilinear_simple_v_h_
#define _sharp_bilinear_simple_v_h_
//---------------------------------------------------------------------------------
extern const unsigned char sharp_bilinear_simple_v[];
extern const int sharp_bilinear_simple_v_size;
//---------------------------------------------------------------------------------
#endif //_sharp_bilinear_simple_v_h_
//---------------------------------------------------------------------------------

View file

@ -0,0 +1,14 @@
/*
This file was autogenerated by raw2c.
Visit http://www.devkitpro.org
*/
//---------------------------------------------------------------------------------
#ifndef _sharp_bilinear_v_h_
#define _sharp_bilinear_v_h_
//---------------------------------------------------------------------------------
extern const unsigned char sharp_bilinear_v[];
extern const int sharp_bilinear_v_size;
//---------------------------------------------------------------------------------
#endif //_sharp_bilinear_v_h_
//---------------------------------------------------------------------------------

View file

@ -0,0 +1,14 @@
/*
This file was autogenerated by raw2c.
Visit http://www.devkitpro.org
*/
//---------------------------------------------------------------------------------
#ifndef _texture_f_h_
#define _texture_f_h_
//---------------------------------------------------------------------------------
extern const unsigned char texture_f[];
extern const int texture_f_size;
//---------------------------------------------------------------------------------
#endif //_texture_f_h_
//---------------------------------------------------------------------------------

View file

@ -0,0 +1,14 @@
/*
This file was autogenerated by raw2c.
Visit http://www.devkitpro.org
*/
//---------------------------------------------------------------------------------
#ifndef _texture_tint_f_h_
#define _texture_tint_f_h_
//---------------------------------------------------------------------------------
extern const unsigned char texture_tint_f[];
extern const int texture_tint_f_size;
//---------------------------------------------------------------------------------
#endif //_texture_tint_f_h_
//---------------------------------------------------------------------------------

View file

@ -0,0 +1,14 @@
/*
This file was autogenerated by raw2c.
Visit http://www.devkitpro.org
*/
//---------------------------------------------------------------------------------
#ifndef _texture_v_h_
#define _texture_v_h_
//---------------------------------------------------------------------------------
extern const unsigned char texture_v[];
extern const int texture_v_size;
//---------------------------------------------------------------------------------
#endif //_texture_v_h_
//---------------------------------------------------------------------------------

View file

@ -0,0 +1,14 @@
/*
This file was autogenerated by raw2c.
Visit http://www.devkitpro.org
*/
//---------------------------------------------------------------------------------
#ifndef _xbr_2x_f_h_
#define _xbr_2x_f_h_
//---------------------------------------------------------------------------------
extern const unsigned char xbr_2x_f[];
extern const int xbr_2x_f_size;
//---------------------------------------------------------------------------------
#endif //_xbr_2x_f_h_
//---------------------------------------------------------------------------------

View file

@ -0,0 +1,14 @@
/*
This file was autogenerated by raw2c.
Visit http://www.devkitpro.org
*/
//---------------------------------------------------------------------------------
#ifndef _xbr_2x_fast_f_h_
#define _xbr_2x_fast_f_h_
//---------------------------------------------------------------------------------
extern const unsigned char xbr_2x_fast_f[];
extern const int xbr_2x_fast_f_size;
//---------------------------------------------------------------------------------
#endif //_xbr_2x_fast_f_h_
//---------------------------------------------------------------------------------

View file

@ -0,0 +1,14 @@
/*
This file was autogenerated by raw2c.
Visit http://www.devkitpro.org
*/
//---------------------------------------------------------------------------------
#ifndef _xbr_2x_fast_v_h_
#define _xbr_2x_fast_v_h_
//---------------------------------------------------------------------------------
extern const unsigned char xbr_2x_fast_v[];
extern const int xbr_2x_fast_v_size;
//---------------------------------------------------------------------------------
#endif //_xbr_2x_fast_v_h_
//---------------------------------------------------------------------------------

View file

@ -0,0 +1,14 @@
/*
This file was autogenerated by raw2c.
Visit http://www.devkitpro.org
*/
//---------------------------------------------------------------------------------
#ifndef _xbr_2x_noblend_f_h_
#define _xbr_2x_noblend_f_h_
//---------------------------------------------------------------------------------
extern const unsigned char xbr_2x_noblend_f[];
extern const int xbr_2x_noblend_f_size;
//---------------------------------------------------------------------------------
#endif //_xbr_2x_noblend_f_h_
//---------------------------------------------------------------------------------

View file

@ -0,0 +1,14 @@
/*
This file was autogenerated by raw2c.
Visit http://www.devkitpro.org
*/
//---------------------------------------------------------------------------------
#ifndef _xbr_2x_noblend_v_h_
#define _xbr_2x_noblend_v_h_
//---------------------------------------------------------------------------------
extern const unsigned char xbr_2x_noblend_v[];
extern const int xbr_2x_noblend_v_size;
//---------------------------------------------------------------------------------
#endif //_xbr_2x_noblend_v_h_
//---------------------------------------------------------------------------------

View file

@ -0,0 +1,14 @@
/*
This file was autogenerated by raw2c.
Visit http://www.devkitpro.org
*/
//---------------------------------------------------------------------------------
#ifndef _xbr_2x_v_h_
#define _xbr_2x_v_h_
//---------------------------------------------------------------------------------
extern const unsigned char xbr_2x_v[];
extern const int xbr_2x_v_size;
//---------------------------------------------------------------------------------
#endif //_xbr_2x_v_h_
//---------------------------------------------------------------------------------

View file

@ -0,0 +1,189 @@
#ifndef VITA2D_H
#define VITA2D_H
#include <psp2/gxm.h>
#include <psp2/types.h>
#include <psp2/kernel/sysmem.h>
#include <psp2/pgf.h>
#ifdef __cplusplus
extern "C" {
#endif
#define RGBA8(r,g,b,a) ((((a)&0xFF)<<24) | (((b)&0xFF)<<16) | (((g)&0xFF)<<8) | (((r)&0xFF)<<0))
typedef struct vita2d_clear_vertex {
float x;
float y;
} vita2d_clear_vertex;
typedef struct vita2d_color_vertex {
float x;
float y;
float z;
unsigned int color;
} vita2d_color_vertex;
typedef struct vita2d_texture_vertex {
float x;
float y;
float z;
float w;
float u;
float v;
} vita2d_texture_vertex;
typedef struct vita2d_texture {
SceGxmTexture gxm_tex;
SceUID data_UID;
SceUID palette_UID;
SceGxmRenderTarget *gxm_rtgt;
SceGxmColorSurface gxm_sfc;
SceGxmDepthStencilSurface gxm_sfd;
SceUID depth_UID;
} vita2d_texture;
typedef struct vita2d_shader_input{
SceGxmProgramParameter * video_size;
SceGxmProgramParameter * texture_size;
SceGxmProgramParameter * output_size;
SceGxmProgramParameter * frame_count;
SceGxmProgramParameter * frame_direction;
SceGxmProgramParameter * frame_rotation;
} vita2d_shader_input;
typedef struct vita2d_shader {
SceGxmShaderPatcherId vertexProgramId;
SceGxmShaderPatcherId fragmentProgramId;
SceGxmVertexProgram *vertexProgram;
SceGxmFragmentProgram *fragmentProgram;
SceGxmProgramParameter * paramPositionAttribute;
SceGxmProgramParameter * paramTexcoordAttribute;
SceGxmProgramParameter * wvpParam;
vita2d_shader_input vertexInput;
vita2d_shader_input fragmentInput;
} vita2d_shader;
typedef struct vita2d_system_pgf_config {
SceFontLanguageCode code;
int (*in_font_group)(unsigned int c);
} vita2d_system_pgf_config;
typedef struct vita2d_font vita2d_font;
typedef struct vita2d_pgf vita2d_pgf;
typedef enum vita2d_start_drawing_flags {
VITA_2D_SCENE_FRAGMENT_SET_DEPENDENCY = 0x00000001u,
VITA_2D_SCENE_VERTEX_WAIT_FOR_DEPENDENCY = 0x00000002u,
VITA_2D_RESET_POOL
= 0x00000010u
} vita2d_start_drawing_flags;
int vita2d_init();
int vita2d_init_advanced(unsigned int temp_pool_size);
void vita2d_wait_rendering_done();
int vita2d_fini();
void vita2d_clear_screen();
void vita2d_swap_buffers();
void vita2d_start_drawing();
void vita2d_start_drawing_advanced(vita2d_texture *target, vita2d_start_drawing_flags flags);
void vita2d_end_drawing();
int vita2d_common_dialog_update();
void vita2d_set_clear_color(unsigned int color);
void vita2d_set_vblank_wait(int enable);
void *vita2d_get_current_fb();
void vita2d_set_region_clip(SceGxmRegionClipMode mode, unsigned int x_min, unsigned int y_min, unsigned int x_max, unsigned int y_max);
void *vita2d_pool_malloc(unsigned int size);
void *vita2d_pool_memalign(unsigned int size, unsigned int alignment);
unsigned int vita2d_pool_free_space();
void vita2d_pool_reset();
void vita2d_draw_pixel(float x, float y, unsigned int color);
void vita2d_draw_line(float x0, float y0, float x1, float y1, unsigned int color);
void vita2d_draw_rectangle(float x, float y, float w, float h, unsigned int color);
void vita2d_draw_fill_circle(float x, float y, float radius, unsigned int color);
void vita2d_texture_set_alloc_memblock_type(SceKernelMemBlockType type);
SceKernelMemBlockType vita2d_texture_get_alloc_memblock_type();
vita2d_texture *vita2d_create_empty_texture(unsigned int w, unsigned int h);
vita2d_texture *vita2d_create_empty_texture_format(unsigned int w, unsigned int h, SceGxmTextureFormat format);
void vita2d_free_texture(vita2d_texture *texture);
unsigned int vita2d_texture_get_width(const vita2d_texture *texture);
unsigned int vita2d_texture_get_height(const vita2d_texture *texture);
unsigned int vita2d_texture_get_stride(const vita2d_texture *texture);
SceGxmTextureFormat vita2d_texture_get_format(const vita2d_texture *texture);
void *vita2d_texture_get_datap(const vita2d_texture *texture);
void *vita2d_texture_get_palette(const vita2d_texture *texture);
SceGxmTextureFilter vita2d_texture_get_min_filter(const vita2d_texture *texture);
SceGxmTextureFilter vita2d_texture_get_mag_filter(const vita2d_texture *texture);
void vita2d_texture_set_filters(vita2d_texture *texture, SceGxmTextureFilter min_filter, SceGxmTextureFilter mag_filter);
void vita2d_draw_texture(const vita2d_texture *texture, float x, float y);
void vita2d_draw_texture_rotate(const vita2d_texture *texture, float x, float y, float rad);
void vita2d_draw_texture_rotate_hotspot(const vita2d_texture *texture, float x, float y, float rad, float center_x, float center_y);
void vita2d_draw_texture_scale(const vita2d_texture *texture, float x, float y, float x_scale, float y_scale);
void vita2d_draw_texture_part(const vita2d_texture *texture, float x, float y, float tex_x, float tex_y, float tex_w, float tex_h);
void vita2d_draw_texture_part_scale(const vita2d_texture *texture, float x, float y, float tex_x, float tex_y, float tex_w, float tex_h, float x_scale, float y_scale);
void vita2d_draw_texture_scale_rotate_hotspot(const vita2d_texture *texture, float x, float y, float x_scale, float y_scale, float rad, float center_x, float center_y);
void vita2d_draw_texture_scale_rotate(const vita2d_texture *texture, float x, float y, float x_scale, float y_scale, float rad);
void vita2d_draw_texture_part_scale_rotate(const vita2d_texture *texture, float x, float y, float tex_x, float tex_y, float tex_w, float tex_h, float x_scale, float y_scale, float rad);
void vita2d_draw_texture_tint(const vita2d_texture *texture, float x, float y, unsigned int color);
void vita2d_draw_texture_tint_rotate(const vita2d_texture *texture, float x, float y, float rad, unsigned int color);
void vita2d_draw_texture_tint_rotate_hotspot(const vita2d_texture *texture, float x, float y, float rad, float center_x, float center_y, unsigned int color);
void vita2d_draw_texture_tint_scale(const vita2d_texture *texture, float x, float y, float x_scale, float y_scale, unsigned int color);
void vita2d_draw_texture_tint_part(const vita2d_texture *texture, float x, float y, float tex_x, float tex_y, float tex_w, float tex_h, unsigned int color);
void vita2d_draw_texture_tint_part_scale(const vita2d_texture *texture, float x, float y, float tex_x, float tex_y, float tex_w, float tex_h, float x_scale, float y_scale, unsigned int color);
void vita2d_draw_texture_tint_scale_rotate_hotspot(const vita2d_texture *texture, float x, float y, float x_scale, float y_scale, float rad, float center_x, float center_y, unsigned int color);
void vita2d_draw_texture_tint_scale_rotate(const vita2d_texture *texture, float x, float y, float x_scale, float y_scale, float rad, unsigned int color);
void vita2d_draw_texture_part_tint_scale_rotate(const vita2d_texture *texture, float x, float y, float tex_x, float tex_y, float tex_w, float tex_h, float x_scale, float y_scale, float rad, unsigned int color);
vita2d_texture *vita2d_load_PNG_file(const char *filename);
vita2d_texture *vita2d_load_PNG_buffer(const void *buffer);
vita2d_texture *vita2d_load_JPEG_file(const char *filename);
vita2d_texture *vita2d_load_JPEG_buffer(const void *buffer, unsigned long buffer_size);
vita2d_texture *vita2d_load_BMP_file(const char *filename);
vita2d_texture *vita2d_load_BMP_buffer(const void *buffer);
vita2d_font *vita2d_load_font_file(const char *filename);
vita2d_font *vita2d_load_font_mem(const void *buffer, unsigned int size);
void vita2d_free_font(vita2d_font *font);
int vita2d_font_draw_text(vita2d_font *font, int x, int y, unsigned int color, unsigned int size, const char *text);
int vita2d_font_draw_textf(vita2d_font *font, int x, int y, unsigned int color, unsigned int size, const char *text, ...);
void vita2d_font_text_dimensions(vita2d_font *font, unsigned int size, const char *text, int *width, int *height);
int vita2d_font_text_width(vita2d_font *font, unsigned int size, const char *text);
int vita2d_font_text_height(vita2d_font *font, unsigned int size, const char *text);
/* PGF functions are weak imports at the moment, they have to be resolved manually */
vita2d_pgf *vita2d_load_system_pgf(int numFonts, const vita2d_system_pgf_config *configs);
vita2d_pgf *vita2d_load_default_pgf();
vita2d_pgf *vita2d_load_custom_pgf(const char *path);
void vita2d_free_pgf(vita2d_pgf *font);
int vita2d_pgf_draw_text(vita2d_pgf *font, int x, int y, unsigned int color, float scale, const char *text);
int vita2d_pgf_draw_textf(vita2d_pgf *font, int x, int y, unsigned int color, float scale, const char *text, ...);
void vita2d_pgf_text_dimensions(vita2d_pgf *font, float scale, const char *text, int *width, int *height);
int vita2d_pgf_text_width(vita2d_pgf *font, float scale, const char *text);
int vita2d_pgf_text_height(vita2d_pgf *font, float scale, const char *text);
vita2d_shader *vita2d_create_shader(const SceGxmProgram* vertexProgramGxp, const SceGxmProgram* fragmentProgramGxp);
vita2d_shader *vita2d_create_shader_untextured(const SceGxmProgram* vertexProgramGxp, const SceGxmProgram* fragmentProgramGxp);
void vita2d_texture_set_program(SceGxmVertexProgram *vertexProgram, SceGxmFragmentProgram *fragmentProgram);
void vita2d_texture_set_wvp(SceGxmProgramParameter *wvpParam);
void vita2d_texture_set_vertexInput(vita2d_shader_input *input);
void vita2d_texture_set_fragmentInput(vita2d_shader_input *input);
void vita2d_free_shader(vita2d_shader *shader);
#ifdef __cplusplus
}
#endif
#endif

View file

@ -0,0 +1,129 @@
#ifdef USE_SDL2
#include <SDL.h>
static SDL_Window* window = NULL;
static SDL_Texture* texture = NULL;
static SDL_Texture* prescaled = NULL;
static SDL_Renderer* renderer = NULL;
int prescale_factor_x = 1;
int prescale_factor_y = 1;
int prescaled_width = 320;
int prescaled_height = 240;
int surface_width = 320;
int surface_height = 240;
static int x_offset;
static int y_offset;
static int scaled_height;
static int scaled_width;
static int display_width;
static int display_height;
extern int mainMenu_shader;
extern int mainMenu_displayedLines;
extern int mainMenu_displayHires;
extern int visibleAreaWidth;
extern int displaying_menu;
//uint32_t *texture_pixels=NULL;
extern void update_joycon_mode(void);
#define MIN(a,b) ((a) < (b) ? (a) : (b))
SDL_Surface *SDL_SetVideoMode(int w, int h, int bpp, int flags) {
if (!renderer) {
window = SDL_CreateWindow("uae4all2", 0, 0, 0, 0, SDL_WINDOW_FULLSCREEN_DESKTOP);
renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE);
SDL_RenderClear(renderer);
SDL_DisplayMode DM;
SDL_GetCurrentDisplayMode(0, &DM);
display_width = DM.w;
display_height = DM.h;
}
SDL_Surface *surface = SDL_CreateRGBSurfaceWithFormat(0, w, h, 16, SDL_PIXELFORMAT_RGB565);
surface_width = w;
surface_height = h;
return surface;
}
void SDL_SetVideoModeScaling(int x, int y, float sw, float sh) {
if (mainMenu_shader != 0 && !displaying_menu) {
x_offset = (x * display_width) / 960;
y_offset = (y * display_height) / 544;
scaled_width = (sw * display_width) / 960;
scaled_height = (sh * display_height) / 544;
} else {
int screen_width = 320;
int screen_height = 240;
if (!displaying_menu) {
screen_width = visibleAreaWidth;
if (mainMenu_displayHires)
screen_height = 2 * mainMenu_displayedLines;
else
screen_height = mainMenu_displayedLines;
}
int scale_factor = MIN(display_height / screen_height, display_width / screen_width);
scaled_height = (float) (scale_factor * screen_height);
scaled_width = (float) (scale_factor * screen_width);
x_offset = (display_width - scaled_width) / 2;
y_offset = (display_height - scaled_height) / 2;
}
if (prescaled) {
SDL_DestroyTexture(prescaled);
prescaled = NULL;
}
if (mainMenu_shader == 1) {
prescale_factor_x = scaled_width / surface_width;
prescale_factor_y = scaled_height / surface_height;
prescaled_width = prescale_factor_x * surface_width;
prescaled_height = prescale_factor_y * surface_height;
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "linear");
prescaled = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA8888, SDL_TEXTUREACCESS_TARGET, prescaled_width, prescaled_height);
}
}
void SDL_SetVideoModeBilinear(int value) {
if (value && (mainMenu_shader != 3)) // no linear filtering when shader = SHADER_POINT
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "linear");
else
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "nearest");
}
void SDL_SetVideoModeSync(int value) {
if (1)
SDL_SetHint(SDL_HINT_RENDER_VSYNC, "1");
else
SDL_SetHint(SDL_HINT_RENDER_VSYNC, "0");
}
void SDL_Flip(SDL_Surface *surface) {
update_joycon_mode();
if (surface && renderer && window) {
if (texture) {
SDL_DestroyTexture(texture);
texture = NULL;
}
if (mainMenu_shader == 1 && !displaying_menu) {
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "nearest");
texture = SDL_CreateTextureFromSurface(renderer, surface);
SDL_SetRenderTarget(renderer, prescaled);
SDL_Rect dst_rect_prescale = { 0, 0, prescaled_width, prescaled_height };
SDL_Rect *src_rect_prescale = NULL;
SDL_RenderCopy(renderer, texture, src_rect_prescale, &dst_rect_prescale);
SDL_SetRenderTarget(renderer, NULL);
SDL_Rect dst_rect = { x_offset, y_offset, scaled_width , scaled_height };
SDL_Rect *src_rect = NULL;
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "linear");
SDL_RenderCopy(renderer, prescaled, src_rect, &dst_rect);
SDL_RenderPresent(renderer);
} else {
texture = SDL_CreateTextureFromSurface(renderer, surface);
SDL_Rect dst_rect = { x_offset, y_offset, scaled_width, scaled_height };
SDL_Rect *src_rect = NULL;
SDL_RenderCopy(renderer, texture, src_rect, &dst_rect);
SDL_RenderPresent(renderer);
}
}
}
#endif

View file

@ -0,0 +1,41 @@
// SDL 2 to SDL 1 interface by rsn8887
// to port uae4all2 to Switch
// created 10/29/2018
#ifdef USE_SDL2
#ifndef SDL2_TO_SDL1_H
#define SDL2_TO_SDL1_H
#include <SDL.h>
extern SDL_Surface *prSDLScreen;
#define SDL_HWSURFACE 0
#define SDL_DOUBLEBUF 0
#define SDL_CreateThread(x,y) SDL_CreateThread(x,"uae_thread",y)
#define SDLKey SDL_Keycode
#define SDLKey SDL_Keycode
#define SDLK_KP0 SDLK_KP_0
#define SDLK_KP1 SDLK_KP_1
#define SDLK_KP2 SDLK_KP_2
#define SDLK_KP3 SDLK_KP_3
#define SDLK_KP4 SDLK_KP_4
#define SDLK_KP5 SDLK_KP_5
#define SDLK_KP6 SDLK_KP_6
#define SDLK_KP7 SDLK_KP_7
#define SDLK_KP8 SDLK_KP_8
#define SDLK_KP9 SDLK_KP_9
#define SDLK_LMETA SDLK_LGUI
#define SDLK_RMETA SDLK_RGUI
#define SDL_keysym SDL_Keysym
#define SDL_DisplayFormat(x) SDL_ConvertSurface(x,prSDLScreen->format,0)
#define SDL_SetAlpha(x,y,z) SDL_SetSurfaceAlphaMod(x,z); SDL_SetSurfaceBlendMode(x, SDL_BLENDMODE_BLEND);
SDL_Surface *SDL_SetVideoMode(int w, int h, int bpp, int flags);
void SDL_SetVideoModeScaling(int x, int y, float sw, float sh);
void SDL_SetVideoModeBilinear(int value);
void SDL_Flip(SDL_Surface *surface);
void SDL_SetVideoModeSync(int value);
#endif
#endif

View file

@ -0,0 +1,347 @@
//
// Created by rsn8887 on 05/18/18.
#if defined(__vita__)
#include <psp2/kernel/processmgr.h>
#define displayWidth 960.0
#define displayHeight 544.0
#endif
#if defined(__SWITCH__)
#define SCE_TOUCH_PORT_MAX_NUM 1
#define displayWidth 1280.0
#define displayHeight 720.0
#endif
#include "switch_touch.h"
#include "math.h"
static void initTouch();
static void preprocessEvents(SDL_Event *event);
static void preprocessFingerDown(SDL_Event *event);
static void preprocessFingerUp(SDL_Event *event);
static void preprocessFingerMotion(SDL_Event *event);
static int psp2RearTouch = 0; // always disable rear_touch for now
extern int lastmx;
extern int lastmy;
static int touch_initialized = 0;
unsigned int _simulatedClickStartTime[SCE_TOUCH_PORT_MAX_NUM][2]; // initiation time of last simulated left or right click (zero if no click)
static int hiresdx = 0;
static int hiresdy = 0;
enum {
MAX_NUM_FINGERS = 3, // number of fingers to track per panel
MAX_TAP_TIME = 250, // taps longer than this will not result in mouse click events
MAX_TAP_MOTION_DISTANCE = 10, // max distance finger motion in Vita screen pixels to be considered a tap
SIMULATED_CLICK_DURATION = 50, // time in ms how long simulated mouse clicks should be
}; // track three fingers per panel
typedef struct {
int id; // -1: no touch
Uint32 timeLastDown;
int lastX; // last known screen coordinates
int lastY; // last known screen coordinates
float lastDownX; // SDL touch coordinates when last pressed down
float lastDownY; // SDL touch coordinates when last pressed down
} Touch;
Touch _finger[SCE_TOUCH_PORT_MAX_NUM][MAX_NUM_FINGERS]; // keep track of finger status
typedef enum DraggingType {
DRAG_NONE = 0,
DRAG_TWO_FINGER,
DRAG_THREE_FINGER,
} DraggingType;
DraggingType _multiFingerDragging[SCE_TOUCH_PORT_MAX_NUM]; // keep track whether we are currently drag-and-dropping
typedef int bool;
#define false 0;
#define true 1;
static void initTouch() {
for (int port = 0; port < SCE_TOUCH_PORT_MAX_NUM; port++) {
for (int i = 0; i < MAX_NUM_FINGERS; i++) {
_finger[port][i].id = -1;
}
_multiFingerDragging[port] = DRAG_NONE;
}
for (int port = 0; port < SCE_TOUCH_PORT_MAX_NUM; port++) {
for (int i = 0; i < 2; i++) {
_simulatedClickStartTime[port][i] = 0;
}
}
}
void SWITCH_HandleTouch(SDL_Event *event) {
if (!touch_initialized) {
initTouch();
touch_initialized = 1;
}
preprocessEvents(event);
}
static void preprocessEvents(SDL_Event *event) {
#if defined(__vita__)
// prevent suspend (scummvm games contain a lot of cutscenes..)
sceKernelPowerTick(SCE_KERNEL_POWER_TICK_DISABLE_AUTO_SUSPEND);
sceKernelPowerTick(SCE_KERNEL_POWER_TICK_DISABLE_OLED_OFF);
#endif
// Supported touch gestures:
// left mouse click: single finger short tap
// right mouse click: second finger short tap while first finger is still down
// pointer motion: single finger drag
// left button drag and drop: dual finger drag
// right button drag and drop: triple finger drag
if (event->type == SDL_FINGERDOWN || event->type == SDL_FINGERUP || event->type == SDL_FINGERMOTION) {
// front (0) or back (1) panel
SDL_TouchID port = event->tfinger.touchId;
if (port < SCE_TOUCH_PORT_MAX_NUM && port >= 0) {
if (port == 0 || psp2RearTouch) {
switch (event->type) {
case SDL_FINGERDOWN:
preprocessFingerDown(event);
break;
case SDL_FINGERUP:
preprocessFingerUp(event);
break;
case SDL_FINGERMOTION:
preprocessFingerMotion(event);
break;
}
}
}
}
}
static void preprocessFingerDown(SDL_Event *event) {
// front (0) or back (1) panel
SDL_TouchID port = event->tfinger.touchId;
// id (for multitouch)
SDL_FingerID id = event->tfinger.fingerId;
int x = lastmx;
int y = lastmy;
// make sure each finger is not reported down multiple times
for (int i = 0; i < MAX_NUM_FINGERS; i++) {
if (_finger[port][i].id == id) {
_finger[port][i].id = -1;
}
}
// we need the timestamps to decide later if the user performed a short tap (click)
// or a long tap (drag)
// we also need the last coordinates for each finger to keep track of dragging
for (int i = 0; i < MAX_NUM_FINGERS; i++) {
if (_finger[port][i].id == -1) {
_finger[port][i].id = id;
_finger[port][i].timeLastDown = event->tfinger.timestamp;
_finger[port][i].lastDownX = event->tfinger.x;
_finger[port][i].lastDownY = event->tfinger.y;
_finger[port][i].lastX = x;
_finger[port][i].lastY = y;
break;
}
}
}
static void preprocessFingerUp(SDL_Event *event) {
// front (0) or back (1) panel
SDL_TouchID port = event->tfinger.touchId;
// id (for multitouch)
SDL_FingerID id = event->tfinger.fingerId;
// find out how many fingers were down before this event
int numFingersDown = 0;
for (int i = 0; i < MAX_NUM_FINGERS; i++) {
if (_finger[port][i].id >= 0) {
numFingersDown++;
}
}
int x = lastmx;
int y = lastmy;
for (int i = 0; i < MAX_NUM_FINGERS; i++) {
if (_finger[port][i].id == id) {
_finger[port][i].id = -1;
if (!_multiFingerDragging[port]) {
if ((event->tfinger.timestamp - _finger[port][i].timeLastDown) <= MAX_TAP_TIME) {
// short (<MAX_TAP_TIME ms) tap is interpreted as right/left mouse click depending on # fingers already down
// but only if the finger hasn't moved since it was pressed down by more than MAX_TAP_MOTION_DISTANCE pixels
float xrel = ((event->tfinger.x * displayWidth) - (_finger[port][i].lastDownX * displayWidth));
float yrel = ((event->tfinger.y * displayHeight) - (_finger[port][i].lastDownY * displayHeight));
float maxRSquared = (float) (MAX_TAP_MOTION_DISTANCE * MAX_TAP_MOTION_DISTANCE);
if ((xrel * xrel + yrel * yrel) < maxRSquared) {
if (numFingersDown == 2 || numFingersDown == 1) {
Uint8 simulatedButton = 0;
if (numFingersDown == 2) {
simulatedButton = SDL_BUTTON_RIGHT;
// need to raise the button later
_simulatedClickStartTime[port][1] = event->tfinger.timestamp;
} else if (numFingersDown == 1) {
simulatedButton = SDL_BUTTON_LEFT;
// need to raise the button later
_simulatedClickStartTime[port][0] = event->tfinger.timestamp;
}
event->type = SDL_MOUSEBUTTONDOWN;
event->button.button = simulatedButton;
event->button.state = SDL_PRESSED;
event->button.x = x;
event->button.y = y;
}
}
}
} else if (numFingersDown == 1) {
// when dragging, and the last finger is lifted, the drag is over
Uint8 simulatedButton = 0;
if (_multiFingerDragging[port] == DRAG_THREE_FINGER)
simulatedButton = SDL_BUTTON_RIGHT;
else {
simulatedButton = SDL_BUTTON_LEFT;
}
event->type = SDL_MOUSEBUTTONUP;
event->button.button = simulatedButton;
event->button.state = SDL_RELEASED;
event->button.x = x;
event->button.y = y;
_multiFingerDragging[port] = DRAG_NONE;
}
}
}
}
static void preprocessFingerMotion(SDL_Event *event) {
// front (0) or back (1) panel
SDL_TouchID port = event->tfinger.touchId;
// id (for multitouch)
SDL_FingerID id = event->tfinger.fingerId;
// find out how many fingers were down before this event
int numFingersDown = 0;
for (int i = 0; i < MAX_NUM_FINGERS; i++) {
if (_finger[port][i].id >= 0) {
numFingersDown++;
}
}
if (numFingersDown >= 1) {
int x = lastmx;
int y = lastmy;
int xrel = (int)(event->tfinger.dx * displayWidth);
int yrel = (int)(event->tfinger.dy * displayHeight);
x = lastmx + (int)(event->tfinger.dx * displayWidth);
y = lastmy + (int)(event->tfinger.dy * displayHeight);
// update the current finger's coordinates so we can track it later
for (int i = 0; i < MAX_NUM_FINGERS; i++) {
if (_finger[port][i].id == id) {
_finger[port][i].lastX = x;
_finger[port][i].lastY = y;
}
}
// If we are starting a multi-finger drag, start holding down the mouse button
if (numFingersDown >= 2) {
if (!_multiFingerDragging[port]) {
// only start a multi-finger drag if at least two fingers have been down long enough
int numFingersDownLong = 0;
for (int i = 0; i < MAX_NUM_FINGERS; i++) {
if (_finger[port][i].id >= 0) {
if (event->tfinger.timestamp - _finger[port][i].timeLastDown > MAX_TAP_TIME) {
numFingersDownLong++;
}
}
}
if (numFingersDownLong >= 2) {
Uint8 simulatedButton = 0;
if (numFingersDownLong == 2) {
simulatedButton = SDL_BUTTON_LEFT;
_multiFingerDragging[port] = DRAG_TWO_FINGER;
} else {
simulatedButton = SDL_BUTTON_RIGHT;
_multiFingerDragging[port] = DRAG_THREE_FINGER;
}
int mouseDownX = lastmx;
int mouseDownY = lastmy;
SDL_Event ev;
ev.type = SDL_MOUSEBUTTONDOWN;
ev.button.button = simulatedButton;
ev.button.state = SDL_PRESSED;
ev.button.x = mouseDownX;
ev.button.y = mouseDownY;
SDL_PushEvent(&ev);
}
}
}
//check if this is the "oldest" finger down (or the only finger down), otherwise it will not affect mouse motion
bool updatePointer = true;
if (numFingersDown > 1) {
for (int i = 0; i < MAX_NUM_FINGERS; i++) {
if (_finger[port][i].id == id) {
for (int j = 0; j < MAX_NUM_FINGERS; j++) {
if (_finger[port][j].id >= 0 && (i != j) ) {
if (_finger[port][j].timeLastDown < _finger[port][i].timeLastDown) {
updatePointer = false;
}
}
}
}
}
}
if (updatePointer) {
const int slowdown = 16;
hiresdx += (int)(event->tfinger.dx * displayWidth * slowdown);
hiresdy += (int)(event->tfinger.dy * displayHeight * slowdown);
int xrel = hiresdx / slowdown;
int yrel = hiresdy / slowdown;
if (xrel || yrel) {
int x = lastmx + xrel;
int y = lastmy + yrel;
event->type = SDL_MOUSEMOTION;
event->motion.x = x;
event->motion.y = y;
event->motion.xrel = xrel;
event->motion.yrel = yrel;
hiresdx %= slowdown;
hiresdy %= slowdown;
}
}
}
}
void SWITCH_FinishSimulatedMouseClicks() {
for (int port = 0; port < SCE_TOUCH_PORT_MAX_NUM; port++) {
for (int i = 0; i < 2; i++) {
if (_simulatedClickStartTime[port][i] != 0) {
Uint32 currentTime = SDL_GetTicks();
if (currentTime - _simulatedClickStartTime[port][i] >= SIMULATED_CLICK_DURATION) {
int simulatedButton;
if (i == 0) {
simulatedButton = SDL_BUTTON_LEFT;
} else {
simulatedButton = SDL_BUTTON_RIGHT;
}
SDL_Event ev;
ev.type = SDL_MOUSEBUTTONUP;
ev.button.button = simulatedButton;
ev.button.state = SDL_RELEASED;
ev.button.x = lastmx;
ev.button.y = lastmy;
SDL_PushEvent(&ev);
_simulatedClickStartTime[port][i] = 0;
}
}
}
}
}

View file

@ -0,0 +1,21 @@
//
// Created by rsn8887 on 02/05/18.
#ifndef SWITCH_TOUCH_H
#define SWITCH_TOUCH_H
#include <SDL2/SDL.h>
#if defined(__vita__)
#include <psp2/touch.h>
#endif
#ifdef __cplusplus
extern "C" {
#endif
void SWITCH_HandleTouch(SDL_Event *event);
void SWITCH_FinishSimulatedMouseClicks();
#ifdef __cplusplus
}
#endif
#endif /* SWITCH_TOUCH_H */

View file

@ -3,7 +3,11 @@
#define SUPPORT_THREADS #define SUPPORT_THREADS
#include <limits.h> #include <limits.h>
#ifdef PATH_MAX
#define MAX_DPATH PATH_MAX #define MAX_DPATH PATH_MAX
#else
#define MAX_DPATH 4096
#endif
/* #define DRIVESOUND */ /* #define DRIVESOUND */
/* #define GFXFILTER */ /* #define GFXFILTER */

811
src/osdep/vkbd/vkbd.cpp Normal file
View file

@ -0,0 +1,811 @@
#include<stdio.h>
#include<stdlib.h>
#include<SDL.h>
#ifdef USE_SDL2
#include "sdl2_to_sdl1.h"
#endif
#include "vkbd.h"
#include "keyboard.h"
#define VKBD_MIN_HOLDING_TIME 200
#define VKBD_MOVE_DELAY 50
extern int keycode2amiga(SDL_keysym *prKeySym);
extern int mainMenu_displayHires;
extern int mainMenu_vkbdLanguage;
static int vkbd_x=VKBD_X;
static int vkbd_y=VKBD_Y;
static int vkbd_transparency=255;
static int vkbd_just_blinked=0;
static Uint32 vkbd_last_press_time=0;
static Uint32 vkbd_last_move_time=0;
// Keep track of keys that are sticky
t_vkbd_sticky_key vkbd_sticky_key[] =
{
{ AK_LSH, false, true, 70},
{ AK_RSH, false, true, 81},
{ AK_CTRL, false, true, 54},
{ AK_LALT, false, true, 85},
{ AK_RALT, false, true, 89},
{ AK_LAMI, false, true, 86},
{ AK_RAMI, false, true, 88}
};
int vkbd_let_go_of_direction=0;
int vkbd_mode=0;
int vkbd_move=0;
int vkbd_key=KEYCODE_NOTHING;
SDLKey vkbd_button2=(SDLKey)0; //not implemented
int vkbd_keysave=KEYCODE_NOTHING;
#if !defined (DREAMCAST) && !defined (GP2X) && !defined (PSP) && !defined (GIZMONDO)
int vkbd_init(void) { return 0; }
void vkbd_init_button2(void) { }
void vkbd_quit(void) { }
int vkbd_process(void) { return KEYCODE_NOTHING; }
void vkbd_displace_up(void) { };
void vkbd_displace_down(void) { };
void vkbd_transparency_up(void) { };
void vkbd_transparency_down(void) { };
#else
extern SDL_Surface *prSDLScreen;
static SDL_Surface *ksur;
static SDL_Surface *ksurHires;
static SDL_Surface *canvas; // intermediate surface used to highlight sticky keys
static SDL_Surface *canvasHires; // intermediate surface used to highlight sticky keys
static SDL_Surface *ksurShift;
static SDL_Surface *ksurShiftHires;
static int vkbd_actual=0, vkbd_color=0;
#ifdef GP2X
extern char launchDir [256];
#endif
typedef struct{
SDL_Rect rect;
unsigned char up,down,left,right;
int key;
} t_vkbd_rect;
static t_vkbd_rect *vkbd_rect;
//This is the new US keyboard, based directly on amiga-side keys
//last four numbers: next keys in up,down,left,right directions
static t_vkbd_rect vkbd_rect_US[]=
{
{{ 1, 1, 29, 11 },85,17,16, 1, AK_ESC}, // 0, row 1 start
{{ 31, 1, 14, 11 },86,18, 0, 2, AK_F1}, // 1
{{ 46, 1, 14, 11 },87,19, 1, 3, AK_F2}, // 2
{{ 61, 1, 14, 11 },87,20, 2, 4, AK_F3}, // 3
{{ 76, 1, 14, 11 },87,21, 3, 5, AK_F4}, // 4
{{ 91, 1, 14, 11 },87,22, 4, 6, AK_F5}, // 5
{{106, 1, 14, 11 },87,23, 5, 7, AK_F6}, // 6
{{121, 1, 14, 11 },87,24, 6, 8, AK_F7}, // 7
{{136, 1, 14, 11 },87,25, 7, 9, AK_F8}, // 8
{{151, 1, 14, 11 },87,26, 8,10, AK_F9}, // 9
{{166, 1, 14, 11 },87,27, 9,11, AK_F10}, // 10
{{181, 1, 29, 11 },88,28,10,12, AK_DEL}, // 11
{{211, 1, 29, 11 },90,30,11,13, AK_HELP}, // 12
{{241, 1, 14, 11 },92,32,12,14, AK_NPLPAREN}, // 13
{{256, 1, 14, 11 },69,33,13,15, AK_NPRPAREN}, // 14
{{271, 1, 14, 11 },69,34,14,16, AK_NPDIV}, // 15
{{286, 1, 14, 11 },69,35,15,0, AK_NPMUL}, // 16
{{ 1, 13, 29, 11 }, 0,36,35,18, AK_BACKQUOTE}, // 17, row 2 start
{{ 31, 13, 14, 11 }, 1,37,17,19, AK_1}, // 18
{{ 46, 13, 14, 11 }, 2,38,18,20, AK_2}, // 19
{{ 61, 13, 14, 11 }, 3,39,19,21, AK_3}, // 20
{{ 76, 13, 14, 11 }, 4,40,20,22, AK_4}, // 21
{{ 91, 13, 14, 11 }, 5,41,21,23, AK_5}, // 22
{{106, 13, 14, 11 }, 6,42,22,24, AK_6}, // 23
{{121, 13, 14, 11 }, 7,43,23,25, AK_7}, // 24
{{136, 13, 14, 11 }, 8,44,24,26, AK_8}, // 25
{{151, 13, 14, 11 }, 9,45,25,27, AK_9}, // 26
{{166, 13, 14, 11 },10,46,26,28, AK_0}, // 27
{{181, 13, 14, 11 },11,47,27,29, AK_MINUS}, // 28
{{196, 13, 14, 11 },11,48,28,30, AK_EQUAL}, // 29
{{211, 13, 14, 11 },12,49,29,31, AK_BACKSLASH}, // 30
{{226, 13, 14, 11 },12,49,30,32, AK_BS}, // 31
{{241, 13, 14, 11 },13,50,31,33, AK_NP7}, // 32
{{256, 13, 14, 11 },14,51,32,34, AK_NP8}, // 33
{{271, 13, 14, 11 },15,52,33,35, AK_NP9}, // 34
{{286, 13, 14, 11 },16,53,34,17, AK_NPSUB}, // 35
{{ 1, 25, 29, 11 }, 17,54,53,37, AK_TAB}, // 36, row 3 start
{{ 31, 25, 14, 11 }, 18,55,36,38, AK_Q}, // 37
{{ 46, 25, 14, 11 }, 19,56,37,39, AK_W}, // 38
{{ 61, 25, 14, 11 }, 20,57,38,40, AK_E}, // 39
{{ 76, 25, 14, 11 }, 21,58,39,41, AK_R}, // 40
{{ 91, 25, 14, 11 }, 22,59,40,42, AK_T}, // 41
{{106, 25, 14, 11 }, 23,60,41,43, AK_Y}, // 42
{{121, 25, 14, 11 }, 24,61,42,44, AK_U}, // 43
{{136, 25, 14, 11 }, 25,62,43,45, AK_I}, // 44
{{151, 25, 14, 11 }, 26,63,44,46, AK_O}, // 45
{{166, 25, 14, 11 }, 27,64,45,47, AK_P}, // 46
{{181, 25, 14, 11 }, 28,65,46,48, AK_LBRACKET}, // 47
{{196, 25, 14, 11 }, 29,49,47,49, AK_RBRACKET}, // 48
{{211, 25, 29, 23 }, 30,81,48,50, AK_RET}, // 49
{{241, 25, 14, 11 }, 32,66,49,51, AK_NP4}, // 50
{{256, 25, 14, 11 }, 33,67,50,52, AK_NP5}, // 51
{{271, 25, 14, 11 }, 34,68,51,53, AK_NP6}, // 52
{{286, 25, 14, 11 }, 35,69,52,36, AK_NPADD}, // 53
{{ 1, 37, 29, 11 }, 36,70,69,55, AK_CTRL}, // 54, row 4 start
{{ 31, 37, 14, 11 }, 37,70,54,56, AK_A}, // 55
{{ 46, 37, 14, 11 }, 38,71,55,57, AK_S}, // 56
{{ 61, 37, 14, 11 }, 39,72,56,58, AK_D}, // 57
{{ 76, 37, 14, 11 }, 40,73,57,59, AK_F}, // 58
{{ 91, 37, 14, 11 }, 41,74,58,60, AK_G}, // 59
{{106, 37, 14, 11 }, 42,75,59,61, AK_H}, // 60
{{121, 37, 14, 11 }, 43,76,60,62, AK_J}, // 61
{{136, 37, 14, 11 }, 44,77,61,63, AK_K}, // 62
{{151, 37, 14, 11 }, 45,78,62,64, AK_L}, // 63
{{166, 37, 14, 11 }, 46,79,63,65, AK_SEMICOLON}, // 64
{{181, 37, 14, 11 }, 47,80,64,49, AK_QUOTE}, // 65
{{241, 37, 14, 11 }, 50,83,49,67, AK_NP1}, // 66
{{256, 37, 14, 11 }, 51,83,66,68, AK_NP2}, // 67
{{271, 37, 14, 11 }, 52,84,67,69, AK_NP3}, // 68
{{286, 37, 14, 34 }, 53,16,68,54, AK_ENT}, // 69
{{ 1, 49, 44, 11 }, 54,85,84,71, AK_LSH}, // 70, row 5 start
{{ 46, 49, 14, 11 }, 56,87,70,72, AK_Z}, // 71
{{ 61, 49, 14, 11 }, 57,87,71,73, AK_X}, // 72
{{ 76, 49, 14, 11 }, 58,87,72,74, AK_C}, // 73
{{ 91, 49, 14, 11 }, 59,87,73,75, AK_V}, // 74
{{106, 49, 14, 11 }, 60,87,74,76, AK_B}, // 75
{{121, 49, 14, 11 }, 61,87,75,77, AK_N}, // 76
{{136, 49, 14, 11 }, 62,87,76,78, AK_M}, // 77
{{151, 49, 14, 11 }, 63,87,77,79, AK_COMMA}, // 78
{{166, 49, 14, 11 }, 64,87,78,80, AK_PERIOD}, // 79
{{181, 49, 14, 11 }, 65,88,79,81, AK_SLASH}, // 80
{{196, 49, 29, 11 }, 49,89,80,82, AK_RSH}, // 81
{{226, 49, 14, 11 }, 49,91,81,83, AK_UP}, // 82
{{241, 49, 29, 11 }, 66,92,82,84, AK_NP0}, // 83
{{271, 49, 14, 11 }, 67,69,83,69, AK_NPDEL}, // 84
{{ 1, 61, 29, 11 }, 70,0,69,86, AK_LALT}, // 85, row 6 start
{{ 31, 61, 14, 11 }, 70,1,85,87, AK_LAMI}, // 86
{{ 46, 61,134, 11 }, 71,2,86,88, AK_SPC}, // 87
{{181, 61, 14, 11 }, 80,11,87,89, AK_RAMI}, // 88
{{196, 61, 14, 11 }, 81,11,88,90, AK_RALT}, // 89
{{211, 61, 14, 11 }, 81,12,89,91, AK_LF}, // 90
{{226, 61, 14, 11 }, 82,12,90,92, AK_DN}, // 91
{{241, 61, 14, 11 }, 83,13,91,69, AK_RT}, // 92
};
//UK KEYBOARD
static t_vkbd_rect vkbd_rect_UK[]=
{
{{ 1, 1, 29, 11 },85,17,16, 1, AK_ESC}, // 0, row 1 start
{{ 31, 1, 14, 11 },86,18, 0, 2, AK_F1}, // 1
{{ 46, 1, 14, 11 },87,19, 1, 3, AK_F2}, // 2
{{ 61, 1, 14, 11 },87,20, 2, 4, AK_F3}, // 3
{{ 76, 1, 14, 11 },87,21, 3, 5, AK_F4}, // 4
{{ 91, 1, 14, 11 },87,22, 4, 6, AK_F5}, // 5
{{106, 1, 14, 11 },87,23, 5, 7, AK_F6}, // 6
{{121, 1, 14, 11 },87,24, 6, 8, AK_F7}, // 7
{{136, 1, 14, 11 },87,25, 7, 9, AK_F8}, // 8
{{151, 1, 14, 11 },87,26, 8,10, AK_F9}, // 9
{{166, 1, 14, 11 },87,27, 9,11, AK_F10}, // 10
{{181, 1, 29, 11 },88,28,10,12, AK_DEL}, // 11
{{211, 1, 29, 11 },90,30,11,13, AK_HELP}, // 12
{{241, 1, 14, 11 },92,32,12,14, AK_NPLPAREN}, // 13
{{256, 1, 14, 11 },69,33,13,15, AK_NPRPAREN}, // 14
{{271, 1, 14, 11 },69,34,14,16, AK_NPDIV}, // 15
{{286, 1, 14, 11 },69,35,15,0, AK_NPMUL}, // 16
{{ 1, 13, 29, 11 }, 0,36,35,18, AK_BACKQUOTE}, // 17, row 2 start
{{ 31, 13, 14, 11 }, 1,37,17,19, AK_1}, // 18
{{ 46, 13, 14, 11 }, 2,38,18,20, AK_2}, // 19
{{ 61, 13, 14, 11 }, 3,39,19,21, AK_3}, // 20
{{ 76, 13, 14, 11 }, 4,40,20,22, AK_4}, // 21
{{ 91, 13, 14, 11 }, 5,41,21,23, AK_5}, // 22
{{106, 13, 14, 11 }, 6,42,22,24, AK_6}, // 23
{{121, 13, 14, 11 }, 7,43,23,25, AK_7}, // 24
{{136, 13, 14, 11 }, 8,44,24,26, AK_8}, // 25
{{151, 13, 14, 11 }, 9,45,25,27, AK_9}, // 26
{{166, 13, 14, 11 },10,46,26,28, AK_0}, // 27
{{181, 13, 14, 11 },11,47,27,29, AK_MINUS}, // 28
{{196, 13, 14, 11 },11,48,28,30, AK_EQUAL}, // 29
{{211, 13, 14, 11 },12,49,29,31, AK_BACKSLASH}, // 30
{{226, 13, 14, 11 },12,49,30,32, AK_BS}, // 31
{{241, 13, 14, 11 },13,50,31,33, AK_NP7}, // 32
{{256, 13, 14, 11 },14,51,32,34, AK_NP8}, // 33
{{271, 13, 14, 11 },15,52,33,35, AK_NP9}, // 34
{{286, 13, 14, 11 },16,53,34,17, AK_NPSUB}, // 35
{{ 1, 25, 29, 11 }, 17,54,53,37, AK_TAB}, // 36, row 3 start
{{ 31, 25, 14, 11 }, 18,55,36,38, AK_Q}, // 37
{{ 46, 25, 14, 11 }, 19,56,37,39, AK_W}, // 38
{{ 61, 25, 14, 11 }, 20,57,38,40, AK_E}, // 39
{{ 76, 25, 14, 11 }, 21,58,39,41, AK_R}, // 40
{{ 91, 25, 14, 11 }, 22,59,40,42, AK_T}, // 41
{{106, 25, 14, 11 }, 23,60,41,43, AK_Y}, // 42
{{121, 25, 14, 11 }, 24,61,42,44, AK_U}, // 43
{{136, 25, 14, 11 }, 25,62,43,45, AK_I}, // 44
{{151, 25, 14, 11 }, 26,63,44,46, AK_O}, // 45
{{166, 25, 14, 11 }, 27,64,45,47, AK_P}, // 46
{{181, 25, 14, 11 }, 28,65,46,48, AK_LBRACKET}, // 47
{{196, 25, 14, 11 }, 29,49,47,49, AK_RBRACKET}, // 48
{{211, 25, 29, 23 }, 30,81,48,50, AK_RET}, // 49
{{241, 25, 14, 11 }, 32,66,49,51, AK_NP4}, // 50
{{256, 25, 14, 11 }, 33,67,50,52, AK_NP5}, // 51
{{271, 25, 14, 11 }, 34,68,51,53, AK_NP6}, // 52
{{286, 25, 14, 11 }, 35,69,52,36, AK_NPADD}, // 53
{{ 1, 37, 29, 11 }, 36,70,69,55, AK_CTRL}, // 54, row 4 start
{{ 31, 37, 14, 11 }, 37,93,54,56, AK_A}, // 55 *
{{ 46, 37, 14, 11 }, 38,71,55,57, AK_S}, // 56
{{ 61, 37, 14, 11 }, 39,72,56,58, AK_D}, // 57
{{ 76, 37, 14, 11 }, 40,73,57,59, AK_F}, // 58
{{ 91, 37, 14, 11 }, 41,74,58,60, AK_G}, // 59
{{106, 37, 14, 11 }, 42,75,59,61, AK_H}, // 60
{{121, 37, 14, 11 }, 43,76,60,62, AK_J}, // 61
{{136, 37, 14, 11 }, 44,77,61,63, AK_K}, // 62
{{151, 37, 14, 11 }, 45,78,62,64, AK_L}, // 63
{{166, 37, 14, 11 }, 46,79,63,65, AK_SEMICOLON}, // 64
{{181, 37, 14, 11 }, 47,80,64,49, AK_QUOTE}, // 65
{{241, 37, 14, 11 }, 50,83,49,67, AK_NP1}, // 66
{{256, 37, 14, 11 }, 51,83,66,68, AK_NP2}, // 67
{{271, 37, 14, 11 }, 52,84,67,69, AK_NP3}, // 68
{{286, 37, 14, 34 }, 53,16,68,54, AK_ENT}, // 69
{{ 1, 49, 29, 11 }, 54,85,84,93, AK_LSH}, // 70, row 5 start *
{{ 46, 49, 14, 11 }, 56,87,93,72, AK_Z}, // 71 *
{{ 61, 49, 14, 11 }, 57,87,71,73, AK_X}, // 72
{{ 76, 49, 14, 11 }, 58,87,72,74, AK_C}, // 73
{{ 91, 49, 14, 11 }, 59,87,73,75, AK_V}, // 74
{{106, 49, 14, 11 }, 60,87,74,76, AK_B}, // 75
{{121, 49, 14, 11 }, 61,87,75,77, AK_N}, // 76
{{136, 49, 14, 11 }, 62,87,76,78, AK_M}, // 77
{{151, 49, 14, 11 }, 63,87,77,79, AK_COMMA}, // 78
{{166, 49, 14, 11 }, 64,87,78,80, AK_PERIOD}, // 79
{{181, 49, 14, 11 }, 65,88,79,81, AK_SLASH}, // 80
{{196, 49, 29, 11 }, 49,89,80,82, AK_RSH}, // 81
{{226, 49, 14, 11 }, 49,91,81,83, AK_UP}, // 82
{{241, 49, 29, 11 }, 66,92,82,84, AK_NP0}, // 83
{{271, 49, 14, 11 }, 67,69,83,69, AK_NPDEL}, // 84
{{ 1, 61, 29, 11 }, 70,0,69,86, AK_LALT}, // 85, row 6 start
{{ 31, 61, 14, 11 }, 93,1,85,87, AK_LAMI}, // 86 *
{{ 46, 61,134, 11 }, 71,2,86,88, AK_SPC}, // 87
{{181, 61, 14, 11 }, 80,11,87,89, AK_RAMI}, // 88
{{196, 61, 14, 11 }, 81,11,88,90, AK_RALT}, // 89
{{211, 61, 14, 11 }, 81,12,89,91, AK_LF}, // 90
{{226, 61, 14, 11 }, 82,12,90,92, AK_DN}, // 91
{{241, 61, 14, 11 }, 83,13,91,69, AK_RT}, // 92
// UK extra keys
{{31, 49, 14, 11 }, 55,86,70,71, AK_LTGT}, // 93 *
};
//GERMAN KEYBOARD
static t_vkbd_rect vkbd_rect_GER[]=
{
{{ 1, 1, 29, 11 },85,17,16, 1, AK_ESC}, // 0, row 1 start
{{ 31, 1, 14, 11 },86,18, 0, 2, AK_F1}, // 1
{{ 46, 1, 14, 11 },87,19, 1, 3, AK_F2}, // 2
{{ 61, 1, 14, 11 },87,20, 2, 4, AK_F3}, // 3
{{ 76, 1, 14, 11 },87,21, 3, 5, AK_F4}, // 4
{{ 91, 1, 14, 11 },87,22, 4, 6, AK_F5}, // 5
{{106, 1, 14, 11 },87,23, 5, 7, AK_F6}, // 6
{{121, 1, 14, 11 },87,24, 6, 8, AK_F7}, // 7
{{136, 1, 14, 11 },87,25, 7, 9, AK_F8}, // 8
{{151, 1, 14, 11 },87,26, 8,10, AK_F9}, // 9
{{166, 1, 14, 11 },87,27, 9,11, AK_F10}, // 10
{{181, 1, 29, 11 },88,28,10,12, AK_DEL}, // 11
{{211, 1, 29, 11 },90,30,11,13, AK_HELP}, // 12
{{241, 1, 14, 11 },92,32,12,14, AK_NPLPAREN}, // 13
{{256, 1, 14, 11 },69,33,13,15, AK_NPRPAREN}, // 14
{{271, 1, 14, 11 },69,34,14,16, AK_NPDIV}, // 15
{{286, 1, 14, 11 },69,35,15,0, AK_NPMUL}, // 16
{{ 1, 13, 29, 11 }, 0,36,35,18, AK_BACKQUOTE}, // 17, row 2 start
{{ 31, 13, 14, 11 }, 1,37,17,19, AK_1}, // 18
{{ 46, 13, 14, 11 }, 2,38,18,20, AK_2}, // 19
{{ 61, 13, 14, 11 }, 3,39,19,21, AK_3}, // 20
{{ 76, 13, 14, 11 }, 4,40,20,22, AK_4}, // 21
{{ 91, 13, 14, 11 }, 5,41,21,23, AK_5}, // 22
{{106, 13, 14, 11 }, 6,42,22,24, AK_6}, // 23
{{121, 13, 14, 11 }, 7,43,23,25, AK_7}, // 24
{{136, 13, 14, 11 }, 8,44,24,26, AK_8}, // 25
{{151, 13, 14, 11 }, 9,45,25,27, AK_9}, // 26
{{166, 13, 14, 11 },10,46,26,28, AK_0}, // 27
{{181, 13, 14, 11 },11,47,27,29, AK_MINUS}, // 28
{{196, 13, 14, 11 },11,48,28,30, AK_EQUAL}, // 29
{{211, 13, 14, 11 },12,49,29,31, AK_BACKSLASH}, // 30
{{226, 13, 14, 11 },12,49,30,32, AK_BS}, // 31
{{241, 13, 14, 11 },13,50,31,33, AK_NP7}, // 32
{{256, 13, 14, 11 },14,51,32,34, AK_NP8}, // 33
{{271, 13, 14, 11 },15,52,33,35, AK_NP9}, // 34
{{286, 13, 14, 11 },16,53,34,17, AK_NPSUB}, // 35
{{ 1, 25, 29, 11 }, 17,54,53,37, AK_TAB}, // 36, row 3 start
{{ 31, 25, 14, 11 }, 18,55,36,38, AK_Q}, // 37
{{ 46, 25, 14, 11 }, 19,56,37,39, AK_W}, // 38
{{ 61, 25, 14, 11 }, 20,57,38,40, AK_E}, // 39
{{ 76, 25, 14, 11 }, 21,58,39,41, AK_R}, // 40
{{ 91, 25, 14, 11 }, 22,59,40,42, AK_T}, // 41
{{106, 25, 14, 11 }, 23,60,41,43, AK_Y}, // 42
{{121, 25, 14, 11 }, 24,61,42,44, AK_U}, // 43
{{136, 25, 14, 11 }, 25,62,43,45, AK_I}, // 44
{{151, 25, 14, 11 }, 26,63,44,46, AK_O}, // 45
{{166, 25, 14, 11 }, 27,64,45,47, AK_P}, // 46
{{181, 25, 14, 11 }, 28,65,46,48, AK_LBRACKET}, // 47
{{196, 25, 14, 11 }, 29,94,47,49, AK_RBRACKET}, // 48 *
{{211, 25, 29, 23 }, 30,81,48,50, AK_RET}, // 49
{{241, 25, 14, 11 }, 32,66,49,51, AK_NP4}, // 50
{{256, 25, 14, 11 }, 33,67,50,52, AK_NP5}, // 51
{{271, 25, 14, 11 }, 34,68,51,53, AK_NP6}, // 52
{{286, 25, 14, 11 }, 35,69,52,36, AK_NPADD}, // 53
{{ 1, 37, 29, 11 }, 36,70,69,55, AK_CTRL}, // 54, row 4 start
{{ 31, 37, 14, 11 }, 37,93,54,56, AK_A}, // 55 *
{{ 46, 37, 14, 11 }, 38,71,55,57, AK_S}, // 56
{{ 61, 37, 14, 11 }, 39,72,56,58, AK_D}, // 57
{{ 76, 37, 14, 11 }, 40,73,57,59, AK_F}, // 58
{{ 91, 37, 14, 11 }, 41,74,58,60, AK_G}, // 59
{{106, 37, 14, 11 }, 42,75,59,61, AK_H}, // 60
{{121, 37, 14, 11 }, 43,76,60,62, AK_J}, // 61
{{136, 37, 14, 11 }, 44,77,61,63, AK_K}, // 62
{{151, 37, 14, 11 }, 45,78,62,64, AK_L}, // 63
{{166, 37, 14, 11 }, 46,79,63,65, AK_SEMICOLON}, // 64
{{181, 37, 14, 11 }, 47,80,64,94, AK_QUOTE}, // 65 *
{{241, 37, 14, 11 }, 50,83,49,67, AK_NP1}, // 66
{{256, 37, 14, 11 }, 51,83,66,68, AK_NP2}, // 67
{{271, 37, 14, 11 }, 52,84,67,69, AK_NP3}, // 68
{{286, 37, 14, 34 }, 53,16,68,54, AK_ENT}, // 69
{{ 1, 49, 29, 11 }, 54,85,84,93, AK_LSH}, // 70, row 5 start *
{{ 46, 49, 14, 11 }, 56,87,93,72, AK_Z}, // 71 *
{{ 61, 49, 14, 11 }, 57,87,71,73, AK_X}, // 72
{{ 76, 49, 14, 11 }, 58,87,72,74, AK_C}, // 73
{{ 91, 49, 14, 11 }, 59,87,73,75, AK_V}, // 74
{{106, 49, 14, 11 }, 60,87,74,76, AK_B}, // 75
{{121, 49, 14, 11 }, 61,87,75,77, AK_N}, // 76
{{136, 49, 14, 11 }, 62,87,76,78, AK_M}, // 77
{{151, 49, 14, 11 }, 63,87,77,79, AK_COMMA}, // 78
{{166, 49, 14, 11 }, 64,87,78,80, AK_PERIOD}, // 79
{{181, 49, 14, 11 }, 65,88,79,81, AK_SLASH}, // 80
{{196, 49, 27, 11 }, 49,89,80,82, AK_RSH}, // 81
{{226, 49, 14, 11 }, 49,91,81,83, AK_UP}, // 82
{{241, 49, 29, 11 }, 66,92,82,84, AK_NP0}, // 83
{{271, 49, 14, 11 }, 67,69,83,69, AK_NPDEL}, // 84
{{ 1, 61, 29, 11 }, 70,0,69,86, AK_LALT}, // 85, row 6 start
{{ 31, 61, 14, 11 }, 93,1,85,87, AK_LAMI}, // 86 *
{{ 46, 61,134, 11 }, 71,2,86,88, AK_SPC}, // 87
{{181, 61, 14, 11 }, 80,11,87,89, AK_RAMI}, // 88
{{196, 61, 14, 11 }, 81,11,88,90, AK_RALT}, // 89
{{211, 61, 14, 11 }, 81,12,89,91, AK_LF}, // 90
{{226, 61, 14, 11 }, 82,12,90,92, AK_DN}, // 91
{{241, 61, 14, 11 }, 83,13,91,69, AK_RT}, // 92
//German extra keys
{{31, 49, 14, 11 }, 55,86,70,71, AK_LTGT}, // 93 *
{{196, 37, 14, 11 }, 48,81,65,49, AK_NUMBERSIGN}, // 94 *
};
void vkbd_init_button2(void)
{
vkbd_button2=(SDLKey)0;
}
void vkbd_reset_sticky_keys(void)
{
for (int i=0; i<NUM_STICKY; i++)
{
vkbd_sticky_key[i].can_switch=true;
vkbd_sticky_key[i].stuck=false;
}
}
int vkbd_init(void)
{
int i;
char tmpchar[256];
char tmpchar2[256];
char vkbdFileName[256];
char vkbdHiresFileName[256];
char vkbdShiftFileName[256];
char vkbdShiftHiresFileName[256];
switch (mainMenu_vkbdLanguage)
{
case 1:
snprintf(vkbdFileName, 256, "vkbdUKLarge.bmp");
snprintf(vkbdHiresFileName, 256, "vkbdUKLargeHires.bmp");
snprintf(vkbdShiftFileName, 256, "vkbdUKLargeShift.bmp");
snprintf(vkbdShiftHiresFileName, 256, "vkbdUKLargeShiftHires.bmp");
vkbd_rect=vkbd_rect_UK;
break;
case 2:
snprintf(vkbdFileName, 256, "vkbdGERLarge.bmp");
snprintf(vkbdHiresFileName, 256, "vkbdGERLargeHires.bmp");
snprintf(vkbdShiftFileName, 256, "vkbdGERLargeShift.bmp");
snprintf(vkbdShiftHiresFileName, 256, "vkbdGERLargeShiftHires.bmp");
vkbd_rect=vkbd_rect_GER;
break;
default:
snprintf(vkbdFileName, 256, "vkbdUSLarge.bmp");
snprintf(vkbdHiresFileName, 256, "vkbdUSLargeHires.bmp");
snprintf(vkbdShiftFileName, 256, "vkbdUSLargeShift.bmp");
snprintf(vkbdShiftHiresFileName, 256, "vkbdUSLargeShiftHires.bmp");
vkbd_rect=vkbd_rect_US;
break;
}
#if defined(__PSP2__) || defined(__SWITCH__)
snprintf(tmpchar, 256, "%s%s", DATA_PREFIX, vkbdFileName);
snprintf(tmpchar2, 256, "%s%s", DATA_PREFIX, vkbdHiresFileName);
#else
#ifdef GP2X
snprintf(tmpchar, 256, "%s/data/%s", launchDir, vkbdFileName);
snprintf(tmpchar2, 256, "%s/data/%s", launchDir, vkbdHiresFileName);
#else
#ifdef GIZMONDO
snprintf(tmpchar, 256, "%s", "\\SD Card\\uae4all\\data\\%s",vkbdFileName);
snprintf(tmpchar2, 256, "%s", "\\SD Card\\uae4all\\data\\%s",vkbdHiresFileName);
#else
snprintf(tmpchar, 256, "%s%s", DATA_PREFIX, vkbdFileName);
snprintf(tmpchar2, 256, "%s%s", DATA_PREFIX, vkbdHiresFileName);
#endif
#endif
#endif //__PSP2__
SDL_Surface *tmp = SDL_LoadBMP(tmpchar);
if (tmp==NULL)
{
printf("Virtual Keyboard Bitmap Error: %s\n",SDL_GetError());
return -1;
}
ksur=SDL_DisplayFormat(tmp);
SDL_FreeSurface(tmp);
tmp = SDL_LoadBMP(tmpchar2);
if (tmp==NULL)
{
printf("Virtual Keyboard Bitmap Error: %s\n",SDL_GetError());
return -1;
}
ksurHires=SDL_DisplayFormat(tmp);
SDL_FreeSurface(tmp);
// intermediate surfaces to highlight sticky keys on
canvas=SDL_DisplayFormat(ksur);
canvasHires=SDL_DisplayFormat(ksurHires);
//for large keyboard, load another image for shifted keys, and set transparency
#if defined(__PSP2__) || defined(__SWITCH__)
snprintf(tmpchar, 256, "%s%s", DATA_PREFIX, vkbdShiftFileName);
snprintf(tmpchar2, 256, "%s%s", DATA_PREFIX, vkbdShiftHiresFileName);
#else
#ifdef GP2X
snprintf(tmpchar, 256, "%s/data/%s", launchDir, vkbdShiftFileName);
snprintf(tmpchar2, 256, "%s/data/%s", launchDir, vkbdShiftHiresFileName);
#else
#ifdef GIZMONDO
snprintf(tmpchar, 256, "%s", "\\SD Card\\uae4all\\data\\%s",vkbdShiftFileName);
snprintf(tmpchar2, 256, "%s", "\\SD Card\\uae4all\\data\\%s",vkbdShiftHiresFileName);
#else
snprintf(tmpchar, 256, "%s%s", DATA_PREFIX, vkbdShiftFileName);
snprintf(tmpchar2, 256, "%s%s", DATA_PREFIX, vkbdShiftHiresFileName);
#endif
#endif
#endif //__PSP2__
tmp = SDL_LoadBMP(tmpchar);
if (tmp==NULL)
{
printf("Virtual Keyboard Bitmap Error: %s\n",SDL_GetError());
return -1;
}
ksurShift=SDL_DisplayFormat(tmp);
SDL_FreeSurface(tmp);
tmp = SDL_LoadBMP(tmpchar2);
if (tmp==NULL)
{
printf("Virtual Keyboard Bitmap Error: %s\n",SDL_GetError());
return -1;
}
ksurShiftHires=SDL_DisplayFormat(tmp);
SDL_FreeSurface(tmp);
vkbd_transparency=128; //default transparency is 128 for keyboard
SDL_SetAlpha(canvas, SDL_SRCALPHA | SDL_RLEACCEL, vkbd_transparency);
SDL_SetAlpha(canvasHires, SDL_SRCALPHA | SDL_RLEACCEL, vkbd_transparency);
vkbd_actual=0;
#if !defined(__PSP2__) && !defined(__SWITCH__) //no need to show keyboard on first startup
vkbd_redraw();
#endif
for (int i=0; i<NUM_STICKY; i++)
{
vkbd_sticky_key[i].stuck=false;
}
vkbd_x=(prSDLScreen->w-ksur->w)/2;
vkbd_y=prSDLScreen->h-ksur->h;
vkbd_mode=0;
vkbd_move=0;
vkbd_last_press_time=0;
vkbd_last_move_time=0;
vkbd_key=KEYCODE_NOTHING;
vkbd_button2=(SDLKey)0;
vkbd_keysave=KEYCODE_NOTHING;
return 0;
}
void vkbd_quit(void)
{
int i;
SDL_FreeSurface(ksurShift);
SDL_FreeSurface(ksurShiftHires);
SDL_FreeSurface(ksur);
SDL_FreeSurface(ksurHires);
vkbd_mode=0;
for (int i=0; i<NUM_STICKY; i++)
{
vkbd_sticky_key[i].stuck=false;
}
}
void vkbd_redraw(void)
{
SDL_Rect r;
SDL_Surface *toDraw;
SDL_Surface *myCanvas;
if (mainMenu_displayHires)
{
if (vkbd_sticky_key[0].stuck || vkbd_sticky_key[1].stuck)
toDraw=ksurShiftHires;
else
toDraw=ksurHires;
myCanvas=canvasHires;
}
else
{
if (vkbd_sticky_key[0].stuck || vkbd_sticky_key[1].stuck)
toDraw=ksurShift;
else
toDraw=ksur;
myCanvas=canvas;
}
// blit onto intermediate canvas
r.x=0;
r.y=0;
r.w=toDraw->w;
r.h=toDraw->h;
SDL_BlitSurface(toDraw,NULL,myCanvas,&r);
// highlight sticky keys that are pressed with a green dot
// do this on a canvas to ensure correct transparency on final blit
Uint32 sticky_key_color=SDL_MapRGB(myCanvas->format, 0, 255, 0);
for (int i=0; i<NUM_STICKY; i++) {
if (vkbd_sticky_key[i].stuck==true) {
int index = vkbd_sticky_key[i].index;
if (mainMenu_displayHires)
{
r.x=2*vkbd_rect[index].rect.x+2;
r.w=6;
}
else
{
r.x=vkbd_rect[index].rect.x+1;
r.w=3;
}
r.y=vkbd_rect[index].rect.y+1;
r.h=3;
SDL_FillRect(myCanvas,&r,sticky_key_color);
}
}
if (vkbd_y>prSDLScreen->h-myCanvas->h)
vkbd_y=prSDLScreen->h-myCanvas->h;
vkbd_x=(prSDLScreen->w-myCanvas->w)/2;
r.x=vkbd_x;
r.y=vkbd_y;
r.w=myCanvas->w;
r.h=myCanvas->h;
SDL_BlitSurface(myCanvas,NULL,prSDLScreen,&r);
}
void vkbd_transparency_up(void)
{
switch (vkbd_transparency)
{
case 255:
vkbd_transparency=192;
break;
case 192:
vkbd_transparency=128;
break;
case 128:
vkbd_transparency=64;
break;
case 64:
vkbd_transparency=255;
break;
default:
vkbd_transparency=64;
break;
}
if (vkbd_transparency != 255)
{
SDL_SetAlpha(canvas, SDL_SRCALPHA | SDL_RLEACCEL, vkbd_transparency);
SDL_SetAlpha(canvasHires, SDL_SRCALPHA | SDL_RLEACCEL, vkbd_transparency);
}
else //fully opague
{
SDL_SetAlpha(canvas, 0, 255);
SDL_SetAlpha(canvasHires, 0, 255);
}
}
void vkbd_transparency_down(void)
{
switch (vkbd_transparency)
{
case 255:
vkbd_transparency=64;
break;
case 192:
vkbd_transparency=255;
break;
case 128:
vkbd_transparency=192;
break;
case 64:
vkbd_transparency=128;
break;
default:
vkbd_transparency=255;
break;
}
if (vkbd_transparency != 255)
{
SDL_SetAlpha(canvas, SDL_SRCALPHA | SDL_RLEACCEL, vkbd_transparency);
SDL_SetAlpha(canvasHires, SDL_SRCALPHA | SDL_RLEACCEL, vkbd_transparency);
}
else //fully opague
{
SDL_SetAlpha(canvas, 0, 255);
SDL_SetAlpha(canvasHires, 0, 255);
}
}
void vkbd_displace_up(void)
{
if (vkbd_y>3)
vkbd_y-=4;
else
vkbd_y=0;
}
void vkbd_displace_down(void)
{
if (vkbd_y<prSDLScreen->h-ksur->h-3)
vkbd_y+=4;
else
vkbd_y=prSDLScreen->h-ksur->h;
}
int vkbd_process(void)
{
Uint32 now=SDL_GetTicks();
SDL_Rect r;
vkbd_redraw();
if (vkbd_move&VKBD_BUTTON)
{
vkbd_move=0;
int amigaKeyCode=vkbd_rect[vkbd_actual].key;
//some keys are sticky
for (int i=0; i<NUM_STICKY; i++)
{
if (amigaKeyCode == vkbd_sticky_key[i].code)
{
if (vkbd_sticky_key[i].can_switch)
{
vkbd_sticky_key[i].stuck=!vkbd_sticky_key[i].stuck;
vkbd_sticky_key[i].can_switch=false;
return amigaKeyCode;
}
else return (KEYCODE_NOTHING);
}
}
return amigaKeyCode;
}
if (vkbd_move&VKBD_BUTTON_BACKSPACE)
{
vkbd_move=0;
return AK_BS;
}
if (vkbd_move&VKBD_BUTTON_SHIFT)
{
vkbd_move=0;
// hotkey for shift toggle (arbitrarily use left shift here)
if (vkbd_sticky_key[0].can_switch)
{
vkbd_sticky_key[0].stuck=!vkbd_sticky_key[0].stuck;
vkbd_sticky_key[0].can_switch=false;
return(AK_LSH);
} else
return(KEYCODE_NOTHING);
}
if (vkbd_move&VKBD_BUTTON_RESET_STICKY)
{
vkbd_move=0;
// hotkey to reset all sticky keys at once
vkbd_reset_sticky_keys();
return(KEYCODE_STICKY_RESET); // special return code to reset amiga keystate
}
if (vkbd_move&VKBD_LEFT || vkbd_move&VKBD_RIGHT || vkbd_move&VKBD_UP || vkbd_move&VKBD_DOWN)
{
if (vkbd_let_go_of_direction) //just pressing down
vkbd_last_press_time=now;
if (
(
now-vkbd_last_press_time>VKBD_MIN_HOLDING_TIME
&& now-vkbd_last_move_time>VKBD_MOVE_DELAY
)
|| vkbd_let_go_of_direction
)
{
vkbd_last_move_time=now;
if (vkbd_move&VKBD_LEFT)
vkbd_actual=vkbd_rect[vkbd_actual].left;
else if (vkbd_move&VKBD_RIGHT)
vkbd_actual=vkbd_rect[vkbd_actual].right;
if (vkbd_move&VKBD_UP)
vkbd_actual=vkbd_rect[vkbd_actual].up;
else if (vkbd_move&VKBD_DOWN)
vkbd_actual=vkbd_rect[vkbd_actual].down;
}
vkbd_let_go_of_direction=0;
}
else
vkbd_let_go_of_direction=1;
if (mainMenu_displayHires)
{
r.x=vkbd_x+2*vkbd_rect[vkbd_actual].rect.x;
r.w=2*vkbd_rect[vkbd_actual].rect.w;
}
else
{
r.x=vkbd_x+vkbd_rect[vkbd_actual].rect.x;
r.w=vkbd_rect[vkbd_actual].rect.w;
}
r.y=vkbd_y+vkbd_rect[vkbd_actual].rect.y;
r.h=vkbd_rect[vkbd_actual].rect.h;
if (!vkbd_just_blinked)
{
SDL_FillRect(prSDLScreen,&r,vkbd_color);
vkbd_just_blinked=1;
//vkbd_color = ~vkbd_color;
}
else
{
vkbd_just_blinked=0;
}
return KEYCODE_NOTHING; //nothing on the vkbd was pressed
}
#endif

53
src/osdep/vkbd/vkbd.h Normal file
View file

@ -0,0 +1,53 @@
#ifndef VKBD_H
#define VKBD_H
#include<SDL.h>
#ifdef USE_SDL2
#include "sdl2_to_sdl1.h"
#endif
#define VKBD_X 20
#define VKBD_Y 200
#define VKBD_LEFT 1
#define VKBD_RIGHT 2
#define VKBD_UP 4
#define VKBD_DOWN 8
#define VKBD_BUTTON 16
#define VKBD_BUTTON_BACKSPACE 32
#define VKBD_BUTTON_SHIFT 64
#define VKBD_BUTTON_RESET_STICKY 128
#define VLBD_BUTTON2 128
// special return codes for vkbd_process
#define KEYCODE_NOTHING -1234567
#define KEYCODE_STICKY_RESET -100
#define NUM_STICKY 7 // number of sticky keys (shift, alt etc)
int vkbd_init(void);
void vkbd_quit(void);
void vkbd_redraw(void);
int vkbd_process(void);
void vkbd_init_button2(void);
void vkbd_displace_up(void);
void vkbd_displace_down(void);
void vkbd_transparency_up(void);
void vkbd_transparency_down(void);
void vkbd_reset_sticky_keys(void);
extern int vkbd_mode;
extern int vkbd_move;
typedef struct
{
int code; // amiga-side keycode
bool stuck; // is it currently stuck pressed?
bool can_switch; // de-bounce
unsigned char index; // index in vkbd_rect[]
} t_vkbd_sticky_key;
extern t_vkbd_sticky_key vkbd_sticky_key[NUM_STICKY];
extern int vkbd_key;
extern int vkbd_keysave;
extern SDLKey vkbd_button2;
extern int keymappings[10][3];
#endif // VKBD_H

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 225 KiB

View file

@ -0,0 +1,5 @@
menu_inv_color=0x9a,0x9a,0xaa
menu_win0_color=0x20,0x20,0x30
menu_win1_color=0x70,0x70,0x80
menu_barra0_color=0x40,0x40,0x50
menu_barra1_color=0x80,0x80,0x90

BIN
switchdata/data/text.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

BIN
switchdata/data/window.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

BIN
switchdata/icon0.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB