After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 782611 - gamepad: Simplify the gamepad system
gamepad: Simplify the gamepad system
Status: RESOLVED FIXED
Product: gnome-games
Classification: Core
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: GNOME Games maintainers
GNOME Games maintainers
Depends on:
Blocks:
 
 
Reported: 2017-05-14 06:26 UTC by Adrien Plazas
Modified: 2017-08-14 07:32 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
event: Add Event (8.00 KB, patch)
2017-05-14 10:19 UTC, Adrien Plazas
committed Details | Review
gamepad: Add the 'event' signal to RawGamepad (2.24 KB, patch)
2017-05-14 10:19 UTC, Adrien Plazas
committed Details | Review
gamepad: Make LinuxrawGamepad emit the 'event' signal (3.12 KB, patch)
2017-05-14 10:19 UTC, Adrien Plazas
committed Details | Review
gamepad: Add the 'event' signal to Gamepad (2.10 KB, patch)
2017-05-14 10:19 UTC, Adrien Plazas
committed Details | Review
gamepad: Handle 'event' signal from RawGamepad (8.70 KB, patch)
2017-05-14 10:19 UTC, Adrien Plazas
committed Details | Review
gamepad: Stop emitting specific gamepad events (4.62 KB, patch)
2017-05-14 10:19 UTC, Adrien Plazas
committed Details | Review
gamepad: Remove specific gamepad event signals (4.89 KB, patch)
2017-05-14 10:19 UTC, Adrien Plazas
committed Details | Review
event: Add linux/input-event-codes.h (27.01 KB, patch)
2017-05-14 10:20 UTC, Adrien Plazas
committed Details | Review
gamepad: Map the input types to Linux event codes (5.39 KB, patch)
2017-05-14 10:20 UTC, Adrien Plazas
committed Details | Review
gamepad: Drop usage of StandardGamepadButton in Vala (4.58 KB, patch)
2017-05-14 10:20 UTC, Adrien Plazas
committed Details | Review
gamepad: Drop usage of StandardGamepadAxis in Vala (3.83 KB, patch)
2017-05-14 10:20 UTC, Adrien Plazas
committed Details | Review
gamepad: Remove custom types (24.53 KB, patch)
2017-05-14 10:20 UTC, Adrien Plazas
committed Details | Review
gamepad: Rename GamepadMappedEvent into GamepadInput (11.68 KB, patch)
2017-05-14 10:20 UTC, Adrien Plazas
committed Details | Review
gamepad: Merge GamepadInput and input_t (8.13 KB, patch)
2017-05-14 10:20 UTC, Adrien Plazas
committed Details | Review
gamepad: Simplify mapping destination parsing (6.07 KB, patch)
2017-05-14 10:20 UTC, Adrien Plazas
committed Details | Review
gamepad: Make names clear in GamepadMapping (11.40 KB, patch)
2017-05-14 10:20 UTC, Adrien Plazas
committed Details | Review
gamepad: Make gamepad emit Event objects (13.90 KB, patch)
2017-05-14 10:20 UTC, Adrien Plazas
committed Details | Review
event: Allow to keep hardware info (7.50 KB, patch)
2017-05-15 08:45 UTC, Adrien Plazas
none Details | Review
event: Allow to keep hardware info (7.59 KB, patch)
2017-05-15 09:44 UTC, Adrien Plazas
none Details | Review
event: Allow to keep hardware info (10.58 KB, patch)
2017-05-24 17:49 UTC, Adrien Plazas
committed Details | Review
gamepad: Use GamepadInput in GamepadDPad (1.96 KB, patch)
2017-05-24 17:55 UTC, Adrien Plazas
committed Details | Review

Description Adrien Plazas 2017-05-14 06:26:11 UTC
The gamepad system is quite complex for the  moment:
- it has its own custom types, requiring conversion from the native code type
- gamepad events are poorly defined
- the gamepad's GUID can't be accessed from the Gamepad class
- the hardware events can't be accessed from the Gamepad class
- the mapping of a gamepad can't be directly edited
- the code of the Mapping class is somewhat hard to read
- the distinction between Gamepad and RawGamepad is somewhat artificial\

Because of all that I suggest to refactor the gamepad system to make it simpler.
Comment 1 Adrien Plazas 2017-05-14 10:19:14 UTC
Created attachment 351811 [details] [review]
event: Add Event

