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

kbrepeatdelay and kbrepeatrate for cbm targets #452

Merged
merged 9 commits into from
Aug 20, 2017

Conversation

mrdudz
Copy link
Contributor

@mrdudz mrdudz commented Jun 16, 2017

quick PR to get things going... (not really ready yet)

since it came up on the list recently - do we want these functions? :) are the names OK or not? should prototypes go into conio.h ?

asminc/plus4.inc Outdated
@@ -33,6 +33,11 @@ FKEY_COUNT := $55D ; Characters for function key
FKEY_SPACE := $55F ; Function key definitions
FKEY_ORIG := $F3D2 ; Original definitions

;FIXME: he?! these ok? :o)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, they are $540, $541 and $542.

asminc/pet.inc Outdated
@@ -31,6 +31,11 @@ BASIC_BUF_LEN = 81 ; Maximum length of command-line

KEY_BUF := $26F ; Keyboard buffer

;FIXME: these are wrong?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed.
40 columns: $3ee, $3ea, $3e9
80 columns: $e4, $e5, $e6

@mrdudz
Copy link
Contributor Author

mrdudz commented Jun 21, 2017

more?

how should we handle the difference between 40- and 80- column models? they are different targets anyway, right? so the different constants could be achived using some ifdef magic? or another .inc? or what?

@mrdudz
Copy link
Contributor Author

mrdudz commented Jun 22, 2017

i was thinking of the PET targets :)

@polluks
Copy link
Contributor

polluks commented Jun 22, 2017

Oh I see. Check in target pet for SCR_LINELEN.

@polluks
Copy link
Contributor

polluks commented Jun 22, 2017

Just for Uz...
cbm510: $D7 and $D8
http://www.von-bassewitz.de/uz/oldcomputers/p500/rom500.s.html

@greg-king5
Copy link
Contributor

How should we handle the difference between 40- and 80- column PET/CBM models?

(cc65 has a single -t pet target.) cputc() tests it during run-time:
https://github.com/cc65/cc65/blob/master/libsrc/pet/cputc.s#L84-L86

So, you will need to define constants like KBDREPEAT40 and KBDREPEAT80, and to choose the right one, at run-time.


I think that it makes sense to put kbdrepeat()'s prototype in <cbm.h>. The others are tick count-down timers; the Kernal changes them!

@mrdudz
Copy link
Contributor Author

mrdudz commented Jun 23, 2017

I think that it makes sense to put kbdrepeat()'s prototype in <cbm.h>.

mmmh - but that would indicate they are CBM specific (which they hopefully wont be on the long run)

@polluks
Copy link
Contributor

polluks commented Jun 23, 2017

Well, the functions are something like get_tv(), for example the NES will never get a kbdrepeat().

@mrdudz
Copy link
Contributor Author

mrdudz commented Jun 23, 2017

by that logic, also kbhit and cgetc (and probably more) shouldnt be in conio either :)

@polluks
Copy link
Contributor

polluks commented Jun 23, 2017

I see, there's something inconsistent.
Take a look at hello.c our conio reference
#if defined(__NES__) || defined(__PCE__) || defined(__GAMATE__)
conio expects an input, therefore its name, but you don't have a keyboard this time.

Because many targets have an implementation, get_tv() should move to conio?
The question is whether kbdrepeat() will be useful without conio or not IMHO.

@oliverschmidt
Copy link
Contributor

oliverschmidt commented Jun 24, 2017

Hi,

Maybe I don't have a (good enough) overview but...

I think this isn't a precise science. It's rather about a sense of what is appropriate.

I'd say something that is available on (almost) all targets (think keyboard) and/or can be emulated on (almost) all targets (think F-keys) belongs into a shared header structured by topics (conio, tgi, mouse, ...). Something that is available on one (or few) targets belongs into the target header(s).

Let's not discuss things here which have already found their places - even if those places might not always be optimal and/or follow the guide I laid out above.

Those keyboard repeat setting functions seem pretty target specific to me. I'd guess no non-CBM target supplies something similar. So I personally clearly see them in cbm.h.

