Skip to content

Commit

Permalink
Bug fix in configuration apps
Browse files Browse the repository at this point in the history
Bug: Configuring zero buttons on a vJoy device crashes vJoy (On W10 1803)
Fix: In the descriptor written to the registry
  • Loading branch information
shauleiz committed May 27, 2018
1 parent f4bba70 commit ee75b72
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,4 @@ apps/vJoyList/gen-versioninfo.h
SDK.zip
SDK/ReadMe.pdf
SDK/c#/ReadMe.pdf
apps/vJoyConf/vJoyConf.aps
7 changes: 5 additions & 2 deletions apps/vJoyConf/vJoyConf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -940,6 +940,9 @@ int CreateHidReportDesc(void ** data, UINT nButtons, bool * axes, int nPovHatsCo
if (nButtons>128)
nButtons = 128;

/* Special case of zero buttons - Local Min Usage is 0 rather than 1 */
UINT localminusage_buttons = nButtons ? 0x01 : 0x00;

// POV (Cont): 0-4
if (nPovHatsCont<0)
nPovHatsCont = 0;
Expand Down Expand Up @@ -1107,8 +1110,8 @@ int CreateHidReportDesc(void ** data, UINT nButtons, bool * axes, int nPovHatsCo
NEXT_BYTE(buffer, 0x00)
NEXT_BYTE(buffer, HIDP_GLOBAL_UNIT_1) // UNIT (None): 65 00
NEXT_BYTE(buffer, 0x00)
NEXT_BYTE(buffer, HIDP_LOCAL_USAGE_MIN_1) // USAGE_MINIMUM(1): 19 01
NEXT_BYTE(buffer, 0x01)
NEXT_BYTE(buffer, HIDP_LOCAL_USAGE_MIN_1) // USAGE_MINIMUM(1): 19 01/00
NEXT_BYTE(buffer, localminusage_buttons)
NEXT_BYTE(buffer, HIDP_LOCAL_USAGE_MAX_1) // USAGE_MAXIMUM(nButtons): 29 nButtons
NEXT_BYTE(buffer, nButtons)
NEXT_BYTE(buffer, HIDP_GLOBAL_REPORT_SIZE) // REPORT_SIZE(1): 75 01
Expand Down
7 changes: 5 additions & 2 deletions apps/vJoyConf/vJoyConfig/vJoyConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,9 @@ int CreateHidReportDesc(void ** data, UINT nButtons, bool * axes, int nPovHatsCo
if (nButtons>128)
nButtons = 128;

/* Special case of zero buttons - Local Min Usage is 0 rather than 1 */
UINT localminusage_buttons = nButtons ? 0x01 : 0x00;

// POV (Cont): 0-4
if (nPovHatsCont<0)
nPovHatsCont = 0;
Expand Down Expand Up @@ -701,8 +704,8 @@ int CreateHidReportDesc(void ** data, UINT nButtons, bool * axes, int nPovHatsCo
NEXT_BYTE(buffer, 0x00)
NEXT_BYTE(buffer, HIDP_GLOBAL_UNIT_1) // UNIT (None): 65 00
NEXT_BYTE(buffer, 0x00)
NEXT_BYTE(buffer, HIDP_LOCAL_USAGE_MIN_1) // USAGE_MINIMUM(1): 19 01
NEXT_BYTE(buffer, 0x01)
NEXT_BYTE(buffer, HIDP_LOCAL_USAGE_MIN_1) // USAGE_MINIMUM(1): 19 01/00
NEXT_BYTE(buffer, localminusage_buttons)
NEXT_BYTE(buffer, HIDP_LOCAL_USAGE_MAX_1) // USAGE_MAXIMUM(nButtons): 29 nButtons
NEXT_BYTE(buffer, nButtons)
NEXT_BYTE(buffer, HIDP_GLOBAL_REPORT_SIZE) // REPORT_SIZE(1): 75 01
Expand Down

0 comments on commit ee75b72

Please sign in to comment.