This will be used to propagate gamepad events and to replace the current
gamepad event system by a simpler one.
Comment 2 Adrien Plazas 2017-05-14 10:19:20 UTC
Created attachment 351812 [details] [review]
gamepad: Add the 'event' signal to RawGamepad

This will be used to propagate gamepad events in a simpler way.
Comment 3 Adrien Plazas 2017-05-14 10:19:26 UTC
Created attachment 351813 [details] [review]
gamepad: Make LinuxrawGamepad emit the 'event' signal

This will be used to propagate gamepad events in a simpler way.
Comment 4 Adrien Plazas 2017-05-14 10:19:33 UTC
Created attachment 351814 [details] [review]
gamepad: Add the 'event' signal to Gamepad

This will be used to propagate gamepad events from the raw gamepad.
Comment 5 Adrien Plazas 2017-05-14 10:19:39 UTC
Created attachment 351815 [details] [review]
gamepad: Handle 'event' signal from RawGamepad

Make the Gamepad class handle the 'event' signal from RawGamepad instead
of any other event signal from it.

This will be used to propagate gamepad events in a simpler way.
Comment 6 Adrien Plazas 2017-05-14 10:19:46 UTC
Created attachment 351816 [details] [review]
gamepad: Stop emitting specific gamepad events

Don't emit any '*-event' signal so 'event' is the only signal emitting
gamepad events as they are not listend to anymore.
Comment 7 Adrien Plazas 2017-05-14 10:19:52 UTC
Created attachment 351817 [details] [review]
gamepad: Remove specific gamepad event signals

Drop the '*-event' signals as they are neither listened nor emitted.
Comment 8 Adrien Plazas 2017-05-14 10:20:00 UTC
Created attachment 351818 [details] [review]
event: Add linux/input-event-codes.h

This will allow to use the Linux input event codes in non-Linux
dependent parts of the code to standardize on the Linux input codes
instead of our custom values.
Comment 9 Adrien Plazas 2017-05-14 10:20:06 UTC
Created attachment 351819 [details] [review]
gamepad: Map the input types to Linux event codes

This will help transitionning from the custom input types to Linux event
codes.
Comment 10 Adrien Plazas 2017-05-14 10:20:13 UTC
Created attachment 351820 [details] [review]
gamepad: Drop usage of StandardGamepadButton in Vala
Comment 11 Adrien Plazas 2017-05-14 10:20:19 UTC
Created attachment 351821 [details] [review]
gamepad: Drop usage of StandardGamepadAxis in Vala
Comment 12 Adrien Plazas 2017-05-14 10:20:25 UTC
Created attachment 351822 [details] [review]
gamepad: Remove custom types

Remove StandardGamepadButton, StandardGamepadAxis and GamepadInputType
and directly use the corresponding Linux event types and codes.
Comment 13 Adrien Plazas 2017-05-14 10:20:32 UTC
Created attachment 351823 [details] [review]
gamepad: Rename GamepadMappedEvent into GamepadInput

This better reflect the goal of the type and make it shorter.
Comment 14 Adrien Plazas 2017-05-14 10:20:38 UTC
Created attachment 351824 [details] [review]
gamepad: Merge GamepadInput and input_t

As event codes use generic types now there is no need to have two fields
to distinguish their types in GamepadInput. Merging the various type
specific values make GamepadInput similar to input_t, the later can then
be replaced.
Comment 15 Adrien Plazas 2017-05-14 10:20:45 UTC
Created attachment 351825 [details] [review]
gamepad: Simplify mapping destination parsing

Replace parse_input_type(), parse_axis() and parse_button() by the new
parse_destination() function, making parsing the destination of the
mapping simpler.
Comment 16 Adrien Plazas 2017-05-14 10:20:52 UTC
Created attachment 351826 [details] [review]
gamepad: Make names clear in GamepadMapping

Rename some variables and functions in the GamepadMapping class to make
a better distinction between the input source and the destionation it
maps to.
Comment 17 Adrien Plazas 2017-05-14 10:20:59 UTC
Created attachment 351827 [details] [review]
gamepad: Make gamepad emit Event objects

Replace the 'button-event' and 'axis-event' signals from Gamepad by the
'button-press-event', 'button-release-event', 'axis-event' and
'hat-event' ones sending Event objects after mapping them is the Gamepad
object has a mapping, or directly if it doesn't.
Comment 18 Abhinav Singh 2017-05-14 14:40:13 UTC
Review of attachment 351811 [details] [review]:

Tried my best :P

::: src/event/event.c
@@ +22,3 @@
+  g_return_val_if_fail (self, NULL);
+
+  copy = games_event_new ();

copy is probably missing a memset?
Comment 19 Adrien Plazas 2017-05-14 17:03:39 UTC
Review of attachment 351811 [details] [review]:

::: src/event/event.c
@@ +22,3 @@
+  g_return_val_if_fail (self, NULL);
+
+  copy = games_event_new ();

Probably more a memcpy, good catch. :)
Comment 20 Adrien Plazas 2017-05-14 17:05:53 UTC
Attachment 351811 [details] pushed as f602e51 - event: Add Event
Attachment 351812 [details] pushed as 49659f1 - gamepad: Add the 'event' signal to RawGamepad
Attachment 351813 [details] pushed as fb85071 - gamepad: Make LinuxrawGamepad emit the 'event' signal
Attachment 351814 [details] pushed as ae3f974 - gamepad: Add the 'event' signal to Gamepad
Attachment 351815 [details] pushed as 4df760b - gamepad: Handle 'event' signal from RawGamepad
Attachment 351816 [details] pushed as 718d7aa - gamepad: Stop emitting specific gamepad events
Attachment 351817 [details] pushed as df3ff58 - gamepad: Remove specific gamepad event signals
Attachment 351818 [details] pushed as 7f7c0df - event: Add linux/input-event-codes.h
Attachment 351819 [details] pushed as 8af72d7 - gamepad: Map the input types to Linux event codes
Attachment 351820 [details] pushed as 03b5f73 - gamepad: Drop usage of StandardGamepadButton in Vala
Attachment 351821 [details] pushed as 30104a2 - gamepad: Drop usage of StandardGamepadAxis in Vala
Attachment 351822 [details] pushed as 3ef5bcc - gamepad: Remove custom types
Attachment 351823 [details] pushed as 804fa2a - gamepad: Rename GamepadMappedEvent into GamepadInput
Attachment 351824 [details] pushed as fea45fa - gamepad: Merge GamepadInput and input_t
Attachment 351825 [details] pushed as 8553ebc - gamepad: Simplify mapping destination parsing
Attachment 351826 [details] pushed as 29d41cf - gamepad: Make names clear in GamepadMapping
Attachment 351827 [details] pushed as d942798 - gamepad: Make gamepad emit Event objects
Comment 21 Adrien Plazas 2017-05-14 17:08:29 UTC
Closed by accident: reopening.

The following points haven't been fixed:
- the gamepad's GUID can't be accessed from the Gamepad class
- the mapping of a gamepad can't be directly edited
- the distinction between Gamepad and RawGamepad is somewhat artificial
Comment 22 Adrien Plazas 2017-05-15 08:45:30 UTC
Created attachment 351870 [details] [review]
event: Allow to keep hardware info

Turn the 'index' field into 'hardware_index' and add fields containing
the code of the input related to the event.

Also remove the barely useful 'send_event' field.

This avoid loosing information related to the original hardware event,
whether the event is mapped or not.
Comment 23 Adrien Plazas 2017-05-15 09:44:59 UTC
Created attachment 351875 [details] [review]
event: Allow to keep hardware info

Turn the 'index' field into 'hardware_index' and add fields containing
the code of the input related to the event.

Also remove the barely useful 'send_event' field.

This avoid loosing information related to the original hardware event,
whether the event is mapped or not.
Comment 24 Adrien Plazas 2017-05-24 17:49:50 UTC
Created attachment 352516 [details] [review]
event: Allow to keep hardware info

Turn the 'index' field into 'hardware_index' and add fields containing
the code of the input related to the event.

Also remove the barely useful 'send_event' field.

This avoid loosing information related to the original hardware event,
whether the event is mapped or not.
Comment 25 Adrien Plazas 2017-05-24 17:55:04 UTC
Created attachment 352522 [details] [review]
gamepad: Use GamepadInput in GamepadDPad

This makes the code simpler.
Comment 26 Adrien Plazas 2017-05-24 17:55:42 UTC
Attachment 352516 [details] pushed as 488180f - event: Allow to keep hardware info
Attachment 352522 [details] pushed as 2dc64b7 - gamepad: Use GamepadInput in GamepadDPad