Skip to content

Commit

Permalink
- cleaned up hid-ids.h, we only need the Nintendo IDs.
Browse files Browse the repository at this point in the history
- made versioning more maintainable
- renamed README to README.md
- changed project name to hid-wiimote-plus to distinguish it from the original
- added version information to the module, to make it easier to identify if it's loaded
  • Loading branch information
dkosmari committed Mar 24, 2023
1 parent d3afd21 commit 0a1adb7
Show file tree
Hide file tree
Showing 11 changed files with 451 additions and 1,348 deletions.
11 changes: 11 additions & 0 deletions .hgignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
syntax: glob

*.cmd
*.ko
*.mod
*.mod.c
*.o
*.tar.gz
*~
Module.symvers
modules.order
339 changes: 339 additions & 0 deletions COPYING

Large diffs are not rendered by default.

35 changes: 24 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
PACKAGE := hid-wiimote
# this is used for packaging, to distinguish from the original
PACKAGE := hid-wiimote-plus

VERSION := 0.8.2
# this is used to name the module file, so it must match the original to override it
MODULE := hid-wiimote

VERSION := 0.8.3

DISTDIR := $(PACKAGE)-$(VERSION)

DISTFILES := \
dkms.conf \
99-wiimote.rules \
COPYING \
dkms.conf.in \
gamepad.rst \
hid-ids.h \
hid-wiimote-core.c \
Expand All @@ -14,8 +20,7 @@ DISTFILES := \
hid-wiimote.h \
Kbuild \
Makefile \
99-wiimote.rules \
README
README.md


KDIR ?= /lib/modules/$(shell uname -r)/build
Expand All @@ -28,7 +33,7 @@ SRCDIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))


default:
$(info Run `make install` or `make uninstall` as root.)
$(error Run `make install` or `make uninstall` as root.)


build:
Expand All @@ -39,6 +44,7 @@ clean:
$(info cleaning up)
make -C $(KDIR) M=$(SRCDIR) clean
$(RM) -r $(DISTDIR)
$(RM) dkms.conf


dist:
Expand All @@ -48,8 +54,8 @@ dist:
$(RM) -r $(DISTDIR)


install:
rm -rf $(SRCTREE)/$(PACKAGE)-$(VERSION)
install: dkms.conf
$(RM) -rf $(SRCTREE)/$(PACKAGE)-$(VERSION)
cp -r $(SRCDIR) $(SRCTREE)/$(PACKAGE)-$(VERSION)
-cp -r 99-wiimote.rules /etc/udev/rules.d/
dkms add -m $(PACKAGE) -v $(VERSION)
Expand All @@ -58,6 +64,13 @@ install:


uninstall:
rm -f /etc/udev/rules.d/99-wiimote.rules
dkms remove -m $(PACKAGE) -v $(VERSION) --all
rm -rf /usr/src/$(PACKAGE)-$(VERSION)
$(RM) /etc/udev/rules.d/99-wiimote.rules
-dkms remove -m $(PACKAGE) -v $(VERSION) --all
$(RM) -r /usr/src/$(PACKAGE)-$(VERSION)


dkms.conf: dkms.conf.in
sed -e "s/@PACKAGE@/$(PACKAGE)/g" \
-e "s/@VERSION@/$(VERSION)/g" \
-e "s/@MODULE@/$(MODULE)/g" \
$< > $@
62 changes: 0 additions & 62 deletions README

This file was deleted.

65 changes: 65 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
hid-wiimote-plus
================

This is a modification of the built-in Linux kernel module for Nintendo Wii remotes. It's
a drop-in replacement for the original module.


How is it different?
--------------------

1. The mapping from Wii remotes (and accessories) buttons and axes was modified to respect
the Linux kernel conventions, and behave like gamepads, instead of a mixture of gamepad
and keyboard. For convenience, [gamepad.rst](gamepad.rst) from the Linux docs is
included here.

- D-pad buttons are now mapped to `BTN_DPAD_*` events, instead of keyboard arrow keys.

- Buttons +/Start and -/Select are now mapped to `BTN_START and BTN_SELECT`.

- Face/action buttons are now mapped to east, south, north, west buttons.

2. Better battery status reporting, to make it interact more nicely with desktop
environments.

3. Memory allocation is done in the module's scope, so it's guaranteed to be released when
the module unloads.

4. Accelerometer and gyro devices register proper metadata
(`INPUT_PROP_ACCELEROMETER` and correct units.)

5. Sticks (Nunchuk and Classic Controller) don't invert the Y axis anymore. Positive
values mean "down."

6. Classic Controller Pro no longer reports analog shoulder buttons (L/R), only
the Classic Controller (not Pro) has them. Range for analog shoulder buttons
has been corrected from [-30,+30] to [0,+60].

7. Balance Board reports its sensors as HAT0X, HAT1X, HAT2X, HAT3X; that is,
four 1-D axes instead of two 2-D axes.

8. No more emulation of an analog stick through the d-pad.


How to install?
---------------

You will need the kernel development headers in your system. Additionally, you will need
the DKMS package; it allows for easy install and uninstall, and will automatically rebuild
the module when the kernel is updated.

Use the commands:

sudo make install

To uninstall, use:

sudo make uninstall


If you just want to test it, without installing it, use these commands instead:

make build
sudo rmmod hid-wiimote
sudo insmod ./hid-wiimote.ko

8 changes: 4 additions & 4 deletions dkms.conf → dkms.conf.in
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# config for dkms
PACKAGE_NAME="hid-wiimote"
PACKAGE_VERSION="0.7"
BUILT_MODULE_NAME[0]="hid-wiimote"
PACKAGE_NAME="@PACKAGE@"
PACKAGE_VERSION="@VERSION@"
BUILT_MODULE_NAME[0]="@MODULE@"
DEST_MODULE_LOCATION="/kernel/drivers/hid"
MODULES_CONF_OBSOLETES[0]="hid-wiimote"
MODULES_CONF_OBSOLETES[0]="@MODULE@"
AUTOINSTALL="yes"
MAKE[0]="make build KDIR=${kernel_source_dir} SRCTREE=${source_tree}"
Loading

0 comments on commit 0a1adb7

Please sign in to comment.