2005-11-18 18:54:58 +03:00
|
|
|
/*
|
2006-01-20 17:20:24 +03:00
|
|
|
* (C)opyright MMIV-MMVI Anselm R. Garbe <garbeam at gmail dot com>
|
2005-11-18 18:54:58 +03:00
|
|
|
* 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-12-08 03:46:45 +03:00
|
|
|
result[0] = 0;
|
2005-11-18 18:54:58 +03:00
|
|
|
|
|
|
|
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)
|
2006-02-01 22:56:02 +03:00
|
|
|
cext_strlcat(result, "M1-", 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)
|
2006-02-01 22:56:02 +03:00
|
|
|
cext_strlcat(result, "M4-", 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;
|
2006-02-01 22:56:02 +03:00
|
|
|
if (strstr(val, "M1-"))
|
2005-11-18 18:54:58 +03:00
|
|
|
mod |= Mod1Mask;
|
|
|
|
if (strstr(val, "M2-"))
|
|
|
|
mod |= Mod2Mask;
|
|
|
|
if (strstr(val, "M3-"))
|
|
|
|
mod |= Mod3Mask;
|
2006-02-01 22:56:02 +03:00
|
|
|
if (strstr(val, "M2-"))
|
2005-11-18 18:54:58 +03:00
|
|
|
mod |= Mod4Mask;
|
|
|
|
if (strstr(val, "M5-"))
|
|
|
|
mod |= Mod5Mask;
|
|
|
|
return mod;
|
|
|
|
}
|