Compare commits
1 Commits
cleanup/er
...
agent/w092
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
74e0a35ce7 |
@@ -53,9 +53,9 @@ Progress
|
||||
<!-- progress:start -->
|
||||
| Decompiled | Matched | Linked | Data |
|
||||
|:---:|:---:|:---:|:---:|
|
||||
| 93.35% | 82.08% | 57.94% | 89.10% |
|
||||
| 93.64% | 82.24% | 57.94% | 89.35% |
|
||||
|
||||
units 770/1027 complete, functions 11881/12563 matched.
|
||||
units 770/1027 complete, functions 11926/12563 matched.
|
||||
|
||||
decompiled = code with a C/C++ implementation (objdiff fuzzy), matched = byte-exact code, linked = code actually linked into the DOL, data = byte-exact data
|
||||
<!-- progress:end -->
|
||||
|
||||
240
libs/RVL_SDK/src/kbd/kbd_lib_map_us.c
Normal file
240
libs/RVL_SDK/src/kbd/kbd_lib_map_us.c
Normal file
@@ -0,0 +1,240 @@
|
||||
#include <revolution/types.h>
|
||||
|
||||
void kbdInitMapIntl(void);
|
||||
void kbdInitMap(u32 country, u8 codeCount, u8 flags, u16* keyMap, u16* modifierMap,
|
||||
u8 lockIndex, u8 shiftIndex, u8 altIndex, u8 maxCode, s32 keypadType);
|
||||
|
||||
static u16 kbdKeyMapCANADA[400] = {
|
||||
0x003F, 0x0061, 0x0041, 0x0000, 0x003F, 0x0062, 0x0042, 0x0000,
|
||||
0x003F, 0x0063, 0x0043, 0x0000, 0x003F, 0x0064, 0x0044, 0x0000,
|
||||
0x003F, 0x0065, 0x0045, 0x0000, 0x003F, 0x0066, 0x0046, 0x0000,
|
||||
0x003F, 0x0067, 0x0047, 0x0000, 0x003F, 0x0068, 0x0048, 0x0000,
|
||||
0x003F, 0x0069, 0x0049, 0x0000, 0x003F, 0x006A, 0x004A, 0x0000,
|
||||
0x003F, 0x006B, 0x004B, 0x0000, 0x003F, 0x006C, 0x004C, 0x0000,
|
||||
0x003F, 0x006D, 0x004D, 0x0000, 0x003F, 0x006E, 0x004E, 0x0000,
|
||||
0x003F, 0x006F, 0x004F, 0x0000, 0x003F, 0x0070, 0x0050, 0x0000,
|
||||
0x003F, 0x0071, 0x0051, 0x0000, 0x003F, 0x0072, 0x0052, 0x0000,
|
||||
0x003F, 0x0073, 0x0053, 0x0000, 0x003F, 0x0074, 0x0054, 0x0000,
|
||||
0x003F, 0x0075, 0x0055, 0x0000, 0x003F, 0x0076, 0x0056, 0x0000,
|
||||
0x003F, 0x0077, 0x0057, 0x0000, 0x003F, 0x0078, 0x0058, 0x00BB,
|
||||
0x003F, 0x0079, 0x0059, 0x0000, 0x003F, 0x007A, 0x005A, 0x00AB,
|
||||
0x0000, 0x0031, 0x0021, 0x0000, 0x0000, 0x0032, 0x0040, 0x0000,
|
||||
0x0000, 0x0033, 0x0023, 0x0000, 0x0000, 0x0034, 0x0024, 0x0000,
|
||||
0x0000, 0x0035, 0x0025, 0x0000, 0x0000, 0x0036, 0x003F, 0x0000,
|
||||
0x0000, 0x0037, 0x0026, 0x007B, 0x0000, 0x0038, 0x002A, 0x007D,
|
||||
0x0000, 0x0039, 0x0028, 0x005B, 0x0000, 0x0030, 0x0029, 0x005D,
|
||||
0x0000, 0xF1CD, 0xF1CD, 0xF1CD, 0x0000, 0xF1DB, 0xF1DB, 0xF1DB,
|
||||
0x0000, 0xF1C8, 0xF1C8, 0xF1C8, 0x0000, 0xF1C9, 0xF1C9, 0xF1C9,
|
||||
0x0000, 0x0020, 0x0020, 0x0020, 0x0000, 0x002D, 0x005F, 0x0000,
|
||||
0x0000, 0x003D, 0x002B, 0x00AC, 0x0000, 0x0302, 0x0308, 0x0300,
|
||||
0x003F, 0x00E7, 0x00C7, 0x0303, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||
0x003F, 0x00E0, 0x00C0, 0x0000, 0x0000, 0x003B, 0x003A, 0x00B0,
|
||||
0x003F, 0x00E8, 0x00C8, 0x0000, 0x0000, 0x002F, 0x005C, 0x007C,
|
||||
0x0000, 0x002C, 0x0027, 0x003C, 0x0000, 0x002E, 0x0022, 0x003E,
|
||||
0x003F, 0x00E9, 0x00C9, 0x0000, 0xC000, 0xF008, 0xF008, 0xF008,
|
||||
0x0000, 0xF061, 0xF061, 0xF061, 0x0000, 0xF062, 0xF062, 0xF062,
|
||||
0x0000, 0xF063, 0xF063, 0xF063, 0x0000, 0xF064, 0xF064, 0xF064,
|
||||
0x0000, 0xF065, 0xF065, 0xF065, 0x0000, 0xF066, 0xF066, 0xF066,
|
||||
0x0000, 0xF067, 0xF067, 0xF067, 0x0000, 0xF068, 0xF068, 0xF068,
|
||||
0x0000, 0xF069, 0xF069, 0xF069, 0x0000, 0xF06A, 0xF06A, 0xF06A,
|
||||
0x0000, 0xF06B, 0xF06B, 0xF06B, 0x0000, 0xF06C, 0xF06C, 0xF06C,
|
||||
0xC000, 0xF020, 0xF020, 0xF020, 0xC000, 0xF021, 0xF021, 0xF021,
|
||||
0xC000, 0xF022, 0xF022, 0xF022, 0x0000, 0xF1B0, 0xF1B0, 0xF1B0,
|
||||
0x0000, 0xF1B7, 0xF1B7, 0xF1B7, 0x0000, 0xF1B9, 0xF1B9, 0xF1B9,
|
||||
0x0000, 0xF1AE, 0xF1AE, 0xF1AE, 0x0000, 0xF1B1, 0xF1B1, 0xF1B1,
|
||||
0x0000, 0xF1B3, 0xF1B3, 0xF1B3, 0x0000, 0xF1B6, 0xF1B6, 0xF1B6,
|
||||
0x0000, 0xF1B4, 0xF1B4, 0xF1B4, 0x0000, 0xF1B2, 0xF1B2, 0xF1B2,
|
||||
0x0000, 0xF1B8, 0xF1B8, 0xF1B8, 0xC000, 0xF007, 0xF007, 0xF007,
|
||||
0x0000, 0xF12F, 0xF12F, 0xF12F, 0x0000, 0xF12A, 0xF12A, 0xF12A,
|
||||
0x0000, 0xF12D, 0xF12D, 0xF12D, 0x0000, 0xF12B, 0xF12B, 0xF12B,
|
||||
0x0000, 0xF10D, 0xF10D, 0xF10D, 0x80FF, 0xF171, 0xF131, 0x0000,
|
||||
0x80FF, 0xF172, 0xF132, 0x0000, 0x80FF, 0xF173, 0xF133, 0x0000,
|
||||
0x80FF, 0xF174, 0xF134, 0x0000, 0x80FF, 0xF175, 0xF135, 0x0000,
|
||||
0x80FF, 0xF176, 0xF136, 0x0000, 0x80FF, 0xF177, 0xF137, 0x0000,
|
||||
0x80FF, 0xF178, 0xF138, 0x0000, 0x80FF, 0xF179, 0xF139, 0x0000,
|
||||
0x80FF, 0xF170, 0xF130, 0x0000, 0x80FF, 0xF16E, 0xF12E, 0x0000,
|
||||
0x003F, 0x00F9, 0x00D9, 0x0000, 0xC000, 0xF02F, 0xF02F, 0xF02F,
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xF13D, 0xF13D, 0xF13D,
|
||||
};
|
||||
|
||||
static u16 kbdModifierMapCANADA[32] = {
|
||||
0xC000, 0xF000, 0xF000, 0xF000, 0xC000, 0xF001, 0xF001, 0xF001,
|
||||
0xC000, 0xF002, 0xF002, 0xF002, 0xC000, 0xF003, 0xF003, 0xF003,
|
||||
0xC000, 0xF000, 0xF000, 0xF000, 0xC000, 0xF001, 0xF001, 0xF001,
|
||||
0xC000, 0xF005, 0xF005, 0xF005, 0xC000, 0xF003, 0xF003, 0xF003,
|
||||
};
|
||||
|
||||
static u16 kbdKeyMapCANADA_FR[400] = {
|
||||
0x003F, 0x0061, 0x0041, 0x0000, 0x003F, 0x0062, 0x0042, 0x0000,
|
||||
0x003F, 0x0063, 0x0043, 0x0000, 0x003F, 0x0064, 0x0044, 0x0000,
|
||||
0x003F, 0x0065, 0x0045, 0x0000, 0x003F, 0x0066, 0x0046, 0x0000,
|
||||
0x003F, 0x0067, 0x0047, 0x0000, 0x003F, 0x0068, 0x0048, 0x0000,
|
||||
0x003F, 0x0069, 0x0049, 0x0000, 0x003F, 0x006A, 0x004A, 0x0000,
|
||||
0x003F, 0x006B, 0x004B, 0x0000, 0x003F, 0x006C, 0x004C, 0x0000,
|
||||
0x003F, 0x006D, 0x004D, 0x00B5, 0x003F, 0x006E, 0x004E, 0x0000,
|
||||
0x003F, 0x006F, 0x004F, 0x00A7, 0x003F, 0x0070, 0x0050, 0x00B6,
|
||||
0x003F, 0x0071, 0x0051, 0x0000, 0x003F, 0x0072, 0x0052, 0x0000,
|
||||
0x003F, 0x0073, 0x0053, 0x0000, 0x003F, 0x0074, 0x0054, 0x0000,
|
||||
0x003F, 0x0075, 0x0055, 0x0000, 0x003F, 0x0076, 0x0056, 0x0000,
|
||||
0x003F, 0x0077, 0x0057, 0x0000, 0x003F, 0x0078, 0x0058, 0x0000,
|
||||
0x003F, 0x0079, 0x0059, 0x0000, 0x003F, 0x007A, 0x005A, 0x0000,
|
||||
0x0000, 0x0031, 0x0021, 0x00B1, 0x0000, 0x0032, 0x0022, 0x0040,
|
||||
0x0000, 0x0033, 0x002F, 0x00A3, 0x0000, 0x0034, 0x0024, 0x00A2,
|
||||
0x0000, 0x0035, 0x0025, 0x00A4, 0x0000, 0x0036, 0x003F, 0x00AC,
|
||||
0x0000, 0x0037, 0x0026, 0x00A6, 0x0000, 0x0038, 0x002A, 0x00B2,
|
||||
0x0000, 0x0039, 0x0028, 0x00B3, 0x0000, 0x0030, 0x0029, 0x00BC,
|
||||
0x0000, 0xF1CD, 0xF1CD, 0xF1CD, 0x0000, 0xF1DB, 0xF1DB, 0xF1DB,
|
||||
0x0000, 0xF1C8, 0xF1C8, 0xF1C8, 0x0000, 0xF1C9, 0xF1C9, 0xF1C9,
|
||||
0x0000, 0x0020, 0x0020, 0x0020, 0x0000, 0x002D, 0x005F, 0x00BD,
|
||||
0x0000, 0x003D, 0x002B, 0x00BE, 0x0000, 0x0302, 0x0302, 0x005B,
|
||||
0x0000, 0x0327, 0x0308, 0x005D, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||
0x0000, 0x003C, 0x003E, 0x007D, 0x0000, 0x003B, 0x003A, 0x007E,
|
||||
0x0000, 0x0300, 0x0300, 0x007B, 0x0000, 0x0023, 0x007C, 0x005C,
|
||||
0x0000, 0x002C, 0x0027, 0x00AF, 0x0000, 0x002E, 0x002E, 0x002D,
|
||||
0x003F, 0x00E9, 0x00C9, 0x0301, 0xC000, 0xF008, 0xF008, 0xF008,
|
||||
0x0000, 0xF061, 0xF061, 0xF061, 0x0000, 0xF062, 0xF062, 0xF062,
|
||||
0x0000, 0xF063, 0xF063, 0xF063, 0x0000, 0xF064, 0xF064, 0xF064,
|
||||
0x0000, 0xF065, 0xF065, 0xF065, 0x0000, 0xF066, 0xF066, 0xF066,
|
||||
0x0000, 0xF067, 0xF067, 0xF067, 0x0000, 0xF068, 0xF068, 0xF068,
|
||||
0x0000, 0xF069, 0xF069, 0xF069, 0x0000, 0xF06A, 0xF06A, 0xF06A,
|
||||
0x0000, 0xF06B, 0xF06B, 0xF06B, 0x0000, 0xF06C, 0xF06C, 0xF06C,
|
||||
0xC000, 0xF020, 0xF020, 0xF020, 0xC000, 0xF021, 0xF021, 0xF021,
|
||||
0xC000, 0xF022, 0xF022, 0xF022, 0x0000, 0xF1B0, 0xF1B0, 0xF1B0,
|
||||
0x0000, 0xF1B7, 0xF1B7, 0xF1B7, 0x0000, 0xF1B9, 0xF1B9, 0xF1B9,
|
||||
0x0000, 0xF1AE, 0xF1AE, 0xF1AE, 0x0000, 0xF1B1, 0xF1B1, 0xF1B1,
|
||||
0x0000, 0xF1B3, 0xF1B3, 0xF1B3, 0x0000, 0xF1B6, 0xF1B6, 0xF1B6,
|
||||
0x0000, 0xF1B4, 0xF1B4, 0xF1B4, 0x0000, 0xF1B2, 0xF1B2, 0xF1B2,
|
||||
0x0000, 0xF1B8, 0xF1B8, 0xF1B8, 0xC000, 0xF007, 0xF007, 0xF007,
|
||||
0x0000, 0xF12F, 0xF12F, 0xF12F, 0x0000, 0xF12A, 0xF12A, 0xF12A,
|
||||
0x0000, 0xF12D, 0xF12D, 0xF12D, 0x0000, 0xF12B, 0xF12B, 0xF12B,
|
||||
0x0000, 0xF10D, 0xF10D, 0xF10D, 0x80FF, 0xF171, 0xF131, 0x0000,
|
||||
0x80FF, 0xF172, 0xF132, 0x0000, 0x80FF, 0xF173, 0xF133, 0x0000,
|
||||
0x80FF, 0xF174, 0xF134, 0x0000, 0x80FF, 0xF175, 0xF135, 0x0000,
|
||||
0x80FF, 0xF176, 0xF136, 0x0000, 0x80FF, 0xF177, 0xF137, 0x0000,
|
||||
0x80FF, 0xF178, 0xF138, 0x0000, 0x80FF, 0xF179, 0xF139, 0x0000,
|
||||
0x80FF, 0xF170, 0xF130, 0x0000, 0x80FF, 0xF16E, 0xF12E, 0x0000,
|
||||
0x0000, 0x00AB, 0x00BB, 0x00B0, 0x0000, 0xF02F, 0xF02F, 0xF02F,
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xF13D, 0xF13D, 0xF13D,
|
||||
};
|
||||
|
||||
static u16 kbdModifierMapCANADA_FR[32] = {
|
||||
0xC000, 0xF000, 0xF000, 0xF000, 0xC000, 0xF001, 0xF001, 0xF001,
|
||||
0xC000, 0xF002, 0xF002, 0xF002, 0xC000, 0xF003, 0xF003, 0xF003,
|
||||
0xC000, 0xF000, 0xF000, 0xF000, 0xC000, 0xF001, 0xF001, 0xF001,
|
||||
0xC000, 0xF005, 0xF005, 0xF005, 0xC000, 0xF003, 0xF003, 0xF003,
|
||||
};
|
||||
|
||||
static u16 kbdKeyMapLATIN_AMERICA[400] = {
|
||||
0x003F, 0x0061, 0x0041, 0x0000, 0x003F, 0x0062, 0x0042, 0x0000,
|
||||
0x003F, 0x0063, 0x0043, 0x0000, 0x003F, 0x0064, 0x0044, 0x0000,
|
||||
0x003F, 0x0065, 0x0045, 0x0000, 0x003F, 0x0066, 0x0046, 0x0000,
|
||||
0x003F, 0x0067, 0x0047, 0x0000, 0x003F, 0x0068, 0x0048, 0x0000,
|
||||
0x003F, 0x0069, 0x0049, 0x0000, 0x003F, 0x006A, 0x004A, 0x0000,
|
||||
0x003F, 0x006B, 0x004B, 0x0000, 0x003F, 0x006C, 0x004C, 0x0000,
|
||||
0x003F, 0x006D, 0x004D, 0x0000, 0x003F, 0x006E, 0x004E, 0x0000,
|
||||
0x003F, 0x006F, 0x004F, 0x0000, 0x003F, 0x0070, 0x0050, 0x0000,
|
||||
0x003F, 0x0071, 0x0051, 0x0040, 0x003F, 0x0072, 0x0052, 0x0000,
|
||||
0x003F, 0x0073, 0x0053, 0x0000, 0x003F, 0x0074, 0x0054, 0x0000,
|
||||
0x003F, 0x0075, 0x0055, 0x0000, 0x003F, 0x0076, 0x0056, 0x0000,
|
||||
0x003F, 0x0077, 0x0057, 0x0000, 0x003F, 0x0078, 0x0058, 0x0000,
|
||||
0x003F, 0x0079, 0x0059, 0x0000, 0x003F, 0x007A, 0x005A, 0x0000,
|
||||
0x0000, 0x0031, 0x0021, 0x0000, 0x0000, 0x0032, 0x0022, 0x0000,
|
||||
0x0000, 0x0033, 0x0023, 0x0000, 0x0000, 0x0034, 0x0024, 0x0000,
|
||||
0x0000, 0x0035, 0x0025, 0x0000, 0x0000, 0x0036, 0x0026, 0x0000,
|
||||
0x0000, 0x0037, 0x002F, 0x0000, 0x0000, 0x0038, 0x0028, 0x0000,
|
||||
0x0000, 0x0039, 0x0029, 0x0000, 0x0000, 0x0030, 0x003D, 0x0000,
|
||||
0x0000, 0xF1CD, 0xF1CD, 0xF1CD, 0x0000, 0xF1DB, 0xF1DB, 0xF1DB,
|
||||
0x0000, 0xF1C8, 0xF1C8, 0xF1C8, 0x0000, 0xF1C9, 0xF1C9, 0xF1C9,
|
||||
0x0000, 0x0020, 0x0020, 0x0020, 0x0000, 0x0027, 0x003F, 0x005C,
|
||||
0x0000, 0x00BF, 0x00A1, 0x0000, 0x0000, 0x0301, 0x0308, 0x0000,
|
||||
0x0000, 0x002B, 0x002A, 0x007E, 0x0000, 0x0000, 0x0000, 0x0000,
|
||||
0x0000, 0x007D, 0x005D, 0x0300, 0x003F, 0x00F1, 0x00D1, 0x0000,
|
||||
0x0000, 0x007B, 0x005B, 0x0302, 0x0000, 0x007C, 0x00B0, 0x00AC,
|
||||
0x0000, 0x002C, 0x003B, 0x0000, 0x0000, 0x002E, 0x003A, 0x0000,
|
||||
0x0000, 0x002D, 0x005F, 0x0000, 0xC000, 0xF008, 0xF008, 0xF008,
|
||||
0x0000, 0xF061, 0xF061, 0xF061, 0x0000, 0xF062, 0xF062, 0xF062,
|
||||
0x0000, 0xF063, 0xF063, 0xF063, 0x0000, 0xF064, 0xF064, 0xF064,
|
||||
0x0000, 0xF065, 0xF065, 0xF065, 0x0000, 0xF066, 0xF066, 0xF066,
|
||||
0x0000, 0xF067, 0xF067, 0xF067, 0x0000, 0xF068, 0xF068, 0xF068,
|
||||
0x0000, 0xF069, 0xF069, 0xF069, 0x0000, 0xF06A, 0xF06A, 0xF06A,
|
||||
0x0000, 0xF06B, 0xF06B, 0xF06B, 0x0000, 0xF06C, 0xF06C, 0xF06C,
|
||||
0xC000, 0xF020, 0xF020, 0xF020, 0xC000, 0xF021, 0xF021, 0xF021,
|
||||
0xC000, 0xF022, 0xF022, 0xF022, 0x0000, 0xF1B0, 0xF1B0, 0xF1B0,
|
||||
0x0000, 0xF1B7, 0xF1B7, 0xF1B7, 0x0000, 0xF1B9, 0xF1B9, 0xF1B9,
|
||||
0x0000, 0xF1AE, 0xF1AE, 0xF1AE, 0x0000, 0xF1B1, 0xF1B1, 0xF1B1,
|
||||
0x0000, 0xF1B3, 0xF1B3, 0xF1B3, 0x0000, 0xF1B6, 0xF1B6, 0xF1B6,
|
||||
0x0000, 0xF1B4, 0xF1B4, 0xF1B4, 0x0000, 0xF1B2, 0xF1B2, 0xF1B2,
|
||||
0x0000, 0xF1B8, 0xF1B8, 0xF1B8, 0xC000, 0xF007, 0xF007, 0xF007,
|
||||
0x0000, 0xF12F, 0xF12F, 0xF12F, 0x0000, 0xF12A, 0xF12A, 0xF12A,
|
||||
0x0000, 0xF12D, 0xF12D, 0xF12D, 0x0000, 0xF12B, 0xF12B, 0xF12B,
|
||||
0x0000, 0xF10D, 0xF10D, 0xF10D, 0x80FF, 0xF171, 0xF131, 0x0000,
|
||||
0x80FF, 0xF172, 0xF132, 0x0000, 0x80FF, 0xF173, 0xF133, 0x0000,
|
||||
0x80FF, 0xF174, 0xF134, 0x0000, 0x80FF, 0xF175, 0xF135, 0x0000,
|
||||
0x80FF, 0xF176, 0xF136, 0x0000, 0x80FF, 0xF177, 0xF137, 0x0000,
|
||||
0x80FF, 0xF178, 0xF138, 0x0000, 0x80FF, 0xF179, 0xF139, 0x0000,
|
||||
0x80FF, 0xF170, 0xF130, 0x0000, 0x80FF, 0xF16E, 0xF12E, 0x0000,
|
||||
0x0000, 0x003C, 0x003E, 0x0000, 0xC000, 0xF02F, 0xF02F, 0xF02F,
|
||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0xF13D, 0xF13D, 0xF13D,
|
||||
};
|
||||
|
||||
static u16 kbdModifierMapLATIN_AMERICA[32] = {
|
||||
0xC000, 0xF000, 0xF000, 0xF000, 0xC000, 0xF001, 0xF001, 0xF001,
|
||||
0xC000, 0xF002, 0xF002, 0xF002, 0xC000, 0xF003, 0xF003, 0xF003,
|
||||
0xC000, 0xF000, 0xF000, 0xF000, 0xC000, 0xF001, 0xF001, 0xF001,
|
||||
0xC000, 0xF005, 0xF005, 0xF005, 0xC000, 0xF003, 0xF003, 0xF003,
|
||||
};
|
||||
|
||||
static u16 kbdKeyMapUSA[300] = {
|
||||
0x003F, 0x0061, 0x0041, 0x003F, 0x0062, 0x0042, 0x003F, 0x0063,
|
||||
0x0043, 0x003F, 0x0064, 0x0044, 0x003F, 0x0065, 0x0045, 0x003F,
|
||||
0x0066, 0x0046, 0x003F, 0x0067, 0x0047, 0x003F, 0x0068, 0x0048,
|
||||
0x003F, 0x0069, 0x0049, 0x003F, 0x006A, 0x004A, 0x003F, 0x006B,
|
||||
0x004B, 0x003F, 0x006C, 0x004C, 0x003F, 0x006D, 0x004D, 0x003F,
|
||||
0x006E, 0x004E, 0x003F, 0x006F, 0x004F, 0x003F, 0x0070, 0x0050,
|
||||
0x003F, 0x0071, 0x0051, 0x003F, 0x0072, 0x0052, 0x003F, 0x0073,
|
||||
0x0053, 0x003F, 0x0074, 0x0054, 0x003F, 0x0075, 0x0055, 0x003F,
|
||||
0x0076, 0x0056, 0x003F, 0x0077, 0x0057, 0x003F, 0x0078, 0x0058,
|
||||
0x003F, 0x0079, 0x0059, 0x003F, 0x007A, 0x005A, 0x0000, 0x0031,
|
||||
0x0021, 0x0000, 0x0032, 0x0040, 0x0000, 0x0033, 0x0023, 0x0000,
|
||||
0x0034, 0x0024, 0x0000, 0x0035, 0x0025, 0x0000, 0x0036, 0x005E,
|
||||
0x0000, 0x0037, 0x0026, 0x0000, 0x0038, 0x002A, 0x0000, 0x0039,
|
||||
0x0028, 0x0000, 0x0030, 0x0029, 0x0000, 0xF1CD, 0xF1CD, 0x0000,
|
||||
0xF1DB, 0xF1DB, 0x0000, 0xF1C8, 0xF1C8, 0x0000, 0xF1C9, 0xF1C9,
|
||||
0x0000, 0x0020, 0x0020, 0x0000, 0x002D, 0x005F, 0x0000, 0x003D,
|
||||
0x002B, 0x0000, 0x005B, 0x007B, 0x0000, 0x005D, 0x007D, 0x0000,
|
||||
0x005C, 0x007C, 0x0000, 0x0000, 0x0000, 0x0000, 0x003B, 0x003A,
|
||||
0x0000, 0x0027, 0x0022, 0x0000, 0x0060, 0x007E, 0x0000, 0x002C,
|
||||
0x003C, 0x0000, 0x002E, 0x003E, 0x0000, 0x002F, 0x003F, 0xC000,
|
||||
0xF008, 0xF008, 0x0000, 0xF061, 0xF061, 0x0000, 0xF062, 0xF062,
|
||||
0x0000, 0xF063, 0xF063, 0x0000, 0xF064, 0xF064, 0x0000, 0xF065,
|
||||
0xF065, 0x0000, 0xF066, 0xF066, 0x0000, 0xF067, 0xF067, 0x0000,
|
||||
0xF068, 0xF068, 0x0000, 0xF069, 0xF069, 0x0000, 0xF06A, 0xF06A,
|
||||
0x0000, 0xF06B, 0xF06B, 0x0000, 0xF06C, 0xF06C, 0xC000, 0xF020,
|
||||
0xF020, 0xC000, 0xF021, 0xF021, 0xC000, 0xF022, 0xF022, 0x0000,
|
||||
0xF1B0, 0xF1B0, 0x0000, 0xF1B7, 0xF1B7, 0x0000, 0xF1B9, 0xF1B9,
|
||||
0x0000, 0xF1AE, 0xF1AE, 0x0000, 0xF1B1, 0xF1B1, 0x0000, 0xF1B3,
|
||||
0xF1B3, 0x0000, 0xF1B6, 0xF1B6, 0x0000, 0xF1B4, 0xF1B4, 0x0000,
|
||||
0xF1B2, 0xF1B2, 0x0000, 0xF1B8, 0xF1B8, 0xC000, 0xF007, 0xF007,
|
||||
0x0000, 0xF12F, 0xF12F, 0x0000, 0xF12A, 0xF12A, 0x0000, 0xF12D,
|
||||
0xF12D, 0x0000, 0xF12B, 0xF12B, 0x0000, 0xF10D, 0xF10D, 0x80FF,
|
||||
0xF171, 0xF131, 0x80FF, 0xF172, 0xF132, 0x80FF, 0xF173, 0xF133,
|
||||
0x80FF, 0xF174, 0xF134, 0x80FF, 0xF175, 0xF135, 0x80FF, 0xF176,
|
||||
0xF136, 0x80FF, 0xF177, 0xF137, 0x80FF, 0xF178, 0xF138, 0x80FF,
|
||||
0xF179, 0xF139, 0x80FF, 0xF170, 0xF130, 0x80FF, 0xF16E, 0xF12E,
|
||||
0x0000, 0x0000, 0x0000, 0xC000, 0xF02F, 0xF02F, 0x0000, 0x0000,
|
||||
0x0000, 0x0000, 0xF13D, 0xF13D,
|
||||
};
|
||||
|
||||
static u16 kbdModifierMapUSA[24] = {
|
||||
0xC000, 0xF000, 0xF000, 0xC000, 0xF001, 0xF001, 0xC000, 0xF002,
|
||||
0xF002, 0xC000, 0xF003, 0xF003, 0xC000, 0xF000, 0xF000, 0xC000,
|
||||
0xF001, 0xF001, 0xC000, 0xF002, 0xF002, 0xC000, 0xF003, 0xF003,
|
||||
};
|
||||
|
||||
void KBDInitRegionUS(void) {
|
||||
kbdInitMapIntl();
|
||||
kbdInitMap(3, 4, 0x10, kbdKeyMapCANADA, kbdModifierMapCANADA, 0, 0, 3, 100, 2);
|
||||
kbdInitMap(4, 4, 0x10, kbdKeyMapCANADA_FR, kbdModifierMapCANADA_FR, 0, 0, 3, 100, 2);
|
||||
kbdInitMap(17, 4, 0x10, kbdKeyMapLATIN_AMERICA, kbdModifierMapLATIN_AMERICA, 0, 0, 3, 100, 2);
|
||||
kbdInitMap(33, 3, 0, kbdKeyMapUSA, kbdModifierMapUSA, 0, 0, 0, 100, 0);
|
||||
}
|
||||
339
libs/RVL_SDK/src/kpr/kpr_lib.c
Normal file
339
libs/RVL_SDK/src/kpr/kpr_lib.c
Normal file
@@ -0,0 +1,339 @@
|
||||
#include <revolution/kpr.h>
|
||||
#include <revolution/os.h>
|
||||
|
||||
struct KPRDeadKey {
|
||||
u16 accent;
|
||||
u16 base;
|
||||
u16 composed;
|
||||
};
|
||||
|
||||
const struct KPRDeadKey kprDeadKeyMap[] = {
|
||||
{0x0300, 0x0300, 0x0060},
|
||||
{0x0300, 0x0041, 0x00C0},
|
||||
{0x0300, 0x0045, 0x00C8},
|
||||
{0x0300, 0x0049, 0x00CC},
|
||||
{0x0300, 0x004F, 0x00D2},
|
||||
{0x0300, 0x0055, 0x00D9},
|
||||
{0x0300, 0x0061, 0x00E0},
|
||||
{0x0300, 0x0065, 0x00E8},
|
||||
{0x0300, 0x0069, 0x00EC},
|
||||
{0x0300, 0x006F, 0x00F2},
|
||||
{0x0300, 0x0075, 0x00F9},
|
||||
{0x0301, 0x0301, 0x00B4},
|
||||
{0x0301, 0x0041, 0x00C1},
|
||||
{0x0301, 0x0045, 0x00C9},
|
||||
{0x0301, 0x0049, 0x00CD},
|
||||
{0x0301, 0x004F, 0x00D3},
|
||||
{0x0301, 0x0055, 0x00DA},
|
||||
{0x0301, 0x0059, 0x00DD},
|
||||
{0x0301, 0x0061, 0x00E1},
|
||||
{0x0301, 0x0065, 0x00E9},
|
||||
{0x0301, 0x0069, 0x00ED},
|
||||
{0x0301, 0x006F, 0x00F3},
|
||||
{0x0301, 0x0075, 0x00FA},
|
||||
{0x0301, 0x0079, 0x00FD},
|
||||
{0x0302, 0x0302, 0x005E},
|
||||
{0x0302, 0x0041, 0x00C2},
|
||||
{0x0302, 0x0045, 0x00CA},
|
||||
{0x0302, 0x0049, 0x00CE},
|
||||
{0x0302, 0x004F, 0x00D4},
|
||||
{0x0302, 0x0055, 0x00DB},
|
||||
{0x0302, 0x0061, 0x00E2},
|
||||
{0x0302, 0x0065, 0x00EA},
|
||||
{0x0302, 0x0069, 0x00EE},
|
||||
{0x0302, 0x006F, 0x00F4},
|
||||
{0x0302, 0x0075, 0x00FB},
|
||||
{0x0303, 0x0303, 0x007E},
|
||||
{0x0303, 0x0041, 0x00C3},
|
||||
{0x0303, 0x004E, 0x00D1},
|
||||
{0x0303, 0x004F, 0x00D5},
|
||||
{0x0303, 0x0061, 0x00E3},
|
||||
{0x0303, 0x006E, 0x00F1},
|
||||
{0x0303, 0x006F, 0x00F5},
|
||||
{0x0308, 0x0308, 0x00A8},
|
||||
{0x0308, 0x0041, 0x00C4},
|
||||
{0x0308, 0x0045, 0x00CB},
|
||||
{0x0308, 0x0049, 0x00CF},
|
||||
{0x0308, 0x004F, 0x00D6},
|
||||
{0x0308, 0x0055, 0x00DC},
|
||||
{0x0308, 0x0059, 0x0178},
|
||||
{0x0308, 0x0061, 0x00E4},
|
||||
{0x0308, 0x0065, 0x00EB},
|
||||
{0x0308, 0x0069, 0x00EF},
|
||||
{0x0308, 0x006F, 0x00F6},
|
||||
{0x0308, 0x0075, 0x00FC},
|
||||
{0x0308, 0x0079, 0x00FF},
|
||||
{0x0327, 0x0327, 0x00B8},
|
||||
{0x0327, 0x0043, 0x00C7},
|
||||
{0x0327, 0x0063, 0x00E7},
|
||||
{0x030D, 0x030D, 0x0027},
|
||||
{0x030D, 0x0041, 0x00C1},
|
||||
{0x030D, 0x0045, 0x00C9},
|
||||
{0x030D, 0x0049, 0x00CD},
|
||||
{0x030D, 0x004F, 0x00D3},
|
||||
{0x030D, 0x0055, 0x00DA},
|
||||
{0x030D, 0x0059, 0x00DD},
|
||||
{0x030D, 0x0043, 0x00C7},
|
||||
{0x030D, 0x0061, 0x00E1},
|
||||
{0x030D, 0x0065, 0x00E9},
|
||||
{0x030D, 0x0069, 0x00ED},
|
||||
{0x030D, 0x006F, 0x00F3},
|
||||
{0x030D, 0x0075, 0x00FA},
|
||||
{0x030D, 0x0079, 0x00FD},
|
||||
{0x030D, 0x0063, 0x00E7},
|
||||
{0x030E, 0x030E, 0x0022},
|
||||
{0x030E, 0x0041, 0x00C4},
|
||||
{0x030E, 0x0045, 0x00CB},
|
||||
{0x030E, 0x0049, 0x00CF},
|
||||
{0x030E, 0x004F, 0x00D6},
|
||||
{0x030E, 0x0055, 0x00DC},
|
||||
{0x030E, 0x0059, 0x0178},
|
||||
{0x030E, 0x0061, 0x00E4},
|
||||
{0x030E, 0x0065, 0x00EB},
|
||||
{0x030E, 0x0069, 0x00EF},
|
||||
{0x030E, 0x006F, 0x00F6},
|
||||
{0x030E, 0x0075, 0x00FC},
|
||||
{0x030E, 0x0079, 0x00FF},
|
||||
{0x0344, 0x0344, 0x0385},
|
||||
{0x0344, 0x03B9, 0x0390},
|
||||
{0x0344, 0x03C5, 0x03B0},
|
||||
{0x0308, 0x0399, 0x03AA},
|
||||
{0x0308, 0x03A5, 0x03AB},
|
||||
{0x0308, 0x03B9, 0x03CA},
|
||||
{0x0308, 0x03C5, 0x03CB},
|
||||
{0x0301, 0x0391, 0x0386},
|
||||
{0x0301, 0x0395, 0x0388},
|
||||
{0x0301, 0x0397, 0x0389},
|
||||
{0x0301, 0x0399, 0x038A},
|
||||
{0x0301, 0x039F, 0x038C},
|
||||
{0x0301, 0x03A5, 0x038E},
|
||||
{0x0301, 0x03A9, 0x038F},
|
||||
{0x0301, 0x03B1, 0x03AC},
|
||||
{0x0301, 0x03B5, 0x03AD},
|
||||
{0x0301, 0x03B7, 0x03AE},
|
||||
{0x0301, 0x03B9, 0x03AF},
|
||||
{0x0301, 0x03BF, 0x03CC},
|
||||
{0x0301, 0x03C5, 0x03CD},
|
||||
{0x0301, 0x03C9, 0x03CE},
|
||||
{0x0000, 0x0000, 0x0000},
|
||||
};
|
||||
|
||||
const u16 kprLookupTable1252[] = {
|
||||
0x20AC, 0x0000, 0x201A, 0x0192, 0x201E, 0x2026, 0x2020, 0x2021,
|
||||
0x02C6, 0x2030, 0x0160, 0x2039, 0x0152, 0x0000, 0x017D, 0x0000,
|
||||
0x0000, 0x2018, 0x2019, 0x201C, 0x201D, 0x2022, 0x2013, 0x2014,
|
||||
0x02DC, 0x2122, 0x0161, 0x203A, 0x0153, 0x0000, 0x017E, 0x0178,
|
||||
};
|
||||
|
||||
const u16 kprLookupTable437[] = {
|
||||
0x00C7, 0x00FC, 0x00E9, 0x00E2, 0x00E4, 0x00E0, 0x00E5, 0x00E7,
|
||||
0x00EA, 0x00EB, 0x00E8, 0x00EF, 0x00EE, 0x00EC, 0x00C4, 0x00C5,
|
||||
0x00C9, 0x00E6, 0x00C6, 0x00F4, 0x00F6, 0x00F2, 0x00FB, 0x00F9,
|
||||
0x00FF, 0x00D6, 0x00DC, 0x00A2, 0x00A3, 0x00A5, 0x20A7, 0x0192,
|
||||
0x00E1, 0x00ED, 0x00F3, 0x00FA, 0x00F1, 0x00D1, 0x00AA, 0x00BA,
|
||||
0x00BF, 0x2310, 0x00AC, 0x00BD, 0x00BC, 0x00A1, 0x00AB, 0x00BB,
|
||||
0x2591, 0x2592, 0x2593, 0x2502, 0x2524, 0x2561, 0x2562, 0x2556,
|
||||
0x2555, 0x2563, 0x2551, 0x2557, 0x255D, 0x255C, 0x255B, 0x2510,
|
||||
0x2514, 0x2534, 0x252C, 0x251C, 0x2500, 0x253C, 0x255E, 0x255F,
|
||||
0x255A, 0x2554, 0x2569, 0x2566, 0x2560, 0x2550, 0x256C, 0x2567,
|
||||
0x2568, 0x2564, 0x2565, 0x2559, 0x2558, 0x2552, 0x2553, 0x256B,
|
||||
0x256A, 0x2518, 0x250C, 0x2588, 0x2584, 0x258C, 0x2590, 0x2580,
|
||||
0x03B1, 0x00DF, 0x0393, 0x03C0, 0x03A3, 0x03C3, 0x00B5, 0x03C4,
|
||||
0x03A6, 0x0398, 0x03A9, 0x03B4, 0x221E, 0x03C6, 0x03B5, 0x2229,
|
||||
0x2261, 0x00B1, 0x2265, 0x2264, 0x2320, 0x2321, 0x00F7, 0x2248,
|
||||
0x00B0, 0x2219, 0x00B7, 0x221A, 0x207F, 0x00B2, 0x25A0, 0x00A0,
|
||||
};
|
||||
|
||||
static void (*kprProcDeadKeysFP)(KPRQueue* queue);
|
||||
static void (*kprProcRomajiFP)(KPRQueue* queue);
|
||||
const char* __KPRVersion = "<< RVL_SDK - KPR \trelease build: Apr 20 2010 11:21:44 (0x4199_60831) >>";
|
||||
|
||||
void KPRProcessDeadKeys(KPRQueue* queue);
|
||||
BOOL KPRProcessAltKeypad(KPRQueue* queue, u16 character);
|
||||
|
||||
void KPRInitRegionUS(void) {
|
||||
kprProcDeadKeysFP = KPRProcessDeadKeys;
|
||||
}
|
||||
|
||||
void KPRInitQueue(KPRQueue* queue) {
|
||||
static u8 once;
|
||||
if (!once) {
|
||||
OSRegisterVersion(__KPRVersion);
|
||||
once = TRUE;
|
||||
}
|
||||
queue->mode = KPR_MODE_ALT_KEYPAD;
|
||||
queue->oCount = 0;
|
||||
queue->iCount = 0;
|
||||
queue->altVal = 0;
|
||||
}
|
||||
|
||||
void KPRClearQueue(KPRQueue* queue) {
|
||||
queue->oCount = 0;
|
||||
queue->iCount = 0;
|
||||
queue->altVal = 0;
|
||||
}
|
||||
|
||||
void KPRSetMode(KPRQueue* queue, KPRMode mode) {
|
||||
queue->mode = mode;
|
||||
queue->oCount = 0;
|
||||
queue->iCount = 0;
|
||||
queue->altVal = 0;
|
||||
}
|
||||
|
||||
u8 KPRPutChar(KPRQueue* queue, u16 character) {
|
||||
BOOL interrupts;
|
||||
if (queue->oCount + queue->iCount + 1 >= 5) {
|
||||
OSPanic("kpr_lib.c", 215, "KPRPutChar: Overflow");
|
||||
}
|
||||
interrupts = OSDisableInterrupts();
|
||||
if (!(queue->mode & KPR_MODE_ALT_KEYPAD) || !KPRProcessAltKeypad(queue, character)) {
|
||||
queue->text[queue->oCount + queue->iCount] = character;
|
||||
++queue->iCount;
|
||||
if (queue->mode & KPR_MODE_DEADKEY) {
|
||||
kprProcDeadKeysFP(queue);
|
||||
} else if ((queue->mode & KPR_MODE_JP_ROMAJI_KATAKANA) || (queue->mode & KPR_MODE_JP_ROMAJI_HIRAGANA)) {
|
||||
kprProcRomajiFP(queue);
|
||||
} else {
|
||||
queue->oCount = queue->iCount;
|
||||
queue->iCount = 0;
|
||||
}
|
||||
if (character == 0xFFFF) {
|
||||
--queue->oCount;
|
||||
}
|
||||
}
|
||||
OSRestoreInterrupts(interrupts);
|
||||
return queue->oCount;
|
||||
}
|
||||
|
||||
u16 KPRGetChar(KPRQueue* queue) {
|
||||
BOOL interrupts;
|
||||
u16 character;
|
||||
u16* source;
|
||||
u32 index;
|
||||
if (!queue->oCount) {
|
||||
return 0;
|
||||
}
|
||||
interrupts = OSDisableInterrupts();
|
||||
character = queue->text[0];
|
||||
source = &queue->text[1];
|
||||
for (index = 1; index < queue->iCount + queue->oCount; ++index) {
|
||||
source[-1] = *source;
|
||||
++source;
|
||||
}
|
||||
--queue->oCount;
|
||||
OSRestoreInterrupts(interrupts);
|
||||
return character;
|
||||
}
|
||||
|
||||
u8 KPRLookAhead(KPRQueue* queue, u16* destination, u32 capacity) {
|
||||
BOOL interrupts;
|
||||
u8 index;
|
||||
if (destination == NULL || capacity == 0) {
|
||||
return queue->iCount + queue->oCount;
|
||||
}
|
||||
interrupts = OSDisableInterrupts();
|
||||
for (index = 0; index < queue->iCount + queue->oCount && index < capacity; ++index) {
|
||||
destination[index] = queue->text[index];
|
||||
}
|
||||
if (index < capacity) {
|
||||
destination[index] = 0;
|
||||
}
|
||||
OSRestoreInterrupts(interrupts);
|
||||
return queue->iCount + queue->oCount;
|
||||
}
|
||||
|
||||
BOOL KPRProcessAltKeypad(KPRQueue* queue, u16 character) {
|
||||
if (queue->altVal != 0) {
|
||||
u32 accumulator = queue->altVal;
|
||||
u32 leadingZero = accumulator & 0x80000000;
|
||||
u32 value;
|
||||
accumulator &= 0x7FFFFFFF;
|
||||
queue->altVal = accumulator;
|
||||
if (character >= 0xF130 && character <= 0xF139) {
|
||||
if (accumulator > 0x6666666) {
|
||||
return TRUE;
|
||||
}
|
||||
queue->altVal = leadingZero | (character - 0xF130 + accumulator * 10);
|
||||
return TRUE;
|
||||
}
|
||||
value = queue->altVal;
|
||||
if (value >= 128 && value <= 255) {
|
||||
if (leadingZero) {
|
||||
if (value < 160) {
|
||||
value = kprLookupTable1252[value - 128];
|
||||
}
|
||||
} else {
|
||||
value = kprLookupTable437[value - 128];
|
||||
}
|
||||
} else if (value > 255) {
|
||||
u32 converted = 32;
|
||||
if (value <= 0x6666666) {
|
||||
converted = (u8)value;
|
||||
}
|
||||
value = converted;
|
||||
}
|
||||
{
|
||||
int index = queue->oCount + queue->iCount;
|
||||
u16* destination = &queue->text[index];
|
||||
for (; index > queue->oCount; --index, --destination) {
|
||||
*destination = destination[-1];
|
||||
}
|
||||
}
|
||||
queue->text[queue->oCount] = value;
|
||||
queue->altVal = 0;
|
||||
++queue->oCount;
|
||||
return character == 0;
|
||||
}
|
||||
if (character >= 0xF130 && character <= 0xF139) {
|
||||
if (character == 0xF130) {
|
||||
queue->altVal = 0x80000000;
|
||||
} else {
|
||||
queue->altVal = character - 0xF130;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
if (character == 0) {
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void KPRProcessDeadKeys(KPRQueue* queue) {
|
||||
int index;
|
||||
int firstFallback;
|
||||
int secondFallback;
|
||||
if (queue->iCount == 1) {
|
||||
for (index = 0; index < 107; ++index) {
|
||||
if (queue->text[queue->oCount] == kprDeadKeyMap[index].accent) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
++queue->oCount;
|
||||
queue->iCount = 0;
|
||||
return;
|
||||
}
|
||||
firstFallback = 0;
|
||||
secondFallback = 107;
|
||||
for (index = 0; index < 107; ++index) {
|
||||
u16 first = queue->text[queue->oCount];
|
||||
if (first == kprDeadKeyMap[index].accent && queue->text[queue->oCount + 1] == kprDeadKeyMap[index].base) {
|
||||
queue->text[queue->oCount] = kprDeadKeyMap[index].composed;
|
||||
queue->iCount = 0;
|
||||
++queue->oCount;
|
||||
return;
|
||||
}
|
||||
if (first == kprDeadKeyMap[index].accent && first == kprDeadKeyMap[index].base) {
|
||||
firstFallback = index;
|
||||
}
|
||||
if (queue->text[queue->oCount + 1] == kprDeadKeyMap[index].accent && queue->text[queue->oCount + 1] == kprDeadKeyMap[index].base) {
|
||||
secondFallback = index;
|
||||
}
|
||||
}
|
||||
queue->text[queue->oCount] = kprDeadKeyMap[firstFallback].composed;
|
||||
if (secondFallback < 107) {
|
||||
queue->text[queue->oCount + 1] = kprDeadKeyMap[secondFallback].composed;
|
||||
}
|
||||
queue->iCount = 0;
|
||||
queue->oCount += 2;
|
||||
return;
|
||||
}
|
||||
51
libs/RVL_SDK/src/nup/nup_mem.cpp
Normal file
51
libs/RVL_SDK/src/nup/nup_mem.cpp
Normal file
@@ -0,0 +1,51 @@
|
||||
#include <revolution/mem.h>
|
||||
|
||||
namespace nup {
|
||||
static MEMAllocator* __mem;
|
||||
|
||||
void* __nupMallocAlign(unsigned long size, unsigned long alignment) {
|
||||
if (__mem == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
MEMHeapHandle heap = (MEMHeapHandle)__mem->heap;
|
||||
if (heap->magic != 0x45585048) {
|
||||
return NULL;
|
||||
}
|
||||
return MEMAllocFromExpHeapEx(heap, size, alignment);
|
||||
}
|
||||
|
||||
void* __nupMalloc(unsigned long size) {
|
||||
if (__mem == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
MEMHeapHandle heap = (MEMHeapHandle)__mem->heap;
|
||||
if (heap->magic != 0x45585048) {
|
||||
return NULL;
|
||||
}
|
||||
return MEMAllocFromExpHeapEx(heap, size, 32);
|
||||
}
|
||||
|
||||
void __nupFree(void* block) {
|
||||
if (__mem != NULL) {
|
||||
MEMHeapHandle heap = (MEMHeapHandle)__mem->heap;
|
||||
if (heap->magic == 0x45585048 && block != NULL) {
|
||||
MEMFreeToExpHeap(heap, block);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int __nupRegisterAllocator(MEMAllocator* allocator) {
|
||||
int result = 0;
|
||||
if (allocator == NULL) {
|
||||
result = -5011;
|
||||
} else {
|
||||
if (((MEMHeapHandle)allocator->heap)->magic != 0x45585048) {
|
||||
result = -5011;
|
||||
}
|
||||
if (((MEMHeapHandle)allocator->heap)->magic == 0x45585048) {
|
||||
__mem = allocator;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
352
src/scene/setting/AOSSLink.c
Normal file
352
src/scene/setting/AOSSLink.c
Normal file
@@ -0,0 +1,352 @@
|
||||
#include <revolution/os.h>
|
||||
#include <revolution/ncd.h>
|
||||
#include <private/wd.h>
|
||||
#include <string.h>
|
||||
|
||||
s32 AOSSi_cancel_flag;
|
||||
static u8 ipAddress[4];
|
||||
static u8 ipNetmask[4];
|
||||
static u8 ipGateway[4];
|
||||
static u8 primaryDns[4];
|
||||
static u8 secondaryDns[4];
|
||||
static void* (*allocateMemory)(u32, s32);
|
||||
static void (*releaseMemory)(u32, void*, s32);
|
||||
static void (*statusCallback)(void);
|
||||
static NCDIfConfig AOSS_810BD4A8;
|
||||
static NCDIpConfig AOSS_810BD608;
|
||||
|
||||
struct AOSSRate {
|
||||
u16 mask;
|
||||
u8 value;
|
||||
u8 reserved;
|
||||
};
|
||||
static struct AOSSRate supportedRates[] = {
|
||||
{1, 2, 0}, {2, 4, 0}, {4, 11, 0}, {8, 12, 0},
|
||||
{16, 18, 0}, {32, 22, 0}, {64, 24, 0}, {128, 36, 0},
|
||||
{256, 48, 0}, {512, 72, 0}, {1024, 96, 0}, {2048, 108, 0}
|
||||
};
|
||||
struct AOSSAccessPoint {
|
||||
u32 ssidLength;
|
||||
u8 ssid[32];
|
||||
u32 channel;
|
||||
u32 signal;
|
||||
u32 privacy;
|
||||
u8 bssid[6];
|
||||
u16 capabilities;
|
||||
u32 rateCount;
|
||||
u8 rates[12];
|
||||
u32 beaconPeriod;
|
||||
u32 mode;
|
||||
};
|
||||
struct AOSSAccessPointList {
|
||||
u32 count;
|
||||
struct AOSSAccessPoint accessPoints[1];
|
||||
};
|
||||
struct AOSSConnection {
|
||||
u32 ssidLength;
|
||||
u8 ssid[32];
|
||||
u32 security;
|
||||
u32 keyLength;
|
||||
u8 key[64];
|
||||
};
|
||||
struct AOSSConnectionStatus {
|
||||
u32 connected;
|
||||
u32 ssidLength;
|
||||
u8 ssid[32];
|
||||
u32 channel;
|
||||
};
|
||||
|
||||
void AOSSi_Cancel(void) {
|
||||
AOSSi_cancel_flag = 1;
|
||||
}
|
||||
|
||||
void AOSS_813FD17C(OSAlarm* alarm, OSContext* context) {
|
||||
OSSendMessage((OSMessageQueue*)alarm->tag, NULL, 0);
|
||||
}
|
||||
|
||||
void AOSS_813FD18C(u32 milliseconds) {
|
||||
OSMessage storage;
|
||||
OSMessage message;
|
||||
OSMessageQueue queue;
|
||||
OSAlarm alarm;
|
||||
OSInitMessageQueue(&queue, &storage, 1);
|
||||
OSCreateAlarm(&alarm);
|
||||
OSSetAlarmTag(&alarm, (u32)&queue);
|
||||
OSSetAlarm(&alarm, (u32)(milliseconds * (OS_TIMER_CLOCK / 1000)), AOSS_813FD17C);
|
||||
OSReceiveMessage(&queue, &message, 1);
|
||||
}
|
||||
|
||||
void* AOSSi_Alloc(u32 size) {
|
||||
if (allocateMemory != NULL) {
|
||||
return allocateMemory(0, size);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void AOSSi_Free(void* block) {
|
||||
if (releaseMemory != NULL) {
|
||||
releaseMemory(0, block, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void AOSS_813FD25C(u8* destination, u32 address) {
|
||||
int index;
|
||||
for (index = 0; index < 4; ++index) {
|
||||
*destination++ = address >> ((3 - index) * 8);
|
||||
}
|
||||
}
|
||||
|
||||
int AOSSi_SetNCDIPAddr(u32 address, u32 netmask, u32 gateway, u32 dns1, u32 dns2) {
|
||||
AOSS_813FD25C(ipAddress, address);
|
||||
AOSS_813FD25C(ipNetmask, netmask);
|
||||
AOSS_813FD25C(ipGateway, gateway);
|
||||
AOSS_813FD25C(primaryDns, dns1);
|
||||
AOSS_813FD25C(secondaryDns, dns2);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int AOSSi_InitLocal(void* (*allocate)(u32, s32), void (*release)(u32, void*, s32)) {
|
||||
BOOL interrupts;
|
||||
if (allocate == NULL || release == NULL) {
|
||||
return -1;
|
||||
}
|
||||
interrupts = OSDisableInterrupts();
|
||||
allocateMemory = allocate;
|
||||
releaseMemory = release;
|
||||
AOSSi_cancel_flag = 0;
|
||||
OSRestoreInterrupts(interrupts);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int AOSSi_EndLocal(void) {
|
||||
BOOL interrupts = OSDisableInterrupts();
|
||||
allocateMemory = NULL;
|
||||
releaseMemory = NULL;
|
||||
OSRestoreInterrupts(interrupts);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int AOSSi_WLANGetBSSList(struct AOSSAccessPointList** output) {
|
||||
int result = -1;
|
||||
int startupRetries = 0;
|
||||
int scanRetries = 0;
|
||||
int cleanupRetries = 0;
|
||||
int unlockRetries = 0;
|
||||
int driver;
|
||||
u8* buffer;
|
||||
WD_Info info ATTRIBUTE_ALIGN(32);
|
||||
WDScanParam scan;
|
||||
u8 macAddress[6];
|
||||
if (allocateMemory == NULL || releaseMemory == NULL) {
|
||||
return -1;
|
||||
}
|
||||
driver = NCDLockWirelessDriver();
|
||||
if (driver <= 0) {
|
||||
return -1;
|
||||
}
|
||||
startup:
|
||||
if (WD_Startup(3) != 0) {
|
||||
if (startupRetries > 10) {
|
||||
goto unlock;
|
||||
}
|
||||
++startupRetries;
|
||||
AOSS_813FD18C(10);
|
||||
goto startup;
|
||||
}
|
||||
if (WD_GetInfo(&info) == 0) {
|
||||
memcpy(macAddress, info.MAC, 6);
|
||||
}
|
||||
buffer = AOSSi_Alloc(0x3200);
|
||||
if (buffer != NULL) {
|
||||
memset(buffer, 0, 0x3200);
|
||||
scan.channelBit = info.enableChannel;
|
||||
scan.maxChannelTime = 40;
|
||||
memset(scan.bssid, 255, 6);
|
||||
scan.type = 0;
|
||||
scan.ssidLength = 0;
|
||||
memset(scan.ssid, 0, 32);
|
||||
memset(scan.ssidMask, 255, 32);
|
||||
while (1) {
|
||||
int scanResult = WD_Scan(&scan, buffer, 0x3200);
|
||||
int count;
|
||||
struct AOSSAccessPointList* list;
|
||||
WDBssDesc* descriptor;
|
||||
int index;
|
||||
if (scanResult != 0 && scanResult != WD_INTERNAL_ERR_4) {
|
||||
break;
|
||||
}
|
||||
count = *(u16*)buffer;
|
||||
if (count != 0) {
|
||||
list = AOSSi_Alloc(sizeof(*list) + (count - 1) * sizeof(struct AOSSAccessPoint));
|
||||
if (list == NULL) {
|
||||
result = -1;
|
||||
break;
|
||||
}
|
||||
list->count = count;
|
||||
descriptor = (WDBssDesc*)&buffer[2];
|
||||
for (index = 0; index < count; ++index) {
|
||||
struct AOSSAccessPoint* accessPoint = &list->accessPoints[index];
|
||||
int rate;
|
||||
int rateCount = 0;
|
||||
accessPoint->ssidLength = descriptor->ssidLength;
|
||||
memcpy(accessPoint->ssid, descriptor->ssid, 32);
|
||||
accessPoint->channel = descriptor->channel;
|
||||
memcpy(accessPoint->bssid, descriptor->bssid, 6);
|
||||
for (rate = 0; rate < 12; ++rate) {
|
||||
if (descriptor->rateSet.support & supportedRates[rate].mask) {
|
||||
accessPoint->rates[rateCount] = supportedRates[rate].value;
|
||||
if (descriptor->rateSet.basic & supportedRates[rate].mask) {
|
||||
accessPoint->rates[rateCount] |= 128;
|
||||
}
|
||||
++rateCount;
|
||||
}
|
||||
}
|
||||
accessPoint->rateCount = rateCount;
|
||||
accessPoint->beaconPeriod = descriptor->beaconPeriod;
|
||||
if ((descriptor->capabilities & 3) == 1) {
|
||||
accessPoint->mode = 1;
|
||||
} else if ((descriptor->capabilities & 3) == 2) {
|
||||
accessPoint->mode = 2;
|
||||
} else {
|
||||
accessPoint->mode = 0;
|
||||
}
|
||||
descriptor = (WDBssDesc*)((u16*)descriptor + descriptor->length);
|
||||
}
|
||||
*output = list;
|
||||
result = 0;
|
||||
break;
|
||||
}
|
||||
if (AOSSi_cancel_flag == 1) {
|
||||
result = -1;
|
||||
break;
|
||||
}
|
||||
if (++scanRetries > 10) {
|
||||
list = AOSSi_Alloc(sizeof(*list));
|
||||
if (list == NULL) {
|
||||
result = -1;
|
||||
break;
|
||||
}
|
||||
list->count = 0;
|
||||
result = 0;
|
||||
*output = list;
|
||||
break;
|
||||
}
|
||||
AOSS_813FD18C(100);
|
||||
}
|
||||
AOSSi_Free(buffer);
|
||||
}
|
||||
cleanup:
|
||||
if (WD_Cleanup() != 0) {
|
||||
if (cleanupRetries > 10) {
|
||||
result = -1;
|
||||
goto unlock;
|
||||
}
|
||||
++cleanupRetries;
|
||||
AOSS_813FD18C(10);
|
||||
goto cleanup;
|
||||
}
|
||||
unlock:
|
||||
if (NCDUnlockWirelessDriver(driver) != 0) {
|
||||
if (unlockRetries > 10) {
|
||||
result = -1;
|
||||
return -1;
|
||||
}
|
||||
++unlockRetries;
|
||||
AOSS_813FD18C(10);
|
||||
goto unlock;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
int AOSSi_WLANConnect(struct AOSSConnection* connection, struct AOSSConnectionStatus* status) {
|
||||
int retries = 0;
|
||||
int result = 0;
|
||||
WD_Info info ATTRIBUTE_ALIGN(32);
|
||||
NCDIfConfig* interfaceConfig = &AOSS_810BD4A8;
|
||||
NCDIpConfig* ipConfig;
|
||||
memset(interfaceConfig, 0, sizeof(*interfaceConfig));
|
||||
interfaceConfig->selectedMedia = 1;
|
||||
interfaceConfig->netif.wireless.rateset = 0;
|
||||
interfaceConfig->netif.wireless.configMethod = 0;
|
||||
if (connection->keyLength == 0) {
|
||||
interfaceConfig->netif.wireless.config.manual.privacy.mode = 0;
|
||||
}
|
||||
if (connection->keyLength == 5) {
|
||||
interfaceConfig->netif.wireless.config.manual.privacy.mode = 1;
|
||||
interfaceConfig->netif.wireless.config.manual.privacy.wep40.keyId = 0;
|
||||
memcpy(interfaceConfig->netif.wireless.config.manual.privacy.wep40.key,
|
||||
connection->key, connection->keyLength);
|
||||
} else if (connection->keyLength == 13) {
|
||||
interfaceConfig->netif.wireless.config.manual.privacy.mode = 2;
|
||||
interfaceConfig->netif.wireless.config.manual.privacy.wep104.keyId = 0;
|
||||
memcpy(interfaceConfig->netif.wireless.config.manual.privacy.wep104.key,
|
||||
connection->key, connection->keyLength);
|
||||
} else if (connection->keyLength == 16) {
|
||||
return -1;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
interfaceConfig->netif.wireless.config.manual.ssidLength = (u8)connection->ssidLength;
|
||||
memcpy(interfaceConfig->netif.wireless.config.manual.ssid, connection->ssid, connection->ssidLength);
|
||||
ipConfig = &AOSS_810BD608;
|
||||
memset(ipConfig, 0, sizeof(*ipConfig));
|
||||
ipConfig->adjust.maxTransferUnit = 1300;
|
||||
ipConfig->adjust.tcpRetransTimeout = 100;
|
||||
ipConfig->adjust.dhcpRetransCount = 4;
|
||||
ipConfig->useDhcp = 0;
|
||||
ipConfig->useProxy = 0;
|
||||
memcpy(ipConfig->ip.addr, ipAddress, 4);
|
||||
memcpy(ipConfig->ip.netmask, ipNetmask, 4);
|
||||
memcpy(ipConfig->ip.gateway, ipGateway, 4);
|
||||
memcpy(ipConfig->ip.dns1, primaryDns, 4);
|
||||
memcpy(ipConfig->ip.dns2, secondaryDns, 4);
|
||||
if (NCDSetIpConfig(ipConfig) != 0) {
|
||||
result = -1;
|
||||
}
|
||||
if (result == 0 && NCDSetIfConfig(&AOSS_810BD4A8) != 0) {
|
||||
result = -1;
|
||||
}
|
||||
if (result == 0) {
|
||||
while (!NCDIsInterfaceDecided()) {
|
||||
if (AOSSi_cancel_flag == 1) {
|
||||
result = -1;
|
||||
break;
|
||||
}
|
||||
if (retries > 600) {
|
||||
result = -1;
|
||||
break;
|
||||
}
|
||||
++retries;
|
||||
AOSS_813FD18C(10);
|
||||
}
|
||||
}
|
||||
if (result == 0) {
|
||||
status->connected = 1;
|
||||
if (WD_GetInfo(&info) == 0) {
|
||||
status->channel = info.channel;
|
||||
}
|
||||
status->ssidLength = interfaceConfig->netif.wireless.config.manual.ssidLength;
|
||||
memcpy(status->ssid, interfaceConfig->netif.wireless.config.manual.ssid,
|
||||
interfaceConfig->netif.wireless.config.manual.ssidLength);
|
||||
} else {
|
||||
status->connected = 0;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void AOSSi_Sleep(u32 milliseconds) {
|
||||
AOSS_813FD18C(milliseconds);
|
||||
}
|
||||
|
||||
int AOSSi_Status(void) {
|
||||
if (statusCallback != NULL) {
|
||||
statusCallback();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void AOSS_SetCallback(void (*callback)(void)) {
|
||||
BOOL interrupts = OSDisableInterrupts();
|
||||
statusCallback = callback;
|
||||
OSRestoreInterrupts(interrupts);
|
||||
}
|
||||
284
src/scene/setting/iplRakuRakuThread.cpp
Normal file
284
src/scene/setting/iplRakuRakuThread.cpp
Normal file
@@ -0,0 +1,284 @@
|
||||
#include "utility/iplThread.h"
|
||||
#include <egg/core.h>
|
||||
#include <revolution/mem.h>
|
||||
#include <revolution/ncd.h>
|
||||
#include <revolution/soex.h>
|
||||
#include <string.h>
|
||||
|
||||
struct RakuProgress {
|
||||
s32 state;
|
||||
int remainingTime;
|
||||
int result;
|
||||
};
|
||||
struct RakuConfiguration {
|
||||
char ssid[32];
|
||||
s32 security;
|
||||
u32 keyId;
|
||||
char wepKeys[4][32];
|
||||
char passphrase[64];
|
||||
};
|
||||
extern "C" {
|
||||
int ATERMi_ApConfigGetVersion();
|
||||
int ATERMi_ApConfigGetState(RakuProgress* progress);
|
||||
int ATERMi_ApConfigGetResult(RakuConfiguration* configuration);
|
||||
int ATERMi_ApConfigStart(int priority, u32 scanLimit, void (*callback)(RakuProgress*),
|
||||
void* (*allocate)(u32), void (*release)(void*), u32 stackSize);
|
||||
int ATERMi_ApConfigEnd();
|
||||
}
|
||||
|
||||
namespace ipl {
|
||||
namespace scene {
|
||||
extern "C" MEMAllocator RakuRakuThread_810BDDD0;
|
||||
MEMAllocator RakuRakuThread_810BDDD0;
|
||||
struct RakuStatus {
|
||||
RakuProgress progress;
|
||||
RakuConfiguration configuration;
|
||||
};
|
||||
extern "C" RakuStatus RakuRakuThread_810BDDE0;
|
||||
RakuStatus RakuRakuThread_810BDDE0;
|
||||
extern "C" OSMessageQueue RakuRakuThread_810BDED4;
|
||||
OSMessageQueue RakuRakuThread_810BDED4;
|
||||
static OSTime startTime;
|
||||
static bool active;
|
||||
static OSMessage messageSlot;
|
||||
static int displayState = 1;
|
||||
|
||||
extern "C" {
|
||||
static void* RakuRakuThread_813FDEF0(u32, s32 size);
|
||||
static void RakuRakuThread_813FDEFC(u32, void* block, s32);
|
||||
static void* RakuRakuThread_813FDF08(u32 size);
|
||||
static void RakuRakuThread_813FDF18(void* block);
|
||||
}
|
||||
|
||||
struct RakuStack {
|
||||
u32 storage[4080];
|
||||
u32 sentinel;
|
||||
};
|
||||
class RakuRakuThread : public utility::ut_thread {
|
||||
public:
|
||||
RakuRakuThread(EGG::Heap* heap);
|
||||
virtual ~RakuRakuThread();
|
||||
virtual void* Run();
|
||||
virtual void unk_0x2C() = 0;
|
||||
void RakuRakuThread_813FDA04();
|
||||
static void progressCallback(RakuProgress* progress);
|
||||
void destroy();
|
||||
int start();
|
||||
int getState();
|
||||
int cancel();
|
||||
int finish(NCDApConfig* config, int* result);
|
||||
void printInfo() NO_INLINE;
|
||||
private:
|
||||
int mReserved;
|
||||
int mFinished;
|
||||
int mRunning;
|
||||
int mPriority;
|
||||
void* mHeapBuffer;
|
||||
RakuStack* mStack;
|
||||
MEMHeapHandle mHeap;
|
||||
};
|
||||
|
||||
void RakuRakuThread::RakuRakuThread_813FDA04() {
|
||||
BOOL interrupts = OSDisableInterrupts();
|
||||
RakuRakuThread_810BDDE0.progress = *(RakuProgress*)this;
|
||||
startTime = OSGetTime();
|
||||
OSRestoreInterrupts(interrupts);
|
||||
}
|
||||
|
||||
void RakuRakuThread::progressCallback(RakuProgress* progress) {
|
||||
((RakuRakuThread*)progress)->RakuRakuThread_813FDA04();
|
||||
}
|
||||
|
||||
RakuRakuThread::RakuRakuThread(EGG::Heap* heap) : utility::ut_thread() {
|
||||
u32 version = ATERMi_ApConfigGetVersion();
|
||||
if (((version >> 12) & 15) * 10 + ((version >> 8) & 15) != 1) {
|
||||
mHeapBuffer = NULL;
|
||||
} else {
|
||||
mHeapBuffer = heap->alloc(0x40000, 32);
|
||||
mStack = (RakuStack*)heap->alloc(4096, 32);
|
||||
}
|
||||
mHeap = NULL;
|
||||
active = false;
|
||||
mFinished = 0;
|
||||
mRunning = 0;
|
||||
OSInitMessageQueue(&RakuRakuThread_810BDED4, &messageSlot, 1);
|
||||
}
|
||||
|
||||
RakuRakuThread::~RakuRakuThread() {
|
||||
if (mRunning) {
|
||||
OSJamMessage(&RakuRakuThread_810BDED4, (OSMessage)2, 1);
|
||||
WaitForThreadExit();
|
||||
}
|
||||
destroy();
|
||||
}
|
||||
|
||||
void RakuRakuThread::destroy() {
|
||||
if (active) {
|
||||
OSSendMessage(&RakuRakuThread_810BDED4, (OSMessage)1, 0);
|
||||
u32 start = OSGetTick();
|
||||
while ((u32)(OSGetTick() - start) / (OS_TIMER_CLOCK / 1000) < 2000) {
|
||||
RakuProgress progress;
|
||||
if (ATERMi_ApConfigGetState(&progress) == 1 && progress.state == 7) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
SOFinish();
|
||||
active = false;
|
||||
}
|
||||
if (mHeap != NULL) {
|
||||
MEMDestroyExpHeap(mHeap);
|
||||
memset(&RakuRakuThread_810BDDD0, 0, sizeof(MEMAllocator));
|
||||
mHeap = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
int RakuRakuThread::start() {
|
||||
if (active || mHeapBuffer == NULL) {
|
||||
return 0;
|
||||
}
|
||||
BOOL interrupts = OSDisableInterrupts();
|
||||
startTime = OSGetTime();
|
||||
mHeap = MEMCreateExpHeapEx(mHeapBuffer, 0x40000, 2);
|
||||
MEMInitAllocatorForExpHeap(&RakuRakuThread_810BDDD0, mHeap, 32);
|
||||
mPriority = OSGetThreadPriority(OSGetCurrentThread()) - 1;
|
||||
active = true;
|
||||
mFinished = 0;
|
||||
memset(&RakuRakuThread_810BDDE0.configuration, 0, sizeof(RakuConfiguration));
|
||||
memset(&RakuRakuThread_810BDDE0.progress, 0, sizeof(RakuProgress));
|
||||
SOLibraryConfig socketConfig;
|
||||
socketConfig.alloc = RakuRakuThread_813FDEF0;
|
||||
socketConfig.free = RakuRakuThread_813FDEFC;
|
||||
SOInit(&socketConfig);
|
||||
ATERMi_ApConfigStart(mPriority, 200,
|
||||
progressCallback,
|
||||
RakuRakuThread_813FDF08, RakuRakuThread_813FDF18, 4096);
|
||||
if (!mRunning) {
|
||||
mRunning = 1;
|
||||
memset(mStack, 0, 4);
|
||||
Create(mStack, 4096, mPriority - 1, true);
|
||||
OSReport("RakuRakuThread (for End function) start with prio(%d) \n", mPriority);
|
||||
}
|
||||
OSRestoreInterrupts(interrupts);
|
||||
return 1;
|
||||
}
|
||||
|
||||
void* RakuRakuThread::Run() {
|
||||
OSMessage message;
|
||||
while (true) {
|
||||
while (OSReceiveMessage(&RakuRakuThread_810BDED4, &message, 0)) {
|
||||
if ((s32)message == 2) {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
OSReceiveMessage(&RakuRakuThread_810BDED4, &message, 1);
|
||||
if ((s32)message == 2) {
|
||||
break;
|
||||
}
|
||||
mStack->sentinel = 0x97654321;
|
||||
ATERMi_ApConfigEnd();
|
||||
mFinished = 1;
|
||||
if (!mRunning) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
static void* RakuRakuThread_813FDEF0(u32, s32 size) {
|
||||
return MEMAllocFromAllocator(&RakuRakuThread_810BDDD0, size);
|
||||
}
|
||||
static void RakuRakuThread_813FDEFC(u32, void* block, s32) {
|
||||
MEMFreeToAllocator(&RakuRakuThread_810BDDD0, block);
|
||||
}
|
||||
static void* RakuRakuThread_813FDF08(u32 size) {
|
||||
return MEMAllocFromAllocator(&RakuRakuThread_810BDDD0, size);
|
||||
}
|
||||
static void RakuRakuThread_813FDF18(void* block) {
|
||||
MEMFreeToAllocator(&RakuRakuThread_810BDDD0, block);
|
||||
}
|
||||
|
||||
int RakuRakuThread::getState() {
|
||||
if (!active) {
|
||||
return 0;
|
||||
}
|
||||
BOOL interrupts = OSDisableInterrupts();
|
||||
switch (RakuRakuThread_810BDDE0.progress.state) {
|
||||
case 1: displayState = 1; break;
|
||||
case 2: displayState = 2; break;
|
||||
case 3: displayState = 2; break;
|
||||
case 4: displayState = 4; break;
|
||||
case 5: displayState = 5; break;
|
||||
case 6: displayState = 6; break;
|
||||
case 7: displayState = 7; break;
|
||||
default: displayState = 1; break;
|
||||
}
|
||||
if (displayState != 6 && displayState != 7 &&
|
||||
((u32)OSGetTime() - (u32)startTime) / (OS_TIMER_CLOCK / 1000) >= 90000) {
|
||||
OSSendMessage(&RakuRakuThread_810BDED4, (OSMessage)1, 0);
|
||||
}
|
||||
OSRestoreInterrupts(interrupts);
|
||||
return displayState;
|
||||
}
|
||||
|
||||
int RakuRakuThread::cancel() {
|
||||
return OSSendMessage(&RakuRakuThread_810BDED4, (OSMessage)1, 0);
|
||||
}
|
||||
|
||||
int RakuRakuThread::finish(NCDApConfig* config, int* result) {
|
||||
if (!active) {
|
||||
if (result != NULL) {
|
||||
*result = -99;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
s32 state = RakuRakuThread_810BDDE0.progress.state;
|
||||
if ((u32)(state - 6) > 1) {
|
||||
return 0;
|
||||
}
|
||||
if (!mFinished) {
|
||||
if (state == 6) {
|
||||
ATERMi_ApConfigGetResult(&RakuRakuThread_810BDDE0.configuration);
|
||||
printInfo();
|
||||
}
|
||||
OSSendMessage(&RakuRakuThread_810BDED4, (OSMessage)1, 0);
|
||||
return 0;
|
||||
}
|
||||
SOFinish();
|
||||
active = false;
|
||||
destroy();
|
||||
if (config != NULL) {
|
||||
RakuConfiguration* settings = &RakuRakuThread_810BDDE0.configuration;
|
||||
memcpy(config->ssid, settings->ssid, 32);
|
||||
config->ssidLength = strlen(settings->ssid);
|
||||
if (settings->security == 1) {
|
||||
config->privacy.mode = 1;
|
||||
config->privacy.wep40.keyId = settings->keyId;
|
||||
for (int index = 0; index < 4; ++index) {
|
||||
memcpy(config->privacy.wep40.key[index], settings->wepKeys[index], 5);
|
||||
}
|
||||
} else if (settings->security == 2) {
|
||||
config->privacy.mode = 2;
|
||||
config->privacy.wep104.keyId = settings->keyId;
|
||||
for (int index = 0; index < 4; ++index) {
|
||||
memcpy(config->privacy.wep104.key[index], settings->wepKeys[index], 13);
|
||||
}
|
||||
} else if (settings->security == 4) {
|
||||
config->privacy.mode = 4;
|
||||
memcpy(config->privacy.tkip.key, settings->passphrase, 64);
|
||||
config->privacy.tkip.keyLen = strlen(settings->passphrase);
|
||||
} else if (settings->security == 5) {
|
||||
config->privacy.mode = 6;
|
||||
memcpy(config->privacy.aes.key, settings->passphrase, 64);
|
||||
config->privacy.aes.keyLen = strlen(settings->passphrase);
|
||||
}
|
||||
}
|
||||
if (result != NULL) {
|
||||
*result = RakuRakuThread_810BDDE0.progress.result;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
void RakuRakuThread::printInfo() {
|
||||
}
|
||||
}
|
||||
}
|
||||
85
src/scene/setting/iplSensitivity.cpp
Normal file
85
src/scene/setting/iplSensitivity.cpp
Normal file
@@ -0,0 +1,85 @@
|
||||
#include "system/iplSystem.h"
|
||||
#include "system/iplNand.h"
|
||||
#include "utility/iplGraphics.h"
|
||||
#include <revolution/tpl.h>
|
||||
|
||||
extern "C" {
|
||||
WPADStatus* KPADGetWPADRingBuffer(s32 channel);
|
||||
WPADFSStatus* KPADGetWPADFSRingBuffer(s32 channel);
|
||||
WPADCLStatus* KPADGetWPADCLRingBuffer(s32 channel);
|
||||
}
|
||||
|
||||
namespace ipl {
|
||||
class SensitivityDrawing {
|
||||
public:
|
||||
static void draw(nand::File* texture);
|
||||
};
|
||||
|
||||
void SensitivityDrawing::draw(nand::File* texture) {
|
||||
GXRenderModeObj renderMode = *System::getRenderModeObj();
|
||||
nw4r::ut::Rect projection;
|
||||
System::getProjectionRect(&projection);
|
||||
GXColor background = {96, 96, 96, 192};
|
||||
u32 scissorX, scissorY, scissorWidth, scissorHeight;
|
||||
GXGetScissor(&scissorX, &scissorY, &scissorWidth, &scissorHeight);
|
||||
f32 projectionWidth = projection.GetWidth();
|
||||
f32 projectionHeight = projection.GetHeight();
|
||||
f32 halfWidth = 0.5f * projectionWidth;
|
||||
f32 scaleX = renderMode.fbWidth / projectionWidth;
|
||||
f32 scaleY = renderMode.efbHeight / projectionHeight;
|
||||
f32 halfHeight = 0.5f * projectionHeight;
|
||||
utility::Graphics::setDefaultOrtho(0);
|
||||
projectionHeight = projection.GetHeight();
|
||||
projectionWidth = projection.GetWidth();
|
||||
GXSetScissor(scaleX * (0.5f * projection.left + halfWidth),
|
||||
scaleY * (-45.0f + (0.5f * projection.top + halfHeight)),
|
||||
scaleX * (0.5f * projectionWidth),
|
||||
scaleY * (0.5f * projectionHeight));
|
||||
utility::Graphics::drawPolygon(projection, background);
|
||||
controller::Interface* controller = System::getYoungController();
|
||||
if (controller != NULL && controller->getKPADStatus() != NULL) {
|
||||
GXTexObj image;
|
||||
TPLGetGXTexObjFromPalette((TPLPalette*)texture->getBuffer(), &image, 1);
|
||||
GXInitTexObjWrapMode(&image, GX_MIRROR, GX_MIRROR);
|
||||
f32 width = projection.GetWidth();
|
||||
f32 height = projection.GetHeight();
|
||||
f32 horizontalScale = (0.5f * width) / 1024.0f;
|
||||
f32 verticalScale = (0.5f * height) / 768.0f;
|
||||
int sample = WPADGetLatestIndexInBuf(controller->getChannel());
|
||||
DPDObject* object;
|
||||
DPDObject* first;
|
||||
switch (controller->getType()) {
|
||||
case 0: {
|
||||
WPADStatus* status = KPADGetWPADRingBuffer(controller->getChannel()) + sample;
|
||||
object = &status->obj[3];
|
||||
first = &status->obj[0];
|
||||
break;
|
||||
}
|
||||
case 1: {
|
||||
WPADFSStatus* status = KPADGetWPADFSRingBuffer(controller->getChannel()) + sample;
|
||||
object = &status->obj[3];
|
||||
first = &status->obj[0];
|
||||
break;
|
||||
}
|
||||
case 2: {
|
||||
WPADCLStatus* status = KPADGetWPADCLRingBuffer(controller->getChannel()) + sample;
|
||||
object = &status->obj[3];
|
||||
first = &status->obj[0];
|
||||
break;
|
||||
}
|
||||
}
|
||||
do {
|
||||
if (object->size != 0) {
|
||||
f32 radius = 0.15f * (object->size + 25);
|
||||
f32 x = (object->x - 512) * horizontalScale;
|
||||
f32 y = (object->y - 384) * verticalScale;
|
||||
GXColor foreground = {255, 255, 255, 255};
|
||||
nw4r::ut::Rect rectangle(x - radius, -y + radius - -45.0f,
|
||||
x + radius, -y - radius - -45.0f);
|
||||
utility::Graphics::drawTexture(rectangle, image, foreground, 2, utility::Graphics::ORI_NONE);
|
||||
}
|
||||
} while (--object >= first);
|
||||
}
|
||||
GXSetScissor(scissorX, scissorY, scissorWidth, scissorHeight);
|
||||
}
|
||||
}
|
||||
156
src/scene/setting/iplUSBAP.cpp
Normal file
156
src/scene/setting/iplUSBAP.cpp
Normal file
@@ -0,0 +1,156 @@
|
||||
#include <revolution/os.h>
|
||||
#include <revolution/wd.h>
|
||||
#include <string.h>
|
||||
|
||||
static OSThread usbapThread;
|
||||
static u8 usbapStack[4096];
|
||||
static OSMessageQueue usbapMessageQ;
|
||||
static wchar_t usbapNickname[11];
|
||||
static OSMessage registrationMessage;
|
||||
static void (*registrationCallback)(int);
|
||||
static s32 registrationMode;
|
||||
static u16 enabledChannels;
|
||||
static u8* scanBuffer;
|
||||
struct RegisteredAccessPoints {
|
||||
u8 count;
|
||||
u8 addresses[20][6];
|
||||
};
|
||||
static RegisteredAccessPoints* registeredAccessPoints;
|
||||
|
||||
extern "C" {
|
||||
static void* DoRegistration(void*);
|
||||
}
|
||||
|
||||
extern "C" BOOL USBAPStartRegistration(void*, void*, u32 priority, u32 mode,
|
||||
void* nickname, void (*callback)(int),
|
||||
u16* buffer, u8* accessPoints) {
|
||||
BOOL interrupts = OSDisableInterrupts();
|
||||
scanBuffer = (u8*)buffer;
|
||||
registeredAccessPoints = (RegisteredAccessPoints*)accessPoints;
|
||||
if (usbapThread.state != 0 && !OSIsThreadTerminated(&usbapThread)) {
|
||||
OSRestoreInterrupts(interrupts);
|
||||
return FALSE;
|
||||
}
|
||||
if (priority > 31 || nickname == NULL || callback == NULL) {
|
||||
OSRestoreInterrupts(interrupts);
|
||||
return FALSE;
|
||||
}
|
||||
registrationMode = mode;
|
||||
registrationCallback = callback;
|
||||
memcpy(usbapNickname, nickname, 20);
|
||||
OSInitMessageQueue(&usbapMessageQ, ®istrationMessage, 1);
|
||||
if (OSCreateThread(&usbapThread, DoRegistration, NULL, usbapStack + sizeof(usbapStack),
|
||||
sizeof(usbapStack), priority, OS_THREAD_ATTR_DETACH) == TRUE) {
|
||||
OSRestoreInterrupts(interrupts);
|
||||
while (OSResumeThread(&usbapThread) > 1) {
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
OSRestoreInterrupts(interrupts);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
extern "C" BOOL USBAPCancelRegistration() {
|
||||
return OSSendMessage(&usbapMessageQ, NULL, 0);
|
||||
}
|
||||
|
||||
extern "C" BOOL USBAPIsThreadTerminated() {
|
||||
return OSIsThreadTerminated(&usbapThread);
|
||||
}
|
||||
|
||||
struct USBAPSSID {
|
||||
u8 prefix[8];
|
||||
u8 reserved;
|
||||
u8 flags;
|
||||
u8 version;
|
||||
u8 status;
|
||||
wchar_t nickname[10];
|
||||
};
|
||||
|
||||
struct USBAPScan {
|
||||
u16 channelBit;
|
||||
u16 maxChannelTime;
|
||||
u8 bssid[6];
|
||||
u16 type;
|
||||
u16 ssidLength;
|
||||
USBAPSSID ssid;
|
||||
u8 ssidMask[32];
|
||||
};
|
||||
|
||||
static void* DoRegistration(void*) {
|
||||
BOOL success;
|
||||
int result;
|
||||
if (WDCheckEnableChannel(&enabledChannels) != 0) {
|
||||
success = FALSE;
|
||||
if (registrationCallback != NULL) {
|
||||
registrationCallback(FALSE);
|
||||
}
|
||||
goto complete;
|
||||
}
|
||||
do {
|
||||
OSMessage message;
|
||||
OSYieldThread();
|
||||
if (OSReceiveMessage(&usbapMessageQ, &message, 0) == TRUE) {
|
||||
success = FALSE;
|
||||
if (registrationCallback != NULL) {
|
||||
registrationCallback(FALSE);
|
||||
}
|
||||
goto complete;
|
||||
}
|
||||
USBAPScan scan;
|
||||
scan.channelBit = enabledChannels;
|
||||
scan.maxChannelTime = 100;
|
||||
result = 0;
|
||||
memset(scan.bssid, 255, 6);
|
||||
scan.type = 0;
|
||||
scan.ssidLength = 32;
|
||||
memcpy(scan.ssid.prefix, "NWCUSBAP", 8);
|
||||
scan.ssid.reserved = 0;
|
||||
scan.ssid.flags = 1;
|
||||
if (registrationMode == 1) {
|
||||
scan.ssid.flags |= 2;
|
||||
}
|
||||
scan.ssid.version = 1;
|
||||
scan.ssid.status = 0;
|
||||
memcpy(scan.ssid.nickname, usbapNickname, 20);
|
||||
memset(scan.ssidMask, 0, 8);
|
||||
memset(&scan.ssidMask[8], 255, 24);
|
||||
if (WDScanOnce(scanBuffer, 2048, (WDScanParam*)&scan) == 0) {
|
||||
u16 count = *(u16*)scanBuffer;
|
||||
WDBssDesc* accessPoint = (WDBssDesc*)&scanBuffer[2];
|
||||
int found = 0;
|
||||
int failed = 0;
|
||||
for (int index = 0; index < count; ++index) {
|
||||
if (accessPoint->ssidLength == 32 && strncmp((char*)accessPoint->ssid, "NWCUSBAP", 8) == 0) {
|
||||
RegisteredAccessPoints* registered = registeredAccessPoints;
|
||||
int address;
|
||||
for (address = 0; address < 20; ++address) {
|
||||
if (memcmp(accessPoint->bssid, registered->addresses[address], 6) == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (address == 20) {
|
||||
USBAPSSID* response = (USBAPSSID*)accessPoint->ssid;
|
||||
if (response->flags == 1) {
|
||||
memcpy(registeredAccessPoints->addresses[registeredAccessPoints->count], accessPoint->bssid, 6);
|
||||
found = 1;
|
||||
++registeredAccessPoints->count;
|
||||
} else if (response->flags == 0) {
|
||||
failed = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
accessPoint = (WDBssDesc*)((u16*)accessPoint + accessPoint->length);
|
||||
}
|
||||
if (found) {
|
||||
result = (failed != 0) + 1;
|
||||
}
|
||||
}
|
||||
} while (result == 0);
|
||||
success = result == 1;
|
||||
if (registrationCallback != NULL) {
|
||||
registrationCallback(success);
|
||||
}
|
||||
complete:
|
||||
return (void*)success;
|
||||
}
|
||||
67
src/scene/setting/iplUSBAPThread.cpp
Normal file
67
src/scene/setting/iplUSBAPThread.cpp
Normal file
@@ -0,0 +1,67 @@
|
||||
#include <revolution/os.h>
|
||||
#include <string.h>
|
||||
#include "utility/iplCharacterCode.h"
|
||||
|
||||
extern "C" {
|
||||
BOOL USBAPStartRegistration(void*, void*, u32, u32, void*, void (*)(int), u16*, u8*);
|
||||
BOOL USBAPCancelRegistration();
|
||||
BOOL USBAPIsThreadTerminated();
|
||||
}
|
||||
|
||||
namespace ipl {
|
||||
namespace scene {
|
||||
|
||||
class USBAPThread {
|
||||
public:
|
||||
USBAPThread();
|
||||
void Init(unsigned short* buffer, unsigned char* accessPoints);
|
||||
BOOL cancel();
|
||||
BOOL is();
|
||||
void setData(const wchar_t* nickname, unsigned char* result);
|
||||
void callback();
|
||||
private:
|
||||
wchar_t mNickname[10];
|
||||
};
|
||||
|
||||
static u8* registrationResult;
|
||||
|
||||
USBAPThread::USBAPThread() {
|
||||
}
|
||||
|
||||
void USBAPRegisterCallback(int result) {
|
||||
if (result == 1) {
|
||||
*registrationResult = 1;
|
||||
OSReport("Registration completed !\n");
|
||||
} else {
|
||||
*registrationResult = 2;
|
||||
OSReport("Registration failed...\n");
|
||||
}
|
||||
}
|
||||
|
||||
void USBAPThread::Init(unsigned short* buffer, unsigned char* accessPoints) {
|
||||
int priority = OSGetThreadPriority(OSGetCurrentThread()) + 1;
|
||||
if (USBAPStartRegistration(NULL, NULL, priority,
|
||||
0, this, USBAPRegisterCallback, buffer, accessPoints) == 1) {
|
||||
OSReport("Registration started\n");
|
||||
}
|
||||
}
|
||||
|
||||
BOOL USBAPThread::cancel() {
|
||||
return USBAPCancelRegistration();
|
||||
}
|
||||
|
||||
BOOL USBAPThread::is() {
|
||||
return USBAPIsThreadTerminated();
|
||||
}
|
||||
|
||||
void USBAPThread::setData(const wchar_t* nickname, unsigned char* result) {
|
||||
registrationResult = result;
|
||||
memcpy(mNickname, nickname, 20);
|
||||
utility::CharacterCode::changeEndian(mNickname, 10);
|
||||
}
|
||||
|
||||
void USBAPThread::callback() {
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
88
tools/decomp-assist/sol-low-batch.attempts.md
Normal file
88
tools/decomp-assist/sol-low-batch.attempts.md
Normal file
@@ -0,0 +1,88 @@
|
||||
# Setting and SDK batch
|
||||
|
||||
All units remain NonMatching. No shared header or configure.py changes.
|
||||
|
||||
## USBAPThread::Init
|
||||
|
||||
1. Nested current-thread priority expression: 32/32 instructions, two li instructions swapped.
|
||||
2. Separate priority temporary: unchanged.
|
||||
3. Pointer, integer, and Boolean argument declarations: unchanged. Retained pointer parameters and the priority temporary.
|
||||
|
||||
## USBAP::DoRegistration
|
||||
|
||||
1. WDScanParam plus a local typed SSID pointer: 160/161 instructions and larger frame.
|
||||
2. A typed scan structure and corrected response flags: 161/161, 48 differences.
|
||||
3. Shared function exit for cancellation and initial failure: 161/161, 35 differences, mostly register assignments.
|
||||
|
||||
## SensitivityDrawing::draw
|
||||
|
||||
1. Independent GetWidth/GetHeight expressions: 278/278, 39 differences.
|
||||
2. Width/height temporaries: 15 differences.
|
||||
3. Explicit dimensions in the texture section: 11 differences.
|
||||
4. Direct GXSetScissor arguments: removed the integer register permutation.
|
||||
5. Four dimension and scale declaration variants: best seven differences.
|
||||
6. Horizontal scale computed before vertical scale: one operand-order difference.
|
||||
7. Division by 1024 rather than multiplication by its reciprocal: zero instruction differences. Corrected the vertical offset constant to -45 after examining the target constant bytes. Code is exact; the constant pool still differs.
|
||||
|
||||
## RakuRakuThread
|
||||
|
||||
Constructor, destructor, callback, destroy, Run, getState, four allocator callbacks, cancel, and printInfo reached exact instructions in the separate-global implementation. The additional progressCallback adapts the recovered member callback to the ATERM callback signature. That recovered signature needs parent review.
|
||||
|
||||
### start
|
||||
|
||||
1. Separate allocator, status, and queue globals: 97/96 instructions.
|
||||
2. A domain context containing those fields: 96/96, 30 differences; changed previously exact functions through relocation offsets.
|
||||
3. An explicit context pointer before the active check: 96/96, one mr versus addi difference, but worsened other owned functions. Restored the separate globals to preserve 12 exact functions.
|
||||
|
||||
### finish
|
||||
|
||||
1. Separate globals and early state rejection: 136/133 instructions.
|
||||
2. Signed state and unsigned state-range check: removed branch differences.
|
||||
3. Domain context and nested success branch: 133/133, 115 differences.
|
||||
4. Context pointer, out-of-line printInfo and delayed configuration pointer: 132/133, allocation and address-generation differences. Restored separate globals and retained the signed security field and out-of-line printInfo.
|
||||
|
||||
## AOSSLink
|
||||
|
||||
Twelve functions have exact instructions. Swapping the alarm message/storage declaration order fixed AOSS_813FD18C.
|
||||
|
||||
### AOSSi_WLANGetBSSList
|
||||
|
||||
1. Structured access-point output and while retry loops: 227/227, 186 differences.
|
||||
2. Startup label, retry increment ordering and aligned scan variables: 227/227, 186 differences; larger frame.
|
||||
3. Cleanup/unlock labels and ordinary scan/mac locals: 227/227, 202 differences. Corrected the access-point layout with its real privacy field, restoring the 84-byte record size. Remaining differences involve stack placement, loop scheduling and register allocation.
|
||||
|
||||
### AOSSi_WLANConnect
|
||||
|
||||
1. Direct global configuration fields: 162/155 instructions.
|
||||
2. Typed interface/IP pointers: 154/155 instructions.
|
||||
3. Separate cancellation and timeout branches, pre-sleep retry increment: 156/155 instructions. Remaining differences involve pointer lifetime, control flow and register allocation.
|
||||
|
||||
## nup_mem::__nupRegisterAllocator
|
||||
|
||||
The three allocation/free functions match exactly; allocator registration remains open.
|
||||
|
||||
1. Two heap-magic checks in the non-null branch: 17/19 instructions; compiler removes two repeated loads.
|
||||
2. Explicit heap pointer and validity Boolean: unchanged.
|
||||
3. Separate null-aware registration branch: 21/19 instructions with two extra null-check instructions. Restored the first version.
|
||||
|
||||
## kbd_lib_map_us
|
||||
|
||||
Restored the eight ordinary key/modifier tables as u16 arrays and four region registrations. Code and data match 100 percent.
|
||||
|
||||
## kpr_lib
|
||||
|
||||
Seven functions have exact instructions after using a byte for the initialization guard.
|
||||
|
||||
### KPRProcessAltKeypad
|
||||
|
||||
1. Shared normalized and converted value plus while shift loop: 96/96, 28 differences.
|
||||
2. Separate accumulator and translated value, digit subtraction before multiplication: 96/96, 25 differences.
|
||||
3. For-form insertion shift loop: unchanged. Kept the readable for loop. Remaining differences are register assignments.
|
||||
|
||||
### KPRProcessDeadKeys
|
||||
|
||||
1. Initialized fallback indices, second-character temporary: 89/90 instructions.
|
||||
2. Initialize fallbacks after the single-character case and load the second character inside the matching condition: 91/90.
|
||||
3. A moving mapping pointer: 91/90 with more register differences. Restored variant two. The original reads an unset fallback register on invalid input; this source deliberately initializes that fallback rather than adding an uninitialized value to obtain a match.
|
||||
|
||||
Not attempted: vi/i2c, nup/nup_nhttp, axfx/AXFXChorusExp, and all eight requested eZiText units. This is a partial batch, not completion.
|
||||
Reference in New Issue
Block a user