indexing description: "[ Joystick hat event ]" date: "$Date$" revision: "$Revision$" class EM_JOYSTICK_HAT_EVENT inherit EM_EVENT redefine out, make, type end EM_JOYSTICK_HAT undefine out redefine out, value end create make feature {NONE} -- Initialization make (a_pointer: POINTER) is -- Create a joystick hat event. do Precursor (a_pointer) create sdl_joystick_hat_event_struct.make_shared (a_pointer) end -- /* Joystick hat position change event structure */ -- typedef struct SDL_JoyHatEvent { -- Uint8 type; /* SDL_JOYHATMOTION */ -- Uint8 which; /* The joystick device index */ -- Uint8 hat; /* The joystick hat index */ -- Uint8 value; /* The hat position value: -- SDL_HAT_LEFTUP SDL_HAT_UP SDL_HAT_RIGHTUP -- SDL_HAT_LEFT SDL_HAT_CENTERED SDL_HAT_RIGHT -- SDL_HAT_LEFTDOWN SDL_HAT_DOWN SDL_HAT_RIGHTDOWN -- Note that zero means the POV is centered. -- */ -- } SDL_JoyHatEvent; feature -- Queries type: INTEGER is -- Event type value -- (`em_key_down_event' or `em_key_up_event') do result := em_joystick_hat_event end is_device: INTEGER is -- From which joystick device did this event come? do result := sdl_joystick_hat_event_struct.which end is_hat: INTEGER is -- From which hat did this event come? do result := sdl_joystick_hat_event_struct.hat end value: INTEGER is -- return the current value of the respective hat -- in this event -- The value range is a INTEGER representing the hat's direction do result := sdl_joystick_hat_event_struct.value end feature -- Output out: STRING is -- Textual representation do result := "EM_JOYSTICK_HAT_EVENT" if is_hat_rightup then result := result + " rightup" elseif is_hat_rightdown then result := result + " rightdown" elseif is_hat_leftup then result := result + " leftup" elseif is_hat_leftdown then result := result + " leftdown" elseif is_hat_centered then result := result + " centered" elseif is_hat_up then result := result + " up" elseif is_hat_right then result := result + " right" elseif is_hat_down then result := result + " down" elseif is_hat_left then result := result + " left" end result := result + " (Hat #" + is_hat.out + ")" end feature {NONE} -- Implementation sdl_joystick_hat_event_struct: SDL_JOY_HAT_EVENT_STRUCT -- Wrapped struct containing informatiuon about the joystick event. invariant sdl_joystick_hat_event_struct_not_void: sdl_joystick_hat_event_struct /= Void end