Absolute mouse coordinates

https://github.com/MiSTer-devel/Main_MiSTer/wiki

Moderators: Mug UK, Zorro 2, Greenious, spiny, Sorgelig, Moderator Team

Sorgelig
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 4702
Joined: Mon Dec 14, 2015 10:51 am
Location: Russia/Taiwan

Re: Absolute mouse coordinates

Postby Sorgelig » Tue May 07, 2019 3:48 pm

Dolphinbar in mode 1 has mouse cursor freeze and short time upon press A/B. Probably for better mouse handling. So it's not good for lightgun emulation. Mode 2 has no such freezes but A/B buttons are swapped, so NES core need update to react on both mouse buttons as a trigger.

Sorgelig
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 4702
Joined: Mon Dec 14, 2015 10:51 am
Location: Russia/Taiwan

Re: Absolute mouse coordinates

Postby Sorgelig » Tue May 07, 2019 3:51 pm

Locutus73 wrote:Mode 4 is intended for Dolphin emulator use, so we can find some code here https://github.com/dolphin-emu/dolphin

Only for Windows!
In Linux, mode 4 is not supported what i found so far.

Sorgelig
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 4702
Joined: Mon Dec 14, 2015 10:51 am
Location: Russia/Taiwan

Re: Absolute mouse coordinates

Postby Sorgelig » Tue May 07, 2019 3:57 pm

Locutus73 wrote:By the way, what would be the use of more than one wiimote? Two player lightgun games?

besides the IR pointer wiimote can be used as traditional gamepad. Together with nunchuck or classic controller it's pretty much normal gamepad. In Native mode you can use several wiimotes. Can it be use as 2 lightguns - it's up to the core.

btw, there is 3rd party adapters for wiimote to connect Gamecube gamepad, and even there is adaptor for DB9! So it's a good opportunity to make a wireless retro joystick :)

Locutus73
Captain Atari
Captain Atari
Posts: 473
Joined: Wed Feb 07, 2018 6:13 pm

Re: Absolute mouse coordinates

Postby Locutus73 » Wed May 08, 2019 5:29 am

Sorgelig wrote:besides the IR pointer wiimote can be used as traditional gamepad. Together with nunchuck or classic controller it's pretty much normal gamepad. In Native mode you can use several wiimotes. Can it be use as 2 lightguns - it's up to the core.

Yeah you’re right, I even defined gamepad maps for main MiSTer and NES both for cwiid and Dolphinbar... it’s just I’m used to think to the Wiimote basically as a lightgun and using other controllers otherwise. The Wiimote (with no accessories) can be also successfully used as a two button NES controller when held horizontally.
I suspect the Wiimote can be used for Nintendo Mini Classic Controllers too, so having good NES/SNES joypad replica with the added benefit of wireless and additional buttons (i.e. menu button) on the Wiimote.

Sorgelig wrote:btw, there is 3rd party adapters for wiimote to connect Gamecube gamepad, and even there is adaptor for DB9! So it's a good opportunity to make a wireless retro joystick :)

Yup, I have a pair of them, bought back then along the Dolphinbar for using OG GameCube controllers with Dolphin Emulator... actually never used them :oops:

Regards.

Locutus73

Lightwave
Atari User
Atari User
Posts: 31
Joined: Sun Dec 16, 2018 8:18 pm

Re: Absolute mouse coordinates

Postby Lightwave » Wed May 08, 2019 7:00 am

Locutus73 wrote:I suspect the Wiimote can be used for Nintendo Mini Classic Controllers too, so having good NES/SNES joypad replica with the added benefit of wireless and additional buttons (i.e. menu button) on the Wiimote.


This is correct, the NES and SNES Classic Controllers work perfectly with the Wiimote.

I am currently using both of these controllers with the MiSTer via a Raphnet USB adapter, but it would be cool to have the option to use them wirelessly through the Wiimote as well (and the extra buttons would definitely be nice for menu, etc.)

Sorgelig
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 4702
Joined: Mon Dec 14, 2015 10:51 am
Location: Russia/Taiwan

