Add connection type to menu core.

This commit is contained in:
sorgelig
2018-01-14 15:25:13 +08:00
parent a0c05a2291
commit c8b776c087
3 changed files with 32 additions and 15 deletions

View File

@@ -68,8 +68,8 @@ unsigned char charfont[128][8] =
{ 0x3e,0x3e,0x22,0x22,0x22,0x3e,0x3e,0x00 }, // 25 [0x19] unchecked checkbox
{ 0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x3e,0x00 }, // 26 [0x1a] checked checkbox
{ 0x00,0x00,0x00,0x0c,0x0c,0x00,0x00,0x00 }, // 27 [0x1b] middle dot
{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, // 28 [0x1c]
{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, // 29 [0x1d]
{ 0x68,0x78,0x6b,0x0f,0x6b,0x78,0x68,0x00 }, // 28 [0x1c] ethernet
{ 0x02,0x09,0x25,0x95,0x95,0x25,0x09,0x02 }, // 29 [0x1d] wifi
{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, // 30 [0x1e]
{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, // 31 [0x1f]
{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }, // 32 [0x20]

View File

@@ -44,7 +44,7 @@
#if 1
// ikbd debug output in red
#define IKBD_DEBUG
#define ikbd_debugf(a, ...) printf("\033[1;31mIKBD: " a "\033[0m\n", ##__VA_ARGS__)
#define ikbd_debugf(a, ...) printf("\033[1;32mIKBD: " a "\033[0m\n", ##__VA_ARGS__)
#else
#define ikbd_debugf(...)
#endif

41
menu.c
View File

@@ -478,9 +478,10 @@ static uint32_t menu_key_get(void)
return(c);
}
char* getIP()
static char netType;
char* getNet()
{
struct ifaddrs *ifaddr, *ifa;
struct ifaddrs *ifaddr, *ifa, *ifae = 0, *ifaw = 0;
int family, s;
static char host[NI_MAXHOST];
@@ -494,17 +495,32 @@ char* getIP()
{
if (ifa->ifa_addr == NULL) continue;
s = getnameinfo(ifa->ifa_addr, sizeof(struct sockaddr_in), host, NI_MAXHOST, NULL, 0, NI_NUMERICHOST);
if ((strcmp(ifa->ifa_name, "eth0") == 0) && (ifa->ifa_addr->sa_family == AF_INET)) ifae = ifa;
if ((strncmp(ifa->ifa_name, "wlan", 4) == 0) && (ifa->ifa_addr->sa_family == AF_INET)) ifaw = ifa;
}
if ((strcmp(ifa->ifa_name, "eth0") == 0) && (ifa->ifa_addr->sa_family == AF_INET))
{
freeifaddrs(ifaddr);
return host;
}
ifa = 0;
netType = 0;
if (ifaw)
{
ifa = ifaw;
netType = 2;
}
if (ifae)
{
ifa = ifae;
netType = 1;
}
if (ifa)
{
strcpy(host, "IP: ");
getnameinfo(ifa->ifa_addr, sizeof(struct sockaddr_in), host+strlen(host), NI_MAXHOST-strlen(host), NULL, 0, NI_NUMERICHOST);
}
freeifaddrs(ifaddr);
return NULL;
return ifa ? host : 0;
}
void HandleUI(void)
@@ -3206,12 +3222,11 @@ void HandleUI(void)
rtc_timer = GetTimer(1000);
char str[64] = { 0 };
sprintf(str, " MiSTer ");
char *net = getNet();
if (menustate == MENU_STORAGE)
{
char *ip = getIP();
if (ip) sprintf(str + strlen(str), "IP: %s", ip);
else sprintf(str + strlen(str), " No network");
strcat(str, net ? net : " no network");
}
else
{
@@ -3223,6 +3238,8 @@ void HandleUI(void)
}
}
if (net) str[9] = 0x1b + netType;
OsdWrite(16, "", 1, 0);
OsdWrite(17, str, 1, 0);
OsdWrite(18, "", 1, 0);