移除手柄时自动松开所有按下了的键,整理代码
This commit is contained in:
@@ -298,6 +298,15 @@ local jsAxisEventName={
|
|||||||
triggerleft='triggerleft',
|
triggerleft='triggerleft',
|
||||||
triggerright='triggerright'
|
triggerright='triggerright'
|
||||||
}
|
}
|
||||||
|
local gamePadKeys={'a','b','x','y','back','guide','start','leftstick','rightstick','leftshoulder','rightshoulder','dpup','dpdown','dpleft','dpright'}
|
||||||
|
local dPadToKey={
|
||||||
|
dpup='up',
|
||||||
|
dpdown='down',
|
||||||
|
dpleft='left',
|
||||||
|
dpright='right',
|
||||||
|
start='return',
|
||||||
|
back='escape',
|
||||||
|
}
|
||||||
function love.joystickadded(JS)
|
function love.joystickadded(JS)
|
||||||
jsState[JS:getID()]={
|
jsState[JS:getID()]={
|
||||||
_loveJSObj=JS,
|
_loveJSObj=JS,
|
||||||
@@ -310,6 +319,11 @@ end
|
|||||||
function love.joystickremoved(JS)
|
function love.joystickremoved(JS)
|
||||||
local js=jsState[JS:getID()]
|
local js=jsState[JS:getID()]
|
||||||
if js then
|
if js then
|
||||||
|
for i=1,#gamePadKeys do
|
||||||
|
if JS:isGamepadDown(gamePadKeys[i])then
|
||||||
|
love.gamepadreleased(JS,gamePadKeys[i])
|
||||||
|
end
|
||||||
|
end
|
||||||
love.gamepadaxis(JS,'leftx',0)
|
love.gamepadaxis(JS,'leftx',0)
|
||||||
love.gamepadaxis(JS,'lefty',0)
|
love.gamepadaxis(JS,'lefty',0)
|
||||||
love.gamepadaxis(JS,'rightx',0)
|
love.gamepadaxis(JS,'rightx',0)
|
||||||
@@ -320,7 +334,6 @@ function love.joystickremoved(JS)
|
|||||||
MES.new('info',"Joystick removed")
|
MES.new('info',"Joystick removed")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function love.gamepadaxis(JS,axis,val)
|
function love.gamepadaxis(JS,axis,val)
|
||||||
local js=jsState[JS:getID()]
|
local js=jsState[JS:getID()]
|
||||||
if js then
|
if js then
|
||||||
@@ -355,15 +368,6 @@ function love.gamepadaxis(JS,axis,val)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local dPadToKey={
|
|
||||||
dpup='up',
|
|
||||||
dpdown='down',
|
|
||||||
dpleft='left',
|
|
||||||
dpright='right',
|
|
||||||
start='return',
|
|
||||||
back='escape',
|
|
||||||
}
|
|
||||||
function love.gamepadpressed(_,i)
|
function love.gamepadpressed(_,i)
|
||||||
mouseShow=false
|
mouseShow=false
|
||||||
if SCN.swapping then return end
|
if SCN.swapping then return end
|
||||||
|
|||||||
Reference in New Issue
Block a user