From f0f21507db78a15b1ac4dbc48ecfd3ebdd4d4e75 Mon Sep 17 00:00:00 2001 From: yellows8 Date: Wed, 18 Mar 2020 22:33:15 -0400 Subject: [PATCH 1/2] fs/fsdev: Added fsdevMountDeviceSaveData/fsOpen_DeviceSaveData, and minor other adjustments. --- nx/include/switch/runtime/devices/fs_dev.h | 3 +++ nx/include/switch/services/fs.h | 8 ++++++-- nx/source/runtime/devices/fs_dev.c | 13 +++++++++++++ nx/source/services/fs.c | 16 +++++++++++++++- 4 files changed, 37 insertions(+), 3 deletions(-) diff --git a/nx/include/switch/runtime/devices/fs_dev.h b/nx/include/switch/runtime/devices/fs_dev.h index 78f7e009..7aff1308 100644 --- a/nx/include/switch/runtime/devices/fs_dev.h +++ b/nx/include/switch/runtime/devices/fs_dev.h @@ -33,6 +33,9 @@ Result fsdevMountSdmc(void); /// Mounts the specified save data. Result fsdevMountSaveData(const char *name, u64 application_id, AccountUid uid); +/// Mounts the specified DeviceSaveData. +Result fsdevMountDeviceSaveData(const char *name, u64 application_id); + /// Mounts the specified system save data. Result fsdevMountSystemSaveData(const char *name, FsSaveDataSpaceId save_data_space_id, u64 system_save_data_id, AccountUid uid); diff --git a/nx/include/switch/services/fs.h b/nx/include/switch/services/fs.h index b69b3246..99871a22 100644 --- a/nx/include/switch/services/fs.h +++ b/nx/include/switch/services/fs.h @@ -367,10 +367,14 @@ Result fsGetGlobalAccessLogMode(u32* out_mode); Result fsCreate_SystemSaveDataWithOwner(FsSaveDataSpaceId save_data_space_id, u64 system_save_data_id, AccountUid uid, u64 owner_id, s64 size, s64 journal_size, u32 flags); Result fsCreate_SystemSaveData(FsSaveDataSpaceId save_data_space_id, u64 system_save_data_id, s64 size, s64 journal_size, u32 flags); -/// Wrapper(s) for fsOpenSaveDataFileSystem. -/// See FsSave for program_id and uid. +/// Wrapper for fsOpenSaveDataFileSystem. +/// See \ref FsSaveDataAttribute for application_id and uid. Result fsOpen_SaveData(FsFileSystem* out, u64 application_id, AccountUid uid); +/// Wrapper for fsOpenSaveDataFileSystem, for opening DeviceSaveData. +/// See \ref FsSaveDataAttribute for application_id. +Result fsOpen_DeviceSaveData(FsFileSystem* out, u64 application_id); + /// Wrapper for fsOpenSaveDataFileSystemBySystemSaveDataId. /// WARNING: You can brick when writing to SystemSaveData, if the data is corrupted etc. Result fsOpen_SystemSaveData(FsFileSystem* out, FsSaveDataSpaceId save_data_space_id, u64 system_save_data_id, AccountUid uid); diff --git a/nx/source/runtime/devices/fs_dev.c b/nx/source/runtime/devices/fs_dev.c index a70b7418..a9ef1bf1 100644 --- a/nx/source/runtime/devices/fs_dev.c +++ b/nx/source/runtime/devices/fs_dev.c @@ -465,6 +465,19 @@ Result fsdevMountSaveData(const char *name, u64 application_id, AccountUid uid) return rc; } +Result fsdevMountDeviceSaveData(const char *name, u64 application_id) +{ + FsFileSystem fs; + Result rc = fsOpen_DeviceSaveData(&fs, application_id); + if(R_SUCCEEDED(rc)) + { + int ret = fsdevMountDevice(name, fs); + if(ret==-1) + rc = MAKERESULT(Module_Libnx, LibnxError_OutOfMemory); + } + return rc; +} + Result fsdevMountSystemSaveData(const char *name, FsSaveDataSpaceId save_data_space_id, u64 system_save_data_id, AccountUid uid) { FsFileSystem fs; diff --git a/nx/source/services/fs.c b/nx/source/services/fs.c index 2613f3f2..5adc51e4 100644 --- a/nx/source/services/fs.c +++ b/nx/source/services/fs.c @@ -483,6 +483,10 @@ Result fsCreate_SystemSaveData(FsSaveDataSpaceId save_data_space_id, u64 system_ } // Wrapper(s) for fsOpenSaveDataFileSystem. +static Result _fsOpen_SaveDataFs(FsFileSystem* out, FsSaveDataAttribute *attr) { + return fsOpenSaveDataFileSystem(out, FsSaveDataSpaceId_User, attr); +} + Result fsOpen_SaveData(FsFileSystem* out, u64 application_id, AccountUid uid) { FsSaveDataAttribute attr; @@ -491,7 +495,17 @@ Result fsOpen_SaveData(FsFileSystem* out, u64 application_id, AccountUid uid) { attr.uid = uid; attr.save_data_type = FsSaveDataType_Account; - return fsOpenSaveDataFileSystem(out, FsSaveDataSpaceId_User, &attr); + return _fsOpen_SaveDataFs(out, &attr); +} + +Result fsOpen_DeviceSaveData(FsFileSystem* out, u64 application_id) { + FsSaveDataAttribute attr; + + memset(&attr, 0, sizeof(attr)); + attr.application_id = application_id; + attr.save_data_type = FsSaveDataType_Device; + + return _fsOpen_SaveDataFs(out, &attr); } Result fsOpen_SystemSaveData(FsFileSystem* out, FsSaveDataSpaceId save_data_space_id, u64 system_save_data_id, AccountUid uid) { From 3dbafe61833757ec9731fd94c66b68bf75e86f4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=BB=E7=92=83=E5=85=94?= <48943340+Polytoo@users.noreply.github.com> Date: Sat, 21 Mar 2020 00:43:44 +0800 Subject: [PATCH 2/2] More keyboard types (#387) --- nx/include/switch/applets/swkbd.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/nx/include/switch/applets/swkbd.h b/nx/include/switch/applets/swkbd.h index cc8e77bf..9b7d5ec3 100644 --- a/nx/include/switch/applets/swkbd.h +++ b/nx/include/switch/applets/swkbd.h @@ -18,9 +18,15 @@ typedef enum { /// Type of keyboard. typedef enum { - SwkbdType_Normal = 0, ///< Normal keyboard. - SwkbdType_NumPad = 1, ///< Number pad. The buttons at the bottom left/right are only available when they're set by \ref swkbdConfigSetLeftOptionalSymbolKey / \ref swkbdConfigSetRightOptionalSymbolKey. - SwkbdType_QWERTY = 2, ///< QWERTY (and variants) keyboard only. + SwkbdType_Normal = 0, ///< Normal keyboard. + SwkbdType_NumPad = 1, ///< Number pad. The buttons at the bottom left/right are only available when they're set by \ref swkbdConfigSetLeftOptionalSymbolKey / \ref swkbdConfigSetRightOptionalSymbolKey. + SwkbdType_QWERTY = 2, ///< QWERTY (and variants) keyboard only. + SwkbdType_Unknown3 = 3, ///< The same as SwkbdType_Normal keyboard. + SwkbdType_Latin = 4, ///< All Latin like languages keyboard only (without CJK keyboard). + SwkbdType_ZhHans = 5, ///< Chinese Simplified keyboard only. + SwkbdType_ZhHant = 6, ///< Chinese Traditional keyboard only. + SwkbdType_Korean = 7, ///< Korean keyboard only. + SwkbdType_All = 8, ///< All language keyboards. } SwkbdType; /// Bitmask for SwkbdArgCommon::keySetDisableBitmask. This disables keys on the keyboard when the corresponding bit(s) are set.