Skip to contentSkip to conversation

input: add support for SEGA Dreamcast controller as joystick

PATCH In review Adrian McMenamin 3 participants 4 messages May 18, 2008 – Jun 15, 2008

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 input: add support for SEGA Dreamcast controller as joystick

Use a Maple controller as a joystick device.

---

drivers/input/joystick/Kconfig +13 -0
diff -ruN a/drivers/input/joystick/Kconfig b/drivers/input/joystick/Kconfig
@@ -294,4 +294,17 @@
 	  This option enables support for the LED which surrounds the Big X on
 	  XBox 360 controller.
 
+config JOYSTICK_MAPLE
+	tristate "Dreamcast control pad"
+	depends on SH_DREAMCAST
+	select MAPLE
+	help
+	  Say Y here if you have a SEGA Dreamcast and want to use your
+	  controller.
+
+	  Most Dreamcast users will say Y.
+
+	  To compile this as a module choose M here: the
+	  module will be called maplecontrol.
+
 endif
drivers/input/joystick/Makefile +1 -0
diff -ruN a/drivers/input/joystick/Makefile b/drivers/input/joystick/Makefile
@@ -19,6 +19,7 @@
 obj-$(CONFIG_JOYSTICK_INTERACT)		+= interact.o
 obj-$(CONFIG_JOYSTICK_JOYDUMP)		+= joydump.o
 obj-$(CONFIG_JOYSTICK_MAGELLAN)		+= magellan.o
+obj-$(CONFIG_JOYSTICK_MAPLE)		+= maplecontrol.o
 obj-$(CONFIG_JOYSTICK_SIDEWINDER)	+= sidewinder.o
 obj-$(CONFIG_JOYSTICK_SPACEBALL)	+= spaceball.o
 obj-$(CONFIG_JOYSTICK_SPACEORB)		+= spaceorb.o
drivers/input/joystick/maplecontrol.c +217 -0

217 lines not on this page · raw message

#1 lore raw

drivers/input/joystick/maplecontrol.c line 21

Quoted 4 lines · Adrian McMenamin
drivers/input/joystick/maplecontrol.c +4 -0
+MODULE_AUTHOR("YAEGASHI Takeshi <[email protected]>");
+MODULE_DESCRIPTION("SEGA Dreamcast controller driver");
+MODULE_LICENSE("GPL");
+

MODULE_AUTHOR() is a bit ambiguous here. As this is user-visible by way of modinfo, it really doesn't make any sense to list someone who has nothing to do with the driver in its present form here. Especially since it's been 7 years since their last contribution or even basic list activity, I think it's safe to say that you are going to be the only one that users wish to contact about this.

In this case, the copyright should suffice. You may wish to add a bit of a note there indicating where the driver came from, but there's not much point in going beyond that.

Note that if you aren't comfortable with being in MODULE_AUTHOR(), you can also make this more generic and attribute it to the LinuxDC or Linux/SH teams respectively, as that's a bit more true to form as far as all copyright holders are concerned, and gives people a pointer to a list to go to with problems.

It's probably more reasonable to treat MODULE_AUTHOR() as MODULE_MAINTAINER() rather than the literal original author, as the latter is of zero interest or relevance to users that are looking at this information on the other side of the fence.

drivers/input/joystick/maplecontrol.c line 26

Quoted 5 lines
drivers/input/joystick/maplecontrol.c +5 -0
+struct dc_pad {
+	struct input_dev *dev;
+	struct maple_device *mdev;
+};
+

This is pretty ugly, you should really fix up your private device pointer layering to get around having to use this structure at all.

drivers/input/joystick/maplecontrol.c line 200

Quoted 6 lines
drivers/input/joystick/maplecontrol.c +6 -0
+static struct maple_driver dc_pad_driver = {
+	.function =	MAPLE_FUNC_CONTROLLER,
+	.connect =	dc_pad_connect,
+	.disconnect =	dc_pad_disconnect,
+	.drv = {
+		.name = "Dreamcast_controller",

Is there some particular reason why the driver name can't reflect the module name? There's no reason to have such sickeningly verbose driver names.

drivers/input/joystick/maplecontrol.c line 205

Quoted 5 lines
drivers/input/joystick/maplecontrol.c +5 -0
+		.probe = probe_maple_controller,
+		.remove = remove_maple_controller,
+	},
+};
+

