Initial accelerometer support

This commit is contained in:
wheremyfoodat 2024-08-15 17:31:55 +03:00
parent ff7e0f9ca8
commit c772b1c702
4 changed files with 45 additions and 3 deletions

View file

@ -56,6 +56,7 @@ class HIDService {
s16 circlePadX, circlePadY; // Circlepad state
s16 touchScreenX, touchScreenY; // Touchscreen state
s16 roll, pitch, yaw; // Gyroscope state
s16 accelX, accelY, accelZ; // Accelerometer state
bool accelerometerEnabled;
bool eventsInitialized;
@ -87,6 +88,11 @@ class HIDService {
*(T*)&sharedMem[offset] = value;
}
template <typename T>
T* getSharedMemPointer(size_t offset) {
return (T*)&sharedMem[offset];
}
public:
static constexpr float gyroscopeCoeff = 14.375f; // Same as retail 3DS
@ -130,6 +136,12 @@ class HIDService {
void setPitch(s16 value) { pitch = value; }
void setYaw(s16 value) { yaw = value; }
void setAccel(s16 x, s16 y, s16 z) {
accelX = x;
accelY = y;
accelZ = z;
}
void updateInputs(u64 currentTimestamp);
void setSharedMem(u8* ptr) {