Angband.oook.cz
Angband.oook.cz
AboutVariantsLadderForumCompetitionComicScreenshotsFunniesLinks

Go Back   Angband Forums > Angband > Vanilla

Reply
 
Thread Tools Display Modes
Old September 7, 2017, 16:13   #21
Sky
Knight
 
Join Date: Oct 2016
Location: Glasgae
Age: 44
Posts: 675
Sky is on a distinguished road
But it would still do that. It only distinguishes between commands received before and after an action.
__________________
#ARKENSTONESMATTER
Sky is offline   Reply With Quote
Old September 7, 2017, 16:20   #22
Derakon
Prophet
 
Derakon's Avatar
 
Join Date: Dec 2009
Posts: 7,943
Derakon is on a distinguished road
Quote:
Originally Posted by Sky View Post
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.
I seriously question the amount of time you save by holding a button down vs. just hitting it 15 times in rapid succession. It's not too hard to hit a key 5 times a second; are you really that hard-pressed for time that you need to save 2 seconds (remembering that it takes a bit for key repeat to kick in) while fighting trolls?
Derakon is offline   Reply With Quote
Old September 7, 2017, 16:27   #23
kandrc
Adept
 
Join Date: Dec 2007
Posts: 221
kandrc is on a distinguished road
Quote:
Originally Posted by Sky View Post
But it would still do that. It only distinguishes between commands received before and after an action.
Often I'm honestly not certain if you're serious, or if you're a very clever troll.
kandrc is offline   Reply With Quote
Old September 7, 2017, 18:52   #24
takkaria
Veteran
 
takkaria's Avatar
 
Join Date: Apr 2007
Posts: 1,826
Donated: $40
takkaria is on a distinguished road
Quote:
Originally Posted by Sky View Post
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".
I don't think there's any concept of commands 'stacking' in Angband like you say. Angband gets told by its frontend, which gets told by the OS, that a key got pressed. Angband does an instruction, and then goes back to the frontend to ask for another command. It goes like this:

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.
__________________
"Physician, heal thyself."
takkaria is offline   Reply With Quote
Old September 8, 2017, 07:39   #25
kaypy
Adept
 
Join Date: May 2009
Posts: 242
kaypy is on a distinguished road
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...
kaypy is offline   Reply With Quote
Old September 8, 2017, 08:44   #26
takkaria
Veteran
 
takkaria's Avatar
 
Join Date: Apr 2007
Posts: 1,826
Donated: $40
takkaria is on a distinguished road
Quote:
Originally Posted by kaypy View Post
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...
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.
__________________
"Physician, heal thyself."
takkaria is offline   Reply With Quote
Old October 6, 2017, 16:37   #27
t4nk
Adept
 
Join Date: May 2016
Posts: 249
t4nk is on a distinguished road
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

Quote:
Originally Posted by takkaria View Post
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.
The best typists can type about 600 symbols per minute. (I heard in typing competitions they use stenography, and special keyboards with "chords" - no idea what that is - and then can show about 1200 symbols/min, but 600 is a pretty reasonable limit for a normal human with a standard keyboard). That's 10 symbols/sec, or 1 symbol in 100 milliseconds, which is a considerable time... Of course, 600 is average, and peak speed is higher than that, but if keypresses come faster than, say, once per 50 msecs, it means that the user is holding down a key, or pressed several keys (almost) simultaneously. So the pseudocode looks like:
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
    }
}
You can also memorize the previous key, and only discard the new key if the time is not right and the new key is the same as the previous one (so that "movement delay" would work).

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.
t4nk is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
stop *some* items from stacking Sky Vanilla 4 May 1, 2017 15:30
Stop the Hunger Clock bio_hazard Idle chatter 3 November 13, 2016 20:02
Will the TY curse ever stop? poschengbandplayer Variants 3 September 20, 2015 17:24
Sangband - Rest won't stop until hungry Bucolic Verdancy Variants 5 May 23, 2014 04:37
Bug: cannot stop editing keymaps jens Development 1 June 20, 2011 16:19


All times are GMT +1. The time now is 23:03.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2017, vBulletin Solutions, Inc.