From b06a6ff29f55ba8fd99e592aaad09bce3cb13e6e Mon Sep 17 00:00:00 2001
From: yellows8 <yellows8@users.noreply.github.com>
Date: Wed, 11 Sep 2019 16:36:08 -0400
Subject: [PATCH] Updated sysver checks for the AbstractedPad cmds which were
 removed in [9.0.0+].

---
 nx/include/switch/services/hiddbg.h | 11 ++++++++---
 nx/source/services/hiddbg.c         | 10 +++++-----
 2 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/nx/include/switch/services/hiddbg.h b/nx/include/switch/services/hiddbg.h
index c82b0779..c5ff3ade 100644
--- a/nx/include/switch/services/hiddbg.h
+++ b/nx/include/switch/services/hiddbg.h
@@ -90,20 +90,25 @@ Result hiddbgUpdateDesignInfo(u32 colorBody, u32 colorButtons, u32 colorLeftGrip
 /// This doesn't seem to be usable?
 Result hiddbgReadSerialFlash(u32 offset, void* buffer, size_t size, u64 UniquePadId);
 
-/// Gets a list of AbstractedPadHandles, where AbstractedPadHandles is the output array with max entries = count. total_entries is total entries written to the output array. Only available with [5.0.0+].
+/// Gets a list of AbstractedPadHandles, where AbstractedPadHandles is the output array with max entries = count. total_entries is total entries written to the output array.
+/// Only available with [5.0.0-8.1.0].
 Result hiddbgGetAbstractedPadHandles(u64 *AbstractedPadHandles, s32 count, s32 *total_entries);
 
-/// Gets the state for the specified AbstractedPadHandle. Only available with [5.0.0+].
+/// Gets the state for the specified AbstractedPadHandle.
+/// Only available with [5.0.0-8.1.0].
 Result hiddbgGetAbstractedPadState(u64 AbstractedPadHandle, HiddbgAbstractedPadState *state);
 
-/// Similar to \ref hiddbgGetAbstractedPadHandles except this also returns the state for each pad in output array states. Only available with [5.0.0+].
+/// Similar to \ref hiddbgGetAbstractedPadHandles except this also returns the state for each pad in output array states.
+/// Only available with [5.0.0-8.1.0].
 Result hiddbgGetAbstractedPadsState(u64 *AbstractedPadHandles, HiddbgAbstractedPadState *states, s32 count, s32 *total_entries);
 
 /// Sets AutoPilot state for the specified pad.
 /// AbstractedVirtualPadId can be any unique value as long as it's within bounds. For example, 0-7 is usable.
+/// Only available with [5.0.0-8.1.0].
 Result hiddbgSetAutoPilotVirtualPadState(s8 AbstractedVirtualPadId, const HiddbgAbstractedPadState *state);
 
 /// Clears AutoPilot state for the specified pad set by \ref hiddbgSetAutoPilotVirtualPadState.
+/// Only available with [5.0.0-8.1.0].
 Result hiddbgUnsetAutoPilotVirtualPadState(s8 AbstractedVirtualPadId);
 
 /// Clears AutoPilot state for all pads set by \ref hiddbgSetAutoPilotVirtualPadState.
diff --git a/nx/source/services/hiddbg.c b/nx/source/services/hiddbg.c
index 925db2d4..0d82e427 100644
--- a/nx/source/services/hiddbg.c
+++ b/nx/source/services/hiddbg.c
@@ -293,7 +293,7 @@ Result hiddbgReadSerialFlash(u32 offset, void* buffer, size_t size, u64 UniquePa
 }
 
 Result hiddbgGetAbstractedPadHandles(u64 *AbstractedPadHandles, s32 count, s32 *total_entries) {
-    if (hosversionBefore(5,0,0))
+    if (hosversionBefore(5,0,0) || hosversionAtLeast(9,0,0))
         return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
 
     Result rc;
@@ -333,7 +333,7 @@ Result hiddbgGetAbstractedPadHandles(u64 *AbstractedPadHandles, s32 count, s32 *
 }
 
 Result hiddbgGetAbstractedPadState(u64 AbstractedPadHandle, HiddbgAbstractedPadState *state) {
-    if (hosversionBefore(5,0,0))
+    if (hosversionBefore(5,0,0) || hosversionAtLeast(9,0,0))
         return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
 
     Result rc;
@@ -373,7 +373,7 @@ Result hiddbgGetAbstractedPadState(u64 AbstractedPadHandle, HiddbgAbstractedPadS
 }
 
 Result hiddbgGetAbstractedPadsState(u64 *AbstractedPadHandles, HiddbgAbstractedPadState *states, s32 count, s32 *total_entries) {
-    if (hosversionBefore(5,0,0))
+    if (hosversionBefore(5,0,0) || hosversionAtLeast(9,0,0))
         return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
 
     Result rc;
@@ -414,7 +414,7 @@ Result hiddbgGetAbstractedPadsState(u64 *AbstractedPadHandles, HiddbgAbstractedP
 }
 
 Result hiddbgSetAutoPilotVirtualPadState(s8 AbstractedVirtualPadId, const HiddbgAbstractedPadState *state) {
-    if (hosversionBefore(5,0,0))
+    if (hosversionBefore(5,0,0) || hosversionAtLeast(9,0,0))
         return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
 
     Result rc;
@@ -454,7 +454,7 @@ Result hiddbgSetAutoPilotVirtualPadState(s8 AbstractedVirtualPadId, const Hiddbg
 }
 
 Result hiddbgUnsetAutoPilotVirtualPadState(s8 AbstractedVirtualPadId) {
-    if (hosversionBefore(5,0,0))
+    if (hosversionBefore(5,0,0) || hosversionAtLeast(9,0,0))
         return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer);
 
     Result rc;