From f4799aa679eee6b34853fd9fe4e2bb4ef5cb9ca6 Mon Sep 17 00:00:00 2001 From: TheoryOfNekomata Date: Sat, 25 Feb 2023 12:09:05 +0800 Subject: [PATCH] Update input code Correctly include portmidi in tests. --- TODO.md | 1 + .../subprojects/portmidi/portmidi.mock.h | 25 +------------------ src/packages/game/input/IZ_action.h | 2 +- src/packages/game/input/IZ_joystick.h | 5 ++-- src/packages/game/input/IZ_midi.h | 4 --- 5 files changed, 6 insertions(+), 31 deletions(-) diff --git a/TODO.md b/TODO.md index 501cf41..d111c48 100644 --- a/TODO.md +++ b/TODO.md @@ -1,6 +1,7 @@ - [X] Improve logging (remove SDL/lws dependency) - [X] Unify memset/memcpy/free/malloc functions (remove SDL/lws dependency) - [ ] Revisit unit tests +- [ ] Implement character sprites + animations - [ ] Implement memory pool - [ ] Fix gamepad mapping - [ ] Provide default mapping diff --git a/__mocks__/subprojects/portmidi/portmidi.mock.h b/__mocks__/subprojects/portmidi/portmidi.mock.h index 2f090be..cfbafa9 100644 --- a/__mocks__/subprojects/portmidi/portmidi.mock.h +++ b/__mocks__/subprojects/portmidi/portmidi.mock.h @@ -1,32 +1,9 @@ #ifndef PORTMIDI_MOCK_H #define PORTMIDI_MOCK_H -#define PORTMIDI_INCLUDED - +#include #include "../../../src/packages/common/IZ_common.h" -typedef i32 PmDeviceID; -typedef void PortMidiStream; -typedef i32 PmTimestamp; -typedef PmTimestamp (*PmTimeProcPtr)(void *time_info); -typedef i32 PmMessage; -typedef struct { - PmMessage message; - PmTimestamp timestamp; -} PmEvent; -typedef struct { - int structVersion; /**< @brief this internal structure version */ - const char *interf; /**< @brief underlying MIDI API, e.g. - "MMSystem" or "DirectX" */ - char *name; /**< @brief device name, e.g. "USB MidiSport 1x1" */ - int input; /**< @brief true iff input is available */ - int output; /**< @brief true iff output is available */ - int opened; /**< @brief used by generic PortMidi for error checking */ - int is_virtual; /**< @brief true iff this is/was a virtual device */ -} PmDeviceInfo; - -#define PmStream PortMidiStream - static PmDeviceInfo MOCK_DEVICE_INFO = { .output = 1, .input = 1, diff --git a/src/packages/game/input/IZ_action.h b/src/packages/game/input/IZ_action.h index 7961902..455c27b 100644 --- a/src/packages/game/input/IZ_action.h +++ b/src/packages/game/input/IZ_action.h @@ -3,7 +3,7 @@ #include "../../common/IZ_common.h" -#define IZ_CONTROLS (unsigned char) 16 +#define IZ_CONTROLS ((u8) 16) typedef u16 IZ_Action; diff --git a/src/packages/game/input/IZ_joystick.h b/src/packages/game/input/IZ_joystick.h index ca23003..a356b39 100644 --- a/src/packages/game/input/IZ_joystick.h +++ b/src/packages/game/input/IZ_joystick.h @@ -5,6 +5,7 @@ #include #include #include +#include "../../common/IZ_common.h" #include "../../config/IZ_config.h" #include "../../stdinc/IZ_string.h" #include "../../stdinc/IZ_stdlib.h" @@ -12,7 +13,7 @@ typedef u8 IZ_PadButton; -static const u16 IZ_DEFAULT_AXIS_THRESHOLD = 8000; +#define IZ_DEFAULT_AXIS_THRESHOLD ((u16) 8000) typedef enum { IZ_JOY_AXIS_DIRECTION_HORIZONTAL1 = 0, @@ -56,7 +57,7 @@ static const IZ_JoystickState IZ_JOYSTICK_DEFAULT_STATE[IZ_PLAYERS] = { 13, 14, }, - .axis_threshold = 8000u, + .axis_threshold = IZ_DEFAULT_AXIS_THRESHOLD, .device_id = 0, .guid = { .data = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } diff --git a/src/packages/game/input/IZ_midi.h b/src/packages/game/input/IZ_midi.h index ccfddfb..d35766a 100644 --- a/src/packages/game/input/IZ_midi.h +++ b/src/packages/game/input/IZ_midi.h @@ -2,11 +2,7 @@ #define IZ_MIDI_H #include - -#ifndef PORTMIDI_INCLUDED -#define PORTMIDI_INCLUDED #include -#endif #include #include "../../config/IZ_config.h"