setup some stylus control

This commit is contained in:
zeromus 2015-11-08 03:10:09 -06:00
parent bce9b6f33d
commit 0a412f779e
3 changed files with 203 additions and 152 deletions

View File

@ -104,150 +104,150 @@ namespace BizHawk.Emulation.Cores
public enum RETRO_KEY
{
UNKNOWN = 0,
FIRST = 0,
BACKSPACE = 8,
TAB = 9,
CLEAR = 12,
RETURN = 13,
PAUSE = 19,
ESCAPE = 27,
SPACE = 32,
EXCLAIM = 33,
QUOTEDBL = 34,
HASH = 35,
DOLLAR = 36,
AMPERSAND = 38,
QUOTE = 39,
LEFTPAREN = 40,
RIGHTPAREN = 41,
ASTERISK = 42,
PLUS = 43,
COMMA = 44,
MINUS = 45,
PERIOD = 46,
SLASH = 47,
_0 = 48,
_1 = 49,
_2 = 50,
_3 = 51,
_4 = 52,
_5 = 53,
_6 = 54,
_7 = 55,
_8 = 56,
_9 = 57,
COLON = 58,
SEMICOLON = 59,
LESS = 60,
EQUALS = 61,
GREATER = 62,
QUESTION = 63,
AT = 64,
LEFTBRACKET = 91,
BACKSLASH = 92,
RIGHTBRACKET = 93,
CARET = 94,
UNDERSCORE = 95,
BACKQUOTE = 96,
a = 97,
b = 98,
c = 99,
d = 100,
e = 101,
f = 102,
g = 103,
h = 104,
i = 105,
j = 106,
k = 107,
l = 108,
m = 109,
n = 110,
o = 111,
p = 112,
q = 113,
r = 114,
s = 115,
t = 116,
u = 117,
v = 118,
w = 119,
x = 120,
y = 121,
z = 122,
DELETE = 127,
UNKNOWN = 0,
FIRST = 0,
BACKSPACE = 8,
TAB = 9,
CLEAR = 12,
RETURN = 13,
PAUSE = 19,
ESCAPE = 27,
SPACE = 32,
EXCLAIM = 33,
QUOTEDBL = 34,
HASH = 35,
DOLLAR = 36,
AMPERSAND = 38,
QUOTE = 39,
LEFTPAREN = 40,
RIGHTPAREN = 41,
ASTERISK = 42,
PLUS = 43,
COMMA = 44,
MINUS = 45,
PERIOD = 46,
SLASH = 47,
_0 = 48,
_1 = 49,
_2 = 50,
_3 = 51,
_4 = 52,
_5 = 53,
_6 = 54,
_7 = 55,
_8 = 56,
_9 = 57,
COLON = 58,
SEMICOLON = 59,
LESS = 60,
EQUALS = 61,
GREATER = 62,
QUESTION = 63,
AT = 64,
LEFTBRACKET = 91,
BACKSLASH = 92,
RIGHTBRACKET = 93,
CARET = 94,
UNDERSCORE = 95,
BACKQUOTE = 96,
a = 97,
b = 98,
c = 99,
d = 100,
e = 101,
f = 102,
g = 103,
h = 104,
i = 105,
j = 106,
k = 107,
l = 108,
m = 109,
n = 110,
o = 111,
p = 112,
q = 113,
r = 114,
s = 115,
t = 116,
u = 117,
v = 118,
w = 119,
x = 120,
y = 121,
z = 122,
DELETE = 127,
KP0 = 256,
KP1 = 257,
KP2 = 258,
KP3 = 259,
KP4 = 260,
KP5 = 261,
KP6 = 262,
KP7 = 263,
KP8 = 264,
KP9 = 265,
KP_PERIOD = 266,
KP_DIVIDE = 267,
KP_MULTIPLY = 268,
KP_MINUS = 269,
KP_PLUS = 270,
KP_ENTER = 271,
KP_EQUALS = 272,
KP0 = 256,
KP1 = 257,
KP2 = 258,
KP3 = 259,
KP4 = 260,
KP5 = 261,
KP6 = 262,
KP7 = 263,
KP8 = 264,
KP9 = 265,
KP_PERIOD = 266,
KP_DIVIDE = 267,
KP_MULTIPLY = 268,
KP_MINUS = 269,
KP_PLUS = 270,
KP_ENTER = 271,
KP_EQUALS = 272,
UP = 273,
DOWN = 274,
RIGHT = 275,
LEFT = 276,
INSERT = 277,
HOME = 278,
END = 279,
PAGEUP = 280,
PAGEDOWN = 281,
UP = 273,
DOWN = 274,
RIGHT = 275,
LEFT = 276,
INSERT = 277,
HOME = 278,
END = 279,
PAGEUP = 280,
PAGEDOWN = 281,
F1 = 282,
F2 = 283,
F3 = 284,
F4 = 285,
F5 = 286,
F6 = 287,
F7 = 288,
F8 = 289,
F9 = 290,
F10 = 291,
F11 = 292,
F12 = 293,
F13 = 294,
F14 = 295,
F15 = 296,
F1 = 282,
F2 = 283,
F3 = 284,
F4 = 285,
F5 = 286,
F6 = 287,
F7 = 288,
F8 = 289,
F9 = 290,
F10 = 291,
F11 = 292,
F12 = 293,
F13 = 294,
F14 = 295,
F15 = 296,
NUMLOCK = 300,
CAPSLOCK = 301,
SCROLLOCK = 302,
RSHIFT = 303,
LSHIFT = 304,
RCTRL = 305,
LCTRL = 306,
RALT = 307,
LALT = 308,
RMETA = 309,
LMETA = 310,
LSUPER = 311,
RSUPER = 312,
MODE = 313,
COMPOSE = 314,
NUMLOCK = 300,
CAPSLOCK = 301,
SCROLLOCK = 302,
RSHIFT = 303,
LSHIFT = 304,
RCTRL = 305,
LCTRL = 306,
RALT = 307,
LALT = 308,
RMETA = 309,
LMETA = 310,
LSUPER = 311,
RSUPER = 312,
MODE = 313,
COMPOSE = 314,
HELP = 315,
PRINT = 316,
SYSREQ = 317,
BREAK = 318,
MENU = 319,
POWER = 320,
EURO = 321,
UNDO = 322,
HELP = 315,
PRINT = 316,
SYSREQ = 317,
BREAK = 318,
MENU = 319,
POWER = 320,
EURO = 321,
UNDO = 322,
LAST
LAST
};
[Flags]

