yuzu-emu
/
yuzu
Archived
1
0
Fork 0
This repository has been archived on 2024-03-23. You can view files and clone it, but cannot push or open issues or pull requests.
yuzu/src/core/hle/service/hid.h

113 lines
3.1 KiB
C
Raw Normal View History

2014-04-17 00:58:36 +00:00
// Copyright 2014 Citra Emulator Project
// Licensed under GPLv2
// Refer to the license.txt file included.
#pragma once
#include "core/hle/service/service.h"
2014-09-03 05:24:03 +00:00
#include "common/bit_field.h"
2014-04-17 00:58:36 +00:00
////////////////////////////////////////////////////////////////////////////////////////////////////
// Namespace HID_User
// This service is used for interfacing to physical user controls... perhaps "Human Interface
// Devices"? Uses include game pad controls, accelerometers, gyroscopes, etc.
namespace HID_User {
2014-09-04 01:12:58 +00:00
/// Structure of a PAD controller state
2014-09-03 05:24:03 +00:00
struct PADState {
union {
u32 hex;
2014-09-04 01:12:58 +00:00
BitField<0, 1, u32> a;
BitField<1, 1, u32> b;
BitField<2, 1, u32> select;
BitField<3, 1, u32> start;
BitField<4, 1, u32> right;
BitField<5, 1, u32> left;
BitField<6, 1, u32> up;
BitField<7, 1, u32> down;
BitField<8, 1, u32> r;
BitField<9, 1, u32> l;
BitField<10, 1, u32> x;
BitField<11, 1, u32> y;
BitField<28, 1, u32> circle_right;
BitField<29, 1, u32> circle_left;
BitField<30, 1, u32> circle_up;
BitField<31, 1, u32> circle_down;
2014-09-03 05:24:03 +00:00
};
};
2014-09-04 01:12:58 +00:00
/// Structure of a single entry in the PADData's PAD state history array
struct PADDataEntry {
PADState current_state;
PADState delta_additions;
PADState delta_removals;
s16 circle_pad_x;
s16 circle_pad_y;
};
/// Structure of all data related to the 3DS Pad
struct PADData {
s64 index_reset_ticks;
s64 index_reset_ticks_previous;
u32 index; // the index of the last updated PAD state history element
u32 pad1;
u32 pad2;
PADState current_state; // same as entries[index].current_state
u32 raw_circle_pad_data;
u32 pad3;
std::array<PADDataEntry, 8> entries; // PAD state history
};
// Pre-defined PADStates for single button presses
const PADState PAD_NONE = {{0}};
const PADState PAD_A = {{1u << 0}};
const PADState PAD_B = {{1u << 1}};
const PADState PAD_SELECT = {{1u << 2}};
const PADState PAD_START = {{1u << 3}};
const PADState PAD_RIGHT = {{1u << 4}};
const PADState PAD_LEFT = {{1u << 5}};
const PADState PAD_UP = {{1u << 6}};
const PADState PAD_DOWN = {{1u << 7}};
const PADState PAD_R = {{1u << 8}};
const PADState PAD_L = {{1u << 9}};
const PADState PAD_X = {{1u << 10}};
const PADState PAD_Y = {{1u << 11}};
const PADState PAD_CIRCLE_RIGHT = {{1u << 28}};
const PADState PAD_CIRCLE_LEFT = {{1u << 29}};
const PADState PAD_CIRCLE_UP = {{1u << 30}};
const PADState PAD_CIRCLE_DOWN = {{1u << 31}};
// Methods for updating the HID module's state
void PADButtonPress(PADState pad_state);
void PADButtonRelease(PADState pad_state);
void PADUpdateComplete();
/// HID service interface
2014-04-17 00:58:36 +00:00
class Interface : public Service::Interface {
public:
Interface();
~Interface();
/**
* Gets the string port name used by CTROS for the service
* @return Port name of service
*/
std::string GetPortName() const {
2014-04-17 00:58:36 +00:00
return "hid:USER";
}
};
} // namespace