Given that they are not considered part of conio I personally think that names starting with 'kb' are fine. I would however rather use the prefix 'kbd' instead of just 'kb'. Or are there things in the CBM world (i.e. BASIC commands or alike) that make the names suggested a premier choice?

Regards,
Oliver

@oliverschmidt
Copy link
Contributor

Ooops, didn't want to close!

@oliverschmidt oliverschmidt reopened this Jun 24, 2017
@greg-king5
Copy link
Contributor

Also, ... portable programs that use stdio might want to use kbdrepeat() to make CBM keyboards act the way that other keyboards act.

We should have also some defined constants for kbdrepeat():

#define KBDREPEAT_CURSOR 0x00
#define KBDREPEAT_NONE 0x40
#define KBDREPEAT_ALL 0x80

@oliverschmidt
Copy link
Contributor

oliverschmidt commented Jun 25, 2017

Also, ... portable programs that use stdio might want to use kbdrepeat() to make CBM keyboards act the way that other keyboards act.

I think I understand that this statement refers to your proposal to "set" "something" on the keyboard by default on conio initialization. There were however strong oppsite opinions.

Is it possible to elaborate on the topic in a way a non-CBM insider understand the issue? I.e. I presume that a "normal" computer in a "normal" scenario (like i.e. working in the BASIC screen editor) behaves like this: I press a key and the key is accepted once - but if I continue to hold down the key then after some delay (!) the key starts to auto repeat until I release the key.

@mrdudz
Copy link
Contributor Author

mrdudz commented Jun 25, 2017

on CBM targets the regular alphanumeric keys do not have any repeat at all - only the "editor" keys (cursor, space, insert/delete). why space belongs to them, i have no idea :)

@oliverschmidt
Copy link
Contributor

Thanks - and do I understand it correctly that it is possible to have repeat for the "regular" keys as well? Does the repeat have the "usual" delay before starting? If both question are answered with 'yes' then why isn't it desirable to activate repeat for all keys by default (just like we i.e. switch to lower case output by default) ?

@mrdudz
Copy link
Contributor Author

mrdudz commented Jun 25, 2017

yes its possible. and yes they will have the initial delay. however i dont think it should be default, since its not what a typical c64 users expects - most programs do not work this way.

@oliverschmidt
Copy link
Contributor

Thanks for the explanation. So it's about soft facts and meeting expectations...

@greg-king5
Copy link
Contributor

greg-king5 commented Jun 26, 2017

I'm not aware of any programs that demand that the alpha-numerics never repeat. I find it difficult to imagine that a program would fail if a key was to repeat -- after we held it down for awhile. If a program like that does exist, then it's very unusual; so, it should tell people, "don't hold down any keys". And, it should disable repeating on keyboards that support that switch.

I still think that -- portable -- programs should be able to have some consistent expectations about the environments on which they run. So, ... programs should expect to be able to print lower-case text, with capital letters where they're needed. And maybe, they should expect that everybody's keyboards repeat every key.

By the way, Commodore wasn't consistent with their models! The C128 and the Plus4, for example, do repeat every key, by default.

@oliverschmidt
Copy link
Contributor

I personally think that Greg's argument is valid. However to be honest it's just not important enough to me to enter a dispute about that topic.

Maybe a reasonable compromise would be to have a cc65 constructor that activates the repeat feature and that is as easily as possible to be activated by the user who wants it. Ideally from the build command line...

Copy link
Contributor

@oliverschmidt oliverschmidt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Beside the "FIXME" question I'd really like to see some - at least rudimentary - documentation.

  • The question about enabling the keyboard repeat by default seems to have lost momentum so I don't see it blocking this pull request (anymore).

@@ -31,6 +31,18 @@ BASIC_BUF_LEN = 81 ; Maximum length of command-line

KEY_BUF := $26F ; Keyboard buffer

