ValveSoftware / ValveSoftware/source-sdk-2013

IsKeypad function logic is incorrect

Open Beginner friendly
#1,708 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
10k
Forks
3k
Avg merge
8d 11h
Merged PRs (30d)
2

Description

Currently, the IsKeypad function in inputsystem is implemented as:

https://github.com/ValveSoftware/source-sdk-2013/blob/2d3a6efb50bba856a44e73d4f0098ed4a726699c/src/public/inputsystem/ButtonCode.h#L311-L314

This code doesn't work, because the MOUSE_FIRST enum value checked for the lower bound is larger than the KEY_PAD_DECIMAL value that is checked for the upper bound. Therefore, this function currently returns false for all inputs.

This is probably a typo, and the lower bound should be checked against KEY_PAD_0 instead of MOUSE_FIRST:

return ( code >= KEY_PAD_0 ) && ( code <= KEY_PAD_DECIMAL );

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Open src/public/inputsystem/ButtonCode.h at the IsKeypad function around lines 311-314 and inspect the keypad enum range. Confirm that the function recognizes codes from KEY_PAD_0 through KEY_PAD_DECIMAL; the issue is done when keypad inputs no longer return false because of the lower-bound check.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
game-dev
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
78/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.