VOGONS


First post, by emendelson

User metadata
Rank Oldbie
Rank
Oldbie

Is it possible to create a Mapper handler without binding it to a keystroke, so that the handler is available for binding in the Mapper if the user wants it, but it isn't bound to a key by default.

I know, of course, that I can create a mapper file that does not bind an event to a keystroke, but I am trying to figure out if it's possible to build DOSBox with a handler that does not have a preassigned keystroke.

I've tried various ways of modifying (for example) this line of code. I see that I can replace MMOD2 with 0, but I can't find any way to replace MK_f12 with nothing. I've tried 0, blank, and "", but I can't get any of them to build.

//MAPPER_AddHandler(DOSBOX_UnlockSpeed, MK_f12, MMOD2,"speedlock","Speedlock");

Many thanks for any help with this.

Reply 1 of 2, by ripsaw8080

User metadata
Rank DOSBox Author
Rank
DOSBox Author

An easy way is to add an unhandled key type in mapper.h and use that when adding the event handler.

 enum MapKeys {
MK_f1,MK_f2,MK_f3,MK_f4,MK_f5,MK_f6,MK_f7,MK_f8,MK_f9,MK_f10,MK_f11,MK_f12,
- MK_return,MK_kpminus,MK_scrolllock,MK_printscreen,MK_pause,MK_home
+ MK_return,MK_kpminus,MK_scrolllock,MK_printscreen,MK_pause,MK_home,MK_none

};

It's not ideal because the mapper will show an "unknown key" as the default binding for the event, but it gets the job done because that binding can't be activated. You'd have to do some more coding to prevent the default binding from being added by the mapper.

Reply 2 of 2, by emendelson

User metadata
Rank Oldbie
Rank
Oldbie

Thank you! That gets the job done just about perfectly, I think. No one is going to think that "Unknown key" refers to any specific key and try to press it. (We're long past the day when people asked, "Where's the 'any key'?")

I had been thinking of messing with SDL_keysym.h and creating some non-existent key, but that quickly seemed like a very bad idea. Your suggestion is elegant and efficient and gets the job done. Thanks again.