Re: Absolute mouse coordinates

Postby Sorgelig » Fri May 10, 2019 12:44 pm

After study the Dolphin emulator code, it definitely should work with mode 4 in Linux. But it's done through very awkward way. So Dolphis has the whole driver code which uses Wiimote in a low level mode using reports.
Since native support works fine now, i'm not interesting in adding low level dolphinbar code support myself. If some one is willing to do it, then i would be glad to integrate.
I think it's better to write a special app which will work similar to wminput as a user-space input driver. So this app will push the input events to uinput and then MiSTer will work with it as with traditional input device.

Locutus73
Captain Atari
Captain Atari
Posts: 473
Joined: Wed Feb 07, 2018 6:13 pm

Re: Absolute mouse coordinates

Postby Locutus73 » Sat May 11, 2019 10:34 am

@sorgelig
Just tested the new Wiimote implementation and it's sweet: the IR pointer is smooth (as with cwiid, much better than Dolphinbar) and the IR doesn't interfere with the joypad wizard anymore.
Just sweet.
I love the new joypad wizard layout too, much more understandable!
:cheers:

Thank you very much

Locutus73

User avatar
kitrinx
Captain Atari
Captain Atari
Posts: 160
Joined: Wed Sep 26, 2018 6:03 am

Re: Absolute mouse coordinates

Postby kitrinx » Sun May 12, 2019 6:12 pm

The new integrated wiimote support is very good. Thank you for this.

User avatar
kitrinx
Captain Atari
Captain Atari
Posts: 160
Joined: Wed Sep 26, 2018 6:03 am

Re: Absolute mouse coordinates

Postby kitrinx » Mon May 13, 2019 8:04 pm

@sorgelig Nice job with SNES light gun. With your custom wiimote module, would it be hard to make a small calibration routine so it could be set up for true LoS targeting? Then it would be just like a real lightgun.

Sorgelig
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 4702
Joined: Mon Dec 14, 2015 10:51 am
Location: Russia/Taiwan

Re: Absolute mouse coordinates

Postby Sorgelig » Mon May 13, 2019 9:56 pm

kitrinx wrote:@sorgelig Nice job with SNES light gun. With your custom wiimote module, would it be hard to make a small calibration routine so it could be set up for true LoS targeting? Then it would be just like a real lightgun.

I didn't find the info about calibrating the Wiimote. If you point me to such info, then i will tell you how hard it to implement. On the Wii i even can define the position of bar top/bottom. In Linux driver there is no such option.

P.S.: if you are talking about calibrating inside the SNES to match the wiimote cross with in-game target, then all games i've tried have calibration screen where you can do this. Some games have hidden calibration screen opened by specific button press. For example in "T2: Arcade game" you have to hold the cursor button and press the fire on the title screen.
My lightgun module gives only 1-2 pixel shifts horizontally between visible cross and real latched values. Thus from HW point of view wiimote is more precise than original Super Scope. It's just games have random calibrated point, so you need to use in-game calibration which is the part of standard usage scenario of SuperScope.

Sorgelig
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 4702
Joined: Mon Dec 14, 2015 10:51 am
Location: Russia/Taiwan

Re: Absolute mouse coordinates

Postby Sorgelig » Mon May 13, 2019 10:07 pm

I plan to add no-cursor mode. So in games providing the cursor you will be able to use without calibration.

User avatar
kitrinx
Captain Atari
Captain Atari
Posts: 160
Joined: Wed Sep 26, 2018 6:03 am

Re: Absolute mouse coordinates

Postby kitrinx » Tue May 14, 2019 1:46 am

Sorgelig wrote:I didn't find the info about calibrating the Wiimote. If you point me to such info, then i will tell you how hard it to implement. On the Wii i even can define the position of bar top/bottom. In Linux driver there is no such option.


To the best of my knowledge, there's no internal method for doing this. The way the wii does it, and I assume most other things that use the wiimote, is they apply an offset to the input based on user feedback. For example:

