Fix card reading
This commit is contained in:
parent
c90a3e08a6
commit
d54a6453ad
2
Makefile
2
Makefile
@ -63,7 +63,7 @@ dist-no-7z: options ${OUT} patches
|
||||
cp ${TARGET}/${OUT}.dll out/
|
||||
mv out/${OUT}.dll out/bnusio.dll
|
||||
cp ${TARGET}/patches.*.dll out/plugins
|
||||
cp dist/* out/
|
||||
cp -r dist/* out/
|
||||
|
||||
.PHONY: dist
|
||||
dist: dist-no-7z
|
||||
|
2
dist/plugins/patches.toml
vendored
Normal file
2
dist/plugins/patches.toml
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
shared_audio = true
|
||||
vsync = false
|
@ -3,7 +3,7 @@ CC := clang
|
||||
TARGET := x86_64-pc-windows-gnu
|
||||
SRC = dllmain.c
|
||||
OBJ = ${addprefix ../../${TARGET}/patches/8.18/,${SRC:.c=.o}}
|
||||
EXTERN_SRC = tomlc99/toml.c minhook/src/buffer.c minhook/src/hook.c minhook/src/trampoline.c minhook/src/hde/hde32.c minhook/src/hde/hde64.c
|
||||
EXTERN_SRC = src/helpers.c tomlc99/toml.c minhook/src/buffer.c minhook/src/hook.c minhook/src/trampoline.c minhook/src/hde/hde32.c minhook/src/hde/hde64.c
|
||||
EXTERN_OBJ = ${addprefix ../../${TARGET}/,${EXTERN_SRC:.c=.o}}
|
||||
CFLAGS = -std=c99 -I../../src -I../../minhook/include -I../../tomlc99 -Wall -Ofast -target ${TARGET} -DWIN32_LEAN_AND_MEAN -D_WIN32_WINNT=_WIN32_WINNT_WIN7
|
||||
LDFLAGS := -shared -static -static-libgcc -s
|
||||
|
@ -11,12 +11,14 @@ HOOK_DYNAMIC (u8, __fastcall, qrReadFromCOM1, u64 a1) {
|
||||
i32 __stdcall DllMain (HMODULE mod, DWORD cause, void *ctx) {
|
||||
if (cause != DLL_PROCESS_ATTACH) return 1;
|
||||
|
||||
toml_table_t *config = openConfig (configPath ("plugins/patches.toml"));
|
||||
if (!config) return 1;
|
||||
void *handle = GetModuleHandle (0);
|
||||
WRITE_MEMORY (ASLR (0x1400239C0, handle), u8, 0xC3); // Stop error
|
||||
WRITE_MEMORY (ASLR (0x140314E8D, handle), u8, 0xB0, 0x01); // Unlock songs
|
||||
WRITE_MEMORY (ASLR (0x140692E17, handle), u8, 0xEB); // Shared audio
|
||||
if (readConfigBool (config, "shared_audio", true)) WRITE_MEMORY (ASLR (0x140692E17, handle), u8, 0xEB); // Shared audio
|
||||
WRITE_MEMORY (ASLR (0x140313726, handle), u8, 0x00, 0x7F); // Remove song limit
|
||||
WRITE_MEMORY (ASLR (0x140517339, handle), u8, 0xBA, 0x00, 0x00, 0x00, 0x00, 0x90); // Disable VSync
|
||||
if (!readConfigBool (config, "vsync", false)) WRITE_MEMORY (ASLR (0x140517339, handle), u8, 0xBA, 0x00, 0x00, 0x00, 0x00, 0x90); // Disable VSync
|
||||
// Save settings cross session without F:/ and G:/ drive
|
||||
WRITE_MEMORY (ASLR (0x140B5C528, handle), u8, "./Setting1.bin");
|
||||
WRITE_MEMORY (ASLR (0x140B5C538, handle), u8, "./Setting2.bin");
|
||||
|
@ -58,23 +58,22 @@ HOOK_DYNAMIC (i64, __fastcall, UsbFinderGetSerialNumber, i32 a1, char *a2) {
|
||||
return 0;
|
||||
}
|
||||
HOOK_DYNAMIC (u64, __stdcall, bngrw_DevReset) { return 1; }
|
||||
HOOK_DYNAMIC (u64, __stdcall, bngrw_ReadMifare) { return 0xffffff9c; }
|
||||
HOOK_DYNAMIC (u64, __stdcall, bngrw_ReadMifare) { return 0xFFFFFF9C; }
|
||||
HOOK_DYNAMIC (void, __stdcall, bngrw_fin) { return; }
|
||||
HOOK_DYNAMIC (u64, __stdcall, bngrw_GetFwVersion) { return 0; }
|
||||
HOOK_DYNAMIC (u64, __stdcall, bngrw_GetStationID) { return 0; }
|
||||
HOOK_DYNAMIC (u64, __stdcall, bngrw_GetRetryCount) { return 0; }
|
||||
HOOK_DYNAMIC (u64, __stdcall, bngrw_Init) { return 0; }
|
||||
HOOK_DYNAMIC (i32, __stdcall, bngrw_IsCmdExec) { return -1; }
|
||||
HOOK_DYNAMIC (u64, __stdcall, bngrw_IsCmdExec) { return 0xFFFFFFFF; }
|
||||
HOOK_DYNAMIC (u64, __stdcall, bngrw_ReqAction) { return 1; }
|
||||
HOOK_DYNAMIC (u64, __stdcall, bngrw_ReqAiccAuth) { return 1; }
|
||||
HOOK_DYNAMIC (u64, __stdcall, bngrw_ReqBeep) { return 1; }
|
||||
HOOK_DYNAMIC (i32, __stdcall, bngrw_ReqCancel, u32 a1) { return a1 > 7 ? -100 : 1; }
|
||||
HOOK_DYNAMIC (u64, __stdcall, bngrw_ReqFwCleanup) { return 1; }
|
||||
HOOK_DYNAMIC (u64, __stdcall, bngrw_ReqFwVersionUp) { return 1; }
|
||||
HOOK_DYNAMIC (i32, __stdcall, bngrw_ReqLatchID, u32 a1) { return a1 < 8 ? -100 : 1; }
|
||||
HOOK_DYNAMIC (i32, __stdcall, bngrw_ReqLatchID, u32 a1) { return (a1 < 8 ? -100 : 1); }
|
||||
HOOK_DYNAMIC (u64, __stdcall, bngrw_ReqLed) { return 1; }
|
||||
HOOK_DYNAMIC (i32, __stdcall, bngrw_ReqSendMail, u32 a1, u32 a2, u32 a3, u64 a4, u64 a5) { return a1 < 8 && a5 ? 1 : -100; }
|
||||
HOOK_DYNAMIC (i32, __stdcall, bngrw_ReqSendUrl, u32 a1, u32 a2, u32 a3, u64 a4, u64 a5) { return a1 < 8 && a5 ? 1 : -100; }
|
||||
HOOK_DYNAMIC (i32, __stdcall, bngrw_ReqSendMail, u32 a1, u32 a2, u32 a3, u64 a4, u64 a5) { return (7 < a1 || !a5 ? -100 : 1); }
|
||||
HOOK_DYNAMIC (i32, __stdcall, bngrw_ReqSendUrl, u32 a1, u32 a2, u32 a3, u64 a4, u64 a5) { return (7 < a1 || !a5 ? -100 : 1); }
|
||||
HOOK_DYNAMIC (u64, __stdcall, bngrw_ReqSetLedPower) { return 0; }
|
||||
|
||||
void
|
||||
@ -89,7 +88,7 @@ init_boilerplate () {
|
||||
INSTALL_HOOK_DYNAMIC (UsbFinderGetSerialNumber, PROC_ADDRESS ("nbamUsbFinder.dll", "nbamUsbFinderGetSerialNumber"));
|
||||
|
||||
INSTALL_HOOK_DYNAMIC (bngrw_DevReset, PROC_ADDRESS ("bngrw.dll", "BngRwDevReset"));
|
||||
INSTALL_HOOK_DYNAMIC (bngrw_ReadMifare, PROC_ADDRESS ("bngrw.dll", "BngRwReadMifareAllBlock"));
|
||||
INSTALL_HOOK_DYNAMIC (bngrw_ReadMifare, PROC_ADDRESS ("bngrw.dll", "BngRwExReadMifareAllBlock"));
|
||||
INSTALL_HOOK_DYNAMIC (bngrw_fin, PROC_ADDRESS ("bngrw.dll", "BngRwFin"));
|
||||
INSTALL_HOOK_DYNAMIC (bngrw_GetFwVersion, PROC_ADDRESS ("bngrw.dll", "BngRwGetFwVersion"));
|
||||
INSTALL_HOOK_DYNAMIC (bngrw_GetStationID, PROC_ADDRESS ("bngrw.dll", "BngRwGetStationID"));
|
||||
@ -99,7 +98,6 @@ init_boilerplate () {
|
||||
INSTALL_HOOK_DYNAMIC (bngrw_ReqAction, PROC_ADDRESS ("bngrw.dll", "BngRwReqAction"));
|
||||
INSTALL_HOOK_DYNAMIC (bngrw_ReqAiccAuth, PROC_ADDRESS ("bngrw.dll", "BngRwReqAiccAuth"));
|
||||
INSTALL_HOOK_DYNAMIC (bngrw_ReqBeep, PROC_ADDRESS ("bngrw.dll", "BngRwReqBeep"));
|
||||
INSTALL_HOOK_DYNAMIC (bngrw_ReqCancel, PROC_ADDRESS ("bngrw.dll", "BngRwReqCancel"));
|
||||
INSTALL_HOOK_DYNAMIC (bngrw_ReqFwCleanup, PROC_ADDRESS ("bngrw.dll", "BngRwReqFwCleanup"));
|
||||
INSTALL_HOOK_DYNAMIC (bngrw_ReqFwVersionUp, PROC_ADDRESS ("bngrw.dll", "BngRwReqFwVersionUp"));
|
||||
INSTALL_HOOK_DYNAMIC (bngrw_ReqLatchID, PROC_ADDRESS ("bngrw.dll", "BngRwReqLatchID"));
|
||||
|
@ -1 +1,2 @@
|
||||
#pragma once
|
||||
void init_boilerplate ();
|
36
src/card.cpp
36
src/card.cpp
@ -12,22 +12,34 @@ attach (callbackAttach callback, i32 *data) {
|
||||
t.detach ();
|
||||
}
|
||||
|
||||
bool touchActive = true;
|
||||
|
||||
void
|
||||
touch (callbackTouch callback, u64 data) {
|
||||
mingw_stdthread::thread t ([callback, data] () {
|
||||
mingw_stdthread::this_thread::sleep_for (250ms);
|
||||
u8 cardData[168]
|
||||
= { 0x01, 0x01, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x92, 0x2E, 0x58, 0x32, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x5C, 0x97, 0x44, 0xF0, 0x88, 0x04, 0x00, 0x43, 0x26, 0x2C, 0x33, 0x00, 0x04,
|
||||
0x06, 0x10, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30,
|
||||
0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x00, 0x00, 0x00, 0x00, 0x30, 0x30, 0x30, 0x30,
|
||||
0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4E, 0x42, 0x47, 0x49, 0x43, 0x36,
|
||||
0x00, 0x00, 0xFA, 0xE9, 0x69, 0x00, 0xF6, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||
touch (callbackTouch callback, u64 data, Keybindings insertBind) {
|
||||
touchActive = true;
|
||||
mingw_stdthread::thread t ([callback, data, insertBind] () {
|
||||
while (touchActive) {
|
||||
mingw_stdthread::this_thread::sleep_for (100ms);
|
||||
if (IsButtonDown (insertBind)) {
|
||||
u8 cardData[168] = { 0x01, 0x01, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x92, 0x2E, 0x58, 0x32, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0x5C, 0x97, 0x44, 0xF0, 0x88, 0x04, 0x00, 0x43, 0x26,
|
||||
0x2C, 0x33, 0x00, 0x04, 0x06, 0x10, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30,
|
||||
0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30,
|
||||
0x00, 0x00, 0x00, 0x00, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30,
|
||||
0x30, 0x30, 0x30, 0x30, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4E, 0x42, 0x47, 0x49, 0x43, 0x36, 0x00, 0x00, 0xFA, 0xE9, 0x69, 0x00, 0xF6,
|
||||
0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
||||
memcpy (cardData + 0x2C, "7F5C9744F111111143262C3300040610", 33);
|
||||
memcpy (cardData + 0x50, "30764352518498791337", 21);
|
||||
callback (0, 0, cardData, data);
|
||||
}
|
||||
}
|
||||
});
|
||||
t.detach ();
|
||||
}
|
||||
|
||||
void
|
||||
touchCancel () {
|
||||
touchActive = false;
|
||||
}
|
||||
|
@ -1,10 +1,13 @@
|
||||
#pragma once
|
||||
#include "helpers.h"
|
||||
#include "poll.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
void attach (callbackAttach callback, i32 *data);
|
||||
void touch (callbackTouch callback, u64 data);
|
||||
void touch (callbackTouch callback, u64 data, Keybindings insertBind);
|
||||
void touchCancel ();
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -64,6 +64,7 @@ u16 __fastcall bnusio_GetCoin (i32 a1) {
|
||||
SetConfigValue (config, "DEBUG_ENTER", &DEBUG_ENTER);
|
||||
|
||||
SetConfigValue (config, "COIN_ADD", &COIN_ADD);
|
||||
SetConfigValue (config, "CARD_INSERT", &CARD_INSERT);
|
||||
|
||||
SetConfigValue (config, "P1_LEFT_BLUE", &P1_LEFT_BLUE);
|
||||
SetConfigValue (config, "P1_LEFT_RED", &P1_LEFT_RED);
|
||||
@ -104,17 +105,13 @@ HOOK_DYNAMIC (u64, __stdcall, bngrw_attach, i32 a1, char *a2, i32 a3, i32 a4, ca
|
||||
}
|
||||
|
||||
HOOK_DYNAMIC (i32, __stdcall, bngrw_reqWaitTouch, u32 a1, i32 a2, u32 a3, callbackTouch callback, u64 a5) {
|
||||
if (!IsButtonDown (CARD_INSERT)) return -1;
|
||||
touch (callback, a5);
|
||||
touch (callback, a5, CARD_INSERT);
|
||||
return 1;
|
||||
}
|
||||
|
||||
HOOK_DYNAMIC (HWND, __stdcall, WindowCreateExW, DWORD dwExStyle, LPCWSTR lpClassName, LPCWSTR lpWindowName, DWORD dwStyle, int X, int Y, int nWidth,
|
||||
int nHeight, HWND hWndParent, HMENU hMenu, HINSTANCE hInstance, LPVOID lpParam) {
|
||||
if (nWidth > 0 && nHeight > 0)
|
||||
return originalWindowCreateExW (dwExStyle, lpClassName, lpWindowName, dwStyle, X, Y, GetSystemMetrics (SM_CXSCREEN),
|
||||
GetSystemMetrics (SM_CYSCREEN), hWndParent, hMenu, hInstance, lpParam);
|
||||
else return originalWindowCreateExW (dwExStyle, lpClassName, lpWindowName, dwStyle, X, Y, nWidth, nHeight, hWndParent, hMenu, hInstance, lpParam);
|
||||
HOOK_DYNAMIC (i32, __stdcall, bngrw_ReqCancel, u32 a1) {
|
||||
touchCancel ();
|
||||
return (7 < a1 ? -100 : 1);
|
||||
}
|
||||
|
||||
i32 __stdcall DllMain (HMODULE mod, DWORD cause, void *ctx) {
|
||||
@ -125,7 +122,7 @@ i32 __stdcall DllMain (HMODULE mod, DWORD cause, void *ctx) {
|
||||
|
||||
INSTALL_HOOK_DYNAMIC (bngrw_attach, PROC_ADDRESS ("bngrw.dll", "BngRwAttach"));
|
||||
INSTALL_HOOK_DYNAMIC (bngrw_reqWaitTouch, PROC_ADDRESS ("bngrw.dll", "BngRwReqWaitTouch"));
|
||||
INSTALL_HOOK_DYNAMIC (WindowCreateExW, PROC_ADDRESS ("user32.dll", "CreateWindowExW"));
|
||||
INSTALL_HOOK_DYNAMIC (bngrw_ReqCancel, PROC_ADDRESS ("bngrw.dll", "BngRwReqCancel"));
|
||||
|
||||
// Set current directory to the directory of the executable
|
||||
// Find all files in the plugins directory that end with .dll
|
||||
|
94
src/poll.c
94
src/poll.c
@ -347,130 +347,122 @@ SetRumble (int left, int right) {
|
||||
}
|
||||
}
|
||||
|
||||
inline bool
|
||||
bool
|
||||
KeyboardIsDown (uint8_t keycode) {
|
||||
return currentKeyboardState[keycode];
|
||||
}
|
||||
|
||||
inline bool
|
||||
bool
|
||||
KeyboardIsUp (uint8_t keycode) {
|
||||
return !KeyboardIsDown (keycode);
|
||||
}
|
||||
|
||||
inline bool
|
||||
bool
|
||||
KeyboardIsTapped (uint8_t keycode) {
|
||||
return KeyboardIsDown (keycode) && KeyboardWasUp (keycode);
|
||||
}
|
||||
|
||||
inline bool
|
||||
bool
|
||||
KeyboardIsReleased (uint8_t keycode) {
|
||||
return KeyboardIsUp (keycode) && KeyboardWasDown (keycode);
|
||||
}
|
||||
|
||||
inline bool
|
||||
bool
|
||||
KeyboardWasDown (uint8_t keycode) {
|
||||
return lastKeyboardState[keycode];
|
||||
}
|
||||
|
||||
inline bool
|
||||
bool
|
||||
KeyboardWasUp (uint8_t keycode) {
|
||||
return !KeyboardWasDown (keycode);
|
||||
}
|
||||
|
||||
inline POINT
|
||||
GetMousePosition () {
|
||||
return currentMouseState.Position;
|
||||
POINT
|
||||
GetMousePosition () { return currentMouseState.Position; }
|
||||
|
||||
POINT
|
||||
GetLastMousePosition () { return lastMouseState.Position; }
|
||||
|
||||
POINT
|
||||
GetMouseRelativePosition () { return currentMouseState.RelativePosition; }
|
||||
|
||||
POINT
|
||||
GetLastMouseRelativePosition () { return lastMouseState.RelativePosition; }
|
||||
|
||||
void
|
||||
SetMousePosition (POINT newPosition) {
|
||||
currentMouseState.Position = newPosition;
|
||||
}
|
||||
|
||||
inline POINT
|
||||
GetLastMousePosition () {
|
||||
return lastMouseState.Position;
|
||||
}
|
||||
|
||||
inline POINT
|
||||
GetMouseRelativePosition () {
|
||||
return currentMouseState.RelativePosition;
|
||||
}
|
||||
|
||||
inline POINT
|
||||
GetLastMouseRelativePosition () {
|
||||
return lastMouseState.RelativePosition;
|
||||
}
|
||||
|
||||
inline void
|
||||
SetMousePosition (POINT new) {
|
||||
currentMouseState.Position = new;
|
||||
}
|
||||
|
||||
inline bool
|
||||
bool
|
||||
GetMouseScrollUp () {
|
||||
return currentMouseState.ScrolledUp;
|
||||
}
|
||||
|
||||
inline bool
|
||||
bool
|
||||
GetMouseScrollDown () {
|
||||
return currentMouseState.ScrolledDown;
|
||||
}
|
||||
|
||||
inline bool
|
||||
bool
|
||||
GetWasMouseScrollUp () {
|
||||
return lastMouseState.ScrolledUp;
|
||||
}
|
||||
|
||||
inline bool
|
||||
bool
|
||||
GetWasMouseScrollDown () {
|
||||
return lastMouseState.ScrolledDown;
|
||||
}
|
||||
|
||||
inline bool
|
||||
bool
|
||||
GetMouseScrollIsReleased (enum Scroll scroll) {
|
||||
if (scroll == MOUSE_SCROLL_UP) return !GetMouseScrollUp () && GetWasMouseScrollUp ();
|
||||
else return !GetMouseScrollDown () && GetWasMouseScrollDown ();
|
||||
}
|
||||
|
||||
inline bool
|
||||
bool
|
||||
GetMouseScrollIsDown (enum Scroll scroll) {
|
||||
if (scroll == MOUSE_SCROLL_UP) return GetMouseScrollUp ();
|
||||
else return GetMouseScrollDown ();
|
||||
}
|
||||
|
||||
inline bool
|
||||
bool
|
||||
GetMouseScrollIsTapped (enum Scroll scroll) {
|
||||
if (scroll == MOUSE_SCROLL_UP) return GetMouseScrollUp () && !GetWasMouseScrollUp ();
|
||||
else return GetMouseScrollDown () && !GetWasMouseScrollDown ();
|
||||
}
|
||||
|
||||
inline bool
|
||||
bool
|
||||
ControllerButtonIsDown (SDL_GameControllerButton button) {
|
||||
return currentControllerButtonsState[button];
|
||||
}
|
||||
|
||||
inline bool
|
||||
bool
|
||||
ControllerButtonIsUp (SDL_GameControllerButton button) {
|
||||
return !ControllerButtonIsDown (button);
|
||||
}
|
||||
|
||||
inline bool
|
||||
bool
|
||||
ControllerButtonWasDown (SDL_GameControllerButton button) {
|
||||
return lastControllerButtonsState[button];
|
||||
}
|
||||
|
||||
inline bool
|
||||
bool
|
||||
ControllerButtonWasUp (SDL_GameControllerButton button) {
|
||||
return !ControllerButtonWasDown (button);
|
||||
}
|
||||
|
||||
inline bool
|
||||
bool
|
||||
ControllerButtonIsTapped (SDL_GameControllerButton button) {
|
||||
return ControllerButtonIsDown (button) && ControllerButtonWasUp (button);
|
||||
}
|
||||
|
||||
inline bool
|
||||
bool
|
||||
ControllerButtonIsReleased (SDL_GameControllerButton button) {
|
||||
return ControllerButtonIsUp (button) && ControllerButtonWasDown (button);
|
||||
}
|
||||
|
||||
inline bool
|
||||
bool
|
||||
ControllerAxisIsDown (enum SDLAxis axis) {
|
||||
switch (axis) {
|
||||
case SDL_AXIS_LEFT_LEFT: return currentControllerAxisState.LeftLeft;
|
||||
@ -488,12 +480,12 @@ ControllerAxisIsDown (enum SDLAxis axis) {
|
||||
}
|
||||
}
|
||||
|
||||
inline bool
|
||||
bool
|
||||
ControllerAxisIsUp (enum SDLAxis axis) {
|
||||
return !ControllerAxisIsDown (axis);
|
||||
}
|
||||
|
||||
inline bool
|
||||
bool
|
||||
ControllerAxisWasDown (enum SDLAxis axis) {
|
||||
switch (axis) {
|
||||
case SDL_AXIS_LEFT_LEFT: return lastControllerAxisState.LeftLeft;
|
||||
@ -511,32 +503,32 @@ ControllerAxisWasDown (enum SDLAxis axis) {
|
||||
}
|
||||
}
|
||||
|
||||
inline bool
|
||||
bool
|
||||
ControllerAxisWasUp (enum SDLAxis axis) {
|
||||
return !ControllerAxisWasDown (axis);
|
||||
}
|
||||
|
||||
inline bool
|
||||
bool
|
||||
ControllerAxisIsTapped (enum SDLAxis axis) {
|
||||
return ControllerAxisIsDown (axis) && ControllerAxisWasUp (axis);
|
||||
}
|
||||
|
||||
inline bool
|
||||
bool
|
||||
ControllerAxisIsReleased (enum SDLAxis axis) {
|
||||
return ControllerAxisIsUp (axis) && ControllerAxisWasDown (axis);
|
||||
}
|
||||
|
||||
inline bool
|
||||
bool
|
||||
IsButtonTapped (struct Keybindings bindings) {
|
||||
return GetInternalButtonState (bindings).Tapped;
|
||||
}
|
||||
|
||||
inline bool
|
||||
bool
|
||||
IsButtonReleased (struct Keybindings bindings) {
|
||||
return GetInternalButtonState (bindings).Released;
|
||||
}
|
||||
|
||||
inline bool
|
||||
bool
|
||||
IsButtonDown (struct Keybindings bindings) {
|
||||
return GetInternalButtonState (bindings).Down;
|
||||
}
|
@ -1,3 +1,4 @@
|
||||
#pragma once
|
||||
#include <SDL.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
@ -61,6 +62,9 @@ struct InternalButtonState {
|
||||
unsigned int Tapped : 1;
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
bool InitializePoll (void *DivaWindowHandle);
|
||||
void UpdatePoll (void *DivaWindowHandle);
|
||||
void DisposePoll ();
|
||||
@ -80,7 +84,7 @@ POINT GetMousePosition ();
|
||||
POINT GetLastMousePosition ();
|
||||
POINT GetMouseRelativePosition ();
|
||||
POINT GetLastMouseRelativePosition ();
|
||||
void SetMousePosition (POINT new);
|
||||
void SetMousePosition (POINT newPosition);
|
||||
bool GetMouseScrollUp ();
|
||||
bool GetMouseScrollDown ();
|
||||
bool GetWasMouseScrollUp ();
|
||||
@ -103,3 +107,6 @@ bool ControllerAxisIsReleased (enum SDLAxis axis);
|
||||
bool IsButtonTapped (struct Keybindings bindings);
|
||||
bool IsButtonReleased (struct Keybindings bindings);
|
||||
bool IsButtonDown (struct Keybindings bindings);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user