dualshock gamepad controls, no throw on Use

stable-5.1
Tobias Zwick 2010-02-20 17:48:07 +01:00
parent 6d01638ae8
commit dcff2fd95b
3 changed files with 255 additions and 81 deletions

View File

@ -5,7 +5,7 @@
Virtual cursor for gamepad controls
*/
local crew, angle, dirx, diry, saveangle;
local crew, angle, dirx, diry, saveangle, xpos,ypos;
static const CURSOR_Radius = 100;
@ -13,11 +13,13 @@ protected func Initialize()
{
this["Visibility"] = VIS_None;
saveangle = 900;
dirx = diry = xpos = ypos = 0;
}
public func FxMoveTimer()
{
var speed = 0;
// dpad mode
if(diry)
{
if (diry < 0) speed = -Sin(angle,100,10);
@ -30,6 +32,17 @@ public func FxMoveTimer()
else if (dirx > 0) speed = +Cos(angle,100,10);
angle += 30*speed/100;
}
// analog pad mode
if(!dirx && !diry)
{
var target_angle = Angle(0,0,xpos,ypos)*10;
var analog_strength = BoundBy(Sqrt(xpos*xpos+ypos*ypos),0,100);
var angle_diff = Normalize(target_angle - angle, -1800, 10);
var dir = angle_diff / Abs(angle_diff);
angle = angle + angle_diff * analog_strength / 100;
}
UpdatePosition();
crew->TriggerHoldingControl();
@ -86,17 +99,22 @@ public func IsAiming()
return GetEffect("Move",this);
}
public func Aim(int ctrl, int x, int y, int repeat, int release)
public func Aim(int ctrl, int strength, int repeat, int release)
{
if (ctrl == CON_AimAnalog)
if (strength != nil)
{
Message("%d,%d",this,x,y);
dirx = diry = 0;
if(ctrl == CON_AimUp) ypos = -strength;
if(ctrl == CON_AimDown) ypos = strength;
if(ctrl == CON_AimLeft) xpos = -strength;
if(ctrl == CON_AimRight) xpos = strength;
}
// stop
else if (release)
{
if(ctrl == CON_AimUp || ctrl == CON_AimDown) diry = 0;
if(ctrl == CON_AimLeft || ctrl == CON_AimRight) dirx = 0;
else if(ctrl == CON_AimLeft || ctrl == CON_AimRight) dirx = 0;
}
else if(!release && !repeat)
{

View File

@ -375,9 +375,9 @@ public func ObjectControl(int plr, int ctrl, int x, int y, int strength, bool re
// aiming with analog pad or keys
if(VirtualCursorAiming())
{
if (ctrl == CON_AimAnalog || ctrl == CON_AimUp || ctrl == CON_AimDown || ctrl == CON_AimLeft || ctrl == CON_AimRight)
if (ctrl == CON_AimUp || ctrl == CON_AimDown || ctrl == CON_AimLeft || ctrl == CON_AimRight)
{
VirtualCursor()->Aim(ctrl,x,y,repeat,release);
VirtualCursor()->Aim(ctrl,strength,repeat,release);
return true;
}
}
@ -612,9 +612,6 @@ private func StartUseDelayedControl(int ctrl, control, object obj)
{
using = obj;
var hold_enabled = obj->Call("~HoldingEnabled");
if (hold_enabled)
SetPlayerControlEnabled(GetOwner(), CON_AimAnalog, true);
if (ctrl == CON_UseDelayed) alt = false;
else alt = true;
@ -656,7 +653,6 @@ private func StopUseControl(control, int x, int y, object obj, bool cancel)
if (holding_enabled)
{
SetPlayerControlEnabled(GetOwner(), CON_Aim, false);
SetPlayerControlEnabled(GetOwner(), CON_AimAnalog, false);
}
if (virtual_cursor)
virtual_cursor->StopAim();
@ -702,9 +698,6 @@ private func StopUseDelayedControl(control, object obj)
using = nil;
alt = false;
noholdingcallbacks = false;
if (holding_enabled)
SetPlayerControlEnabled(GetOwner(), CON_AimAnalog, false);
return handled;
}

View File

@ -26,15 +26,12 @@
# ---------------
# Aim
#
# Gamepad controls (w/ analog pad)
# Gamepad controls
# -------------------------------------
# CancelUse ThrowDelayed ThrowAltDelayed
# UseDelayed UseAltDelayed
# AimAnalog
#
# Gamepad controls (w\ analog pad) / keyboard only
# ------------------------------------------------
# AimUp AimDown AimLeft AimRight
# AimXMin, AimXMax, AimYMin, AimYMax
#
# with Keyboard
# ------------------
@ -51,12 +48,6 @@
GUIName=Aim
GUIDesc=Aim with mouse
[ControlDef]
Identifier=AimAnalog
DefaultDisabled=1
GUIName=Aim
GUIDesc=Aim with analog pad
[ControlDef]
Identifier=AimUp
GUIName=Aim up
@ -494,11 +485,11 @@
#
# Hotkey0-9 (0-9)
#
# Use, Throw Left mouse button
# Use Left mouse button
# Throw Shift+Left mouse button
# Drop S+Left mouse button
#
# UseAlt, ThrowAlt Right mouse button
# UseAlt Right mouse button
# ThrowAlt Shift+Right mouse button
# DropAlt S+Right mouse button
#
@ -736,10 +727,10 @@
Priority=100
Control=Use
[Assignment]
Key=GameMouse1ButtonLeft
Priority=50
Control=Throw
#[Assignment]
#Key=GameMouse1ButtonLeft
#Priority=50
#Control=Throw
[Assignment]
Key=Shift+GameMouse1ButtonLeft
@ -755,10 +746,10 @@
Priority=100
Control=UseAlt
[Assignment]
Key=GameMouse1ButtonRight
Priority=50
Control=ThrowAlt
#[Assignment]
#Key=GameMouse1ButtonRight
#Priority=50
#Control=ThrowAlt
[Assignment]
Key=Shift+GameMouse1ButtonRight
@ -971,10 +962,10 @@
Priority=100
Control=Use
[Assignment]
Key=GameMouse1ButtonLeft
Priority=50
Control=Throw
#[Assignment]
#Key=GameMouse1ButtonLeft
#Priority=50
#Control=Throw
[Assignment]
Key=Shift+GameMouse1ButtonLeft
@ -990,10 +981,10 @@
Priority=100
Control=UseAlt
[Assignment]
Key=GameMouse1ButtonRight
Priority=50
Control=ThrowAlt
#[Assignment]
#Key=GameMouse1ButtonRight
#Priority=50
#Control=ThrowAlt
[Assignment]
Key=Shift+GameMouse1ButtonRight
@ -1020,27 +1011,26 @@
# --------
# MenuLeft, AimLeft, Left Joy1Left
# MenuRight, AimRight, Right Joy1Right
# MenuUp, AimUp, Up, Jump Joy1Up
# MenuUp, AimUp, Up Joy1Up
# MenuDown, AimDown, Down Joy1Down
#
# Use, Throw Joy1A
# Throw Joy1A+Joy1C
# Jump Joy1C
#
# Use Joy1A
# Throw Joy1A+Joy1F
# Drop Joy1Down+Joy1A
#
# UseAlt, ThrowAlt Joy1D
# ThrowAlt Joy1D+Joy1C
# UseAlt Joy1D
# ThrowAlt Joy1D+Joy1F
# DropAlt Joy1Down+Joy1D
#
# PushEnter, GrabNext, Ungrab,
# Grab, Exit, Enter Joy1C
#
# NextCrew Joy1B
# NextItem Joy1E
# NextAltItem Joy1F
# Grab, Exit, Enter Joy1B
#
# MenuOK Joy1C
# MenuCancel Joy1B
#
#
# NextCrew Joy1G
# PlayerMenu Joy1H
[ControlSet]
@ -1091,7 +1081,7 @@
Control=AimUp
[Assignment]
Key=Joy1Up
Key=Joy1C
Priority=10
Control=Jump
@ -1124,68 +1114,63 @@
Control=MenuCancel
[Assignment]
Key=Joy1C
Key=Joy1B
Priority=45
Control=PushEnter
[Assignment]
Key=Joy1C
Key=Joy1B
Priority=40
Control=GrabNext
[Assignment]
Key=Joy1C
Key=Joy1B
Priority=35
Control=Ungrab
[Assignment]
Key=Joy1C
Key=Joy1B
Priority=30
Control=Grab
[Assignment]
Key=Joy1C
Key=Joy1B
Priority=25
Control=Exit
[Assignment]
Key=Joy1C
Key=Joy1B
Priority=20
Control=Enter
[Assignment]
Key=Joy1B
Key=Joy1G
Control=NextCrew
[Assignment]
Key=Joy1H
Control=PlayerMenu
[Assignment]
Key=Joy1E
Control=NextItem
#[Assignment]
#Key=Joy1E
#Control=NextItem
[Assignment]
Key=Joy1F
Control=NextAltItem
#[Assignment]
#Key=Joy1F
#Control=NextAltItem
[Assignment]
Key=Joy1A
Priority=100
Control=UseDelayed
[Assignment]
Key=Joy1A
Priority=50
Control=ThrowDelayed
[Assignment]
Key=Joy1Down,Joy1A
Priority=150
Control=Drop
[Assignment]
Key=Joy1C,Joy1A
Key=Joy1F,Joy1A
Control=ThrowDelayed
[Assignment]
@ -1194,16 +1179,194 @@
Control=UseAltDelayed
[Assignment]
Key=Joy1D
Priority=50
Control=ThrowAltDelayed
[Assignment]
Key=Joy1Down,Joy1D
Key=Joy1Down,Joy1F
Priority=150
Control=DropAlt
[Assignment]
Key=Joy1C,Joy1D
Key=Joy1F,Joy1D
Control=ThrowAltDelayed
# Dualshock-like Gamepad (12 buttons [A-L], 1 D-Pad, 2 analog sticks)
#
# Summary
# --------
# MenuLeft, AimLeft, Left Joy1Left
# MenuRight, AimRight, Right Joy1Right
# MenuUp, AimUp, Up Joy1Up
# MenuDown, AimDown, Down Joy1Down
#
# Jump Joy1C
#
# Use Joy1A
# Throw Joy1G
# Drop Joy1Down+Joy1A
#
# UseAlt Joy1D
# ThrowAlt Joy1H
# DropAlt Joy1Down+Joy1D
#
# PushEnter, GrabNext, Ungrab,
# Grab, Exit, Enter Joy1B
#
# MenuOK Joy1C
# MenuCancel Joy1B
#
# NextCrew Joy1I
# PlayerMenu Joy1J
[ControlSet]
Name=GamepadDualshock
Keyboard=0
Mouse=0
Gamepad=1
[Assignment]
Key=Joy1Left
Priority=50
Control=Left
[Assignment]
Key=Joy1Right
Priority=50
Control=Right
[Assignment]
Key=Joy1Down
Priority=50
Control=Down
[Assignment]
Key=Joy1Up
Priority=50
Control=Up
[Assignment]
Key=Joy1Axis1Min
Control=AimLeft
[Assignment]
Key=Joy1Axis1Max
Control=AimRight
[Assignment]
Key=Joy1Axis2Max
Control=AimDown
[Assignment]
Key=Joy1Axis2Min
Control=AimUp
[Assignment]
Key=Joy1C
Priority=10
Control=Jump
[Assignment]
Key=Joy1Left
Priority=100
Control=MenuLeft
[Assignment]
Key=Joy1Right
Priority=100
Control=MenuRight
[Assignment]
Key=Joy1Down
Priority=100
Control=MenuDown
[Assignment]
Key=Joy1Up
Priority=100
Control=MenuUp
[Assignment]
Key=Joy1C
Control=MenuOK
[Assignment]
Key=Joy1B
Control=MenuCancel
[Assignment]
Key=Joy1B
Priority=45
Control=PushEnter
[Assignment]
Key=Joy1B
Priority=40
Control=GrabNext
[Assignment]
Key=Joy1B
Priority=35
Control=Ungrab
[Assignment]
Key=Joy1B
Priority=30
Control=Grab
[Assignment]
Key=Joy1B
Priority=25
Control=Exit
[Assignment]
Key=Joy1B
Priority=20
Control=Enter
[Assignment]
Key=Joy1I
Control=NextCrew
[Assignment]
Key=Joy1J
Control=PlayerMenu
#[Assignment]
#Key=Joy1E
#Control=NextItem
#[Assignment]
#Key=Joy1F
#Control=NextAltItem
[Assignment]
Key=Joy1A
Priority=100
Control=UseDelayed
[Assignment]
Key=Joy1Down,Joy1A
Priority=150
Control=Drop
[Assignment]
Key=Joy1G
Control=ThrowDelayed
[Assignment]
Key=Joy1D
Priority=100
Control=UseAltDelayed
[Assignment]
Key=Joy1Down,Joy1F
Priority=150
Control=DropAlt
[Assignment]
Key=Joy1H
Control=ThrowAltDelayed
[Assignment]
Key=Joy1K
Control=CancelUse