mirror of
https://github.com/godotengine/godot.git
synced 2024-11-22 12:12:28 +00:00
Move many input enums to their own file
This commit is contained in:
parent
1acc76fecc
commit
e919d894f8
@ -106,10 +106,6 @@ static Vector<_CoreConstant> _global_constants;
|
||||
|
||||
VARIANT_ENUM_CAST(Key);
|
||||
VARIANT_ENUM_CAST(KeyModifierMask);
|
||||
VARIANT_ENUM_CAST(MouseButton);
|
||||
VARIANT_ENUM_CAST(JoyButton);
|
||||
VARIANT_ENUM_CAST(JoyAxis);
|
||||
VARIANT_ENUM_CAST(MIDIMessage);
|
||||
|
||||
void register_global_constants() {
|
||||
BIND_CORE_ENUM_CONSTANT(SIDE_LEFT);
|
||||
|
@ -993,21 +993,21 @@ void Input::joy_hat(int p_device, int p_val) {
|
||||
|
||||
JoyEvent map[HAT_MAX];
|
||||
|
||||
map[HAT_UP].type = TYPE_BUTTON;
|
||||
map[HAT_UP].index = JOY_BUTTON_DPAD_UP;
|
||||
map[HAT_UP].value = 0;
|
||||
map[HatDir::HAT_UP].type = TYPE_BUTTON;
|
||||
map[HatDir::HAT_UP].index = JOY_BUTTON_DPAD_UP;
|
||||
map[HatDir::HAT_UP].value = 0;
|
||||
|
||||
map[HAT_RIGHT].type = TYPE_BUTTON;
|
||||
map[HAT_RIGHT].index = JOY_BUTTON_DPAD_RIGHT;
|
||||
map[HAT_RIGHT].value = 0;
|
||||
map[HatDir::HAT_RIGHT].type = TYPE_BUTTON;
|
||||
map[HatDir::HAT_RIGHT].index = JOY_BUTTON_DPAD_RIGHT;
|
||||
map[HatDir::HAT_RIGHT].value = 0;
|
||||
|
||||
map[HAT_DOWN].type = TYPE_BUTTON;
|
||||
map[HAT_DOWN].index = JOY_BUTTON_DPAD_DOWN;
|
||||
map[HAT_DOWN].value = 0;
|
||||
map[HatDir::HAT_DOWN].type = TYPE_BUTTON;
|
||||
map[HatDir::HAT_DOWN].index = JOY_BUTTON_DPAD_DOWN;
|
||||
map[HatDir::HAT_DOWN].value = 0;
|
||||
|
||||
map[HAT_LEFT].type = TYPE_BUTTON;
|
||||
map[HAT_LEFT].index = JOY_BUTTON_DPAD_LEFT;
|
||||
map[HAT_LEFT].value = 0;
|
||||
map[HatDir::HAT_LEFT].type = TYPE_BUTTON;
|
||||
map[HatDir::HAT_LEFT].index = JOY_BUTTON_DPAD_LEFT;
|
||||
map[HatDir::HAT_LEFT].value = 0;
|
||||
|
||||
if (joy.mapping != -1) {
|
||||
_get_mapped_hat_events(map_db[joy.mapping], 0, map);
|
||||
@ -1162,17 +1162,17 @@ void Input::_get_mapped_hat_events(const JoyDeviceMapping &mapping, int p_hat, J
|
||||
if (binding.inputType == TYPE_HAT && binding.input.hat.hat == p_hat) {
|
||||
int hat_direction;
|
||||
switch (binding.input.hat.hat_mask) {
|
||||
case HAT_MASK_UP:
|
||||
hat_direction = HAT_UP;
|
||||
case HatMask::HAT_MASK_UP:
|
||||
hat_direction = HatDir::HAT_UP;
|
||||
break;
|
||||
case HAT_MASK_RIGHT:
|
||||
hat_direction = HAT_RIGHT;
|
||||
case HatMask::HAT_MASK_RIGHT:
|
||||
hat_direction = HatDir::HAT_RIGHT;
|
||||
break;
|
||||
case HAT_MASK_DOWN:
|
||||
hat_direction = HAT_DOWN;
|
||||
case HatMask::HAT_MASK_DOWN:
|
||||
hat_direction = HatDir::HAT_DOWN;
|
||||
break;
|
||||
case HAT_MASK_LEFT:
|
||||
hat_direction = HAT_LEFT;
|
||||
case HatMask::HAT_MASK_LEFT:
|
||||
hat_direction = HatDir::HAT_LEFT;
|
||||
break;
|
||||
default:
|
||||
ERR_PRINT_ONCE("Joypad button mapping error.");
|
||||
|
@ -72,22 +72,6 @@ public:
|
||||
CURSOR_MAX
|
||||
};
|
||||
|
||||
enum HatMask {
|
||||
HAT_MASK_CENTER = 0,
|
||||
HAT_MASK_UP = 1,
|
||||
HAT_MASK_RIGHT = 2,
|
||||
HAT_MASK_DOWN = 4,
|
||||
HAT_MASK_LEFT = 8,
|
||||
};
|
||||
|
||||
enum HatDir {
|
||||
HAT_UP,
|
||||
HAT_RIGHT,
|
||||
HAT_DOWN,
|
||||
HAT_LEFT,
|
||||
HAT_MAX,
|
||||
};
|
||||
|
||||
enum {
|
||||
JOYPADS_MAX = 16,
|
||||
};
|
||||
@ -149,7 +133,7 @@ private:
|
||||
bool connected = false;
|
||||
bool last_buttons[JOY_BUTTON_MAX] = { false };
|
||||
float last_axis[JOY_AXIS_MAX] = { 0.0f };
|
||||
int last_hat = HAT_MASK_CENTER;
|
||||
int last_hat = HatMask::HAT_MASK_CENTER;
|
||||
int mapping = -1;
|
||||
int hat_current = 0;
|
||||
};
|
||||
|
126
core/input/input_enums.h
Normal file
126
core/input/input_enums.h
Normal file
@ -0,0 +1,126 @@
|
||||
/*************************************************************************/
|
||||
/* input_enums.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#ifndef INPUT_ENUMS_H
|
||||
#define INPUT_ENUMS_H
|
||||
|
||||
enum HatDir {
|
||||
HAT_UP = 0,
|
||||
HAT_RIGHT = 1,
|
||||
HAT_DOWN = 2,
|
||||
HAT_LEFT = 3,
|
||||
HAT_MAX = 4,
|
||||
};
|
||||
|
||||
enum HatMask {
|
||||
HAT_MASK_CENTER = 0,
|
||||
HAT_MASK_UP = 1,
|
||||
HAT_MASK_RIGHT = 2,
|
||||
HAT_MASK_DOWN = 4,
|
||||
HAT_MASK_LEFT = 8,
|
||||
};
|
||||
|
||||
enum JoyAxis {
|
||||
JOY_AXIS_INVALID = -1,
|
||||
JOY_AXIS_LEFT_X = 0,
|
||||
JOY_AXIS_LEFT_Y = 1,
|
||||
JOY_AXIS_RIGHT_X = 2,
|
||||
JOY_AXIS_RIGHT_Y = 3,
|
||||
JOY_AXIS_TRIGGER_LEFT = 4,
|
||||
JOY_AXIS_TRIGGER_RIGHT = 5,
|
||||
JOY_AXIS_SDL_MAX = 6,
|
||||
JOY_AXIS_MAX = 10, // OpenVR supports up to 5 Joysticks making a total of 10 axes.
|
||||
};
|
||||
|
||||
enum JoyButton {
|
||||
JOY_BUTTON_INVALID = -1,
|
||||
JOY_BUTTON_A = 0,
|
||||
JOY_BUTTON_B = 1,
|
||||
JOY_BUTTON_X = 2,
|
||||
JOY_BUTTON_Y = 3,
|
||||
JOY_BUTTON_BACK = 4,
|
||||
JOY_BUTTON_GUIDE = 5,
|
||||
JOY_BUTTON_START = 6,
|
||||
JOY_BUTTON_LEFT_STICK = 7,
|
||||
JOY_BUTTON_RIGHT_STICK = 8,
|
||||
JOY_BUTTON_LEFT_SHOULDER = 9,
|
||||
JOY_BUTTON_RIGHT_SHOULDER = 10,
|
||||
JOY_BUTTON_DPAD_UP = 11,
|
||||
JOY_BUTTON_DPAD_DOWN = 12,
|
||||
JOY_BUTTON_DPAD_LEFT = 13,
|
||||
JOY_BUTTON_DPAD_RIGHT = 14,
|
||||
JOY_BUTTON_MISC1 = 15,
|
||||
JOY_BUTTON_PADDLE1 = 16,
|
||||
JOY_BUTTON_PADDLE2 = 17,
|
||||
JOY_BUTTON_PADDLE3 = 18,
|
||||
JOY_BUTTON_PADDLE4 = 19,
|
||||
JOY_BUTTON_TOUCHPAD = 20,
|
||||
JOY_BUTTON_SDL_MAX = 21,
|
||||
JOY_BUTTON_MAX = 36, // Android supports up to 36 buttons.
|
||||
};
|
||||
|
||||
enum MIDIMessage {
|
||||
MIDI_MESSAGE_NONE = 0,
|
||||
MIDI_MESSAGE_NOTE_OFF = 0x8,
|
||||
MIDI_MESSAGE_NOTE_ON = 0x9,
|
||||
MIDI_MESSAGE_AFTERTOUCH = 0xA,
|
||||
MIDI_MESSAGE_CONTROL_CHANGE = 0xB,
|
||||
MIDI_MESSAGE_PROGRAM_CHANGE = 0xC,
|
||||
MIDI_MESSAGE_CHANNEL_PRESSURE = 0xD,
|
||||
MIDI_MESSAGE_PITCH_BEND = 0xE,
|
||||
};
|
||||
|
||||
enum MouseButton {
|
||||
MOUSE_BUTTON_NONE = 0,
|
||||
MOUSE_BUTTON_LEFT = 1,
|
||||
MOUSE_BUTTON_RIGHT = 2,
|
||||
MOUSE_BUTTON_MIDDLE = 3,
|
||||
MOUSE_BUTTON_WHEEL_UP = 4,
|
||||
MOUSE_BUTTON_WHEEL_DOWN = 5,
|
||||
MOUSE_BUTTON_WHEEL_LEFT = 6,
|
||||
MOUSE_BUTTON_WHEEL_RIGHT = 7,
|
||||
MOUSE_BUTTON_XBUTTON1 = 8,
|
||||
MOUSE_BUTTON_XBUTTON2 = 9,
|
||||
MOUSE_BUTTON_MASK_LEFT = (1 << (MOUSE_BUTTON_LEFT - 1)),
|
||||
MOUSE_BUTTON_MASK_RIGHT = (1 << (MOUSE_BUTTON_RIGHT - 1)),
|
||||
MOUSE_BUTTON_MASK_MIDDLE = (1 << (MOUSE_BUTTON_MIDDLE - 1)),
|
||||
MOUSE_BUTTON_MASK_XBUTTON1 = (1 << (MOUSE_BUTTON_XBUTTON1 - 1)),
|
||||
MOUSE_BUTTON_MASK_XBUTTON2 = (1 << (MOUSE_BUTTON_XBUTTON2 - 1)),
|
||||
};
|
||||
|
||||
inline MouseButton &operator|=(MouseButton &a, MouseButton b) {
|
||||
return (MouseButton &)((int &)a |= (int)b);
|
||||
}
|
||||
|
||||
inline MouseButton &operator&=(MouseButton &a, MouseButton b) {
|
||||
return (MouseButton &)((int &)a &= (int)b);
|
||||
}
|
||||
|
||||
#endif // INPUT_ENUMS_H
|
@ -31,6 +31,7 @@
|
||||
#ifndef INPUT_EVENT_H
|
||||
#define INPUT_EVENT_H
|
||||
|
||||
#include "core/input/input_enums.h"
|
||||
#include "core/io/resource.h"
|
||||
#include "core/math/transform_2d.h"
|
||||
#include "core/string/ustring.h"
|
||||
@ -41,72 +42,6 @@
|
||||
* The events are pretty obvious.
|
||||
*/
|
||||
|
||||
enum MouseButton {
|
||||
MOUSE_BUTTON_LEFT = 1,
|
||||
MOUSE_BUTTON_RIGHT = 2,
|
||||
MOUSE_BUTTON_MIDDLE = 3,
|
||||
MOUSE_BUTTON_WHEEL_UP = 4,
|
||||
MOUSE_BUTTON_WHEEL_DOWN = 5,
|
||||
MOUSE_BUTTON_WHEEL_LEFT = 6,
|
||||
MOUSE_BUTTON_WHEEL_RIGHT = 7,
|
||||
MOUSE_BUTTON_XBUTTON1 = 8,
|
||||
MOUSE_BUTTON_XBUTTON2 = 9,
|
||||
MOUSE_BUTTON_MASK_LEFT = (1 << (MOUSE_BUTTON_LEFT - 1)),
|
||||
MOUSE_BUTTON_MASK_RIGHT = (1 << (MOUSE_BUTTON_RIGHT - 1)),
|
||||
MOUSE_BUTTON_MASK_MIDDLE = (1 << (MOUSE_BUTTON_MIDDLE - 1)),
|
||||
MOUSE_BUTTON_MASK_XBUTTON1 = (1 << (MOUSE_BUTTON_XBUTTON1 - 1)),
|
||||
MOUSE_BUTTON_MASK_XBUTTON2 = (1 << (MOUSE_BUTTON_XBUTTON2 - 1))
|
||||
};
|
||||
|
||||
enum JoyButton {
|
||||
JOY_BUTTON_INVALID = -1,
|
||||
JOY_BUTTON_A = 0,
|
||||
JOY_BUTTON_B = 1,
|
||||
JOY_BUTTON_X = 2,
|
||||
JOY_BUTTON_Y = 3,
|
||||
JOY_BUTTON_BACK = 4,
|
||||
JOY_BUTTON_GUIDE = 5,
|
||||
JOY_BUTTON_START = 6,
|
||||
JOY_BUTTON_LEFT_STICK = 7,
|
||||
JOY_BUTTON_RIGHT_STICK = 8,
|
||||
JOY_BUTTON_LEFT_SHOULDER = 9,
|
||||
JOY_BUTTON_RIGHT_SHOULDER = 10,
|
||||
JOY_BUTTON_DPAD_UP = 11,
|
||||
JOY_BUTTON_DPAD_DOWN = 12,
|
||||
JOY_BUTTON_DPAD_LEFT = 13,
|
||||
JOY_BUTTON_DPAD_RIGHT = 14,
|
||||
JOY_BUTTON_MISC1 = 15,
|
||||
JOY_BUTTON_PADDLE1 = 16,
|
||||
JOY_BUTTON_PADDLE2 = 17,
|
||||
JOY_BUTTON_PADDLE3 = 18,
|
||||
JOY_BUTTON_PADDLE4 = 19,
|
||||
JOY_BUTTON_TOUCHPAD = 20,
|
||||
JOY_BUTTON_SDL_MAX = 21,
|
||||
JOY_BUTTON_MAX = 36, // Android supports up to 36 buttons.
|
||||
};
|
||||
|
||||
enum JoyAxis {
|
||||
JOY_AXIS_INVALID = -1,
|
||||
JOY_AXIS_LEFT_X = 0,
|
||||
JOY_AXIS_LEFT_Y = 1,
|
||||
JOY_AXIS_RIGHT_X = 2,
|
||||
JOY_AXIS_RIGHT_Y = 3,
|
||||
JOY_AXIS_TRIGGER_LEFT = 4,
|
||||
JOY_AXIS_TRIGGER_RIGHT = 5,
|
||||
JOY_AXIS_SDL_MAX = 6,
|
||||
JOY_AXIS_MAX = 10, // OpenVR supports up to 5 Joysticks making a total of 10 axes.
|
||||
};
|
||||
|
||||
enum MIDIMessage {
|
||||
MIDI_MESSAGE_NOTE_OFF = 0x8,
|
||||
MIDI_MESSAGE_NOTE_ON = 0x9,
|
||||
MIDI_MESSAGE_AFTERTOUCH = 0xA,
|
||||
MIDI_MESSAGE_CONTROL_CHANGE = 0xB,
|
||||
MIDI_MESSAGE_PROGRAM_CHANGE = 0xC,
|
||||
MIDI_MESSAGE_CHANNEL_PRESSURE = 0xD,
|
||||
MIDI_MESSAGE_PITCH_BEND = 0xE,
|
||||
};
|
||||
|
||||
/**
|
||||
* Input Modifier Status
|
||||
* for keyboard/mouse events.
|
||||
|
@ -31,6 +31,7 @@
|
||||
#ifndef BINDER_COMMON_H
|
||||
#define BINDER_COMMON_H
|
||||
|
||||
#include "core/input/input_enums.h"
|
||||
#include "core/object/object.h"
|
||||
#include "core/templates/list.h"
|
||||
#include "core/templates/simple_type.h"
|
||||
@ -90,6 +91,12 @@ VARIANT_ENUM_CAST(Error);
|
||||
VARIANT_ENUM_CAST(Side);
|
||||
VARIANT_ENUM_CAST(ClockDirection);
|
||||
VARIANT_ENUM_CAST(Corner);
|
||||
VARIANT_ENUM_CAST(HatDir);
|
||||
VARIANT_ENUM_CAST(HatMask);
|
||||
VARIANT_ENUM_CAST(JoyAxis);
|
||||
VARIANT_ENUM_CAST(JoyButton);
|
||||
VARIANT_ENUM_CAST(MIDIMessage);
|
||||
VARIANT_ENUM_CAST(MouseButton);
|
||||
VARIANT_ENUM_CAST(Orientation);
|
||||
VARIANT_ENUM_CAST(HAlign);
|
||||
VARIANT_ENUM_CAST(VAlign);
|
||||
|
@ -324,15 +324,15 @@ JNIEXPORT void JNICALL Java_org_godotengine_godot_GodotLib_joyhat(JNIEnv *env, j
|
||||
int hat = 0;
|
||||
if (p_hat_x != 0) {
|
||||
if (p_hat_x < 0)
|
||||
hat |= Input::HAT_MASK_LEFT;
|
||||
hat |= HatMask::HAT_MASK_LEFT;
|
||||
else
|
||||
hat |= Input::HAT_MASK_RIGHT;
|
||||
hat |= HatMask::HAT_MASK_RIGHT;
|
||||
}
|
||||
if (p_hat_y != 0) {
|
||||
if (p_hat_y < 0)
|
||||
hat |= Input::HAT_MASK_UP;
|
||||
hat |= HatMask::HAT_MASK_UP;
|
||||
else
|
||||
hat |= Input::HAT_MASK_DOWN;
|
||||
hat |= HatMask::HAT_MASK_DOWN;
|
||||
}
|
||||
jevent.hat = hat;
|
||||
|
||||
|
@ -484,12 +484,12 @@ void JoypadLinux::process_joypads() {
|
||||
case ABS_HAT0X:
|
||||
if (ev.value != 0) {
|
||||
if (ev.value < 0) {
|
||||
joy->dpad = (joy->dpad | Input::HAT_MASK_LEFT) & ~Input::HAT_MASK_RIGHT;
|
||||
joy->dpad = (joy->dpad | HatMask::HAT_MASK_LEFT) & ~HatMask::HAT_MASK_RIGHT;
|
||||
} else {
|
||||
joy->dpad = (joy->dpad | Input::HAT_MASK_RIGHT) & ~Input::HAT_MASK_LEFT;
|
||||
joy->dpad = (joy->dpad | HatMask::HAT_MASK_RIGHT) & ~HatMask::HAT_MASK_LEFT;
|
||||
}
|
||||
} else {
|
||||
joy->dpad &= ~(Input::HAT_MASK_LEFT | Input::HAT_MASK_RIGHT);
|
||||
joy->dpad &= ~(HatMask::HAT_MASK_LEFT | HatMask::HAT_MASK_RIGHT);
|
||||
}
|
||||
|
||||
input->joy_hat(i, joy->dpad);
|
||||
@ -498,12 +498,12 @@ void JoypadLinux::process_joypads() {
|
||||
case ABS_HAT0Y:
|
||||
if (ev.value != 0) {
|
||||
if (ev.value < 0) {
|
||||
joy->dpad = (joy->dpad | Input::HAT_MASK_UP) & ~Input::HAT_MASK_DOWN;
|
||||
joy->dpad = (joy->dpad | HatMask::HAT_MASK_UP) & ~HatMask::HAT_MASK_DOWN;
|
||||
} else {
|
||||
joy->dpad = (joy->dpad | Input::HAT_MASK_DOWN) & ~Input::HAT_MASK_UP;
|
||||
joy->dpad = (joy->dpad | HatMask::HAT_MASK_DOWN) & ~HatMask::HAT_MASK_UP;
|
||||
}
|
||||
} else {
|
||||
joy->dpad &= ~(Input::HAT_MASK_UP | Input::HAT_MASK_DOWN);
|
||||
joy->dpad &= ~(HatMask::HAT_MASK_UP | HatMask::HAT_MASK_DOWN);
|
||||
}
|
||||
|
||||
input->joy_hat(i, joy->dpad);
|
||||
|
@ -390,38 +390,38 @@ bool joypad::check_ff_features() {
|
||||
static int process_hat_value(int p_min, int p_max, int p_value) {
|
||||
int range = (p_max - p_min + 1);
|
||||
int value = p_value - p_min;
|
||||
int hat_value = Input::HAT_MASK_CENTER;
|
||||
int hat_value = HatMask::HAT_MASK_CENTER;
|
||||
if (range == 4) {
|
||||
value *= 2;
|
||||
}
|
||||
|
||||
switch (value) {
|
||||
case 0:
|
||||
hat_value = Input::HAT_MASK_UP;
|
||||
hat_value = (HatMask)HatMask::HAT_MASK_UP;
|
||||
break;
|
||||
case 1:
|
||||
hat_value = Input::HAT_MASK_UP | Input::HAT_MASK_RIGHT;
|
||||
hat_value = (HatMask)(HatMask::HAT_MASK_UP | HatMask::HAT_MASK_RIGHT);
|
||||
break;
|
||||
case 2:
|
||||
hat_value = Input::HAT_MASK_RIGHT;
|
||||
hat_value = (HatMask)HatMask::HAT_MASK_RIGHT;
|
||||
break;
|
||||
case 3:
|
||||
hat_value = Input::HAT_MASK_DOWN | Input::HAT_MASK_RIGHT;
|
||||
hat_value = (HatMask)(HatMask::HAT_MASK_DOWN | HatMask::HAT_MASK_RIGHT);
|
||||
break;
|
||||
case 4:
|
||||
hat_value = Input::HAT_MASK_DOWN;
|
||||
hat_value = (HatMask)HatMask::HAT_MASK_DOWN;
|
||||
break;
|
||||
case 5:
|
||||
hat_value = Input::HAT_MASK_DOWN | Input::HAT_MASK_LEFT;
|
||||
hat_value = (HatMask)(HatMask::HAT_MASK_DOWN | HatMask::HAT_MASK_LEFT);
|
||||
break;
|
||||
case 6:
|
||||
hat_value = Input::HAT_MASK_LEFT;
|
||||
hat_value = (HatMask)HatMask::HAT_MASK_LEFT;
|
||||
break;
|
||||
case 7:
|
||||
hat_value = Input::HAT_MASK_UP | Input::HAT_MASK_LEFT;
|
||||
hat_value = (HatMask)(HatMask::HAT_MASK_UP | HatMask::HAT_MASK_LEFT);
|
||||
break;
|
||||
default:
|
||||
hat_value = Input::HAT_MASK_CENTER;
|
||||
hat_value = (HatMask)HatMask::HAT_MASK_CENTER;
|
||||
break;
|
||||
}
|
||||
return hat_value;
|
||||
|
@ -417,31 +417,31 @@ void JoypadWindows::post_hat(int p_device, DWORD p_dpad) {
|
||||
// BOOL POVCentered = (LOWORD(dwPOV) == 0xFFFF);"
|
||||
// https://docs.microsoft.com/en-us/previous-versions/windows/desktop/ee416628(v%3Dvs.85)#remarks
|
||||
if (LOWORD(p_dpad) == 0xFFFF) {
|
||||
dpad_val = Input::HAT_MASK_CENTER;
|
||||
dpad_val = (HatMask)HatMask::HAT_MASK_CENTER;
|
||||
}
|
||||
if (p_dpad == 0) {
|
||||
dpad_val = Input::HAT_MASK_UP;
|
||||
dpad_val = (HatMask)HatMask::HAT_MASK_UP;
|
||||
|
||||
} else if (p_dpad == 4500) {
|
||||
dpad_val = (Input::HAT_MASK_UP | Input::HAT_MASK_RIGHT);
|
||||
dpad_val = (HatMask)(HatMask::HAT_MASK_UP | HatMask::HAT_MASK_RIGHT);
|
||||
|
||||
} else if (p_dpad == 9000) {
|
||||
dpad_val = Input::HAT_MASK_RIGHT;
|
||||
dpad_val = (HatMask)HatMask::HAT_MASK_RIGHT;
|
||||
|
||||
} else if (p_dpad == 13500) {
|
||||
dpad_val = (Input::HAT_MASK_RIGHT | Input::HAT_MASK_DOWN);
|
||||
dpad_val = (HatMask)(HatMask::HAT_MASK_RIGHT | HatMask::HAT_MASK_DOWN);
|
||||
|
||||
} else if (p_dpad == 18000) {
|
||||
dpad_val = Input::HAT_MASK_DOWN;
|
||||
dpad_val = (HatMask)HatMask::HAT_MASK_DOWN;
|
||||
|
||||
} else if (p_dpad == 22500) {
|
||||
dpad_val = (Input::HAT_MASK_DOWN | Input::HAT_MASK_LEFT);
|
||||
dpad_val = (HatMask)(HatMask::HAT_MASK_DOWN | HatMask::HAT_MASK_LEFT);
|
||||
|
||||
} else if (p_dpad == 27000) {
|
||||
dpad_val = Input::HAT_MASK_LEFT;
|
||||
dpad_val = (HatMask)HatMask::HAT_MASK_LEFT;
|
||||
|
||||
} else if (p_dpad == 31500) {
|
||||
dpad_val = (Input::HAT_MASK_LEFT | Input::HAT_MASK_UP);
|
||||
dpad_val = (HatMask)(HatMask::HAT_MASK_LEFT | HatMask::HAT_MASK_UP);
|
||||
}
|
||||
input->joy_hat(p_device, dpad_val);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user