Gyro control script not working as expected

GPC2 script programming for Titan Two. Code examples, questions, requests.

Gyro control script not working as expected

Postby lildevilhorns » Thu Aug 11, 2022 1:28 pm

Hey y'all. I've been trying to set up mouse and keyboard for Splatoon 2 recently, and I'm using a script by nspl (shoutouts) from the Splatoon 2 thread that others claim works great, however I ran into an issue when using it. The script translates mouse movements to motion controls for snappier movements compared to a control stick, however when moving the mouse up or down the camera keeps going for a bit after you stop moving the mouse, as if it's drifting. I'm using KGM capture through Gtuner.

I've already tried:
-manually setting output protocol
-plugging in pro controller into the INPUT-B slot
-updating controllers
-updating Gtuner
-updating the titan two device
-connecting mouse and keyboard to the titan separately
-using a different mouse
-calibrating gyro on the switch itself

Does anyone know what could be causing this up-down drift? It doesn't affect left-to-right movement at all.

nspl wrote:
Code: Select all
 
#include <switch.gph>
#include <mouse.gph>
 
#define MAXGX 45.0
#define DEFAULT_MMY 0.0
#define MAXR 212.5
 
fix32 mmy;
bool y_toggle = FALSE;
// GIVMXYF:FF0014008000000002000200FC00050A0F14191E23282D32373C41464B50555A5F64
const uint8 mxyc[] = { 0xFF, 0x00, 0x14, 0x00, 0x80, 0x00, 0x00, 0x00, 0x02, 0x00, 0x02, 0x00, 0xFC, 0x00, 0x05, 0x0A, 0x0F, 0x14, 0x19, 0x1E, 0x23, 0x28, 0x2D, 0x32, 0x37, 0x3C, 0x41, 0x46, 0x4B, 0x50, 0x55, 0x5A, 0x5F, 0x64 };
 
init {
    mxyconverter(mxyc);
    mmy = DEFAULT_MMY;
}
 
 
main {
    set_val(SWITCH_ACCZ,0.0 );
    set_val(SWITCH_ACCY,0.0 );
    set_val(SWITCH_GYROZ, 0.0 );
    set_val(SWITCH_GYROY, 0.0 );
    set_val(SWITCH_GYROX, 0.0 );
    set_val(SWITCH_ACCX, 0.0);
    gyro_aim();
}
 
 
void gyro_aim(){
    if(event_active(SWITCH_Y)) {
        y_toggle = !y_toggle;
        mmy = DEFAULT_MMY;
    }
    if(y_toggle) {
        set_val(SWITCH_Y, 100.0);
    }
 
    fix32 my = rad2deg(get_val(SWITCH_RY) / 200.0 * PI) / MAXGX;
    mmy = clamp( mmy + my , -MAXGX , MAXGX );
    set_val(SWITCH_ACCY, mmy );
    if( abs(mmy) != MAXGX ){
        set_val(SWITCH_GYROX, my * MAXR );
    }
    else {
        set_val(GYRO_1_X,0.0);
    }   
 
    set_val(SWITCH_ACCZ, abs(get_val(SWITCH_ACCY)) - 25.0  );
    fix32 gyroz = rad2deg(get_val(SWITCH_RX) / 200.0 * PI) / 45.0 * MAXR;
    set_val(SWITCH_GYROZ, gyroz * -get_val(SWITCH_ACCZ) / 25.0 );
    set_val(SWITCH_GYROY, gyroz * -get_val(SWITCH_ACCY) / 25.0 );
    set_val(SWITCH_ACCX, 0.0 );
    set_val(SWITCH_RY, 0.0);
    set_val(SWITCH_RX, 0.0);
}
 


fix
User avatar
lildevilhorns
Private First Class
Private First Class
 
Posts: 3
Joined: Fri Jul 01, 2022 4:22 pm

Re: Gyro control script not working as expected

Postby Mildern » Thu Aug 18, 2022 4:13 am

I've been trying to work on it, will update the main thread if i ever get a break through.
User avatar
Mildern
Private
Private
 
Posts: 1
Joined: Sun May 23, 2021 7:18 pm

Re: Gyro control script not working as expected

Postby DeGrey » Mon Aug 29, 2022 9:20 pm

I'm also working on this. I'm currently experimenting with increasing the rate of change of Gyro values when moving the mouse vertically. My current (underdeveloped) interpretation of how the vertical aim mechanics work is that the accel value is treated as an absolute reticle position to target, and the gyro value affects the velocity of your aim to reach that position.
User avatar
DeGrey
Private
Private
 
Posts: 1
Joined: Thu Jul 05, 2018 4:46 am


Return to GPC2 Script Programming

Who is online

Users browsing this forum: No registered users and 67 guests