If you display a target on the screen, and tell the user to shoot that target (without providing crosshairs) then X/Y that is read when they pull the trigger can be associated with a real position on the screen. Doing this sequentially for 3 or 4 targets in the corners can let you easily calculate offsets to apply to raw input to make it line up with real positions on the screen. Since the TV doesn't really change the area that it draws in much, and we use scaled joystick input for the cores, you can make it very close to real LoS this way.

Sorgelig
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 4702
Joined: Mon Dec 14, 2015 10:51 am
Location: Russia/Taiwan

Re: Absolute mouse coordinates

Postby Sorgelig » Tue May 14, 2019 7:03 am

kitrinx wrote:To the best of my knowledge, there's no internal method for doing this. The way the wii does it, and I assume most other things that use the wiimote, is they apply an offset to the input based on user feedback. For example:

If you display a target on the screen, and tell the user to shoot that target (without providing crosshairs) then X/Y that is read when they pull the trigger can be associated with a real position on the screen. Doing this sequentially for 3 or 4 targets in the corners can let you easily calculate offsets to apply to raw input to make it line up with real positions on the screen. Since the TV doesn't really change the area that it draws in much, and we use scaled joystick input for the cores, you can make it very close to real LoS this way.

This is just to match the physical position of wiimote in hand with screen coordinates. It won't help to match SNES game target with wiimote target (as different SNES games treat SS coordinates differently). So if you are just looking to natch red cross with in-game cross, then simply use in-game calibration - it will do the job.
Actually for precise physical calibration it should be done on HPS side, where selected window will be cut from the whole range of wiimote coordinates leaving some outside gap for calibration, so core will get a clean calibrated coordinates. I think it must be done in either special calibration core, or in Menu core.
Still wiimote needs one important setting - bar top/bottom position, as even Wii requires this setting. It's something probably not implemented in current driver. Probably some code can be found in Dolphin emulator.

User avatar
kitrinx
Captain Atari
Captain Atari
Posts: 160
Joined: Wed Sep 26, 2018 6:03 am

Re: Absolute mouse coordinates

Postby kitrinx » Tue May 14, 2019 12:38 pm

Sorgelig wrote:This is just to match the physical position of wiimote in hand with screen coordinates. It won't help to match SNES game target with wiimote target (as different SNES games treat SS coordinates differently). So if you are just looking to natch red cross with in-game cross, then simply use in-game calibration - it will do the job.
Actually for precise physical calibration it should be done on HPS side, where selected window will be cut from the whole range of wiimote coordinates leaving some outside gap for calibration, so core will get a clean calibrated coordinates. I think it must be done in either special calibration core, or in Menu core.
Still wiimote needs one important setting - bar top/bottom position, as even Wii requires this setting. It's something probably not implemented in current driver. Probably some code can be found in Dolphin emulator.


Top/bottom or screen calibration, we are basically talking about the same thing. Just making so that where you point the wiimote lines up with what is on the screen. It is relevant for all lightgun cores. It is definitely an HPS side thing. I think for the most part it is just an offset. Since the coordinates are absolute, if the bar is on the top, you just add a constant number to lower it.if you know the right and left offsets, you can add constants there too to make the range line up with a 4:3 screen. You can find the offsets by making the user aim at what they feel is a corner, or the center. Lets say the upper left is coordinate 0,0. If you put a target there, and the user shoots, and the wiimote reads 0, 15, you know you need the offset of -15 to make it line up with the screen. You can also map out the range of what the user feels is the right and left sides of the screen and adjust the range to of the analog stick to match this too. See what I am suggesting?

SNES calibration is a bit different and is timing related I think, since the original super scope was extremely timing sensitive.

Sorgelig
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 4702
Joined: Mon Dec 14, 2015 10:51 am
Location: Russia/Taiwan

Re: Absolute mouse coordinates

Postby Sorgelig » Tue May 14, 2019 4:12 pm

