Fixed openGL OSD, added joystick function
This commit is contained in:
parent
ad6543590c
commit
d1f91a0987
|
@ -149,6 +149,8 @@ public:
|
|||
std::vector<int> heldKeys;
|
||||
std::vector<int> keyStrokes;
|
||||
|
||||
Sint16 getJoyStickAxis(int axisNum);
|
||||
|
||||
void touchScreen(int x, int y);
|
||||
void releaseScreen();
|
||||
|
||||
|
|
|
@ -361,6 +361,16 @@ void EmuInstance::inputProcess()
|
|||
lastHotkeyMask = hotkeyMask;
|
||||
}
|
||||
|
||||
//Used By Lua Scripts
|
||||
Sint16 EmuInstance::getJoyStickAxis(int axisNum){
|
||||
if (joystick)
|
||||
{
|
||||
axisNum = axisNum & 0xF;
|
||||
return SDL_JoystickGetAxis(joystick, axisNum);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void EmuInstance::touchScreen(int x, int y)
|
||||
{
|
||||
touchX = x;
|
||||
|
|
|
@ -347,10 +347,9 @@ AddLuaFunction(Lua_Reads32,Reads32);
|
|||
int Lua_NDSTapDown(lua_State* L)
|
||||
{
|
||||
LuaBundle* bundle = get_bundle(L);
|
||||
melonDS::NDS* nds = bundle->getEmuInstance()->getNDS();
|
||||
int x = luaL_checkinteger(L,1);
|
||||
int y = luaL_checkinteger(L,2);
|
||||
nds->TouchScreen(x,y);
|
||||
bundle->getEmuInstance()->touchScreen(x,y);
|
||||
return 0;
|
||||
}
|
||||
AddLuaFunction(Lua_NDSTapDown,NDSTapDown);
|
||||
|
@ -358,8 +357,7 @@ AddLuaFunction(Lua_NDSTapDown,NDSTapDown);
|
|||
int Lua_NDSTapUp(lua_State* L)
|
||||
{
|
||||
LuaBundle* bundle = get_bundle(L);
|
||||
melonDS::NDS* nds = bundle->getEmuInstance()->getNDS();
|
||||
nds->ReleaseScreen();
|
||||
bundle->getEmuInstance()->releaseScreen();
|
||||
return 0;
|
||||
}
|
||||
AddLuaFunction(Lua_NDSTapUp,NDSTapUp);
|
||||
|
@ -630,4 +628,14 @@ int Lua_getJoy(lua_State* L)
|
|||
}
|
||||
AddLuaFunction(Lua_getJoy,GetJoy);
|
||||
|
||||
int Lua_getJoyStick(lua_State* L)
|
||||
{
|
||||
LuaBundle* bundle = get_bundle(L);
|
||||
int axisNum = luaL_checknumber(L,1);
|
||||
int val = bundle->getEmuInstance()->getJoyStickAxis(axisNum);
|
||||
lua_pushinteger(L,val);
|
||||
return 1;
|
||||
}
|
||||
AddLuaFunction(Lua_getJoyStick,GetJoyStick);
|
||||
|
||||
}
|
|
@ -1163,17 +1163,18 @@ void ScreenPanelGL::drawOverlays(int screenType,int screen)
|
|||
glTexSubImage2D(GL_TEXTURE_2D,0,0,0,overlay.rectangle.width(),overlay.rectangle.height(),GL_RGBA,GL_UNSIGNED_BYTE,overlay.displayBuffer->bits());
|
||||
overlay.flipped = false;
|
||||
}
|
||||
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, overlay.GLTexture);
|
||||
glUniform2f(overlayPosULoc,overlay.rectangle.left(),overlay.rectangle.top());
|
||||
glUniform2f(overlaySizeULoc,overlay.rectangle.width(),overlay.rectangle.height());
|
||||
|
||||
|
||||
if(screenType == canvasTarget_OSD) // OSD gets drawn differently then top or bottom screen target
|
||||
{
|
||||
glUniform2i(osdPosULoc,overlay.rectangle.left(),overlay.rectangle.top());
|
||||
glUniform2i(osdSizeULoc,overlay.rectangle.width(),overlay.rectangle.height());
|
||||
glDrawArrays(GL_TRIANGLES, 0, 2*3);
|
||||
continue;
|
||||
}
|
||||
|
||||
glUniform2f(overlayPosULoc,overlay.rectangle.left(),overlay.rectangle.top());
|
||||
glUniform2f(overlaySizeULoc,overlay.rectangle.width(),overlay.rectangle.height());
|
||||
glUniform1i(overlayScreenTypeULoc, screenType);
|
||||
glUniformMatrix2x3fv(overlayTransformULoc, 1, GL_TRUE,screenMatrix[screen]);
|
||||
glDrawArrays(GL_TRIANGLES,screenType == 0 ? 0 : 2*3, 2*3);
|
||||
|
|
|
@ -46,7 +46,8 @@ function _Update()
|
|||
MousePosText,
|
||||
MouseButtonText,
|
||||
KeysText,
|
||||
JoyText
|
||||
JoyText,
|
||||
JoyStickText,
|
||||
}) do
|
||||
y = y+10
|
||||
Text(0,y,tfunct(),0xffffff)
|
||||
|
@ -90,6 +91,12 @@ function MousePosText()
|
|||
return "MousePos:"..mouse.X..","..mouse.Y
|
||||
end
|
||||
|
||||
function JoyStickText()
|
||||
local x = GetJoyStick(0)
|
||||
local y = GetJoyStick(1)
|
||||
return "JoyStick:"..x..","..y
|
||||
end
|
||||
|
||||
function MouseButtonText()
|
||||
str = ""
|
||||
for k,v in pairs(GetMouse()) do
|
||||
|
|
|
@ -69,6 +69,10 @@ end
|
|||
end
|
||||
```
|
||||
|
||||
`nAxisValue GetJoyStick(nAxisNum)`
|
||||
- Returns the current value of the connected analoge joystick axis
|
||||
- nAxisNum is a 4 bit int, (0-15)
|
||||
|
||||
`tJoyState GetJoy()`
|
||||
- Returns a lua table of the Joypad button states.
|
||||
- Table keys are: `A,B,Select,Start,Right,Left,Up,Down,R,L,X,Y`
|
||||
|
|
Loading…
Reference in New Issue