Modified bin/keymap's -h option to write a variable to the generated header
indicating the name of the keymap. Correspondingly, modified input_server to use the aforementioned variable in order to write the name attribute to ~/config/Key_map. This allows Keymap prefs to correctly recognize the name of the default keymap on a fresh build. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24951 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
f9ee0e634a
commit
1174007caf
@ -773,13 +773,22 @@ Keymap::Save(entry_ref &ref)
|
||||
into the input_server, for example.
|
||||
*/
|
||||
void
|
||||
Keymap::SaveAsHeader(entry_ref &ref)
|
||||
Keymap::SaveAsHeader(entry_ref &ref, const char *mapName)
|
||||
{
|
||||
BPath path;
|
||||
status_t err = path.SetTo(&ref);
|
||||
if (err < B_OK)
|
||||
return;
|
||||
|
||||
BString name = mapName;
|
||||
int slashidx = name.FindLast('/');
|
||||
if (slashidx > 0) {
|
||||
// prune off path
|
||||
name.Remove(0, slashidx + 1);
|
||||
}
|
||||
// prune ".keymap"
|
||||
name.Remove(name.FindLast('.'), 7);
|
||||
|
||||
FILE* file = fopen(path.Path(), "w");
|
||||
|
||||
fprintf(file, "/*\n"
|
||||
@ -787,6 +796,7 @@ Keymap::SaveAsHeader(entry_ref &ref)
|
||||
" * This file is generated automatically. Don't edit!\n"
|
||||
" */\n\n");
|
||||
fprintf(file, "#include <InterfaceDefs.h>\n\n");
|
||||
fprintf(file, "const char *kSystemKeymapName = \"%s\";\n\n", name.String());
|
||||
fprintf(file, "const key_map kSystemKeymap = {\n");
|
||||
fprintf(file, "\tversion:%ld,\n", fKeys.version);
|
||||
fprintf(file, "\tcaps_key:0x%lx,\n", fKeys.caps_key);
|
||||
|
@ -27,7 +27,7 @@ class Keymap {
|
||||
status_t LoadSource(FILE *f);
|
||||
status_t LoadSourceFromRef(entry_ref &ref);
|
||||
void SaveAsCurrent();
|
||||
void SaveAsHeader(entry_ref &ref);
|
||||
void SaveAsHeader(entry_ref &ref, const char *mapname);
|
||||
status_t Use();
|
||||
void Dump();
|
||||
bool IsModifierKey(uint32 keyCode);
|
||||
|
@ -117,7 +117,7 @@ main(int argc, char **argv)
|
||||
} else if (operation == 'h') {
|
||||
Keymap keymap;
|
||||
load_keymap_source(keymap, argv[i]);
|
||||
keymap.SaveAsHeader(outputRef);
|
||||
keymap.SaveAsHeader(outputRef, argv[i]);
|
||||
return 0;
|
||||
} else if (operation == 'b') {
|
||||
entry_ref ref;
|
||||
|
@ -309,12 +309,12 @@ InputServer::_LoadSystemKeymap()
|
||||
memcpy(fChars, kSystemKeyChars, fCharsSize);
|
||||
|
||||
// TODO: why are we doing this?
|
||||
return _SaveKeymap();
|
||||
return _SaveKeymap(true);
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
InputServer::_SaveKeymap()
|
||||
InputServer::_SaveKeymap(bool isDefault)
|
||||
{
|
||||
// we save this keymap to file
|
||||
BPath path;
|
||||
@ -349,6 +349,12 @@ InputServer::_SaveKeymap()
|
||||
if ((err = file.Write(fChars, fCharsSize)) < (ssize_t)fCharsSize)
|
||||
return err;
|
||||
|
||||
// don't bother reporting an error if this fails, since this isn't fatal
|
||||
// the keymap will still be functional, and will just be identified as (Current) in prefs instead of its
|
||||
// actual name
|
||||
if (isDefault)
|
||||
file.WriteAttr("keymap:name", B_STRING_TYPE, 0, kSystemKeymapName, strlen(kSystemKeymapName));
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
@ -173,7 +173,7 @@ class InputServer : public BApplication {
|
||||
|
||||
status_t _LoadKeymap();
|
||||
status_t _LoadSystemKeymap();
|
||||
status_t _SaveKeymap();
|
||||
status_t _SaveKeymap(bool isDefault = false);
|
||||
void _InitKeyboardMouseStates();
|
||||
|
||||
status_t _StartEventLoop();
|
||||
|
Loading…
x
Reference in New Issue
Block a user