These should be __devinit/__devexit at least, with the latter being __devexit_p() wrapped..

drivers/input/joystick/maplecontrol.c line 215

Quoted 10 lines
drivers/input/joystick/maplecontrol.c +10 -0
+static int __init dc_pad_init(void)
+{
+	return 	maple_driver_register(&dc_pad_driver.drv);
+}
+
+static void __exit dc_pad_exit(void)
+{
+	driver_unregister(&dc_pad_driver.drv);
+}
+

If you don't have a maple_driver_unregister(), stub one in, even if it's just a wrapper.

maintainer
#2 lore raw
Quoted 46 lines · Paul Mundt

drivers/input/joystick/maplecontrol.c line 21

Quoted 4 lines · Adrian McMenamin
drivers/input/joystick/maplecontrol.c +4 -0
+MODULE_AUTHOR("YAEGASHI Takeshi <[email protected]>");
+MODULE_DESCRIPTION("SEGA Dreamcast controller driver");
+MODULE_LICENSE("GPL");
+

MODULE_AUTHOR() is a bit ambiguous here. As this is user-visible by way of modinfo, it really doesn't make any sense to list someone who has nothing to do with the driver in its present form here. Especially since it's been 7 years since their last contribution or even basic list activity, I think it's safe to say that you are going to be the only one that users wish to contact about this.

In this case, the copyright should suffice. You may wish to add a bit of a note there indicating where the driver came from, but there's not much point in going beyond that.

Note that if you aren't comfortable with being in MODULE_AUTHOR(), you can also make this more generic and attribute it to the LinuxDC or Linux/SH teams respectively, as that's a bit more true to form as far as all copyright holders are concerned, and gives people a pointer to a list to go to with problems.

It's probably more reasonable to treat MODULE_AUTHOR() as MODULE_MAINTAINER() rather than the literal original author, as the latter is of zero interest or relevance to users that are looking at this information on the other side of the fence.

drivers/input/joystick/maplecontrol.c line 26

Quoted 5 lines
drivers/input/joystick/maplecontrol.c +5 -0
+struct dc_pad {
+	struct input_dev *dev;
+	struct maple_device *mdev;
+};
+

This is pretty ugly, you should really fix up your private device pointer layering to get around having to use this structure at all.

drivers/input/joystick/maplecontrol.c line 200

Quoted 6 lines
drivers/input/joystick/maplecontrol.c +6 -0
+static struct maple_driver dc_pad_driver = {
+	.function =	MAPLE_FUNC_CONTROLLER,
+	.connect =	dc_pad_connect,
+	.disconnect =	dc_pad_disconnect,
+	.drv = {
+		.name = "Dreamcast_controller",

Is there some particular reason why the driver name can't reflect the module name? There's no reason to have such sickeningly verbose driver names.

Quoted 8 lines

drivers/input/joystick/maplecontrol.c line 205

Quoted 5 lines
drivers/input/joystick/maplecontrol.c +5 -0
+		.probe = probe_maple_controller,
+		.remove = remove_maple_controller,
+	},
+};
+

These should be __devinit/__devexit at least, with the latter being __devexit_p() wrapped..

In addition to Pauls comments - is there a reson why maple drivers need to brovide both connect/disconnect and probe/remove functions? Normally the layer has generic probe/remove defined on bus level and individual drivers provide connect/disconnect (or their equivalent) which is called from the bus's probe/remove.

Signature · 1 line
Dmitry
#3 lore raw
Quoted 7 lines · Dmitry Torokhov

In addition to Pauls comments - is there a reson why maple drivers need to brovide both connect/disconnect and probe/remove functions? Normally the layer has generic probe/remove defined on bus level and individual drivers provide connect/disconnect (or their equivalent) which is called from the bus's probe/remove.

Cruft from another era. I will try to clean all that up.