Author Topic: How to detect scroll direction?  (Read 6158 times)

playerzero

  • Jr. Member
  • **
  • Posts: 15
    • View Profile
How to detect scroll direction?
« on: May 23, 2015, 11:19:19 PM »
Hi everyone.
I'm trying to improve my layout design, using Liquid's (experimental) animate module, but I need to be able to detect the direction someone moves through the list (ie; up or down).
Can anyone point me in the right direction?

omegaman

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 880
    • View Profile
Re: How to detect scroll direction?
« Reply #1 on: May 24, 2015, 06:11:55 AM »
playerzero-

Here is the link and example below:

https://github.com/mickelson/attract/blob/v1.5.0/Layouts.md

fe.get_input_state( input_id )
Check if a specific keyboard key, mouse button, joystick button or joystick direction is currently pressed, or check if any input mapped to a particular frontend action is pressed.

Parameter:

input_id - [string] the input to test. This can be a string in the same format as used in the attract.cfg file for input mappings. For example, "LControl" will check the left control key, "Joy0 Up" will check the up direction on the first joystick, "Mouse MiddleButton" will check the middle mouse button, and "select" will check for any input mapped to the game select button...

Note that mouse moves and mouse wheel movements are not available through this function.

Return Value:

true if input is pressed, false otherwise.

fe.get_input_pos()

fe.get_input_pos( input_id )
Return the current position for the specified joystick axis.

Parameter:

input_id - [string] the input to test. The format of this string is the same as that used in the attract.cfg file. For example, "Joy0 Up" is the up direction on the first joystick.
Return Value:

Current position of the specified axis, in range [0..100].

fe.signal()

fe.signal( signal_str )
Signal that a particular frontend action should occur.

Parameters:

signal_str - the action to signal for. Can be one of the following strings:
"select"
"up"
"down"
"page_up"
"page_down"
"prev_list"
"next_list"
"lists_menu"
"prev_filter"
"next_filter"
"filters_menu"
"toggle_layout"
"toggle_movie"
"toggle_mute"
"toggle_rotate_right"
"toggle_flip"
"toggle_rotate_left"
"exit"
"exit_no_menu"
"screenshot"
"configure"
"random_game"
"replay_last_game"
"add_favourite"
"prev_favourite"
"next_favourite"
"add_tags"
"screen_saver"
"prev_letter"
"next_letter"
"reset_window"
Return Value:

None.

raygun

  • Administrator
  • Sr. Member
  • *****
  • Posts: 393
    • View Profile
Re: How to detect scroll direction?
« Reply #2 on: May 24, 2015, 09:08:48 AM »
Another approach would be to add a transition callback function to your layout, and check for "ToNewSelection" transitions.  The "var" parameter is negative if navigating back in the list, and positive if navigating forward.

reference: https://github.com/mickelson/attract/blob/master/Layouts.md#add_transition_callback

playerzero

  • Jr. Member
  • **
  • Posts: 15
    • View Profile
Re: How to detect scroll direction?
« Reply #3 on: May 24, 2015, 04:08:36 PM »
Thanks so much for replying comprehensively like this raygun.

Yes I was messing with getinput state for a while, but didn't know the parameters to use.

Also, AM is easily the best fe I've tried, and I've been searching for a while. Thanks for your great work.