2005-11-18 18:54:58 +03:00
|
|
|
/*
|
|
|
|
* (C)opyright MMIV-MMV Anselm R. Garbe <garbeam at gmail dot com>
|
|
|
|
* See LICENSE file for license details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include "blitz.h"
|
|
|
|
|
|
|
|
/* free the result manually! */
|
2005-12-05 01:45:59 +03:00
|
|
|
char *blitz_modtostr(unsigned long mod)
|
2005-11-18 18:54:58 +03:00
|
|
|
{
|
2005-12-05 01:45:59 +03:00
|
|
|
char result[60];
|
2005-11-18 18:54:58 +03:00
|
|
|
result[0] = '\0';
|
|
|
|
|
|
|
|
if (mod & ShiftMask)
|
2005-12-06 20:58:52 +03:00
|
|
|
cext_strlcat(result, "S-", sizeof(result));
|
2005-11-18 18:54:58 +03:00
|
|
|
if (mod & ControlMask)
|
2005-12-06 20:58:52 +03:00
|
|
|
cext_strlcat(result, "C-", sizeof(result));
|
2005-11-18 18:54:58 +03:00
|
|
|
if (mod & Mod1Mask)
|
2005-12-06 20:58:52 +03:00
|
|
|
cext_strlcat(result, "M-", sizeof(result));
|
2005-11-18 18:54:58 +03:00
|
|
|
if (mod & Mod2Mask)
|
2005-12-06 20:58:52 +03:00
|
|
|
cext_strlcat(result, "M2-", sizeof(result));
|
2005-11-18 18:54:58 +03:00
|
|
|
if (mod & Mod3Mask)
|
2005-12-06 20:58:52 +03:00
|
|
|
cext_strlcat(result, "M3-", sizeof(result));
|
2005-11-18 18:54:58 +03:00
|
|
|
if (mod & Mod4Mask)
|
2005-12-06 20:58:52 +03:00
|
|
|
cext_strlcat(result, "WIN-", sizeof(result));
|
2005-11-18 18:54:58 +03:00
|
|
|
if (mod & Mod5Mask)
|
2005-12-06 20:58:52 +03:00
|
|
|
cext_strlcat(result, "M5-", sizeof(result));
|
|
|
|
return cext_estrdup(result);
|
2005-11-18 18:54:58 +03:00
|
|
|
}
|
|
|
|
|
2005-12-05 01:45:59 +03:00
|
|
|
unsigned long blitz_strtomod(char *val)
|
2005-11-18 18:54:58 +03:00
|
|
|
{
|
2005-12-05 01:45:59 +03:00
|
|
|
unsigned long mod = 0;
|
2005-11-18 18:54:58 +03:00
|
|
|
if (strstr(val, "S-"))
|
|
|
|
mod |= ShiftMask;
|
|
|
|
if (strstr(val, "C-"))
|
|
|
|
mod |= ControlMask;
|
|
|
|
if (strstr(val, "M-"))
|
|
|
|
mod |= Mod1Mask;
|
|
|
|
if (strstr(val, "M2-"))
|
|
|
|
mod |= Mod2Mask;
|
|
|
|
if (strstr(val, "M3-"))
|
|
|
|
mod |= Mod3Mask;
|
|
|
|
if (strstr(val, "WIN-"))
|
|
|
|
mod |= Mod4Mask;
|
|
|
|
if (strstr(val, "M5-"))
|
|
|
|
mod |= Mod5Mask;
|
|
|
|
return mod;
|
|
|
|
}
|