Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changing the term "keys" in input routine #72

Open
ghostsoft opened this issue Nov 30, 2023 · 3 comments
Open

Changing the term "keys" in input routine #72

ghostsoft opened this issue Nov 30, 2023 · 3 comments

Comments

@ghostsoft
Copy link

I wonder if a more console-focused term such as "buttons" could be used instead of "keys" for the following-

  • UpdateKeys
  • wCurKeys
  • wNewKeys

From what I can tell the comments in the code itself uses the word "buttons" and "directions" to refer to the face buttons and d-pad and that "keys" are meant to encompass both of these but I still feel like it's a word not quite suited for the purpose.

@pinobatch
Copy link
Member

pinobatch commented Nov 30, 2023

If it matters: The main reason I used "keys" is because the NES is the first console platform that I learned circa 2000 after having learned the Allegro library, and I carried the habit with me to GBA, my second console platform.

Also libtonc, the GBA counterpart to hardware.inc, uses "keys" all over. Its KI_* and KEY_* constants correspond to hardware.inc's PADB_* and PADF_*.

@eievui5
Copy link
Contributor

eievui5 commented Nov 30, 2023

As a counterexample: pret/pokecrystal uses “Joy” or “Buttons” depending on the context, but never “Keys”.
https://github.com/pret/pokecrystal/blob/master/home/joypad.asm

@quinnyo
Copy link
Contributor

quinnyo commented Jan 21, 2024

I think "keys" is more meaningful, at least as a teaching tool, as it hints at the low-level nature of reading input on the Game Boy. It's a long way from what most game developers would usually be doing (on any other major platform since the mid-late 90s) i.e. data packets on a serial bus, if not much more high-level 'events'.

A "key" is a momentary switch. Also, as you noted, "key" applies to both groups of inputs -- directions and buttons. They are all keys/switches and identical electr(on)ically.

Anyway, if it were to be changed, I think "buttons" (e.g. UpdateButtons) might give the incorrect impression that it is only concerned with the non-directional inputs. So I'd suggest something more generic, like ReadInput.

To clarifyinfo-dump re. the "low-level nature":

(own research)

Reading input on GB is scanning a key matrix like you might on a microcontroller. This is why reading the input state is complicated.

The two groups of keys -- U,D,L,R and A,B,Sta,Sel -- form two columns, connected to the output pins (bits 4,5) of the rP1 port. The four input pins (rows) of the rP1 port are shared by the two columns. Writing the P1F_GET_{BTN|DPAD} bitmasks to rP1 is setting one or the other column low, exclusively.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants