VOGONS


First post, by philpem

User metadata
Rank Newbie
Rank
Newbie

Hi,
I noticed that "make DOSBox pause when it loses input focus" is on the to-do list, so I figured I'd have a go at implementing it. Turns out it wasn't a particularly hard thing to implement, but adding the "spit and polish" is proving a little difficult.

What I want to do is add a key shortcut to DOSBox (like the Alt-Fx keys used for tweaking CPU cycles and frameskip) so I can disable the feature if I need to, and also add an entry to the config file so I can have auto-pause enabled or disabled when DOSBox is started up.

Can someone tell me what bits of code I should look at to figure out how to go about doing this? I had a quick look at /src/gui/sdl_mapper.cpp and sdl_main.cpp but I can't see how to go about doing what I want to do... I think I'm probably looking at the wrong bit of code 😀

Finally, what's the procedure for submitting code to the DOSBox project? Do I need to apply for developer status or do I just post the patches here? (I'm registered with Sourceforge, username 'philpem').

Thanks,
Phil.

Reply 1 of 8, by mirekluza

User metadata
Rank DOSBox Moderator
Rank
DOSBox Moderator
philpem wrote:

Finally, what's the procedure for submitting code to the DOSBox project? Do I need to apply for developer status or do I just post the patches here? (I'm registered with Sourceforge, username 'philpem')

Post patches on sourceforge. There is no chance for you to get developer status out-of-the-blue... Many people who did a lot of work for DOSBOX do not have it...

Mirek

Reply 2 of 8, by Qbix

User metadata
Rank DOSBox Author
Rank
DOSBox Author

make DOSBox pause when it loses input focus" is on the to-do list

Which to do list ?

Instead of adding a seperate option for it, consider adding it to the priority setting
(priority=active,nofocus)
like priority=normal,pause
A keyboard shortcut won't be added as it's the fauture isn't that like to change during runtime.
The correct place to handle to it would either be render.cpp or sdlmain.cpp
I think the code is in sdlmain.cpp (look at the code that changes the priority).
Patches should be submitted at http://sourceforge.net/tracker/?group_id=52551&atid=467234

I hope this doesn't scare you off.

Peter.

Water flows down the stream
How to ask questions the smart way!

Reply 3 of 8, by philpem

User metadata
Rank Newbie
Rank
Newbie
Qbix wrote:

make DOSBox pause when it loses input focus" is on the to-do list

Which to do list ?

(searches around a bit)
Oh, it wasn't a to-do list, it was DosFreak's "DosBox Wish List" thread over in DOSBox General: DOSBox Feature Request Thread

Qbix wrote:

Instead of adding a seperate option for it, consider adding it to the priority setting
(priority=active,nofocus)
like priority=normal,pause

Actually, that sounds like a much better way to handle it.

Qbix wrote:

A keyboard shortcut won't be added as it's the fauture isn't that like to change during runtime.

I suppose you're right about that.. no sense in cluttering up the keymap for something that 99.9% of users aren't going to want to use.

Qbix wrote:

The correct place to handle to it would either be render.cpp or sdlmain.cpp
I think the code is in sdlmain.cpp (look at the code that changes the priority).
Patches should be submitted at http://sourceforge.net/tracker/?group_id=52551&atid=467234

Got it - looks like I need to add a new priority level, then add the code to handle it. Not too difficult.

Qbix wrote:

I hope this doesn't scare you off.

Ha, not in the least. I once did some work on a now-defunct OSS project. The way they did it was, only developers can post patches and only developers can access the developer mailing list. The way to get recognised as a developer was.. to post a few decent patches to the dev ML. Good fun 😀

Reply 4 of 8, by Qbix

User metadata
Rank DOSBox Author
Rank
DOSBox Author

You can take a look at the function that pauses dosbox.
It's connected to the alt-pause key at the moment. Might save you some coding. (and will make you a bit more at home with DOSBox it's code. I think the function is in sdlmain.cpp as well)

For development on DOSBox, you have to submit patches to sf.net or post them here.
The first is somewhat prefered as it raises our ranking on sf.net, although the second is accepted as well. (incase you didn't have a sf.net account). (both is fine as well)

The patches are usually commited by me (and might be reviewed by others).
DOSBox has a lot of active patch creators, instead of lot of devs (which might become inactive after a few weeks).

Water flows down the stream
How to ask questions the smart way!

Reply 5 of 8, by philpem

User metadata
Rank Newbie
Rank
Newbie
Qbix wrote:

You can take a look at the function that pauses dosbox.
It's connected to the alt-pause key at the moment. Might save you some coding. (and will make you a bit more at home with DOSBox it's code. I think the function is in sdlmain.cpp as well)

Heh, that's where I took the code from to begin with. At the moment, though, when DOSBox gets focus back, it's unpausing but not re-enabling the keyboard. Pausing and unpausing with alt-break gets the keyboard going again, though... Odd.

Qbix wrote:

For development on DOSBox, you have to submit patches to sf.net or post them here.
The first is somewhat prefered as it raises our ranking on sf.net, although the second is accepted as well. (incase you didn't have a sf.net account). (both is fine as well)

I've got an SF.net account, so I'll probably put it up on SF. When I get this annoying little bug splattered that is.

Thanks.

Reply 6 of 8, by philpem

User metadata
Rank Newbie
Rank
Newbie

Hmm, I think I can see why nobody's added this feature yet...

When you do an Alt-tab with DOSBox active, it remembers that the ALT key is down. When you switch back, DOSBox still remembers that. So when you press a key - any key - the key that the DOS application sees is actually Alt, plus the key you pressed (F becomes Alt-F). Pressing the Alt key then releasing it forces DB to update its internal state and the keys work fine again.

So now I need to figure out how to fix this.. But for now, the microwave's beeping at me and I'd like to eat my dinner before it goes cold 😀

Reply 7 of 8, by DosFreak

User metadata
Rank l33t++
Rank
l33t++

Emulators such as VPC/Vmware actually capture the keyboard keys and you have to press a specific key combination (CTRL+ALT for Vmware, and ALT for VPC) to get host input back.

This may need to be implemented if DosBox wants to support Windows 3.1 better....and mabye for the pausing if DosBox is not in focus feature.

How To Ask Questions The Smart Way
Make your games work offline

Reply 8 of 8, by philpem

User metadata
Rank Newbie
Rank
Newbie

I've done some more testing, and it looks like it's only alt-tab that affects it. If I use the title bar to switch, or minimise the DOSBox window with the title bar button, the keys are fine. Alt-tab provokes the "sticky alt key" behaviour. *sigh*

More debugging tomorrow... 🙁