mirror of
https://github.com/yuzu-mirror/yuzu
synced 2024-12-05 02:09:55 +00:00
hid: Write to all layouts, implement circular buffers, set up controller metadata.
This commit is contained in:
parent
713c1ed203
commit
d20a883194
2 changed files with 65 additions and 33 deletions
|
@ -65,9 +65,35 @@ private:
|
||||||
if (is_device_reload_pending.exchange(false))
|
if (is_device_reload_pending.exchange(false))
|
||||||
LoadInputDevices();
|
LoadInputDevices();
|
||||||
|
|
||||||
// TODO(shinyquagsire23): This is a hack!
|
// Set up controllers as neon red+blue Joy-Con attached to console
|
||||||
ControllerPadState& state =
|
ControllerHeader& controllerHeader = mem->controllers[Controller_Handheld].header;
|
||||||
mem->controllers[Controller_Handheld].layouts[Layout_Default].entries[0].buttons;
|
controllerHeader.type = ControllerType_Handheld | ControllerType_JoyconPair;
|
||||||
|
controllerHeader.singleColorsDescriptor = ColorDesc_ColorsNonexistent;
|
||||||
|
controllerHeader.rightColorBody = 0xFF3C28;
|
||||||
|
controllerHeader.rightColorButtons = 0x1E0A0A;
|
||||||
|
controllerHeader.leftColorBody = 0x0AB9E6;
|
||||||
|
controllerHeader.leftColorButtons = 0x001E1E;
|
||||||
|
|
||||||
|
for (int layoutIdx = 0; layoutIdx < HID_NUM_LAYOUTS; layoutIdx++)
|
||||||
|
{
|
||||||
|
ControllerLayout& layout = mem->controllers[Controller_Handheld].layouts[layoutIdx];
|
||||||
|
layout.header.numEntries = HID_NUM_ENTRIES;
|
||||||
|
layout.header.maxEntryIndex = HID_NUM_ENTRIES - 1;
|
||||||
|
|
||||||
|
// HID shared memory stores the state of the past 17 samples in a circlular buffer,
|
||||||
|
// each with a timestamp in number of samples since boot.
|
||||||
|
layout.header.timestampTicks = CoreTiming::GetTicks();
|
||||||
|
layout.header.latestEntry = (layout.header.latestEntry + 1) % HID_NUM_ENTRIES;
|
||||||
|
|
||||||
|
ControllerInputEntry& entry = layout.entries[layout.header.latestEntry];
|
||||||
|
entry.connectionState = ConnectionState_Connected | ConnectionState_Wired;
|
||||||
|
entry.timestamp++;
|
||||||
|
entry.timestamp_2++; // TODO(shinyquagsire23): Is this always identical to timestamp?
|
||||||
|
|
||||||
|
// TODO(shinyquagsire23): Set up some LUTs for each layout mapping in the future?
|
||||||
|
// For now everything is just the default handheld layout, but split Joy-Con will
|
||||||
|
// rotate the face buttons and directions for certain layouts.
|
||||||
|
ControllerPadState& state = entry.buttons;
|
||||||
using namespace Settings::NativeButton;
|
using namespace Settings::NativeButton;
|
||||||
state.a.Assign(buttons[A - BUTTON_HID_BEGIN]->GetStatus());
|
state.a.Assign(buttons[A - BUTTON_HID_BEGIN]->GetStatus());
|
||||||
state.b.Assign(buttons[B - BUTTON_HID_BEGIN]->GetStatus());
|
state.b.Assign(buttons[B - BUTTON_HID_BEGIN]->GetStatus());
|
||||||
|
@ -103,6 +129,7 @@ private:
|
||||||
// TODO(shinyquagsire23): Analog stick vals
|
// TODO(shinyquagsire23): Analog stick vals
|
||||||
|
|
||||||
// TODO(shinyquagsire23): Update pad info proper, (circular buffers, timestamps, layouts)
|
// TODO(shinyquagsire23): Update pad info proper, (circular buffers, timestamps, layouts)
|
||||||
|
}
|
||||||
|
|
||||||
// TODO(shinyquagsire23): Update touch info
|
// TODO(shinyquagsire23): Update touch info
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,11 @@ namespace HID {
|
||||||
|
|
||||||
// Begin enums and output structs
|
// Begin enums and output structs
|
||||||
|
|
||||||
|
constexpr u32 HID_NUM_ENTRIES = 17;
|
||||||
|
constexpr u32 HID_NUM_LAYOUTS = 7;
|
||||||
|
constexpr s32 HID_JOYSTICK_MAX = 0x8000;
|
||||||
|
constexpr s32 HID_JOYSTICK_MIN = -0x8000;
|
||||||
|
|
||||||
enum ControllerType : u32 {
|
enum ControllerType : u32 {
|
||||||
ControllerType_ProController = 1 << 0,
|
ControllerType_ProController = 1 << 0,
|
||||||
ControllerType_Handheld = 1 << 1,
|
ControllerType_Handheld = 1 << 1,
|
||||||
|
@ -215,7 +220,7 @@ struct ControllerHeader {
|
||||||
u32 leftColorBody;
|
u32 leftColorBody;
|
||||||
u32 leftColorButtons;
|
u32 leftColorButtons;
|
||||||
u32 rightColorBody;
|
u32 rightColorBody;
|
||||||
u32 rightColorbuttons;
|
u32 rightColorButtons;
|
||||||
};
|
};
|
||||||
static_assert(sizeof(ControllerHeader) == 0x28,
|
static_assert(sizeof(ControllerHeader) == 0x28,
|
||||||
"HID controller header structure has incorrect size");
|
"HID controller header structure has incorrect size");
|
||||||
|
|
Loading…
Reference in a new issue