Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
kmicki committed May 6, 2022
2 parents 1882a9f + 65598a1 commit aa62d52
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 18 deletions.
5 changes: 5 additions & 0 deletions src/hiddev/hiddevreader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,9 @@ namespace kmicki::hiddev
// Fill with generated frames to avoid jitter
auto fillPeriod = std::chrono::microseconds(3200/(diff-1));//3000/(diff-1));

// Flag - replicated frames
frame[0] = 0xDD;

for (int i = 0; i < diff-1; i++)
{
writingLock=false;
Expand All @@ -337,6 +340,8 @@ namespace kmicki::hiddev
writingLock = true;
++(*newInc);
}

frame[0] = 0x01;
}
lastInc = *newInc;

Expand Down
2 changes: 1 addition & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ bool showIncrement = false;
#define FRAME_LEN 64
#define SCAN_PERIOD_US 3900

#define VERSION "1.4"
#define VERSION "1.5"

#define VID 0x28de
#define PID 0x1205
Expand Down
42 changes: 25 additions & 17 deletions src/sdgyrodsu/cemuhookadapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ using namespace kmicki::cemuhook::protocol;
#define SD_SCANTIME_US 4000
#define ACC_1G 0x4000
#define GYRO_1DEGPERSEC 16
#define GYRO_DEADZONE 4
#define ACCEL_SMOOTH 0x7F
#define GYRO_DEADZONE 8
#define ACCEL_SMOOTH 0x1FF

namespace kmicki::sdgyrodsu
{
Expand Down Expand Up @@ -51,21 +51,29 @@ namespace kmicki::sdgyrodsu
data.accX = -(float)SmoothAccel(lastAccelRtL,frame.AccelAxisRightToLeft)/acc1G;
data.accY = -(float)SmoothAccel(lastAccelFtB,frame.AccelAxisFrontToBack)/acc1G;
data.accZ = (float)SmoothAccel(lastAccelTtB,frame.AccelAxisTopToBottom)/acc1G;

auto gyroRtL = frame.GyroAxisRightToLeft;
auto gyroFtB = frame.GyroAxisFrontToBack;
auto gyroTtB = frame.GyroAxisTopToBottom;

if(gyroRtL < GYRO_DEADZONE && gyroRtL > -GYRO_DEADZONE)
gyroRtL = 0;
if(gyroFtB < GYRO_DEADZONE && gyroFtB > -GYRO_DEADZONE)
gyroFtB = 0;
if(gyroTtB < GYRO_DEADZONE && gyroTtB > -GYRO_DEADZONE)
gyroTtB = 0;

data.pitch = (float)gyroRtL/gyro1dps;
data.yaw = -(float)gyroFtB/gyro1dps;
data.roll = (float)gyroTtB/gyro1dps;
if(frame.Header & 0xFF == 0xDD)
{
data.pitch = 0.0f;
data.yaw = 0.0f;
data.roll = 0.0f;
}
else
{
auto gyroRtL = frame.GyroAxisRightToLeft;
auto gyroFtB = frame.GyroAxisFrontToBack;
auto gyroTtB = frame.GyroAxisTopToBottom;

if(gyroRtL < GYRO_DEADZONE && gyroRtL > -GYRO_DEADZONE)
gyroRtL = 0;
if(gyroFtB < GYRO_DEADZONE && gyroFtB > -GYRO_DEADZONE)
gyroFtB = 0;
if(gyroTtB < GYRO_DEADZONE && gyroTtB > -GYRO_DEADZONE)
gyroTtB = 0;

data.pitch = (float)gyroRtL/gyro1dps;
data.yaw = -(float)gyroFtB/gyro1dps;
data.roll = (float)gyroTtB/gyro1dps;
}
}

CemuhookAdapter::CemuhookAdapter(hiddev::HidDevReader & _reader)
Expand Down

0 comments on commit aa62d52

Please sign in to comment.