Skip to content

Commit 2021be8

Browse files
committed
re-enable gyro periodically
1 parent b393dba commit 2021be8

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/main/java/nekomods/deckcontrols/HidInput.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ public void run() {
167167
int lastPressedButtons = 0;
168168
long last_frame_id = -1;
169169
long last_frame_nanos = -1;
170+
long last_reenable_gyro_nanos = -1;
170171
int frame_times_i = 0;
171172
// mouse smoothing
172173
int last_mouse_pad_x = 0;
@@ -190,6 +191,12 @@ public void run() {
190191

191192
long current_nanos = Util.getNanos();
192193

194+
// Turn gyro back on every second; fix for new Steam client
195+
if (current_nanos - last_reenable_gyro_nanos > 1_000_000_000) {
196+
turnGyroOn();
197+
last_reenable_gyro_nanos = current_nanos;
198+
}
199+
193200
long frame_id = (buf[4] & 0xFF) | ((buf[5] & 0xFF) << 8) | ((buf[6] & 0xFF) << 16) | ((buf[7] & 0xFF) << 24);
194201
if (last_frame_id != -1) {
195202
if (last_frame_id - frame_id > 1) {
@@ -435,4 +442,19 @@ public boolean tick(boolean leftRight) {
435442
// HIDIOCSFEATURE
436443
return LibcIo.ioctl(fd, 0xC0414806, buf) == 0;
437444
}
445+
446+
public boolean turnGyroOn() {
447+
// no, we never want to turn the gyro off
448+
449+
byte[] buf = new byte[65];
450+
buf[0] = 0x00;
451+
buf[1] = (byte)0x87;
452+
buf[2] = 0x03;
453+
buf[3] = 0x30;
454+
buf[4] = 0x18;
455+
buf[5] = 0x00;
456+
457+
// HIDIOCSFEATURE
458+
return LibcIo.ioctl(fd, 0xC0414806, buf) == 0;
459+
}
438460
}

0 commit comments

Comments
 (0)