You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-04 12:00:25 +00:00
Use BitField<> in core type masks
* All core types masks are now correctly marked as bitfields. * The enum hacks in MouseButtonMask and many other types are gone. This ensures that binders to other languages non C++ can actually implement type safe bitmasks. * Most bitmask operations replaced by functions in BitField<> * Key is still a problem because its enum and mask at the same time. While it kind of works in C++, this most likely can't be implemented safely in other languages and will have to be changed at some point. Mostly left as-is. * Documentation and API dump updated to reflect bitfields in core types.
This commit is contained in:
@@ -59,7 +59,7 @@ JoypadLinux::Joypad::~Joypad() {
|
||||
}
|
||||
|
||||
void JoypadLinux::Joypad::reset() {
|
||||
dpad = HatMask::CENTER;
|
||||
dpad = 0;
|
||||
fd = -1;
|
||||
for (int i = 0; i < MAX_ABS; i++) {
|
||||
abs_map[i] = -1;
|
||||
@@ -485,27 +485,33 @@ void JoypadLinux::process_joypads() {
|
||||
case ABS_HAT0X:
|
||||
if (joypad_event.value != 0) {
|
||||
if (joypad_event.value < 0) {
|
||||
joypad.dpad = (HatMask)((joypad.dpad | HatMask::LEFT) & ~HatMask::RIGHT);
|
||||
joypad.dpad.set_flag(HatMask::LEFT);
|
||||
joypad.dpad.clear_flag(HatMask::RIGHT);
|
||||
} else {
|
||||
joypad.dpad = (HatMask)((joypad.dpad | HatMask::RIGHT) & ~HatMask::LEFT);
|
||||
joypad.dpad.set_flag(HatMask::RIGHT);
|
||||
joypad.dpad.clear_flag(HatMask::LEFT);
|
||||
}
|
||||
} else {
|
||||
joypad.dpad &= ~(HatMask::LEFT | HatMask::RIGHT);
|
||||
joypad.dpad.clear_flag(HatMask::LEFT);
|
||||
joypad.dpad.clear_flag(HatMask::RIGHT);
|
||||
}
|
||||
input->joy_hat(i, (HatMask)joypad.dpad);
|
||||
input->joy_hat(i, joypad.dpad);
|
||||
break;
|
||||
|
||||
case ABS_HAT0Y:
|
||||
if (joypad_event.value != 0) {
|
||||
if (joypad_event.value < 0) {
|
||||
joypad.dpad = (HatMask)((joypad.dpad | HatMask::UP) & ~HatMask::DOWN);
|
||||
joypad.dpad.set_flag(HatMask::UP);
|
||||
joypad.dpad.clear_flag(HatMask::DOWN);
|
||||
} else {
|
||||
joypad.dpad = (HatMask)((joypad.dpad | HatMask::DOWN) & ~HatMask::UP);
|
||||
joypad.dpad.set_flag(HatMask::DOWN);
|
||||
joypad.dpad.clear_flag(HatMask::UP);
|
||||
}
|
||||
} else {
|
||||
joypad.dpad &= ~(HatMask::UP | HatMask::DOWN);
|
||||
joypad.dpad.clear_flag(HatMask::UP);
|
||||
joypad.dpad.clear_flag(HatMask::DOWN);
|
||||
}
|
||||
input->joy_hat(i, (HatMask)joypad.dpad);
|
||||
input->joy_hat(i, joypad.dpad);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user