Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions Windows/Gopher/Gopher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,9 @@ void Gopher::loadConfigFile()
// Swap stick functions
SWAP_THUMBSTICKS = strtol(cfg.getValueOfKey<std::string>("SWAP_THUMBSTICKS").c_str(), 0, 0);

// Flip-flop scroll direction
SCROLL_FLIPFLOP = strtol(cfg.getValueOfKey<std::string>("SCROLL_FLIPFLOP").c_str(), 0, 0);

// Set the initial window visibility
setWindowVisibility(_hidden);
}
Expand Down Expand Up @@ -561,12 +564,21 @@ void Gopher::handleScrolling()
}

// Handle dead zone
float magnitude = sqrt(tx * tx + ty * ty);
float txSq = tx * tx;
float tySq = ty * ty;
float magnitude = sqrt(txSq + tySq);

if (magnitude > SCROLL_DEAD_ZONE)
{
mouseEvent(MOUSEEVENTF_HWHEEL, tx * getMult(tx * tx, SCROLL_DEAD_ZONE) * SCROLL_SPEED);
mouseEvent(MOUSEEVENTF_WHEEL, ty * getMult(ty * ty, SCROLL_DEAD_ZONE) * SCROLL_SPEED);
// scroll one direction at a time, either horizontally or vertically
if (tySq > txSq)
{
mouseEvent(MOUSEEVENTF_WHEEL, (SCROLL_FLIPFLOP ? -ty : ty) * getMult(tySq, SCROLL_DEAD_ZONE) * SCROLL_SPEED);
}
else
{
mouseEvent(MOUSEEVENTF_HWHEEL, (SCROLL_FLIPFLOP ? -tx : tx) * getMult(txSq, SCROLL_DEAD_ZONE) * SCROLL_SPEED);
}
}
}

Expand Down
1 change: 1 addition & 0 deletions Windows/Gopher/Gopher.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class Gopher
const int FPS = 150; // Update rate of the main Gopher loop. Interpreted as cycles-per-second.
const int SLEEP_AMOUNT = 1000 / FPS; // Number of milliseconds to sleep per iteration.
int SWAP_THUMBSTICKS = 0; // Swaps the function of the thumbsticks when not equal to 0.
int SCROLL_FLIPFLOP = 0; // Flip-flop scroll direction when not equal to 0.

XINPUT_STATE _currentState;

Expand Down