You clearly know enough about programming to be dangerous, so like I said earlier, I encourage you to download the source code and take a stab at implementing it yourself. I don't think people would object to having the functionality you're talking about, so long as it doesn't interfere with normal playstyles. But I don't think you're going to be able to convince anyone to implement it for you. So you're on your own on this one, champ.
stop Angband from stacking commands
Collapse
X
-
Comment
-
ok, let's be constructive. solutions, not problems.
you need have a list of commands, right?? e.g. press 8 -> move up.
what language is angband built in? C+ ? how does it stack commands? does it tell the OS "i have not finished with this command yet" , or does it actually buffer internally the commands? let's assume the former, your basic commands should look something like press 8 -> move up, getchar();
or char buffer[1].
Look, can you plainly explain the "use case"? I don't buy "I have my keyboard set to repeat at 500kps". I you had that you'd be complaining to Microsoft/GNOME/KDE or whatever, because nothing handles *that*. (And, also, you'd *still* be dead even if Angband had a "don't buffer keypresses" policy.)Comment
-
there is an option in the control panel to set how your keyboard repeats commands. by default it's set on medium, and i have set on fast. again, this is not a registry hack, the repeat values are set within Microsoft's standards. it's no different than setting your mouse to move faster.
now, as mage or ranger, occasionally rogue, there will be times where you simply need the fire command repeated many times. maybe you are just killing trolls. if this is a directional, non targeted command (cast acidbolt east) the game will happily repeat commands even when a key is not pressed.
this must be because the commands stack - if you use the keyboard to tell angband (fire 15 bolts east) then angband will tell the system "i will now fire as many bolts east as you have told me" instead of "ok i see that you want a command done, i will do it and then i will wait for new instructions".
the command i wrote above is whatever google first gave me for "purge keyboard I/O buffer" which apparently is what other coders have used to resolve the same problem."i can take this dracolich"Comment
-
Programming issues aside I'm not sure whether I'd even want the change you are asking for. If I've just told the game to fire 15 bolts east it's probably because I want the game to fire 15 bolts east. I mean 15 seems a bit over the top but under safe enough circumstances I might actually want to repeat an action a few times with out using the repeat command.Comment
-
now, as mage or ranger, occasionally rogue, there will be times where you simply need the fire command repeated many times. maybe you are just killing trolls. if this is a directional, non targeted command (cast acidbolt east) the game will happily repeat commands even when a key is not pressed.Comment
-
this must be because the commands stack - if you use the keyboard to tell angband (fire 15 bolts east) then angband will tell the system "i will now fire as many bolts east as you have told me" instead of "ok i see that you want a command done, i will do it and then i will wait for new instructions".
Angband: 'I need a keypress now.'
Frontend: 'Just wait a minute... OK, it's s'
Angband: <does command> 'I need a keypress now.'
Frontend: 'Just wait a minute... OK, it's R'
Angband: <does command> 'I need a keypress now.'
etc.
Angband doesn't get one instruction saying 'fire 15 bolts east', it gets 15 keypresses and it processes each in turn. The OS/graphics library does the keypress buffering for us, and it's good, like kandrc tried to explain. If you don't buffer, you risk losing input, which in a game like Angband would be pretty terrible.takkaria whispers something about options. -more-Comment
-
Hmm
Angband does have the concept of flushing the input buffer. (grep the source for flush and look for something with both "flush" and "input" in proximity)
If someone were sufficiently motivated to hack in a command to flush the buffer, then a macro along the lines of cast-acid-bolt-at-nearest-target-then-flush-the-input-buffer might have interesting effects...Comment
-
Yeah, that sounds like it might work. In fact, you don't need to hack anything in, you can just put a Control-R after the command because redrawing forces a flush.takkaria whispers something about options. -more-Comment
-
I must say you all are unfair to Sky. Throttling keyboard repeat rate is reasonable, possible and easy.
takkaria, unsurprisingly, even figured out how to do it
You could imagine a check where if the current command is the same as the previous one, then you check if the key is held down. But then if you pressed [f1] two times in a row manually (as opposed to with auto-repeat), this wouldn't be the desired behaviour either. You could, I guess, take a note of the time when each keypress comes through and compare it to the time of the previous command, and if they're really close together turn on scanning behaviour. But I imagine that will be pretty error-prone too, and would feel pretty non-deterministic to the player.
Code:void get_input() { static time_t previous_time; while (true) { key k = get_key(); time_t t = get_time(); if (t - previous_time >= KEY_REPEAT_RATE_IN_MSECS) { Term_keypress(k); previous_time = t; return; } // else just forget this key, and read the new one } }
I implemented that in textui2 (but I forgot the previous key thing). That's how all key repeat limiters work, and it doesn't feel non deterministic or anything, if it allows, say, 20 keys per second. After that the difference can only be percieved when holding down a key.
As for flushing the input queue, you can just read from it until it's empty, and, btw, Angband already has TERM_XTRA_FLUSH, which is supposed to do exactly that.Comment
Comment