View File

@ -151,9 +151,19 @@ namespace BizHawk.Emulation.Cores
IntPtr pKey = new IntPtr(*variables++);
string key = Marshal.PtrToStringAnsi(pKey);
Console.WriteLine("Requesting variable: {0}", key);
*variables = unmanagedResources.StringToHGlobalAnsi("0").ToPointer();
//always return default
//TODO: cache settings atoms
if(!Description.Variables.ContainsKey(key))
return false;
//HACK: return pointer for desmume mouse, i want to implement that first
if (key == "desmume_pointer_type")
{
*variables = unmanagedResources.StringToHGlobalAnsi("touch").ToPointer();
return true;
}
*variables = unmanagedResources.StringToHGlobalAnsi(Description.Variables[key].DefaultOption).ToPointer();
return true;
}
return false;
case LibRetro.RETRO_ENVIRONMENT.SET_VARIABLES:
{
void** variables = (void**)data.ToPointer();
@ -165,7 +175,11 @@ namespace BizHawk.Emulation.Cores
break;
string key = Marshal.PtrToStringAnsi(pKey);
string value = Marshal.PtrToStringAnsi(pValue);
environmentInfo.Variables.Add(Tuple.Create(key, value));
var vd = new VariableDescription() { Name = key};
var parts = value.Split(';');
vd.Description = parts[0];
vd.Options = parts[1].TrimStart(' ').Split('|');
Description.Variables[vd.Name] = vd;
}
}
return false;
@ -223,14 +237,29 @@ namespace BizHawk.Emulation.Cores
else return false;
}
//meanings (they are kind of hazy, but once we're done implementing this it will be completely defined by example)
//port = console physical port?
//device = logical device type
//index = sub device index? (multitap?)
//id = button id
short retro_input_state(uint port, uint device, uint index, uint id)
{
//helpful debugging
//Console.WriteLine("{0} {1} {2} {3}", port, device, index, id);
switch ((LibRetro.RETRO_DEVICE)device)
{
case LibRetro.RETRO_DEVICE.POINTER:
{
switch ((LibRetro.RETRO_DEVICE_ID_POINTER)id)
{
case LibRetro.RETRO_DEVICE_ID_POINTER.X: return (short)Controller.GetFloat("Pointer X");
case LibRetro.RETRO_DEVICE_ID_POINTER.Y: return (short)Controller.GetFloat("Pointer Y");
case LibRetro.RETRO_DEVICE_ID_POINTER.PRESSED: return (short)(Controller["Pointer Pressed"] ? 1 : 0);
}
return 0;
}
case LibRetro.RETRO_DEVICE.JOYPAD:
{
//The JOYPAD is sometimes called RetroPad (and we'll call it that in user-facing stuff cos retroarch does)
@ -274,7 +303,6 @@ namespace BizHawk.Emulation.Cores
class RetroEnvironmentInfo
{
public bool SupportNoGame;
public List<Tuple<string, string>> Variables = new List<Tuple<string, string>>();
}
//disposable resources
@ -402,14 +430,8 @@ namespace BizHawk.Emulation.Cores
Description.LibraryVersion = system_info.library_version;
Description.ValidExtensions = system_info.valid_extensions;
Description.SupportsNoGame = environmentInfo.SupportNoGame;
foreach (var vv in environmentInfo.Variables)
{
var vd = new VariableDescription() { Name = vv.Item1 };
var parts = vv.Item2.Split(';');
vd.Description = parts[0];
vd.Options = parts[1].TrimStart(' ').Split('|');
Description.Variables[vd.Name] = vd;
}
//variables need to be done ahead of time, when theyre set through the environment
//some retro_init (for example, desmume) will continue to use variables (and maybe other parts of the environment) from within retro_init
}
catch
{
@ -493,6 +515,12 @@ namespace BizHawk.Emulation.Cores
})
definition.BoolButtons.Add(string.Format(item,"RetroPad"));
definition.BoolButtons.Add("Pointer Pressed");
definition.FloatControls.Add("Pointer X");
definition.FloatControls.Add("Pointer Y");
definition.FloatRanges.Add(new ControllerDefinition.FloatRange(-32767, 0, 32767));
definition.FloatRanges.Add(new ControllerDefinition.FloatRange(-32767, 0, 32767));
return definition;
}

View File

@ -24,7 +24,8 @@
"P2 RetroPad X": "",
"P2 RetroPad A": "",
"P2 RetroPad L": "",
"P2 RetroPad R": ""
"P2 RetroPad R": "",
"Pointer Pressed": "WMouse L",
},
"NES Controller": {
"P1 Up": "UpArrow, J1 POV1U, X1 DpadUp, X1 LStickUp",
@ -1142,6 +1143,28 @@
"Deadzone": 0.1
}
},
"Apple IIe Keyboard": {}
"Apple IIe Keyboard": {},
"LibRetro Controls": {
"Pointer X": {
"Value": "WMouse X",
"Mult": 1.0,
"Deadzone": 0.1
},
"Pointer Y": {
"Value": "WMouse Y",
"Mult": 1.0,
"Deadzone": 0.1
},
"P1 Pointer X": {
"Value": "",
"Mult": 1.0,
"Deadzone": 0.1
},
"P1 Pointer Y": {
"Value": "",
"Mult": 1.0,
"Deadzone": 0.1
}
}
}
}