summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authorLéo Lam <leo@innovatetechnologi.es>2019-05-10 18:52:52 +0200
committerGitHub <noreply@github.com>2019-05-10 18:52:52 +0200
commite7bc86881d7fd42900aaeedaff7c8b1d24d3cd55 (patch)
treef2381c77dda1d60cbf1dfc34f054e4495ddc4323 /Source
parent672e8d78c6c509934666b60139a98c8f1ed52183 (diff)
parent8e2277e1f2a299b2d5ff5070e24b57b20791306f (diff)
Merge pull request #8056 from JosJuice/more-enums-to-constexpr
Turn more enum constants into constexpr
Diffstat (limited to 'Source')
-rw-r--r--Source/Core/Core/HW/DVD/DVDInterface.cpp60
-rw-r--r--Source/Core/Core/HW/DVD/DVDInterface.h30
-rw-r--r--Source/Core/Core/HW/WiimoteEmu/Extension/Classic.h78
-rw-r--r--Source/Core/Core/HW/WiimoteEmu/Extension/Drums.h35
-rw-r--r--Source/Core/Core/HW/WiimoteEmu/Extension/Guitar.h23
-rw-r--r--Source/Core/Core/HW/WiimoteEmu/Extension/Nunchuk.h23
-rw-r--r--Source/Core/Core/HW/WiimoteEmu/Extension/Turntable.h21
-rw-r--r--Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.h36
-rw-r--r--Source/Core/Core/HW/WiimoteReal/WiimoteReal.h21
9 files changed, 138 insertions, 189 deletions
diff --git a/Source/Core/Core/HW/DVD/DVDInterface.cpp b/Source/Core/Core/HW/DVD/DVDInterface.cpp
index 599620a9c7..885b8dd0a1 100644
--- a/Source/Core/Core/HW/DVD/DVDInterface.cpp
+++ b/Source/Core/Core/HW/DVD/DVDInterface.cpp
@@ -59,29 +59,49 @@ constexpr u64 BUFFER_TRANSFER_RATE = 32 * 1024 * 1024;
namespace DVDInterface
{
+// "low" error codes
+constexpr u32 ERROR_READY = 0x0000000; // Ready.
+constexpr u32 ERROR_COVER_L = 0x01000000; // Cover is opened.
+constexpr u32 ERROR_CHANGE_DISK = 0x02000000; // Disk change.
+constexpr u32 ERROR_NO_DISK = 0x03000000; // No disk.
+constexpr u32 ERROR_MOTOR_STOP_L = 0x04000000; // Motor stop.
+constexpr u32 ERROR_NO_DISKID_L = 0x05000000; // Disk ID not read.
+
+// "high" error codes
+constexpr u32 ERROR_NONE = 0x000000; // No error.
+constexpr u32 ERROR_MOTOR_STOP_H = 0x020400; // Motor stopped.
+constexpr u32 ERROR_NO_DISKID_H = 0x020401; // Disk ID not read.
+constexpr u32 ERROR_COVER_H = 0x023a00; // Medium not present / Cover opened.
+constexpr u32 ERROR_SEEK_NDONE = 0x030200; // No seek complete.
+constexpr u32 ERROR_READ = 0x031100; // Unrecovered read error.
+constexpr u32 ERROR_PROTOCOL = 0x040800; // Transfer protocol error.
+constexpr u32 ERROR_INV_CMD = 0x052000; // Invalid command operation code.
+constexpr u32 ERROR_AUDIO_BUF = 0x052001; // Audio Buffer not set.
+constexpr u32 ERROR_BLOCK_OOB = 0x052100; // Logical block address out of bounds.
+constexpr u32 ERROR_INV_FIELD = 0x052400; // Invalid field in command packet.
+constexpr u32 ERROR_INV_AUDIO = 0x052401; // Invalid audio command.
+constexpr u32 ERROR_INV_PERIOD = 0x052402; // Configuration out of permitted period.
+constexpr u32 ERROR_END_USR_AREA = 0x056300; // End of user area encountered on this track.
+constexpr u32 ERROR_MEDIUM = 0x062800; // Medium may have changed.
+constexpr u32 ERROR_MEDIUM_REQ = 0x0b5a01; // Operator medium removal request.
+
// internal hardware addresses
-enum
-{
- DI_STATUS_REGISTER = 0x00,
- DI_COVER_REGISTER = 0x04,
- DI_COMMAND_0 = 0x08,
- DI_COMMAND_1 = 0x0C,
- DI_COMMAND_2 = 0x10,
- DI_DMA_ADDRESS_REGISTER = 0x14,
- DI_DMA_LENGTH_REGISTER = 0x18,
- DI_DMA_CONTROL_REGISTER = 0x1C,
- DI_IMMEDIATE_DATA_BUFFER = 0x20,
- DI_CONFIG_REGISTER = 0x24
-};
+constexpr u32 DI_STATUS_REGISTER = 0x00;
+constexpr u32 DI_COVER_REGISTER = 0x04;
+constexpr u32 DI_COMMAND_0 = 0x08;
+constexpr u32 DI_COMMAND_1 = 0x0C;
+constexpr u32 DI_COMMAND_2 = 0x10;
+constexpr u32 DI_DMA_ADDRESS_REGISTER = 0x14;
+constexpr u32 DI_DMA_LENGTH_REGISTER = 0x18;
+constexpr u32 DI_DMA_CONTROL_REGISTER = 0x1C;
+constexpr u32 DI_IMMEDIATE_DATA_BUFFER = 0x20;
+constexpr u32 DI_CONFIG_REGISTER = 0x24;
// debug commands which may be ORd
-enum
-{
- STOP_DRIVE = 0,
- START_DRIVE = 0x100,
- ACCEPT_COPY = 0x4000,
- DISC_CHECK = 0x8000,
-};
+constexpr u32 STOP_DRIVE = 0;
+constexpr u32 START_DRIVE = 0x100;
+constexpr u32 ACCEPT_COPY = 0x4000;
+constexpr u32 DISC_CHECK = 0x8000;
// DI Status Register
union UDISR
diff --git a/Source/Core/Core/HW/DVD/DVDInterface.h b/Source/Core/Core/HW/DVD/DVDInterface.h
index 3c37ba5534..1239bbf5f1 100644
--- a/Source/Core/Core/HW/DVD/DVDInterface.h
+++ b/Source/Core/Core/HW/DVD/DVDInterface.h
@@ -24,36 +24,6 @@ class Mapping;
namespace DVDInterface
{
-// Not sure about endianness here. I'll just name them like this...
-enum DIErrorLow
-{
- ERROR_READY = 0x00000000, // Ready.
- ERROR_COVER_L = 0x01000000, // Cover is opened.
- ERROR_CHANGE_DISK = 0x02000000, // Disk change.
- ERROR_NO_DISK = 0x03000000, // No disk.
- ERROR_MOTOR_STOP_L = 0x04000000, // Motor stop.
- ERROR_NO_DISKID_L = 0x05000000 // Disk ID not read.
-};
-enum DIErrorHigh
-{
- ERROR_NONE = 0x000000, // No error.
- ERROR_MOTOR_STOP_H = 0x020400, // Motor stopped.
- ERROR_NO_DISKID_H = 0x020401, // Disk ID not read.
- ERROR_COVER_H = 0x023a00, // Medium not present / Cover opened.
- ERROR_SEEK_NDONE = 0x030200, // No seek complete.
- ERROR_READ = 0x031100, // Unrecovered read error.
- ERROR_PROTOCOL = 0x040800, // Transfer protocol error.
- ERROR_INV_CMD = 0x052000, // Invalid command operation code.
- ERROR_AUDIO_BUF = 0x052001, // Audio Buffer not set.
- ERROR_BLOCK_OOB = 0x052100, // Logical block address out of bounds.
- ERROR_INV_FIELD = 0x052400, // Invalid field in command packet.
- ERROR_INV_AUDIO = 0x052401, // Invalid audio command.
- ERROR_INV_PERIOD = 0x052402, // Configuration out of permitted period.
- ERROR_END_USR_AREA = 0x056300, // End of user area encountered on this track.
- ERROR_MEDIUM = 0x062800, // Medium may have changed.
- ERROR_MEDIUM_REQ = 0x0b5a01 // Operator medium removal request.
-};
-
enum DICommand
{
DVDLowInquiry = 0x12,
diff --git a/Source/Core/Core/HW/WiimoteEmu/Extension/Classic.h b/Source/Core/Core/HW/WiimoteEmu/Extension/Classic.h
index ac3016537d..34da9cd452 100644
--- a/Source/Core/Core/HW/WiimoteEmu/Extension/Classic.h
+++ b/Source/Core/Core/HW/WiimoteEmu/Extension/Classic.h
@@ -88,47 +88,43 @@ public:
ControllerEmu::ControlGroup* GetGroup(ClassicGroup group);
- enum
- {
- PAD_RIGHT = 0x80,
- PAD_DOWN = 0x40,
- TRIGGER_L = 0x20,
- BUTTON_MINUS = 0x10,
- BUTTON_HOME = 0x08,
- BUTTON_PLUS = 0x04,
- TRIGGER_R = 0x02,
- NOTHING = 0x01,
- BUTTON_ZL = 0x8000,
- BUTTON_B = 0x4000,
- BUTTON_Y = 0x2000,
- BUTTON_A = 0x1000,
- BUTTON_X = 0x0800,
- BUTTON_ZR = 0x0400,
- PAD_LEFT = 0x0200,
- PAD_UP = 0x0100,
- };
-
- enum
- {
- CAL_STICK_CENTER = 0x80,
- CAL_STICK_RANGE = 0x7f,
- CAL_STICK_BITS = 8,
-
- LEFT_STICK_BITS = 6,
- LEFT_STICK_CENTER_X = CAL_STICK_CENTER >> (CAL_STICK_BITS - LEFT_STICK_BITS),
- LEFT_STICK_CENTER_Y = CAL_STICK_CENTER >> (CAL_STICK_BITS - LEFT_STICK_BITS),
- LEFT_STICK_RADIUS = CAL_STICK_RANGE >> (CAL_STICK_BITS - LEFT_STICK_BITS),
-
- RIGHT_STICK_BITS = 5,
- RIGHT_STICK_CENTER_X = CAL_STICK_CENTER >> (CAL_STICK_BITS - RIGHT_STICK_BITS),
- RIGHT_STICK_CENTER_Y = CAL_STICK_CENTER >> (CAL_STICK_BITS - RIGHT_STICK_BITS),
- RIGHT_STICK_RADIUS = CAL_STICK_RANGE >> (CAL_STICK_BITS - RIGHT_STICK_BITS),
-
- LEFT_TRIGGER_RANGE = 0x1F,
- RIGHT_TRIGGER_RANGE = 0x1F,
- };
-
- static const u8 STICK_GATE_RADIUS = 0x16;
+ static constexpr u16 PAD_RIGHT = 0x80;
+ static constexpr u16 PAD_DOWN = 0x40;
+ static constexpr u16 TRIGGER_L = 0x20;
+ static constexpr u16 BUTTON_MINUS = 0x10;
+ static constexpr u16 BUTTON_HOME = 0x08;
+ static constexpr u16 BUTTON_PLUS = 0x04;
+ static constexpr u16 TRIGGER_R = 0x02;
+ static constexpr u16 NOTHING = 0x01;
+ static constexpr u16 BUTTON_ZL = 0x8000;
+ static constexpr u16 BUTTON_B = 0x4000;
+ static constexpr u16 BUTTON_Y = 0x2000;
+ static constexpr u16 BUTTON_A = 0x1000;
+ static constexpr u16 BUTTON_X = 0x0800;
+ static constexpr u16 BUTTON_ZR = 0x0400;
+ static constexpr u16 PAD_LEFT = 0x0200;
+ static constexpr u16 PAD_UP = 0x0100;
+
+ static constexpr u8 CAL_STICK_CENTER = 0x80;
+ static constexpr u8 CAL_STICK_RANGE = 0x7f;
+ static constexpr int CAL_STICK_BITS = 8;
+
+ static constexpr int LEFT_STICK_BITS = 6;
+ static constexpr u8 LEFT_STICK_CENTER_X = CAL_STICK_CENTER >> (CAL_STICK_BITS - LEFT_STICK_BITS);
+ static constexpr u8 LEFT_STICK_CENTER_Y = CAL_STICK_CENTER >> (CAL_STICK_BITS - LEFT_STICK_BITS);
+ static constexpr u8 LEFT_STICK_RADIUS = CAL_STICK_RANGE >> (CAL_STICK_BITS - LEFT_STICK_BITS);
+
+ static constexpr int RIGHT_STICK_BITS = 5;
+ static constexpr u8 RIGHT_STICK_CENTER_X = CAL_STICK_CENTER >>
+ (CAL_STICK_BITS - RIGHT_STICK_BITS);
+ static constexpr u8 RIGHT_STICK_CENTER_Y = CAL_STICK_CENTER >>
+ (CAL_STICK_BITS - RIGHT_STICK_BITS);
+ static constexpr u8 RIGHT_STICK_RADIUS = CAL_STICK_RANGE >> (CAL_STICK_BITS - RIGHT_STICK_BITS);
+
+ static constexpr u8 LEFT_TRIGGER_RANGE = 0x1F;
+ static constexpr u8 RIGHT_TRIGGER_RANGE = 0x1F;
+
+ static constexpr u8 STICK_GATE_RADIUS = 0x16;
private:
ControllerEmu::Buttons* m_buttons;
diff --git a/Source/Core/Core/HW/WiimoteEmu/Extension/Drums.h b/Source/Core/Core/HW/WiimoteEmu/Extension/Drums.h
index baaf497319..ad3286cbc0 100644
--- a/Source/Core/Core/HW/WiimoteEmu/Extension/Drums.h
+++ b/Source/Core/Core/HW/WiimoteEmu/Extension/Drums.h
@@ -67,8 +67,8 @@ public:
{
None = 0b1111111,
Bass = 0b1011011,
- // TODO: Implement HiHat.
- // HiHat = 0b0011011,
+ // TODO: Implement HiHatPedal.
+ // HiHatPedal = 0b0011011,
Red = 0b1011001,
Yellow = 0b1010001,
Blue = 0b1001111,
@@ -86,25 +86,18 @@ public:
void DoState(PointerWrap& p) override;
- enum : u8
- {
- BUTTON_PLUS = 0x04,
- BUTTON_MINUS = 0x10,
-
- // FYI: The low/high bits of the button byte are "random" when velocity data is present.
- // HAVE_VELOCITY_DATA = 0b10000001,
- };
-
- enum : u8
- {
- // FYI: HiHat sets no bits here.
- PAD_BASS = 0x04,
- PAD_BLUE = 0x08,
- PAD_GREEN = 0x10,
- PAD_YELLOW = 0x20,
- PAD_RED = 0x40,
- PAD_ORANGE = 0x80,
- };
+ // FYI: The low/high bits of the button byte are "random" when velocity data is present.
+ // static constexpr u8 HAVE_VELOCITY_DATA = 0b10000001;
+ static constexpr u8 BUTTON_PLUS = 0x04;
+ static constexpr u8 BUTTON_MINUS = 0x10;
+
+ // FYI: The hi-hat pedal sets no bits here.
+ static constexpr u8 PAD_BASS = 0x04;
+ static constexpr u8 PAD_BLUE = 0x08;
+ static constexpr u8 PAD_GREEN = 0x10;
+ static constexpr u8 PAD_YELLOW = 0x20;
+ static constexpr u8 PAD_RED = 0x40;
+ static constexpr u8 PAD_ORANGE = 0x80;
// Note: My hardware's octagon stick produced the complete range of values (0 - 0x3f)
// It also had perfect center values of 0x20 with absolutely no "play".
diff --git a/Source/Core/Core/HW/WiimoteEmu/Extension/Guitar.h b/Source/Core/Core/HW/WiimoteEmu/Extension/Guitar.h
index ae2e9d8133..86cb8c6d2e 100644
--- a/Source/Core/Core/HW/WiimoteEmu/Extension/Guitar.h
+++ b/Source/Core/Core/HW/WiimoteEmu/Extension/Guitar.h
@@ -57,19 +57,16 @@ public:
ControllerEmu::ControlGroup* GetGroup(GuitarGroup group);
- enum
- {
- BUTTON_PLUS = 0x04,
- BUTTON_MINUS = 0x10,
- BAR_DOWN = 0x40,
-
- BAR_UP = 0x0100,
- FRET_YELLOW = 0x0800,
- FRET_GREEN = 0x1000,
- FRET_BLUE = 0x2000,
- FRET_RED = 0x4000,
- FRET_ORANGE = 0x8000,
- };
+ static constexpr u16 BUTTON_PLUS = 0x04;
+ static constexpr u16 BUTTON_MINUS = 0x10;
+ static constexpr u16 BAR_DOWN = 0x40;
+
+ static constexpr u16 BAR_UP = 0x0100;
+ static constexpr u16 FRET_YELLOW = 0x0800;
+ static constexpr u16 FRET_GREEN = 0x1000;
+ static constexpr u16 FRET_BLUE = 0x2000;
+ static constexpr u16 FRET_RED = 0x4000;
+ static constexpr u16 FRET_ORANGE = 0x8000;
static const u8 STICK_CENTER = 0x20;
static const u8 STICK_RADIUS = 0x1f;
diff --git a/Source/Core/Core/HW/WiimoteEmu/Extension/Nunchuk.h b/Source/Core/Core/HW/WiimoteEmu/Extension/Nunchuk.h
index 71b6eb51f7..42afa582a2 100644
--- a/Source/Core/Core/HW/WiimoteEmu/Extension/Nunchuk.h
+++ b/Source/Core/Core/HW/WiimoteEmu/Extension/Nunchuk.h
@@ -78,24 +78,15 @@ public:
ControllerEmu::ControlGroup* GetGroup(NunchukGroup group);
- enum
- {
- BUTTON_C = 0x02,
- BUTTON_Z = 0x01,
- };
+ static constexpr u8 BUTTON_C = 0x02;
+ static constexpr u8 BUTTON_Z = 0x01;
- enum
- {
- ACCEL_ZERO_G = 0x80,
- ACCEL_ONE_G = 0xB3,
- };
+ static constexpr u8 ACCEL_ZERO_G = 0x80;
+ static constexpr u8 ACCEL_ONE_G = 0xB3;
- enum
- {
- STICK_CENTER = 0x80,
- STICK_RADIUS = 0x7F,
- STICK_GATE_RADIUS = 0x52,
- };
+ static constexpr u8 STICK_CENTER = 0x80;
+ static constexpr u8 STICK_RADIUS = 0x7F;
+ static constexpr u8 STICK_GATE_RADIUS = 0x52;
void LoadDefaults(const ControllerInterface& ciface) override;
diff --git a/Source/Core/Core/HW/WiimoteEmu/Extension/Turntable.h b/Source/Core/Core/HW/WiimoteEmu/Extension/Turntable.h
index de9d2b3eba..8933136150 100644
--- a/Source/Core/Core/HW/WiimoteEmu/Extension/Turntable.h
+++ b/Source/Core/Core/HW/WiimoteEmu/Extension/Turntable.h
@@ -63,21 +63,18 @@ public:
ControllerEmu::ControlGroup* GetGroup(TurntableGroup group);
- enum
- {
- BUTTON_EUPHORIA = 0x1000,
+ static constexpr u16 BUTTON_EUPHORIA = 0x1000;
- BUTTON_L_GREEN = 0x0800,
- BUTTON_L_RED = 0x20,
- BUTTON_L_BLUE = 0x8000,
+ static constexpr u16 BUTTON_L_GREEN = 0x0800;
+ static constexpr u16 BUTTON_L_RED = 0x20;
+ static constexpr u16 BUTTON_L_BLUE = 0x8000;
- BUTTON_R_GREEN = 0x2000,
- BUTTON_R_RED = 0x02,
- BUTTON_R_BLUE = 0x0400,
+ static constexpr u16 BUTTON_R_GREEN = 0x2000;
+ static constexpr u16 BUTTON_R_RED = 0x02;
+ static constexpr u16 BUTTON_R_BLUE = 0x0400;
- BUTTON_MINUS = 0x10,
- BUTTON_PLUS = 0x04,
- };
+ static constexpr u16 BUTTON_MINUS = 0x10;
+ static constexpr u16 BUTTON_PLUS = 0x04;
static constexpr int STICK_BIT_COUNT = 6;
static constexpr u8 STICK_CENTER = (1 << STICK_BIT_COUNT) / 2;
diff --git a/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.h b/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.h
index d90bc65d64..1cfb70657a 100644
--- a/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.h
+++ b/Source/Core/Core/HW/WiimoteEmu/WiimoteEmu.h
@@ -83,27 +83,21 @@ void UpdateCalibrationDataChecksum(T& data, int cksum_bytes)
class Wiimote : public ControllerEmu::EmulatedController
{
public:
- enum : u8
- {
- ACCEL_ZERO_G = 0x80,
- ACCEL_ONE_G = 0x9A,
- };
-
- enum : u16
- {
- PAD_LEFT = 0x01,
- PAD_RIGHT = 0x02,
- PAD_DOWN = 0x04,
- PAD_UP = 0x08,
- BUTTON_PLUS = 0x10,
-
- BUTTON_TWO = 0x0100,
- BUTTON_ONE = 0x0200,
- BUTTON_B = 0x0400,
- BUTTON_A = 0x0800,
- BUTTON_MINUS = 0x1000,
- BUTTON_HOME = 0x8000,
- };
+ static constexpr u8 ACCEL_ZERO_G = 0x80;
+ static constexpr u8 ACCEL_ONE_G = 0x9A;
+
+ static constexpr u16 PAD_LEFT = 0x01;
+ static constexpr u16 PAD_RIGHT = 0x02;
+ static constexpr u16 PAD_DOWN = 0x04;
+ static constexpr u16 PAD_UP = 0x08;
+ static constexpr u16 BUTTON_PLUS = 0x10;
+
+ static constexpr u16 BUTTON_TWO = 0x0100;
+ static constexpr u16 BUTTON_ONE = 0x0200;
+ static constexpr u16 BUTTON_B = 0x0400;
+ static constexpr u16 BUTTON_A = 0x0800;
+ static constexpr u16 BUTTON_MINUS = 0x1000;
+ static constexpr u16 BUTTON_HOME = 0x8000;
explicit Wiimote(unsigned int index);
diff --git a/Source/Core/Core/HW/WiimoteReal/WiimoteReal.h b/Source/Core/Core/HW/WiimoteReal/WiimoteReal.h
index c951f86049..05421a7fb0 100644
--- a/Source/Core/Core/HW/WiimoteReal/WiimoteReal.h
+++ b/Source/Core/Core/HW/WiimoteReal/WiimoteReal.h
@@ -31,29 +31,20 @@ using Report = std::vector<u8>;
constexpr u32 WIIMOTE_DEFAULT_TIMEOUT = 1000;
// Communication channels
-enum WiimoteChannel
-{
- WC_OUTPUT = 0x11,
- WC_INPUT = 0x13,
-};
+constexpr u8 WC_OUTPUT = 0x11;
+constexpr u8 WC_INPUT = 0x13;
// The 4 most significant bits of the first byte of an outgoing command must be
// 0x50 if sending on the command channel and 0xA0 if sending on the interrupt
// channel. On Mac and Linux we use interrupt channel; on Windows, command.
-enum WiimoteReport
-{
#ifdef _WIN32
- WR_SET_REPORT = 0x50
+constexpr u8 WR_SET_REPORT = 0x50;
#else
- WR_SET_REPORT = 0xA0
+constexpr u8 WR_SET_REPORT = 0xA0;
#endif
-};
-enum WiimoteBT
-{
- BT_INPUT = 0x01,
- BT_OUTPUT = 0x02
-};
+constexpr u8 BT_INPUT = 0x01;
+constexpr u8 BT_OUTPUT = 0x02;
class Wiimote
{