v1993 / linuxmotehook

Cemuhook-compliant WiiMote motion provider for Linux
Apache License 2.0
14 stars 0 forks source link

Can't make aiming profile #2

Open Sayora77 opened 4 years ago

Sayora77 commented 4 years ago

I want to be able to make a profile that would have the Wii Remote pointing straight ahead instead of straight up or horizontal, but I can't seem to get one to work. It's useful for games like Splatoon. Thanks!

v1993 commented 4 years ago

I'm nearly sure it is currently possible, but right mapping of axis might be tricky. You first have to make sure that existing configurations work as expected using PadTest before trying to create profiles yourself.

When you'll check out if existing ones are working as expected, I'll try to help you on this issue. Remember, use calibration values to modify directions, not profile settings. Do you have MotionPlus (either connected or built-in), by the way?

Sayora77 commented 4 years ago

The existing configurations do work and I've tried adding a new profile in presets.json to try and make it work. I am using a Wii Remote Plus with MotionPlus built-in.

v1993 commented 4 years ago

Well, first things first: presets.json:

// DO NOT EDIT THIS FILE. USE config.json TO OVERRIDE THESE SETTINGS.

So copy config.template.json to config.json and edit it instead. I'll try to figure out the correct configuration now. Have you supplied calibration values, by the way?

v1993 commented 4 years ago

Please, use presets.json from package from last update and do not touch it as header says.

Sayora77 commented 4 years ago

Oh I didn't notice that. What exactly do I change in config.json because there is no profile there to modify. I have supplied calibration values.

v1993 commented 4 years ago

In version 0.2.2 I've added "Pointed away" profile which should be what you want. Also, hopefully, changes to config will help you to create your own profiles: just add them after last comment (old template lacked comma).

If needed, I'll elaborate a bit more on where and how to add profiles on wiki. Also, I'm going to give a quick description of new profile there.

v1993 commented 4 years ago

I've updated wiki entry. Do you have any further questions? I'll be glad to extend documentation if needed and help.

v1993 commented 4 years ago

Any success getting last version working?

Sayora77 commented 4 years ago

I've tried the pointed away profile and while the rotations are correct, the camera keeps jittering around in Splatoon, even when laying the remote flat making the it unplayable.

v1993 commented 4 years ago

Are you sure your calibrations are still applied (message to console is printed about this)? If yes, does the same happen in other profiles?

Sayora77 commented 4 years ago

The other profiles also jitter. When I run it, it does say I am applying my individual calibration values. However, I'm not sure if they are exact as they can vary each time I run autocalibrate.lua.

v1993 commented 4 years ago

Sadly, I don't think I can do anything about jittering, it's just what WiiMote reports. It is possible to add option of minimal valid rotation, but I'm not sure if that will help. If you wish, I can try to implement this.

Also, autocalibrate.lua may output a bit varying values because it just records movements and takes average, as there really is no (easy) way to read them directly from WiiMote Plus. It is good idea to let it run for half of a minute or so.

Sayora77 commented 4 years ago

I think it would help a lot to have a way to calibrate while main.lua is running like wiimotehook does could just average three seconds. The big problem isn't really jitter but something more akin to Joycon drift only on the y axis where the camera moves to the extremes of up and down without moving the Wii Remote.

v1993 commented 4 years ago

Is it working flawlessly in PadTest? Also, adding such ability would be a pretty big change as this requires to add whole level that handles interaction with user, let that be gui or console.

Have you tried reducing sensitivity? Try overriding axis values for gyro with 0.5 instead of 1 and -0.5 instead of -1, then when problem is gone figure out what axis is problematic and which one is not.

Sayora77 commented 4 years ago

Is there a particular way it should be calibrated? Should it be lying down, upside down, in my hands, should I hold it?

Sayora77 commented 4 years ago

It appear to work fine in PadTest and changing to 0.5 doesn't help.

v1993 commented 4 years ago

Just leave it laying with zero movement applied, position does not matter. Have you tweaked gyro values, not acceleration? What is your resulting profile?

Sayora77 commented 4 years ago

Can it be laying at an angle? This is my calibration setup: 0x************: [-135, -155, -135, 0, 1, 1, 1] I was changing 1,1,1 to zero and the third one is the problematic axis.

Sayora77 commented 4 years ago

I also changed the autocalibrate script to average 3 seconds and there can be some extreme out liers because it is normally about -140, -140, -140, but sometimes gives something along the lines of -45, -110, -200.

v1993 commented 4 years ago

3 seconds is far from enough for good value. Also, calibration setup is a wrong place to change calibration for profiles (it works, but it is still wrong). It's better to override it in individual profile configurations as shown below.