;FIXME: we must somehow handle the difference between the two - how?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this pull request supposed to be merged with this FIXME still in place?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i don't know.... would that be acceptable? i don't like the idea a lot myself.... but i don't know to fix this either. are there preprocessor symbols for 40cols vs 80cols PETs? or even different libraries? can it be checked at runtime, and how? i have no idea about either :)

@mrdudz
Copy link
Contributor Author

mrdudz commented Aug 6, 2017

added some docs. i cant test if its ok because linuxdocs fail to build the docs here, for whatever reason

@oliverschmidt
Copy link
Contributor

added some docs.

:-)

i cant test if its ok because linuxdocs fail to build the docs here, for whatever reason

At least there are no errors/warnings according to Travis CI...

@mrdudz
Copy link
Contributor Author

mrdudz commented Aug 7, 2017

no, but here there are - and when i fix them it will fail on CI :) different linuxdoc versions, i guess

@greg-king5
Copy link
Contributor

Those functions are fastcall. Their prototypes must be marked with __fastcall__, so that they will be called properly even if --all-cdecl is used. And, their funcref descriptions must have the usual note that says that a fastcall function must be used only in the presence of a prototype.


The repeat-delay and the repeat-rate variables aren't "settings". Instead, they are active counters. When a key is pressed, the Kernal changes them 60 times every second. Therefore, there is no "original value" that should be restored by a program. So, their functions should return void.

@mrdudz
Copy link
Contributor Author

mrdudz commented Aug 19, 2017

The repeat-delay and the repeat-rate variables aren't "settings". Instead, they are active counters. When a key is pressed, the Kernal changes them 60 times every second. Therefore, there is no "original value" that should be restored by a program. So, their functions should return void.

ewww. i could have sworn those are persistant settings. like this the two functions are actually not quite useful at all (you'd have to call them after each keyboard scanning) - i'd rather just remove them. no idea why i have even added them back then :=)

@oliverschmidt oliverschmidt merged commit b5a4e56 into cc65:master Aug 20, 2017
@mrdudz
Copy link
Contributor Author

mrdudz commented Aug 21, 2017

mmmh shrug

@oliverschmidt
Copy link
Contributor

Sorry - what is wrong? Should I not have this merged?

@mrdudz
Copy link
Contributor Author

mrdudz commented Aug 21, 2017

as gregg pointed out, the functions that are supposed to set the repeat delay and repeat rate do not work as advertised (and i see no simple way to fix that unfortunately) - so they should probably get removed before someone uses them and wonders that they dont do what they are supposed to do :=)

@oliverschmidt
Copy link
Contributor

oliverschmidt commented Aug 22, 2017

Ah, now I see. Your last two commits are listed below your comment starting with 'ewww' so I presumed your commits were meant to "adjust" what was "wrong". I admit that I was too busy trying to make everybody happy regarding the joystick interface to really try to understand what Greg and you were up to.

So do I get it right this time that this pull request should just have been closed instead of being merged? So a full revert is the right thing to do now?

@mrdudz
Copy link
Contributor Author

mrdudz commented Aug 22, 2017

closed? no.... "someone" should delete the two useless functions, then it can be merged :)

@greg-king5
Copy link
Contributor

Maybe they aren't totally useless. I haven't tested it; but, maybe they can be used to zero those counters immediately after calling cgetc(). It might make the keyboard look more like a joystick; that is, we might get immediate and very rapid key repeating.

@mrdudz
Copy link
Contributor Author

mrdudz commented Aug 23, 2017

that doesnt really work as intended... and resetting the live counters the hard way like that inside your keyboard polling loop.... urks. that sounds like ugly hackery to me that i dont want to encourage :)

oliverschmidt added a commit that referenced this pull request Aug 30, 2017
As discussed in #452 after my premature merge the two functions in question don't work as expected.

Additionally I adjusted several style deviations in the pull request in question.
@oliverschmidt
Copy link
Contributor

"someone" should delete the two useless functions

Done, see 4aa1949

@mrdudz
Copy link
Contributor Author

mrdudz commented Aug 30, 2017 via email

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

Successfully merging this pull request may close these issues.

None yet

4 participants