Looked at the code, I do not query offsets, for buttons etc.
You *must* query for offsets for every controller. The struct that contains the data from all the controller's inputs varies in size depending on the number of axes, hats and buttons it has. Without querying it, you're assuming a certain layout, which is probably why your buttons are getting swapped and why I have buttons that correspond to axes on my controller. It's additionally risky if the controller is simpler, because then you could be accessing data beyond the end of the struct.
Quote:
I was always going rewrite it from scratch if where do more on AmigaInputAnywhere.
That would be nice, but I've started work on my own fixed alternative anyway that's implemented as a commodity.
Quote:
There is no disconnected event type or device event type or anything like that in my SDK.
True, it's not an event you're looking for. But to read an event, you need a valid context, so you need to be sure your device is connected before you use GetEvent()
Quote:
I can query the device by intervals, using AIN_Query() this command takes the context, so if the context is deleted, it will crash...
True, but you don't query a device if you don't have context so that should never happen. Once you find out that the device is disconnected (while you still have context), you drop the context and don't carry out any more reading of the device. Instead, you start from scratch with a new context, repeating if necessary until a suitable device is found.
Quote:
Well i obtained the device, my program owns the device, until my program release the device.
Which is fine in theory, but in reality your program doesn't own the device, the user does. And the user can take away that device no matter what your program thinks.
Quote:
I created the context, its my job delete the context. the context might not be valid, but it should safe to use it.
I agree, any accesses when the context is no longer valid should return an error code to that effect so that you know it's no longer valid (and out-of-context queries should not be forwarded to the USB stack), but unfortunately this isn't the case. As with obtaining the device, the context is at the mercy of the user, not just your program. If the user changes the context, it can't be valid any longer and must be refreshed.
Quote:
I'm not checking the signal before AIN_GetEvent(...) this might be the major mistake in the code.
I guess this is becouse its not using GetMsg( MsgPort )..
This might be a good idea, though it shouldn't be necessary. What might also be a good thing to do, is to query if the controller is connected before AIN_GetEvent().
but I've started work on my own fixed alternative anyway that's implemented as a commodity.
Yes that should like the best way to do it.
Quote:
because then you could be accessing data beyond the end of the struct.
Amiga Input anywhere is reading events it does not poke the device memory, so there is no rick here.
Quote:
This might be a good idea, though it shouldn't be necessary. What might also be a good thing to do, is to query if the controller is connected before AIN_GetEvent().
But it wont be atomic, the user might unplug it between checkng if its connected and AIN_GetEvent,
player can also unplug it while program is event loop, reading the queue
Amiga Input is broken but I agree I can make my code safer maybe.
Edited by LiveForIt on 2020/2/15 15:38:40 Edited by LiveForIt on 2020/2/15 15:44:34 Edited by LiveForIt on 2020/2/15 15:45:11 Edited by LiveForIt on 2020/2/15 15:50:02
(NutsAboutAmiga)
Basilisk II for AmigaOS4 AmigaInputAnywhere Excalibur and other tools and apps.
Amiga Input anywhere is reading events it does not poke the device memory, so there is no rick here.
Fair enough, in which case it would appear that AmigaInput itself is misaligning the struct contents. That would mean the risk is still there of course, just not directly from your code. In that case, perhaps polling it once per frame (the old-fashioned Amiga way of doing things) would be a better option all round? At least supported controllers would be properly recognised.
Quote:
But it wont be atomic, the user might unplug it between checkng if its connected and AIN_GetEvent,
player can also unplug it while program is event loop, reading the queue
Yes, that's true, but the time between the check and the event fetch should be very small compared to the rest of the game loop, which minimises the risk. As for the event list, you can check for connection before each read of the event, or copy the event struct contents to a dummy struct so that each check in the event loop isn't reading the event again.
Quote:
Amiga Input is broken but I agree I can make my code safer maybe.
Yep, it is broken, but a lot can be done to avoid the issues or greatly reduce the risk of them occurring, rather than just shrugging them off.
AmigaInput or AmigaInputAnywhere related i dont know!
But here goes anyway! Last week I tried my Retroflag SNES joypad with no succes at all with my X5000 until I RTFM! I press Y while connecting the USB and it works nicely.
I have an old Logitech Rumblepad2 which have worked now and then through the years with AmigaInput but always at some point crashed/destroyed EnvArc:Sys/AmigaInput..
But since I've switched to the SNES joypad no more crashes/corrupted prefs!
Which leave me to believe that USB stack is the guilty one, what is the max ampere drain allowed by AOS4.1 USB stack and/or AmigaInput?
I know the X5000 has much weaker ampere on USB ports than my A1XE had but worth checking!
AmigaInputAnywhere is tool to fix game and programs that don’t support joypads, I was kind of making fun of AmigaAnywhere at the time, this where name comes from.
The only problem I know of in AmigaInput is that it crashes if PCI is enabled, and that no gamepads are found unless they are calibrated.
Other issues your describing can be result of updating OS, or file corruption in the OS, the filesystem your using and how careful you are when powering off, or rebooting your computer.
Don’t think you have hardware problem, but you always check in Linux if your USB devices are losing connection.
(NutsAboutAmiga)
Basilisk II for AmigaOS4 AmigaInputAnywhere Excalibur and other tools and apps.
If there is any issue, its most likely when the event is pushed into input.device, this where I think Amiga Input Anywhere might fail, it use to work ok, something might have changed in the OS, that I do not control.
Not I had similar problems with vkeyboard as well, of freezes issues. way it never got released.
(NutsAboutAmiga)
Basilisk II for AmigaOS4 AmigaInputAnywhere Excalibur and other tools and apps.
I'm beyond confused trying to use AmigaInputAnyware on OS4depot
Is there a newer version? Would love to play keyboard only game susing either my USB gamepad or my old school jpytsick via my Catweasel Mk4+ if possible
update: some success...by keeping AmigaInput open on workbench somehow I got the gamepad directions to work but no luck with any buttons..well when playing the game as some buttons only work on game screen??
Here's the info you need to make sense of AmigaInoutAnyware aka watch walkero's Twitch video on July16-24
walkero wrote: Quote:
@328gts Thank you for joining. At the start of the stream I shared how people can use joysticks with games that support only keyboards, like the Friking Shark, by using AmigaInputAnywhere from os4depot (http://os4depot.net/?function=showfil ... re/amigainputanywhere.lha)
Thanks
Edited by 328gts on 2024/7/17 20:44:39 Edited by 328gts on 2024/7/19 4:12:12 Edited by 328gts on 2024/7/19 4:13:42
I still can't get any of my gamepad buttons working with AmigaInputAnywhere??? Up, down, left and right on gamepad working but useless if I can't get any buttons working
Hi for example I created a new entry and renamed frikingshark and just changed wher the fire buttons (CTRL and leftALT keys in game) are mapped to my gamepad buttons. So I set/remap to may gamepad (has 12 buttons): ... Button 1 -> CTRL ... Button 6 -> LALT
no other entry was changed. Then just laucnhing frykinshark in AmigaInputAnywhere's GUI O keep the frikinshark entry selected. So during game when on my gamepad a push Button 1 is like I was using CTRL key and same with Button 6 (leftALT)