-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gamepad: add Gamepad package #8
base: main
Are you sure you want to change the base?
Conversation
type Buttons struct { | ||
A, B, Y, X Button | ||
Left, Right, Up, Down Button | ||
LT, RT, LB, RB Button | ||
LeftThumb, RightThumb Button | ||
Start, Back Button | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe replace to map[ButtonID]float32
?
for name, button := range mappingButton { | ||
controller.Buttons.setButtonForce(button, float32(C.getButtonFrom(state, name))) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It sounds very inefficient, but it's easier to understand.
Maybe change the map to [...][2]uinptr
(the first is NSString and the second item is the offset struct-item) and provide access directly to controller.Buttons
). So, the C code will change the Go-Struct directly, so it's a single call to C, instead of multiple calls.
@inkeliz This is going to be fun... which gamepad are you testing with ? |
I'm using Xbox One Controller on Windows and iOS; Nintendo Switch Pro Controller and Xbox on macOS. I notice some issues with remapping on macOS/iOS, that I will fix soon. Since Nintendo Switch uses a "reverted scheme" pressing "A" acts like "B". I think makes more sense to map to the physical button position. Pressing "B" on Nintendo Pro Controller must be the same as "A" on Xbox, and "X" on Playstation (all those buttons have the same position in the gamepad). Another function or field to explain "what is the controller" (brand, name....) might be useful, but some APIs (Windows/XInput) doesn't support it. I can't implement for Linux because I fail to enable pass-through the USB to VM machine. The Android not work based on snapshot/state. The Android is the only one that is event-based exclusive (similar to keystrokes) and those events are sent to the View. Maybe I can manage a way to create a custom invisible View to get those inputs, but I'm not sure if that will work. |
Support gamepad for Windows, macOS, iOS and JS. Signed-off-by: Inkeliz <inkeliz@inkeliz.com>
Hey thanks for the updates !! Ok wil watch out for updates and retest here. I am only testing on Intel Mac for now. It compiles fine but crashes at runtime. If you want output logs let me know. Some things are working at the CLI level though using some custom code. I wish we have github workflow CI to test stuff :) |
What is the exact issue? The logs will be nice. What is the version of macOS did you have? It requires macOS 12, but it should act as "no-op" for older macOS versions. I compile to amd64 (using
It's not possible on all OSes. On iOS/macOS the user can remap in the OS settings and that settings is honored by |
@inkeliz I will put up the full code on a github fork so you can see everything. Bit busy with holidays stuff here right now. |
I have it working only on desktop via USB for now to detect the gamepad type. Will make sure its in the github fork i put up. |
hey @inkeliz The mappings to support many different gamepads are in the ebitne code base here: https://github.com/hajimehoshi/ebiten/blob/main/internal/glfw/glfw/src/mappings.h there are so many gamepads !! DO you think we can use the mappings ? |
I don't know how can we use it. On JS (Gamepad API) the only map supported is
https://w3c.github.io/gamepad/#gamepadmappingtype-enum Currently, it's not checked. But, maybe it must only support "standard" and any other type must be reported as "disconnected". On Windows, the XInput only supports
Again, maybe we can enforce to only support On MacOS/iOS the button mapping can be changed on user settings:
That function is currently used by Gamepad package, so the user can map their gamepad on the OS itself, and some devices are already mapped (like Nintendo Switch). Actually, that is why that package only works on macOS 12+ and iOS 15+. On Android, I don't know, it have other issues. What I want is to add some way to get the device name. That is useful to show the correct icons, for instance show "X" instead of "A". Maybe it can be changed on the in-game settings, but could also be changed by the name of the device. If the name contains "XBOX" it will be "A", if the name contains "DualShock" it will show "X" icon. However, the gamepad package will always report as "A", that is just visual change. |
@inkeliz thanks for the in depth analysis on the mappings and potential uses. I guess we can swing back to the button mappings later... I just realised i forgot to send the logs to you.. I will try to do it today.. |
@whereswaldon, similar to Share Dialog, it's preferable to drop it from Gio-x? |
@inkeliz I'm more interested in this joining |
gamepad mapping file.
https://www.w3.org/TR/gamepad/#remapping
https://github.com/hajimehoshi/ebiten/blob/main/internal/gamepaddb/gamecontrollerdb.txt
:)
…On Thu, 10 Nov 2022 at 21:36, Chris Waldon ***@***.***> wrote:
@inkeliz <https://github.com/inkeliz> I'm more interested in this joining
x. I think it is likely that many people are using Gio for hobby gaming
projects, and I'd like a semi-official way for them to do that. It's also
smaller than share was (lines of code). I will try to review this soon,
but I'm not going to be able to test all permutations of controller and OS.
I have PS3 and Switch controllers, and I can test Linux, Windows, Android,
and WASM. I won't be able to verify correctness for XBox controllers, newer
PlayStation controllers, or on macOS. Are you willing to help with any bugs
for those permutations as they crop up?
—
Reply to this email directly, view it on GitHub
<#8 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AMVPLFD43D3SYMA5RT4QTGTWHVMDFANCNFSM5KYBN3ZA>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Yes.🙂 The only point that I don't remember is the Android. I need to revisit and check what is required to implement Android. |
Related to mapping, @gedw99, this file seems to be related to SDL2/GLFW. This package (and Gio) doesn't use SDL/GLFW. I think Ebiten uses GLFW (at least in the past, I'm not sure currently). Honestly, I'm not sure how we can use that, and if that is (so) important. You can always re-map the gamepad externally to the package. Some OSes (MacOS/iOS) allows the user to customize the gamepad layout and also seems to detect it. On WASM it have only one layout: "There is currently one canonical layout, the Standard Gamepad" (https://www.w3.org/TR/gamepad/#remapping). I think exists another mapping for VR/AR controller, but that is part of XR API. |
Oh I did not realise there is only on mapping for XR ! XR is something I have been pondering about too :) Great stuff |
Would be cool if we get this to the point of a basic demo. |
If you are looking for some basic demo, its parked at gioui/gio-example#3. That can be broken now, due to changes in gio-x/gio. In order to remap you can use |
Thanks @inkeliz will try it out tomorrow.. |
Hey all, I never got a try this out and work on it or the example at gioui/gio-example#3 @whereswaldon thats exactly what i am thinking too. Lots of devs playing around with self made games etc. |
@inkeliz I'm very sorry for the multi-year PR. I've found it extremely difficult (as a new parent) to make time to test this since it involves lots of hardware permutations, and I honestly don't see that changing in the short term. As such, I don't think I can accept it into
Which path would you like to pursue? |
Support gamepad for Windows, macOS, iOS and JS.
Signed-off-by: Inkeliz inkeliz@inkeliz.com