On Wii there are 2 independent settings: bar position and calibration.
So, it's not just offsets. Offset from up to down is pretty large so using just offset will make the range is too narrow and basically you cannot reach the other side of screen if bar position is wrong (unless your monitor is tiny).
So bar position option must be implemented in the driver anyway.
Sure i know how to calibrate. I have 30+ years of programming experience :)
May be some day i will add calibration. Currently i don't really care how i keep my wiimote - i just follow the cross mark :)

User avatar
Newsdee
Atari God
Atari God
Posts: 1406
Joined: Fri Sep 19, 2014 8:40 am

Re: Absolute mouse coordinates

Postby Newsdee » Wed May 15, 2019 2:44 am

What are the recommended settings for the wiimote? I mapped it to Joy1 and set the NES core to use Joy1 for the zapper. The cursor moves but I don't seem to be able to use the trigger.

Do I need to map the trigger to a mouse button? Or is it independent from the gamepad settings? I feel like I'm almost there. And in general is "mouse" more accurate than using one of the Joy1/2 options?

Sorgelig
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 4702
Joined: Mon Dec 14, 2015 10:51 am
Location: Russia/Taiwan

Re: Absolute mouse coordinates

Postby Sorgelig » Wed May 15, 2019 2:00 pm

For NES core there is a special mp for Trigger button. It's going after PowerPad 12 buttons. Pretty much hidden, but it's there :)

Locutus73
Captain Atari
Captain Atari
Posts: 473
Joined: Wed Feb 07, 2018 6:13 pm

Re: Absolute mouse coordinates

Postby Locutus73 » Mon May 20, 2019 3:29 pm

I just saw something interesting here https://github.com/MiSTer-devel/Main_Mi ... a3597f0439
:D

Regards.

Locutus73

User avatar
kitrinx
Captain Atari
Captain Atari
Posts: 160
Joined: Wed Sep 26, 2018 6:03 am

Re: Absolute mouse coordinates

Postby kitrinx » Thu May 23, 2019 2:14 am

For Aimtrak gun users, I have good news. I tested out an Aimtrak today and it works nicely with MiSTer. Setting up the controller is a little hard, so I attached the controller setup. You can use it as a joystick, with the trigger as a mouse button. By default, if you hold the trigger for five seconds the gun will go into calibration mode, and it works well with MiSTer, at least while in the NES core. It moves the cursor around and you shoot at it. After this the gun will be line of sight. I had to turn the IR gain down using the configuration app in windows, but it seems to save the setting to the device, that reduced the jitter.
You do not have the required permissions to view the files attached to this post.

Locutus73
Captain Atari
Captain Atari
Posts: 473
Joined: Wed Feb 07, 2018 6:13 pm

Re: Absolute mouse coordinates

Postby Locutus73 » Thu May 23, 2019 5:43 am

kitrinx wrote:For Aimtrak gun users, I have good news. I tested out an Aimtrak today and it works nicely with MiSTer. Setting up the controller is a little hard, so I attached the controller setup.

@sorgelig
Attaching some MiSTer event logs here would be it possible to automatically assign the Aimtrak IR to the analog stick mapping as you already do for the wiimote, making the configuration wizard a breeze (or not needed at all for basic usage)?

Regards.

Locutus73

Sorgelig
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 4702
Joined: Mon Dec 14, 2015 10:51 am
Location: Russia/Taiwan

Re: Absolute mouse coordinates

Postby Sorgelig » Thu May 23, 2019 6:46 am

yes, i can do it

User avatar
kitrinx
Captain Atari
Captain Atari
Posts: 160
Joined: Wed Sep 26, 2018 6:03 am

Re: Absolute mouse coordinates

Postby kitrinx » Thu May 23, 2019 3:17 pm

Sorgelig wrote:yes, i can do it


Is this what you need?

Code: Select all

