Ticket #7964: Keymap_add_Apple_Aluminum_submenu_1.diff

File Keymap_add_Apple_Aluminum_submenu_1.diff, 9.3 KB (added by jscipione, 13 years ago)

This patch adds the 4 new Apple Aluminum Keyboard Layout files to a submenu in the keymap app called "Apple Aluminum" and remove the original "Apple Aluminium" layout file. The keyboard layout files are added to HaikuImage individually instead of adding all the files in the data/system/data/KeyboardLayouts directory.

  • build/jam/HaikuImage

    diff --git build/jam/HaikuImage build/jam/HaikuImage
    index 90b9eee..0a8ecc9 100644
    AddSymlinkToHaikuImage system data Keymaps : Swedish : Finnish ;  
    499499AddSymlinkToHaikuImage system data Keymaps : Slovene : Croatian ;
    500500AddSymlinkToHaikuImage system data Keymaps : US-International : Brazilian ;
    501501
     502# Copy Keyboard Layout files to the image one-by-one
    502503local keyboardLayoutsDir
    503504    = [ FDirName $(HAIKU_TOP) data system data KeyboardLayouts ] ;
    504 local keyboardLayouts = [ Glob $(keyboardLayoutsDir) : [^.]* ] ;
    505 AddFilesToHaikuImage system data KeyboardLayouts : $(keyboardLayouts) ;
     505local keyboardLayoutFiles =
     506    $(keyboardLayoutsDir)/"Generic 104-key"
     507    $(keyboardLayoutsDir)/"Generic 105-key International"
     508    $(keyboardLayoutsDir)/"IBM Laptop International"
     509    $(keyboardLayoutsDir)/"Kinesis Advantage"
     510    $(keyboardLayoutsDir)/"Kinesis Ergo Elan International"
     511    $(keyboardLayoutsDir)/"TypeMatrix 2030" ;
     512AddDirectoryToHaikuImage system data KeyboardLayouts ;
     513AddFilesToHaikuImage system data KeyboardLayouts
     514    : $(keyboardLayoutFiles) ;
     515
     516local appleAluminumDir
     517    = [ FDirName $(keyboardLayoutsDir) Apple\ Aluminum ] ;
     518local appleAluminumFiles =
     519    $(appleAluminumDir)/"Apple Aluminium Extended International"
     520    $(appleAluminumDir)/"Apple Aluminium International"
     521    $(appleAluminumDir)/"Apple Aluminum (US)"
     522    $(appleAluminumDir)/"Apple Aluminum Extended (US)" ;
     523AddDirectoryToHaikuImage system data KeyboardLayouts Apple\ Aluminum ;
     524AddFilesToHaikuImage system data KeyboardLayouts Apple\ Aluminum
     525    : $(appleAluminumFiles) ;
    506526
    507527local driverSettingsFiles = <driver-settings>kernel ;
    508528SEARCH on $(driverSettingsFiles)
  • deleted file data/system/data/KeyboardLayouts/Apple

    diff --git data/system/data/KeyboardLayouts/Apple Aluminium data/system/data/KeyboardLayouts/Apple Aluminium
    deleted file mode 100644
    index dba6cde..0000000
    + -  
    1 name = Apple aluminium
    2 
    3 # Size shortcuts
    4 default-size = 10,10
    5 $back = 17,10
    6 $fn = 10.5,6
    7 $lshift = 13,10
    8 $ctrl = 14,10
    9 $alt = 12,10
    10 $cmd = 14,10
    11 $b = 5,10
    12 $d = 15,10
    13 $e = l12,20,8
    14 $f = 10,20
    15 $two = 20,10
    16 
    17 # Key rows
    18 [ 0,0;  4,5:-; d$fn:0x01; $fn:+12; d$fn:0x00; 5,6:-; 10,6:0x04+2; 5,6:-;
    19     10,6:+4 ]
    20 [ 0,6; 4,5:-; :0x11+12; d$back:+; $b:-; d:+3; $b:-; d:+1; d:0x6a; d:0x23+1 ]
    21 [ 0,16; 4,5:-; d$d:0x26; :+12; d$e:0x47; $b:-; d:0x34-0x36; $b:-; :+3; d:0x25 ]
    22 [ 0,26; 4,5:led-caps; # integrated into caps key
    23     d17,10:0x3b; :+11; :0x33; 50,10:-; :0x48-0x4a; d:0x3a ]
    24 [ 0,36; 4,5:-; d$lshift:0x4b; :0x69; :0x4c+9; d24,10:+1; 15,10:-; d:+1;
    25     15,10:-; :+3; d$f:+1 ]
    26 [ 0,46; 4,5:-; d$ctrl:0x5c; d$alt:0x5d; d$cmd:0x66; 67,10:0x5e; d$cmd:0x67;
    27     d$alt:0x5f; d$ctrl:0x60; $b:-; d:+3; $b:-; $two:+1; :+1 ]
  • new file data/system/data/KeyboardLayouts/Apple

    diff --git data/system/data/KeyboardLayouts/Apple Aluminum/Apple Aluminium Extended International data/system/data/KeyboardLayouts/Apple Aluminum/Apple Aluminium Extended International
    new file mode 100644
    index 0000000..68c96bb
    - +  
     1name = Apple Aluminium Extended International
     2
     3# Size shortcuts
     4default-size = 10,10
     5$back = 17,10
     6$fn = 10.5,6
     7$lshift = 13,10
     8$ctrl = 14,10
     9$alt = 12,10
     10$cmd = 14,10
     11$b = 5,10
     12$d = 15,10
     13$e = l12,20,8
     14$f = 10,20
     15$two = 20,10
     16
     17# Key rows
     18[ 0,0;  4,5:-; d$fn:0x01; $fn:+12; 15.5,6:-; 10,6:0x70068; 10,6:+2; 5,6:-; 10,6:+4; ]
     19[ 0,6; 4,5:-; :0x11+12; d$back:+; $b:-; :-; d:0x20; d:+1; $b:-; d:+1; d:0x6a; d:0x23+1 ]
     20[ 0,16; 4,5:-; d$d:0x26; :+12; d$e:0x47; $b:-; d:0x34-0x36; $b:-; :+3; d:0x25 ]
     21[ 0,26; 4,5:led-caps; # integrated into caps key
     22    d17,10:0x3b; :+11; :0x33; 50,10:-; :0x48-0x4a; d:0x3a ]
     23[ 0,36; 4,5:-; d$lshift:0x4b; :0x69; :0x4c+9; d24,10:+1; 15,10:-; d:+1;
     24    15,10:-; :+3; d$f:+1 ]
     25[ 0,46; 4,5:-; d$ctrl:0x5c; d$alt:0x5d; d$cmd:0x66; 67,10:0x5e; d$cmd:0x67;
     26    d$alt:0x5f; d$ctrl:0x60; $b:-; d:+3; $b:-; $two:+1; :+1 ]
  • new file data/system/data/KeyboardLayouts/Apple

    diff --git data/system/data/KeyboardLayouts/Apple Aluminum/Apple Aluminium International data/system/data/KeyboardLayouts/Apple Aluminum/Apple Aluminium International
    new file mode 100644
    index 0000000..38758b8
    - +  
     1name = Apple Aluminium International
     2
     3# Size shortcuts
     4default-size = 10,10
     5$back = 17,10
     6$fn = 10.5,6
     7$lshift = 13,10
     8$b = 2,12
     9$d = 15,10
     10$e = l12,20,8
     11$f = 10,20
     12$two = 20,10
     13$last = 10,12
     14$cmd = 14,12
     15$arrow = 10,6
     16
     17# Key rows
     18[ 0,0;  4,5:-; d$fn:0x01; $fn:+12; ]
     19[ 0,6;  4,5:-; :0x11+12; d$back:+; ]
     20[ 0,16; 4,5:-; d$d:0x26; :+12; d$e:0x47; ]
     21[ 0,26; 4,5:led-caps; # integrated into caps key
     22    d17,10:0x3b; :+11; :0x33; ]
     23[ 0,36; 4,5:-; d$lshift:0x4b; :0x69; :0x4c+9; d24,10:+1; ]
     24[ 0,46; 4,5:-; d$last:-; # fn key
     25    d$last:0x5c; d$last:0x5d; d$cmd:0x66; 49,12:0x5e; d$cmd:0x67;
     26    d$last:0x5f; $arrow:-; d$arrow:0x57; $arrow:-; ]
     27[ 121,52; d$arrow:0x61+2; ]
  • new file data/system/data/KeyboardLayouts/Apple

    diff --git data/system/data/KeyboardLayouts/Apple Aluminum/Apple Aluminum (US) data/system/data/KeyboardLayouts/Apple Aluminum/Apple Aluminum (US)
    new file mode 100644
    index 0000000..976c71c
    - +  
     1name = Apple Aluminum (US)
     2
     3# Size shortcuts
     4default-size = 10,10
     5$back = 17,10
     6$fn = 10.5,6
     7$b = 2,12
     8$f = 10,20
     9$two = 20,10
     10$last = 10,12
     11$cmd = 14,12
     12$arrow = 10,6
     13
     14# Key rows
     15[ 0,0;  4,5:-; d$fn:0x01; $fn:+12; ]
     16[ 0,6;  4,5:-; :0x11+12; d$back:+; ]
     17[ 0,16; 4,5:-; d17,10:0x26; :+13; ]
     18[ 0,26; 4,5:led-caps; # integrated into caps key
     19    d19,10:0x3b; :+11; d18,10:0x47; ]
     20[ 0,36; 4,5:-; d24,10:0x4b; :+10; d23,10:+1; ]
     21[ 0,46; 4,5:-; d$last:-; # fn key
     22    d$last:0x5c; d$last:0x5d; d$cmd:0x66; 49,12:0x5e; d$cmd:0x67;
     23    d$last:0x5f; $arrow:-; d$arrow:0x57; $arrow:-; ]
     24[ 121,52; d$arrow:0x61+2; ]
  • new file data/system/data/KeyboardLayouts/Apple

    diff --git data/system/data/KeyboardLayouts/Apple Aluminum/Apple Aluminum Extended (US) data/system/data/KeyboardLayouts/Apple Aluminum/Apple Aluminum Extended (US)
    new file mode 100644
    index 0000000..c2a753b
    - +  
     1name = Apple Aluminum Extended (US)
     2
     3# Size shortcuts
     4default-size = 10,10
     5$back = 17,10
     6$fn = 10.5,6
     7$shift = 24,10
     8$ctrl = 14,10
     9$alt = 12,10
     10$cmd = 14,10
     11$b = 5,10
     12$f = 10,20
     13$two = 20,10
     14
     15# Key rows
     16[ 0,0;  4,5:-; d$fn:0x01; $fn:+12; 15.5,6:-; 10,6:0x70068; 10,6:+2; 5,6:-; 10,6:+4; ]
     17[ 0,6;  4,5:-; :0x11+12; d$back:+; $b:-; :-; d:0x20; d:+1; $b:-; d:+1; d:0x6a; d:0x23+1 ]
     18[ 0,16; 4,5:-; 0,16; 4,5:-; d17,10:0x26; :+13; $b:-; d:0x34-0x36; $b:-; :+3; d:0x25 ]
     19[ 0,26; 4,5:led-caps; # integrated into caps key
     20    d19,10:0x3b; :+11; d18,10:0x47; 40,10:-; :0x48-0x4a; d:0x3a ]
     21[ 0,36; 4,5:-; d24,10:0x4b; :+10; d23,10:+1; 15,10:-; d:+1; 15,10:-; :+3; d$f:+1 ]
     22[ 0,46; 4,5:-; d$ctrl:0x5c; d$alt:0x5d; d$cmd:0x66; 67,10:0x5e; d$cmd:0x67;
     23    d$alt:0x5f; d$ctrl:0x60; $b:-; d:+3; $b:-; $two:+1; :+1 ]
  • src/preferences/keymap/KeymapWindow.cpp

    diff --git src/preferences/keymap/KeymapWindow.cpp src/preferences/keymap/KeymapWindow.cpp
    index 62924a2..53393b1 100644
    KeymapWindow::_AddKeyboardLayouts(BMenu* menu)  
    537537                if (menu->FindItem(ref.name) != NULL)
    538538                    continue;
    539539
    540                 BMessage* message = new BMessage(kChangeKeyboardLayout);
    541                 message->AddRef("ref", &ref);
     540                BDirectory subdirectory;
     541                subdirectory.SetTo(&ref);
     542
     543                if (subdirectory.InitCheck() == B_OK) {
     544                    BMenu* submenu = new BMenu(ref.name);
     545                    submenu->SetRadioMode(true);
     546                   
     547                    entry_ref subref;
     548
     549                    while (subdirectory.GetNextRef(&subref) == B_OK) {
     550                        if (submenu->FindItem(subref.name) != NULL)
     551                            continue;
     552
     553                        BMessage* message = new BMessage(kChangeKeyboardLayout);
     554                        message->AddRef("ref", &subref);
     555               
     556                        submenu->AddItem(new BMenuItem(subref.name, message));
     557                    }
     558                    menu->AddItem(submenu);
     559                } else {
     560                    BMessage* message = new BMessage(kChangeKeyboardLayout);
     561                    message->AddRef("ref", &ref);
    542562
    543                 menu->AddItem(new BMenuItem(ref.name, message));
     563                    menu->AddItem(new BMenuItem(ref.name, message));
     564                }
    544565            }
    545566        }
    546567    }
    KeymapWindow::_SetKeyboardLayout(const char* path)  
    557578        if (status == B_OK) {
    558579            // select item
    559580            for (int32 i = fLayoutMenu->CountItems(); i-- > 0;) {
    560                 BMenuItem* item = fLayoutMenu->ItemAt(i);
    561                 BMessage* message = item->Message();
    562                 entry_ref ref;
    563                 if (message->FindRef("ref", &ref) == B_OK) {
    564                     BPath layoutPath(&ref);
    565                     if (layoutPath == path) {
    566                         item->SetMarked(true);
    567                         break;
     581                BMenu *submenu = fLayoutMenu->SubmenuAt(i);
     582                if (submenu == NULL) {
     583                    BMenuItem* item = fLayoutMenu->ItemAt(i);
     584                    BMessage* message = item->Message();
     585                    entry_ref ref;
     586                    if (message->FindRef("ref", &ref) == B_OK) {
     587                        BPath layoutPath(&ref);
     588                        if (layoutPath == path)
     589                            item->SetMarked(true);
     590                        else
     591                            item->SetMarked(false);
     592                    }
     593                } else {
     594                    for (int32 j = submenu->CountItems(); j-- > 0;) {
     595                        BMenuItem* item = submenu->ItemAt(j);
     596                        BMessage* message = item->Message();
     597                        entry_ref ref;
     598                        if (message->FindRef("ref", &ref) == B_OK) {
     599                            BPath layoutPath(&ref);
     600                            if (layoutPath == path)
     601                                item->SetMarked(true);
     602                            else
     603                                item->SetMarked(false);
     604                        }
    568605                    }
    569606                }
    570607            }