Feature Request: Wiimote Sync

A nice (keyboard based) front end for Arcade / Console game emulators.

Moderator: battlecat

New version of Wiimote script.

Postby Zombie » Sat Jan 22, 2011 6:31 am

Code: Select all
#!/bin/bash

WII_KEYMAP="ir_wahcade"

declare -a MAC_ADDRESS

# killing wminput -d instances
killall wminput

# search wiimotes with hcitool
zenity --info --title "Wiimote Pairing" --text "Getting Wiimote Address." --timeout 5 &
hcitool scan | grep Nintendo | awk '{print $1}' | while read m; MAC_ADDRESS[${#MAC_ADDRESS[*]}]=$m ; done
if test ${#MAC_ADDRESS[*]} -eq 0; then
   zenity --info --title "Wiimote Pairing" --text "No wiimotes found." --timeout 5 &
   exit 0
fi

# start wminput for each macaddress
zenity --info --title "Wiimote Pairing" --text "Put the ${#MAC_ADDRESS[*]} Wiimotes in Discovery Mode." --timeout 5 &
for m in ${MAC_ADDRESS[*]}; do
   wminput -d -c $WII_KEYMAP $m &
done
User avatar
Zombie
 
Posts: 791
Joined: Mon Oct 06, 2008 2:52 pm

Re: Feature Request: Wiimote Sync

Postby Zombie » Sun Jan 23, 2011 11:50 pm

Here is the latest edition of my script to pair a Wiimote.

Code: Select all
#!/bin/bash

wii_keymap="ir_wahcade"
file=$HOME/.wahcade/wiimote-mac

declare -a bd_address

# wiimote-mac is the name of the file with the mac address
# search wiimotes with hcitool
zenity --info --title "Wiimote Pairing" --text "Getting Wiimote Address." --timeout 5 &
if [[ -f $file ]]; then # if file exists
   IFS=$'\n' read -r -d '' -a bd_address < $file
   while read -r bd_address; do
      wminput -d -c "$wii_keymap" "$bd_address" &
      printf '%s\n' "$bd_address" >> "$file" || break
   done < <(comm -23 <(hcitool scan|awk '/Nintendo/{print $1}'|sort -u) <(sort -u "$file"))
   else
         
   # Only Write to the configuration file if there is a Wiimote Address aquired
   if [[ -n "$bd_address" ]]; then
      printf '%s\n' "${bd_address[@]}" > $file
   fi
   #if no Wiimote is found, exit with an error
   if test ${#bd_address[*]} -eq 0; then
      zenity --info --title "Wiimote Pairing" --text "No wiimotes found." --timeout 5 &
      exit 0
   fi
fi


# killing wminput -d instances
killall -q wminput

# start wminput for each macaddress
zenity --info --title "Wiimote Pairing" --text "Put the ${#bd_address[*]} Wiimotes in Discovery Mode." --timeout 5 &
for m in "${bd_address[@]}"; do
   wminput -d -c $wii_keymap $m &
done
User avatar
Zombie
 
Posts: 791
Joined: Mon Oct 06, 2008 2:52 pm

Re: Feature Request: Wiimote Sync

Postby sairuk » Mon Jan 24, 2011 10:08 pm

Just to clarify, this script supports a single wiimote only?

If you detail the usage of the script and how you are running it I will add it to wah!ki as an alternative to the other.
mameau - My random bits | Wah!Ki - A Wah!Cade wiki | Mah!Cade - Experimental Wah!cade Branch | ListGen | Lazarus
User avatar
sairuk
 
Posts: 432
Joined: Sat May 22, 2010 12:37 am

Re: Feature Request: Wiimote Sync

Postby Zombie » Mon Jan 24, 2011 10:10 pm

This script supports multiple Wiimotes, but I still have the music stopping issue.
User avatar
Zombie
 
Posts: 791
Joined: Mon Oct 06, 2008 2:52 pm

Re: Feature Request: Wiimote Sync

Postby Zombie » Tue Jan 25, 2011 2:28 pm

The script you just run, there are no parameters to it, it runs wminput -c ir_wahcade. There's nothing to it. There are no parameters.
User avatar
Zombie
 
Posts: 791
Joined: Mon Oct 06, 2008 2:52 pm

Re: Feature Request: Wiimote Sync

Postby Zombie » Sat Jan 29, 2011 7:13 am

Here is my ir_wahcade config

Code: Select all
Plugin.ir_ptr.X = ABS_X
Plugin.ir_ptr.Y = ABS_Y

#buttons

Wiimote.A      = KEY_1
Wiimote.B      = KEY_2
Wiimote.Up      = KEY_UP
Wiimote.Down   = KEY_DOWN
Wiimote.Left   = KEY_LEFT
Wiimote.Right   = KEY_RIGHT
Wiimote.Minus   = KEY_4
Wiimote.Plus   = KEY_6
Wiimote.Home   = KEY_ESC
Wiimote.1      = KEY_3
Wiimote.2      = KEY_5

Nunchuk.C      = BTN_LEFT
Nunchuk.Z      = BTN_RIGHT

Classic.Dpad.X = ABS_X
Classic.Dpad.Y = ABS_Y
Classic.LStick.X = ABS_HAT0X
Classic.LStick.Y = ABS_HAT0Y
Classic.RStick.X = ABS_HAT1X
Classic.RStick.Y = ABS_HAT1Y
Classic.A = BTN_A
Classic.B = BTN_B
Classic.X = BTN_X
Classic.Y = BTN_Y
Classic.Minus = BTN_SELECT
Classic.Plus  = BTN_START
Classic.Home  = BTN_MODE
Classic.L  = BTN_TL
Classic.R  = BTN_TR
Classic.ZL = BTN_TL2
Classic.ZR = BTN_TR2
User avatar
Zombie
 
Posts: 791
Joined: Mon Oct 06, 2008 2:52 pm

Previous

Return to Wah!Cade

Who is online

Users browsing this forum: No registered users and 2 guests

cron