Skip to content
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

Highlight key being pressed when not in mapping mode #6

Open
Timecraft opened this issue Feb 27, 2020 · 46 comments
Open

Highlight key being pressed when not in mapping mode #6

Timecraft opened this issue Feb 27, 2020 · 46 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@Timecraft
Copy link
Owner

Timecraft commented Feb 27, 2020

Another thing is that in Games we use the same view for testing gamepad by highlighing a key when you press it if you're not in mapping mode. That could be handy here as well.

Originally posted by @Exalm in #4 (comment)

@Timecraft Timecraft added enhancement New feature or request help wanted Extra attention is needed labels Feb 27, 2020
@alice-mkh
Copy link
Contributor

Note that you can't do the "have an svg for every key" trick here, as you can press multiple keys at once. :p

@alice-mkh
Copy link
Contributor

in Games we use a drawing area + render the svg via librsvg. First just render it, then for every pressed button { take its corresponding svg element, and render it masking with another color }.

@Timecraft
Copy link
Owner Author

Note that you can't do the "have an svg for every key" trick here, as you can press multiple keys at once. :p

Yeah, that makes it quite a bit more difficult

@Timecraft
Copy link
Owner Author

in Games we use a drawing area + render the svg via librsvg. First just render it, then for every pressed button { take its corresponding svg element, and render it masking with another color }.

I noticed that there was only one gamepad SVG file in Games. Wasn’t sure how you guys worked with it to highlight buttons. I’ve seen librsvg on the valadoc website, but haven’t gotten an excuse to really look into it. Now I do!

@Timecraft
Copy link
Owner Author

