Skip to content

Commit

Permalink
Merge branch 'master' into Windows_support
Browse files Browse the repository at this point in the history
  • Loading branch information
adangert committed May 14, 2019
2 parents c153d4e + 0e9246f commit 416a9f0
Show file tree
Hide file tree
Showing 40 changed files with 1,202 additions and 1,026 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.python_history
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
Expand Down
35 changes: 17 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ What is JoustMania????
Cool Stuffs!
--------------------------------------

* 16+ Player support
* 18+ Player support
* Super easy setup
* Runs in Headless mode, no screen required
* Optional web interface, view status and change game settings with your phone
Expand All @@ -25,7 +25,9 @@ Cool Stuffs!

Hardware
---------------------------
You will need the following to run JoustMania:
I am currently selling fully set up Joustmania devices (pi, case, bluetooth dongle, sd card) for $79 (or the $10 tier on [patreon](https://www.patreon.com/adangert)) with included shipping domestically. If you would like to inquire about purchasing a fully setup Joustmania device, please reach out to [email protected]

If you would like to build your own device you will need the following:

* A Raspberry Pi 3 B with sd card

Expand All @@ -34,17 +36,17 @@ Optional and **highly recommended**:
* Class 1, Bluetooth 4.0 USB adapters (http://a.co/8YKP9tG)

Note on Hardware: The internal bluetooth is short range and has a high latency, making gameplay laggy and slow, although still possible.
The class 1 adapters allow bluetooth connections up to 300+ feet and allow for the gameplay to be smooth, each adapter can connect to 6 to 7 controllers. I've tested this build with three adapters and 16 controllers successfully.
The class 1 adapters allow bluetooth connections up to 300+ feet and allow for the gameplay to be smooth, each adapter can connect to 6 to 7 controllers. I've tested this build with four adapters and 18 controllers successfully.

Optional:

* USB hub for charging controllers (http://a.co/7T3HDmJ)

This will allow you to charge 9 controllers at once through the pi

**Note: the new psmove controllers with a micro charging connection will not work with Joustmaina, this issue is being looked at with the psmoveapi(https://github.com/thp/psmoveapi/issues/353)**
A good power supply is recommended, (if you see a lightning bolt at the top right of your screen it means your pi is under voltage) Something like this should work well: (https://www.amazon.com/dp/B00L88M8TE)


For questions on hardware, or if you would like to inquire about purchasing a fully setup Joustmania device, please reach out to [email protected]

Installation
---------------------------
Expand All @@ -60,19 +62,12 @@ git clone https://github.com/adangert/JoustMania.git
cd JoustMania
sudo ./setup.sh
```
If you have the bluetooth adapters, disable the on-board bluetooth
```
sudo ./disable_internal_bluetooth.sh
```

You can now disconnect the hdmi cable and run JoustMania in headless mode. JoustMania will automatically boot up on restart, menu music should start playing once the pi boots up.

Update Joust Mania
---------------------------
You can update Joust Mania by doing a `git pull` in the main directory and running
```
./setup.sh
```

Joustmania will auto update when started and connected to the internet. Sometimes there is a large update, it will say so, then you can press the start and select buttons on a controller to start this update, wait until the pi reboots. If you have the AP enabled, you may need to disable it first to gain access to the internet.

Pairing controllers
---------------------------
Expand All @@ -93,8 +88,7 @@ If controllers seem to pair to only one Bluetooth adapter, it is likely that the
How to select a game mode
---------------------------------
* In order to change between games, on any controller press the select button (located on the left side of a controller)
* Changing game types will turn you into an Admin
* In order to remove a controller from play press all four front buttons
* In order to remove a controller from play, hold the playstation button to turn off the controller.

How to start a game
---------------------------------
Expand All @@ -103,7 +97,7 @@ How to start a game

Admin Mode (Sensitivity and convention mode settings)
---------------------------------
You can become an Admin by changing the game mode via the select button, this will allow you to modify the games settings from the four front buttons on the controller, After a game is played the Admin mode will be reset
You can become an Admin by pressing all four front buttons on any controller, this will allow you to modify the games settings from the four front buttons on the controller, After a game is played the Admin mode will be reset

* (Cross) Add or remove a game from Convention mode, your controller will be green if the game is added and Red if it is not, Custom Teams mode can not be added to the Convention mode
* (Circle) Change sensitivity of the game. There are three settings, slow, medium, and fast, you will hear a corresponding sound for each
Expand All @@ -116,7 +110,7 @@ Joustmania can also be controlled via a web browser on your laptop or smartphone
```
sudo ./enable_ap.sh
```
Note that this disables normal Wi-Fi on the Pi, but a wired connection will still work. The default SSID is "JOUSTMANIA" and the default password is "joustmania"; both (and other) settings may be adjusted in the apfiles/hostapd.conf file before running enable_ap.sh. To connect to the game, go to http://joust.mania in your web browser. To disable the access point and restore Wi-Fi, run the command
Note that this disables normal Wi-Fi on the Pi, the ethernet connection may not work either. The default SSID is "JOUSTMANIA" and the default password is "joustmania"; both (and other) settings may be adjusted in the apfiles/hostapd.conf file before running enable_ap.sh. To connect to the game, go to http://10.3.141.1/ in your web browser. To disable the access point and restore Wi-Fi, run the command
```
sudo ./disable_ap.sh
```
Expand Down Expand Up @@ -217,3 +211,8 @@ Custom Music
* This mode allows for multiple game types to be randomly rotated with instructions played before each game
* Random mode defaults to FFA, Random Teams, Werewolves, and Swapper, more game modes can be added or removed as an Admin or via the web interface (see above)
* Modes with an insufficient number of players will be ignored, if none are available Joust Free-for-All is selected

Support and funding
--------------------------
If you love this game you can support its development by helping out with my patreon here:
https://www.patreon.com/adangert
23 changes: 23 additions & 0 deletions apfiles/10-wpa_supplicant
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
if [ -z "$wpa_supplicant_conf" ]; then
for x in \
/etc/wpa_supplicant/wpa_supplicant-"$interface".conf \
/etc/wpa_supplicant/wpa_supplicant.conf \
/etc/wpa_supplicant-"$interface".conf \
/etc/wpa_supplicant.conf \
; do
if [ -s "$x" ]; then
wpa_supplicant_conf="$x"
break
fi
done
fi
: ${wpa_supplicant_conf:=/etc/wpa_supplicant.conf}

if [ "$ifwireless" = "1" ] && \
type wpa_supplicant >/dev/null 2>&1 && \
type wpa_cli >/dev/null 2>&1
then
if [ "$reason" = "IPV4LL" ]; then
wpa_supplicant -B -iwlan0 -f/var/log/wpa_supplicant.log -c/etc/wpa_supplicant/wpa_supplicant.conf
fi
fi
2 changes: 2 additions & 0 deletions apfiles/90-wireless.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ACTION=="add", SUBSYSTEM=="ieee80211", KERNEL=="phy0", \
RUN+="/sbin/iw phy %k interface add uap0 type __ap"
5 changes: 5 additions & 0 deletions apfiles/ap
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
allow-hotplug uap0
auto uap0
iface uap0 inet static
address 10.3.141.1
netmask 255.255.255.0
32 changes: 24 additions & 8 deletions apfiles/dnsmasq.conf
Original file line number Diff line number Diff line change
@@ -1,8 +1,24 @@
interface=wlan0 # Use interface wlan0
listen-address=172.24.1.1 # Explicitly specify the address to listen on
bind-interfaces # Bind to the interface to make sure we aren't sending things elsewhere
server=8.8.8.8 # Forward DNS requests to Google DNS
domain-needed # Don't forward short names
bogus-priv # Never forward addresses in the non-routed address spaces.
dhcp-range=172.24.1.50,172.24.1.150,12h # Assign IP addresses between 172.24.1.50 and 172.24.1.150 with a 12 hour lease time
address=/joust.mania/172.24.1.1
#interface=wlan0 # Use interface wlan0
#listen-address=172.24.1.1 # Explicitly specify the address to listen on
#bind-interfaces # Bind to the interface to make sure we aren't sending things elsewhere
#server=8.8.8.8 # Forward DNS requests to Google DNS
#domain-needed # Don't forward short names
#bogus-priv # Never forward addresses in the non-routed address spaces.
#dhcp-range=172.24.1.50,172.24.1.150,12h # Assign IP addresses between 172.24.1.50 and 172.24.1.150 with a 12 hour lease time
#address=/joust.mania/172.24.1.1

#interface=lo,uap0 # Use interface lo,uap0
#listen-address=172.24.1.1 # Explicitly specify the address to listen on
#no-dhcp-interface=lo,wlan0
#bind-interfaces # Bind to the interface to make sure we aren't sending things elsewhere
#server=8.8.8.8 # Forward DNS requests to Google DNS
#domain-needed # Don't forward short names
#bogus-priv # Never forward addresses in the non-routed address spaces.
#dhcp-range=172.24.1.50,172.24.1.150,12h # Assign IP addresses between 172.24.1.50 and 172.24.1.150 with a 12 hour lease time
#address=/joust.mania/172.24.1.1

interface=lo,uap0
no-dhcp-interface=lo,wlan0
bind-interfaces
server=8.8.8.8
dhcp-range=10.3.141.50,10.3.141.255,12h
46 changes: 32 additions & 14 deletions apfiles/hostapd.conf
Original file line number Diff line number Diff line change
@@ -1,44 +1,62 @@
# This is the name of the WiFi interface we configured above
interface=wlan0
#interface=uap0

# Use the nl80211 driver with the brcmfmac driver
driver=nl80211
#try this is might not work
#driver=nl80211

# This is the name of the network
ssid=JOUSTMANIA
#ssid=JOUSTMANIA

# Use the 2.4GHz band
hw_mode=g
#hw_mode=g

# Use channel 6
channel=6
#channel=6

# Enable 802.11n
ieee80211n=1
#try this, it might not work
#ieee80211n=1

# Enable WMM
wmm_enabled=1
#wmm_enabled=1

# Enable 40MHz channels with 20ns guard interval
ht_capab=[HT40][SHORT-GI-20][DSSS_CCK-40]
#ht_capab=[HT40][SHORT-GI-20][DSSS_CCK-40]

# Accept all MAC addresses
macaddr_acl=0
#macaddr_acl=0

# Use WPA authentication
auth_algs=1
#auth_algs=1

# Require clients to know the network name
ignore_broadcast_ssid=0
#ignore_broadcast_ssid=0

# Use WPA2
wpa=2
#wpa=2

# Use a pre-shared key
wpa_key_mgmt=WPA-PSK
#wpa_key_mgmt=WPA-PSK

# The network passphrase
wpa_passphrase=joustmania
#wpa_passphrase=joustmania

# Use AES, instead of TKIP
#rsn_pairwise=CCMP

#wpa_pairwise=TKIP


interface=uap0
ssid=JOUSTMANIA
hw_mode=g
channel=6
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=2
wpa_passphrase=joustmania
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP
40 changes: 27 additions & 13 deletions apfiles/interfaces
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,38 @@
# Please note that this file is written to be used with dhcpcd
# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'


allow-hotplug wlan0
auto wlan0
iface wlan0 inet dhcp
#wcp-conf /etc/wpa_supplicant/wpa_supplicant.conf


# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d

auto lo
iface lo inet loopback
#allow-hotplug wlan0
#iface wlan0 inet dhcp
# pre-up sleep 10
# wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

auto eth0
iface eth0 inet dhcp
#auto lo
#iface lo inet loopback

#auto eth0
#iface eth0 inet dhcp

#Access point for JoustMania
allow-hotplug wlan0
iface wlan0 inet static
address 172.24.1.1
netmask 255.255.255.0
network 172.24.1.0
broadcast 172.24.1.255
#allow-hotplug wlan0
#iface wlan0 inet static
# address 172.24.1.1
# netmask 255.255.255.0
# network 172.24.1.0
# broadcast 172.24.1.255

#this was already commented out
# wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

allow-hotplug wlan1
iface wlan1 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
#allow-hotplug wlan1
#iface wlan1 inet manual
# wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
14 changes: 14 additions & 0 deletions apfiles/rc.local
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,19 @@ fi

#Access point for JoustMania
iptables-restore < /etc/iptables.ipv4.nat
#hostapd /etc/hostapd/hostapd.conf

sleep 5
#ifdown wlan0

#sleep 2
#rm -f /var/run/wpa_supplicant/wlan0
#ifup wlan0
#iptables -t nat -A POSTROUTING -s 192.168.2.0/24 ! -d 192.168.2.0.0/24 -j MASQUERADE
#hostapd -B /etc/hostapd/hostapd.conf
#dnsmasq

hostapd -B /etc/hostapd/hostapd.conf
dnsmasq

exit 0
3 changes: 3 additions & 0 deletions apfiles/station
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
allow-hotplug wlan0
iface wlan0 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
Binary file added audio/Menu/added_random.wav
Binary file not shown.
Binary file added audio/Menu/high.wav
Binary file not shown.
Binary file modified audio/Menu/instructions_off.wav
Binary file not shown.
Binary file modified audio/Menu/instructions_on.wav
Binary file not shown.
Binary file added audio/Menu/joustmania_failed.wav
Binary file not shown.
Binary file added audio/Menu/joustmania_updated.wav
Binary file not shown.
Binary file added audio/Menu/large_update.wav
Binary file not shown.
Binary file added audio/Menu/low.wav
Binary file not shown.
Binary file added audio/Menu/medium.wav
Binary file not shown.
Binary file added audio/Menu/removed_random.wav
Binary file not shown.
Binary file added audio/Menu/ultra_high.wav
Binary file not shown.
Binary file added audio/Menu/ultra_low.wav
Binary file not shown.
Binary file added audio/Menu/update_started.wav
Binary file not shown.
35 changes: 23 additions & 12 deletions common.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,31 @@
SETTINGSFILE = 'joustsettings.yaml'

#Human speeds[slow, mid, fast]
SLOW_WARNING = [0.1, 0.15, 0.28]
SLOW_MAX = [0.25, 0.8, 1]
FAST_WARNING = [0.5, 0.6, 0.8]
FAST_MAX = [1, 1.4, 1.8]

#SLOW_WARNING = [0.1, 0.15, 0.28]
#SLOW_MAX = [0.5, 0.8, 1]
#SLOW_MAX = [0.25, 0.8, 1]
#FAST_WARNING = [0.5, 0.6, 0.8]
#FAST_MAX = [1, 1.4, 1.8]

WERE_SLOW_WARNING = [0.2, 0.3, 0.4]
WERE_SLOW_MAX = [0.7, 0.9, 1.1]
WERE_FAST_WARNING = [0.6, 0.7, 0.9]
WERE_FAST_MAX = [1.1, 1.5, 2.0]
SLOW_WARNING = [1.0, 1.3, 1.6, 2.0, 2.5]
SLOW_MAX = [1.1, 1.5, 1.8, 2.5, 3.2]
FAST_WARNING = [1.3, 1.6, 1.9, 2.7, 2.8]
FAST_MAX = [1.5, 1.8, 2.8, 3.2, 3.5]

#WERE_SLOW_WARNING = [0.2, 0.3, 0.4]
#WERE_SLOW_MAX = [0.7, 0.9, 1.1]
#WERE_FAST_WARNING = [0.6, 0.7, 0.9]
#WERE_FAST_MAX = [1.1, 1.5, 2.0]

WERE_SLOW_WARNING = [1.1, 1.4, 1.7, 2.1, 2.9]
WERE_SLOW_MAX = [1.2, 1.6, 1.9, 2.6, 3.9]
WERE_FAST_WARNING = [1.4, 1.7, 2.0, 2.8, 3.5]
WERE_FAST_MAX = [1.6, 1.9, 2.9, 3.3, 4.9]

#ZOMBIE_WARNING = [0.5, 0.6, 0.8]
#ZOMBIE_MAX = [0.8, 1, 1.4]

ZOMBIE_WARNING = [0.5, 0.6, 0.8]
ZOMBIE_MAX = [0.8, 1, 1.4]
ZOMBIE_WARNING = [1.2, 1.5, 1.8, 2.6, 2.7]
ZOMBIE_MAX = [1.4, 1.7, 2.7, 3.1, 3.4]


def get_move(serial, move_num):
Expand All @@ -37,6 +45,7 @@ def get_move(serial, move_num):
for move_num in range(psmove.count_connected()):
move = psmove.PSMove(move_num)
if move.get_serial() == serial:
print("returning " +str(move.get_serial()))
return move
return None
else:
Expand Down Expand Up @@ -92,6 +101,7 @@ class Button(enum.Flag):
TRIGGER = psmove.Btn_T

SHAPES = TRIANGLE | CIRCLE | CROSS | SQUARE
UPDATE = SELECT | START

all_shapes = [Button.TRIANGLE, Button.CIRCLE, Button.CROSS, Button.SQUARE]

Expand Down Expand Up @@ -166,6 +176,7 @@ def __str__(self):
REQUIRED_SETTINGS = [
'play_audio',
'move_can_be_admin',
'current_game',
'enforce_minimum',
'sensitivity',
'play_instructions',
Expand Down
Loading

0 comments on commit 416a9f0

Please sign in to comment.