Input event: type=EV_ABS, Axis=0, Offset=3370, jnum=2, ID:d209:1601:04, abs_min = 0, abs_max = 4095
Combined mouse event: btn=0x18, dx=-36, dy=0, scroll=0
PS2 MOUSE: 18 252 0
Input event: type=EV_ABS, Axis=0, Offset=3238, jnum=2, ID:d209:1601:04, abs_min = 0, abs_max = 4095
Combined mouse event: btn=0x18, dx=-33, dy=0, scroll=0
Input event: type=EV_ABS, Axis=0, Offset=3105, jnum=2, ID:d209:1601:04, abs_min = 0, abs_max = 4095
Combined mouse event: btn=0x38, dx=-33, dy=-44, scroll=0
Input event: type=EV_ABS, Axis=1, Offset=235, jnum=2, ID:d209:1601:04, abs_min = 0, abs_max = 4095
PS2 MOUSE: 38 250 252
Input event: type=EV_ABS, Axis=0, Offset=2986, jnum=2, ID:d209:1601:04, abs_min = 0, abs_max = 4095
PS2 code(break)(ext) for core: 116(0x74)
Combined mouse event: btn=0x38, dx=-30, dy=-49, scroll=0
Input event: type=EV_ABS, Axis=1, Offset=499, jnum=2, ID:d209:1601:04, abs_min = 0, abs_max = 4095
Input event: type=EV_ABS, Axis=0, Offset=2866, jnum=2, ID:d209:1601:04, abs_min = 0, abs_max = 4095
Combined mouse event: btn=0x38, dx=-30, dy=-49, scroll=0
Input event: type=EV_ABS, Axis=1, Offset=762, jnum=2, ID:d209:1601:04, abs_min = 0, abs_max = 4095
PS2 MOUSE: 38 250 247

Sorgelig
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 4702
Joined: Mon Dec 14, 2015 10:51 am
Location: Russia/Taiwan

Re: Absolute mouse coordinates

Postby Sorgelig » Thu May 23, 2019 4:17 pm

kitrinx wrote:Is this what you need?

yes.
Also log when input devices are opened, so i will see all devices of this gun.

User avatar
kitrinx
Captain Atari
Captain Atari
Posts: 160
Joined: Wed Sep 26, 2018 6:03 am

Re: Absolute mouse coordinates

Postby kitrinx » Thu May 23, 2019 4:45 pm

Sorgelig wrote:
kitrinx wrote:Is this what you need?

yes.
Also log when input devices are opened, so i will see all devices of this gun.


Code: Select all

Close all devices.
Open up to 20 input devices.
open(/dev/input/event2): 13
open(/dev/input/event1): 14
open(/dev/input/event0): 15
has LEDs.
open(/dev/input/event17): 16
open(/dev/input/event16): 17
open(/dev/input/event8): 18
open(/dev/input/event6): 19
opened 0( 0): /dev/input/event2 (d209:1601) 0 "9" "Ultimarc Ultimarc"
opened 1( 0): /dev/input/event1 (d209:1601) 0 "9" "Ultimarc Ultimarc"
opened 2( 0): /dev/input/event0 (d209:1601) 0 "9" "Ultimarc Ultimarc"
opened 3( 3): /dev/input/event17 (16d0:0d04) 0 "1000" "BLISS-BOX 4-PLAY PORT.1"
opened 4( 3): /dev/input/event16 (16d0:0d04) 0 "1000" "BLISS-BOX 4-PLAY/GP PO1"
opened 5( 5): /dev/input/event8 (054c:05c4) 4 "00:00:00:00:00:00" "Sony Computer Entertainment Wireless Controller"
opened 6( 5): /dev/input/event6 (054c:05c4) 5 "00:00:00:00:00:00" "Sony Computer Entertainment Wireless Controller Touchpad"

Sorgelig
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 4702
Joined: Mon Dec 14, 2015 10:51 am
Location: Russia/Taiwan

Re: Absolute mouse coordinates

Postby Sorgelig » Thu May 23, 2019 5:38 pm

how about the buttons? Do they come from the same eventX or different?

It's better to give me log where present:
1) opening the input devices
2) pointer move in both X and Y
3) press sequentially all available buttons.

This should be the single log so i can match the devices.

It's interesting what "9" in device name means. Is there any info why it present 3 input devices? Do you connect only single gun?


Return to “MiSTer”

Who is online

Users browsing this forum: No registered users and 4 guests