This is mostly working as of right now. Issues being seen:

  • No directions on analog sticks (don't know how to do that properly)
  • Trying to trigger/show ABS_X or ABS_RY does not work
  • Pressing "Home" triggers ABS_X
  • Using ABS_RY triggers "Home"
  • Using ABS_RX triggers ABS_RY
  • Using ABS_Y triggers ABS_RX
  • Using ABS_X triggers ABS_Y

@alice-mkh
Copy link
Contributor

No directions on analog sticks (don't know how to do that properly)

You could e.g. show a circle with an offset matching the position. Games simply highlights the sides, like here:
Screenshot from 2020-03-04 03-26-18

Other things are probably you messing up ids, it's way too specific :p

@alice-mkh
Copy link
Contributor

HighlightId button_middle_right = {"#button_middle_right" , false}; // Select

Typo: // Start

@Timecraft
Copy link
Owner Author

Typo: // Start

Whoops!

@alice-mkh
Copy link
Contributor

alice-mkh commented Mar 3, 2020

So, why analogs are not working well:

highlight ({ EventCode.EV_ABS, axis }, !(-0.8 < value < 0.8))

What if X axis changed to 0.9 and then Y axis changed to 0.1? highlight (..., false);!

You should either track status of both or change how it's displayed not to use the same element.

@alice-mkh
Copy link
Contributor

But given you already have a circle when mapping, I'd suggest to move it around according to the axis position and make it red when you press it.

@alice-mkh
Copy link
Contributor

Also, highlight() has a completely unnecessary O(N) loop, though I suppose Games does this too right now. 😬️

And read_svg() is unused and probably can be simplified (I recently discovered you can cast bytes to a string, but here you should probably just load from resource directly)

@Timecraft
Copy link
Owner Author

Other things are probably you messing up ids, it's way too specific :p

I don't think so. I'm looking at the SVG Id's and the order of the HighlightId's, and they match.

HighlightId INPUT_SOURCES
button_east { { EventCode.EV_KEY, EventCode.BTN_B }, "a" },
button_south { { EventCode.EV_KEY, EventCode.BTN_A }, "b" },
button_north { { EventCode.EV_KEY, EventCode.BTN_X }, "x"},
button_west { { EventCode.EV_KEY, EventCode.BTN_Y }, "y" },
dpad_up { { EventCode.EV_KEY, EventCode.BTN_DPAD_UP }, "dpup" },
dpad_down { { EventCode.EV_KEY, EventCode.BTN_DPAD_DOWN }, "dpdown" },
dpad_left { { EventCode.EV_KEY, EventCode.BTN_DPAD_LEFT }, "dpleft" },
dpad_right { { EventCode.EV_KEY, EventCode.BTN_DPAD_RIGHT }, "dpright" },
left_bumper { { EventCode.EV_KEY, EventCode.BTN_TL }, "leftshoulder" },
left_trigger { { EventCode.EV_KEY, EventCode.BTN_TL2 }, "lefttrigger" },
left_stick { { EventCode.EV_KEY, EventCode.BTN_THUMBL }, "leftstick" },
button_middle_left { { EventCode.EV_KEY, EventCode.BTN_SELECT }, "back" },
right_bumper { { EventCode.EV_KEY, EventCode.BTN_TR }, "rightshoulder" },
right_trigger { { EventCode.EV_KEY, EventCode.BTN_TR2 }, "righttrigger" },
right_stick { { EventCode.EV_KEY, EventCode.BTN_THUMBR }, "rightstick" },
button_middle_right { { EventCode.EV_KEY, EventCode.BTN_START }, "start" },
button_middle { { EventCode.EV_KEY, EventCode.BTN_MODE }, "guide" },
stick_left_analog { { EventCode.EV_ABS, EventCode.ABS_X }, "leftx" },
stick_left_analog { { EventCode.EV_ABS, EventCode.ABS_Y }, "lefty" },
stick_right_analog { { EventCode.EV_ABS, EventCode.ABS_RX }, "rightx" },
stick_right_analog { { EventCode.EV_ABS, EventCode.ABS_RY }, "righty" },

@alice-mkh
Copy link
Contributor

Do you seriously have a button that says "Press Escape" and can't be clicked? 🤣️

The reason home button is not working is because it's not mapped correctly.

@Timecraft
Copy link
Owner Author

And read_svg() is unused

Hence why it's commented out. I should remove that, though

@Timecraft
Copy link
Owner Author

Do you seriously have a button that says "Press Escape" and can't be clicked? 🤣

...It can't be clicked?

@alice-mkh
Copy link
Contributor

Wait, it can? Then there's a bug somewhere.

@Timecraft
Copy link
Owner Author

...It can't be clicked?

The button can be clicked

@alice-mkh
Copy link
Contributor

Aha, if you try to set up a controller again without closing the window, it doesn't work.

@alice-mkh
Copy link
Contributor

And I can't figure out how to map analog sticks, or it's bugged.

@alice-mkh
Copy link
Contributor

The reason home button is not working is because it's not mapped correctly.

Checked with a mapping from Games, that's what it is indeed.

@Timecraft
Copy link
Owner Author

And I can't figure out how to map analog sticks, or it's bugged.

If you're referring to it not showing you which direction to go, yeah, that's what I was meaning:

No directions on analog sticks (don't know how to do that properly)

@Timecraft
Copy link
Owner Author

Checked with a mapping from Games, that's what it is indeed.

This is a me issue?

@Timecraft
Copy link
Owner Author

But given you already have a circle when mapping, I'd suggest to move it around according to the axis position and make it red when you press it.

This is kinda what I was meaning when I was saying "I don't know how to do that properly." I'm not sure how to move that.

@alice-mkh
Copy link
Contributor

No directions on analog sticks (don't know how to do that properly)

Ah, ok.

Well, the easiest way is to split the stick indicators into 2, one for vertical and one for horizontal. But I think it would be better to move a circle.

@alice-mkh
Copy link
Contributor

I'm not sure how to move that.

cr.translate()?

@Timecraft
Copy link
Owner Author

cr.translate()?

Would that not translate the entire context?

@alice-mkh
Copy link
Contributor

This is a me issue?

Yes. I mean it's working with a mapping produced in Games, so you don't produce a correct mapping. :)

@Timecraft
Copy link
Owner Author

Yes. I mean it's working with a mapping produced in Games, so you don't produce a correct mapping. :)

Oh fun. I'll have to see what's going on there, then

@alice-mkh
Copy link
Contributor

Would that not translate the entire context?

cr.push ();
cr.translate (...);
...
cr.pop ();

@alice-mkh
Copy link
Contributor

Would that not translate the entire context?

cr.push ();
cr.translate (...);
...
cr.pop ();

Actually not even that. You already have push_group(), so it should just work for you if you translate between that and pop_group().

@Timecraft
Copy link
Owner Author

cr.push ();
cr.translate (...);
...
cr.pop ();

Oh, duh. That's the reason why it doesn't make the entire thing red 🤦‍♂️

@Timecraft
Copy link
Owner Author

Timecraft commented Mar 3, 2020

Screenshot from 2020-03-03 17-52-28

.... oooooooooooooooh.....
Because I set mode last

@Timecraft
Copy link
Owner Author

For my own notes:

  • Home is triggering ABS_X due to Home being mapped after it should be.
    • Fixing this should fix the rest of the axis issues.
  • To show the analog directions, translate that context between push_group () and pop_group ()

@Timecraft
Copy link
Owner Author

Once I get that last part done, I should be able to remove all of those extra SVG files too!

@alice-mkh
Copy link
Contributor

I opened an issue to do the translation part in Games too, what we do currently is pretty lame.

@Timecraft
Copy link
Owner Author

Think I've got this done. It's a little weird, as it shows a stick for each axis, but it works

@alice-mkh
Copy link
Contributor

@Timecraft
Copy link
Owner Author

It's hard for me to reimplement your code since I don't implement GamepadViewConfiguration, and therefore to not have access to configuration.analog_paths

@Timecraft
Copy link
Owner Author

Reopening this because those analog sticks are still way off

@Timecraft Timecraft reopened this Mar 4, 2020
@alice-mkh
Copy link
Contributor

Well, analog_paths are added in that MR in the first place. Just showing that it can be done really.

@Timecraft
Copy link
Owner Author

The earlier version I had (Where I was treating each analog direction independently) was fairly accurate, so I tried to use the offsets those were giving me to create an X and Y offset to make it more reflective of where the actual analog stick was. That created inaccuracies (pushing the analog stick directly left would not put the on-screen stick directly left)

@Timecraft
Copy link
Owner Author

No clue why if only one axis active it still shows the white circle in the middle, though

@alice-mkh
Copy link
Contributor

(pushing the analog stick directly left would not put the on-screen stick directly left)

🤣️

You are supposed to use those X and Y offsets directly, yes.

@Timecraft
Copy link
Owner Author

The current iteration tried to do things more efficiently, but ends up doing the same thing as the version where they are being dealt with independently. I think it has to do with:

        HighlightId stick_left_analog_x     =             {"#stick_left_analog"   ,       false, Direction.X, 0, 0}; // Left Analog Stick
        HighlightId stick_left_analog_y     =             {"#stick_left_analog"   ,       false, Direction.Y, 0, 0}; // Left Analog Stick
        HighlightId stick_right_analog_x    =             {"#stick_right_analog"  ,       false, Direction.X, 0, 0}; // Right Analog Stick
        HighlightId stick_right_analog_y    =             {"#stick_right_analog"  ,       false, Direction.Y, 0, 0}; // Right Analog Stick

I'm currently dealing with the analogs' x and y separately. However, if I simply comment out those regions, it doesn't help. I think there will need to be some refactoring of the code to get this to work right

@alice-mkh
Copy link
Contributor

Well yh, I did refactor my code a lot to do that.

@Timecraft
Copy link
Owner Author

Yeah, I feel like I'm going to just end up completely rewriting control_view.vala and control_window.vala to clean it up and try to fix #6, #9, #10, #11, #13, and #14

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants