Skip to content

Commit

Permalink
(Hopefully) fixed bug where stick inputs would stop working sometimes…
Browse files Browse the repository at this point in the history
…. Also reduced warnings.
  • Loading branch information
LunaticShiN3 committed Mar 26, 2023
1 parent dcbe5a5 commit 513f1b8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
1 change: 1 addition & 0 deletions Luna's DirectInput8/directinput.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ void DInputGetKeys(HINSTANCE hinst, HWND hwnd) {

if (lpdiKeyboard != NULL) {
HRESULT result = IDirectInputDevice8_GetDeviceState(lpdiKeyboard, (sizeof(deviceState)), (LPVOID*)&deviceState);
deviceState[0] = 0;

if (GetForegroundWindow() == hwnd) {
if (result == DIERR_INPUTLOST) {
Expand Down
2 changes: 1 addition & 1 deletion Luna's DirectInput8/dllmain.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ EXPORT void CALL GetKeys(int Control, BUTTONS* Keys) {
}

for (int i = 0; i < sizeof(config.modifiers) / sizeof(Modifier); i++) {
if (deviceState[config.modifiers[i].keybind] >> 7) {
if ((config.modifiers[i].keybind != 0) && (deviceState[config.modifiers[i].keybind] >> 7)) {
Keys->Y_AXIS = (float)Keys->Y_AXIS * config.modifiers[i].multiplierX; //X and Y axis are swapped because of course they are????
Keys->X_AXIS = (float)Keys->X_AXIS * config.modifiers[i].multiplierY;
}
Expand Down
13 changes: 7 additions & 6 deletions Luna's DirectInput8/gui.c
Original file line number Diff line number Diff line change
Expand Up @@ -235,10 +235,10 @@ void getEditBoxContent(HWND hwndDlg, int nIDDlgItem, byte* returnVariable) {
char lpch[4];
hDlgItem = GetDlgItem(hwndDlg, nIDDlgItem);
GetWindowTextA(hDlgItem, &lpch, sizeof(lpch));
*returnVariable = atoi(lpch);
if (*returnVariable > 127) {
*returnVariable = 127;
setEditBoxContent(hwndDlg, nIDDlgItem, *returnVariable);
returnVariable = atoi(lpch);
if (returnVariable > 127) {
returnVariable = 127;
setEditBoxContent(hwndDlg, nIDDlgItem, returnVariable);
}
}

Expand All @@ -257,6 +257,7 @@ void getConfigKey(HWND hwndDlg, int nIDDlgItem, byte* returnVariable) {
int i, j;
for (j = 0; j < 100; j++) {
IDirectInputDevice8_GetDeviceState(lpdiKeyboard, (sizeof(deviceState)), (LPVOID*)&deviceState);
deviceState[0] = 0;
for (i = 0; i < sizeof(deviceState); i++) {
if (deviceState[i] >> 7) {
*returnVariable = i;
Expand All @@ -271,7 +272,7 @@ void getConfigKey(HWND hwndDlg, int nIDDlgItem, byte* returnVariable) {
}
}

void setButtonLabel(HWND hwndDlg, int nIDDlgItem, byte* returnVariable) {
void setButtonLabel(HWND hwndDlg, int nIDDlgItem, byte returnVariable) {
dips.diph.dwSize = sizeof(dips);
dips.diph.dwHeaderSize = sizeof(diph);
dips.diph.dwHow = DIPH_BYOFFSET;
Expand All @@ -282,7 +283,7 @@ void setButtonLabel(HWND hwndDlg, int nIDDlgItem, byte* returnVariable) {
SetWindowTextW(hDlgItem, dips.wsz);
}

void setEditBoxContent(HWND hwndDlg, int nIDDlgItem, byte* returnVariable) {
void setEditBoxContent(HWND hwndDlg, int nIDDlgItem, byte returnVariable) {
char lpch[4];
hDlgItem = GetDlgItem(hwndDlg, nIDDlgItem);
Edit_LimitText(hDlgItem, 3);
Expand Down

0 comments on commit 513f1b8

Please sign in to comment.