Skip to content

Commit 037ee53

Browse files
authored
Add snap and cycle keybinds (#15)
* Add keybind for "Snap to Closest" and "Cycle Cardinal" * update readme formatting
1 parent df31de2 commit 037ee53

File tree

3 files changed

+36
-7
lines changed

3 files changed

+36
-7
lines changed

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,20 @@ You can configure how the plugin responds to clicks on the compass:
3939
- **On Shift**: Only works when Shift is held down.
4040
- **Off Shift**: Works only when Shift is not held down.
4141

42+
---
4243

4344
### Keybindings
4445

45-
You can set up keyboard shortcuts to instantly snap the camera to any cardinal direction:
46+
You can set up single key shortcuts for quick camera control. To prevent key presses from appearing in the chat, enable the "Key Remapping" plugin (included with RuneLite).
4647

48+
- **Snap to Closest**: Snap camera to the closest cardinal direction when pressed
49+
- **Cycle Cardinal**: Cycle through your custom cycle order of directions when pressed
4750
- **Look North Key**: Face camera North when pressed
4851
- **Look South Key**: Face camera South when pressed
4952
- **Look East Key**: Face camera East when pressed
5053
- **Look West Key**: Face camera West when pressed
5154

52-
To prevent these key presses from appearing in the chat, enable the "Key Remapping" plugin (included with RuneLite).
55+
---
5356

5457
## Issues and Feedback
5558

src/main/java/com/compassCameraControl/CompassCameraControlConfig.java

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,33 @@ default ShiftMode shiftClickMode()
5454
)
5555
String cardinalKeybindingSnap = "cardinalKeybindingSnap";
5656

57+
@ConfigItem(
58+
keyName = "snapCloseKey",
59+
name = "Snap to Closest",
60+
description = "Snaps the camera to the nearest cardinal direction on key press",
61+
position = 5,
62+
section = cardinalKeybindingSnap
63+
)
64+
default ModifierlessKeybind snapCloseKey() {
65+
return new ModifierlessKeybind(KeyEvent.VK_UNDEFINED, 0);
66+
}
67+
68+
@ConfigItem(
69+
keyName = "cycleCardinalKey",
70+
name = "Cycle Cardinal",
71+
description = "Cycles through cardinal directions on key press",
72+
position = 6,
73+
section = cardinalKeybindingSnap
74+
)
75+
default ModifierlessKeybind cycleCardinalKey() {
76+
return new ModifierlessKeybind(KeyEvent.VK_UNDEFINED, 0);
77+
}
78+
5779
@ConfigItem(
5880
keyName = "lookNorthKey",
5981
name = "Look North Key",
6082
description = "Face camera North on key press",
61-
position = 5,
83+
position = 7,
6284
section = cardinalKeybindingSnap
6385
)
6486
default ModifierlessKeybind lookNorthKey() {
@@ -69,7 +91,7 @@ default ModifierlessKeybind lookNorthKey() {
6991
keyName = "lookSouthKey",
7092
name = "Look South Key",
7193
description = "Face camera South on key press",
72-
position = 6,
94+
position = 8,
7395
section = cardinalKeybindingSnap
7496
)
7597
default ModifierlessKeybind lookSouthKey() {
@@ -80,7 +102,7 @@ default ModifierlessKeybind lookSouthKey() {
80102
keyName = "lookEastKey",
81103
name = "Look East Key",
82104
description = "Face camera East on key press",
83-
position = 7,
105+
position = 9,
84106
section = cardinalKeybindingSnap
85107
)
86108
default ModifierlessKeybind lookEastKey() {
@@ -91,7 +113,7 @@ default ModifierlessKeybind lookEastKey() {
91113
keyName = "lookWestKey",
92114
name = "Look West Key",
93115
description = "Face camera West on key press",
94-
position = 8,
116+
position = 10,
95117
section = cardinalKeybindingSnap
96118
)
97119
default ModifierlessKeybind lookWestKey() {

src/main/java/com/compassCameraControl/CompassCameraControlPlugin.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,11 @@ public void keyTyped(KeyEvent e) {
196196

197197
@Override
198198
public void keyPressed(KeyEvent event) {
199-
if (event.getKeyCode() == config.lookNorthKey().getKeyCode()) {
199+
if (event.getKeyCode() == config.snapCloseKey().getKeyCode()) {
200+
alignYaw();
201+
} else if (event.getKeyCode() == config.cycleCardinalKey().getKeyCode()) {
202+
cycleYaw();
203+
} else if (event.getKeyCode() == config.lookNorthKey().getKeyCode()) {
200204
client.setCameraYawTarget(NORTH_YAW);
201205
} else if (event.getKeyCode() == config.lookSouthKey().getKeyCode()) {
202206
client.setCameraYawTarget(SOUTH_YAW);

0 commit comments

Comments
 (0)