Try adding

        "gyro": {
            "p": ["z", 0.5]
        },

into your custom profile (you have derived one from Pointed away and are using it instead, don't you?) and see what happens.

Sayora77 commented 4 years ago

I am using an unmodified Pointed away profile it is not custom. If I try to make a custom profile like that it errors and crashes.

(process:24732): xwiimote-cemu-WARNING **: 14:16:26.740: Failed to parse config file config.json: "/usr/share/lua/5.3/json/decode.lua:91: Unclosed elements present", continuing...
lua: /home/pika/Downloads/linuxmotehook/configloader.lua:126: Property `UseProfile` not found in config but is required
stack traceback:
        [C]: in function 'error'
        /home/pika/Downloads/linuxmotehook/configloader.lua:126: in local 'resolvePropertyDT'
        /home/pika/Downloads/linuxmotehook/configloader.lua:195: in main chunk
        main.lua:54: in main chunk
        [C]: in ?
v1993 commented 4 years ago

Please, show your resulting config.json.

Tip: use ```JSON5 in the beginning for fancy syntax highlighting. It really helps to read reply.

P.S.: by the way, there is no need to censor your wiimote mac. There is really nothing anyone can do with it (not to mention that it is not really its Bluetooth MAC apparently).

Sayora77 commented 4 years ago

What do you mean by ```JSON5 and fancy syntax highlighting? Here is config.json

{
    // Profile to use
    "UseProfile": "Point",

    // Calibration data for your WiiMotes (example is for my). Use `./autocalibrate.lua` to figure out first three values
    // and PadTest for last three (-1/1). One in middle can be left zero.
    "Calibration": {
        0x0005057E0330: [-140, -142, -143, 0, 1, 1, 1],
    },

    // For information on how to create custom profile, read GitHub wiki
    // Add new profiles below this line

    "Point": {
        "basedOn": "base",

        "keys": {
            "up":       "up",
            "right":    "right",
            "down":     "down",
            "left":     "left",

            "A":        "A",
            "B":        "B",
            "options":  "home"
        },

        "accel": {
            "x": ["x", 1],
            "y": ["z", -1],
            "z": ["y", 1]
        },

        "gyro": {
            "p": ["z", 0.5],
            "y": ["x", 1],
            "r": ["y", 1]
}
v1993 commented 4 years ago

You didn't closed two braces in the end. Also, it's better to derive from Pointed away for you. Result should look like this:

{
    // Profile to use
    "UseProfile": "Point",

    // Calibration data for your WiiMotes (example is for my). Use `./autocalibrate.lua` to figure out first three values
    // and PadTest for last three (-1/1). One in middle can be left zero.
    "Calibration": {
        0x0005057E0330: [-140, -142, -143, 0, 1, 1, 1],
    },

    // For information on how to create custom profile, read GitHub wiki
    // Add new profiles below this line

    "Point": {
        "basedOn": "Pointed away",

        "keys": {
            // Here go your custom key overrides
        },

        "accel": {
            // Should be ok as-is
        },

        "gyro": {
            // Tweak sensitivity here
            "p": ["z", 0.5]
        }
    }
}

P.S. That's how you enable syntax highlighting: instead of

```
```

you use

```JSON5
```

(or replace JSON5 with any other language you're using)

Sayora77 commented 4 years ago

Using that profile has the exact same problem as before. It still has drifting. If I get different results from autocalibrate.lua which one should I accept as correct?

v1993 commented 4 years ago

Using that profile has the exact same problem as before. It still has drifting.

What if you replace 0.5 with 0?

If I get different results from autocalibrate.lua which one should I accept as correct?

Doesn't really matter, they should be close enough. Just make sure that you gave enough time to script and didn't moved/rotated wiimote during calibration and you're good.

Sayora77 commented 4 years ago

It still drifts up and down and even if I replace every sensitivity value with zero like this it will still jitter.

"gyro": {
    // Tweak sensitivity here
    "y": ["x", 0],
    "r": ["y", 0],
    "p": ["z", 0]
}
v1993 commented 4 years ago

Hmm, so this is not due to gyro but thanks to accelerometer (?).

By the way, it seems that there IS a problem with acclelerometer directions dissonance with gyroscope in Pointed away, but it isn't present in Vertical.

It's late here, so I'll write more on this and release bugfix tomorrow.

Sayora77 commented 4 years ago

Ok. I look forward to it.

v1993 commented 4 years ago

Dang it! Sorry for not answering. I've deployed fixes for few related problems in the meantime (not released as I wish to close this issue if I can before release), but didn't got to look at another one.

Sayora77 commented 4 years ago

Is it ready yet?