Can't run WiiMote scripts with version 10.666

Official forum for open source FreePIE discussion and development.
Post Reply
MrNatas
One Eyed Hopeful
Posts: 4
Joined: Tue Jan 31, 2017 9:01 pm

Can't run WiiMote scripts with version 10.666

Post by MrNatas »

Hi Everyone.

I'm fiddling with FreePie again, trying to do something about Razer Hydra emulation and WiiMotes. I downloaded some scripts that, I thought, would require an update to the latest version.

Now, though, nothing works anymore, even my old scripts.
Here is the errors I get:

Image

For information, here's the script I'm trying to use, but every other script including the WiiMote give me the same error:

Code: Select all

def map_motionplus(n):
	yaw = wiimote[n].ahrs.yaw
	pitch = wiimote[n].ahrs.pitch
	offYaw = yaw - x_offset
	offPitch = pitch - y_offset
	diagnostics.watch(yaw)
	diagnostics.watch(pitch)
	diagnostics.watch(offYaw)
	diagnostics.watch(offPitch)
	
	x = filters.deadband(filters.delta(offYaw),0.01)
	y = filters.deadband(-filters.delta(offPitch),0.01)
	
	x = x * mouse_sensitivity
	y = y * mouse_sensitivity
	
	diagnostics.watch(x)
	diagnostics.watch(y)
	
	steering_center_reduction_x = 1.0
	steering_center_reduction_y = 1.0
	
	if x > 0:
		steering_center_reduction_x = sensitivity_center_reduction ** (1 - (x / steering_max))
	elif x < 0:
		steering_center_reduction_x = sensitivity_center_reduction ** (1 - (x / steering_min))
	if y > 0:
		steering_center_reduction_y = sensitivity_center_reduction ** (1 - (y / steering_max))
	elif y < 0:
		steering_center_reduction_y = sensitivity_center_reduction ** (1 - (y / steering_min))
	
	x = x + ((float(x) * steering_sensitivity) / steering_center_reduction_x)
	y = y + ((float(y) * steering_sensitivity) / steering_center_reduction_y)
	
	if x > steering_max:
		x = steering_max
	elif x < steering_min:
		x = steering_min
		
	if y > steering_max:
		y = steering_max
	elif y < steering_min:
		y = steering_min	
	
	x = int(round(x))
	y = int(round(y))
	
	mouse.deltaX = x
	mouse.deltaY = y
	
def map_button(n, wiimote_button, keyboard_key):
	if wiimote[n].buttons.button_down(wiimote_button):
		keyboard.setKeyDown(keyboard_key)
	else:
		keyboard.setKeyUp(keyboard_key)
	
def map_nunchuck_button(n, nunchuck_button, keyboard_key):
	if wiimote[n].nunchuck.buttons.button_down(nunchuck_button):
		keyboard.setKeyDown(keyboard_key)
	else:
		keyboard.setKeyUp(keyboard_key)
	
def map_axis(n):
	if wiimote[n].nunchuck.stick.x > 25:
		keyboard.setKeyDown(Key.D)
	else:
		keyboard.setKeyUp(Key.D)
	
	if wiimote[n].nunchuck.stick.x < -25:
		keyboard.setKeyDown(Key.A)
	else:
		keyboard.setKeyUp(Key.A)
		
	if wiimote[n].nunchuck.stick.y > 25:
		keyboard.setKeyDown(Key.W)
	else:
		keyboard.setKeyUp(Key.W)
		
	if wiimote[n].nunchuck.stick.y < -25:
		keyboard.setKeyDown(Key.S)
	else:
		keyboard.setKeyUp(Key.S)
	
def map_buttons(n):
	map_button(n, WiimoteButtons.A, Key.E)
	map_button(n, WiimoteButtons.One, Key.LeftControl)
	map_button(n, WiimoteButtons.Two, Key.F1)
	map_button(n, WiimoteButtons.Plus, Key.Return)
	map_button(n, WiimoteButtons.Minus, Key.Z)
	map_button(n, WiimoteButtons.DPadUp, Key.Space)
	#map_button(n, WiimoteButtons.Home, Key.Escape)
	
def map_buttons_altC(n):
	map_button(n, WiimoteButtons.A, Key.F)
	map_button(n, WiimoteButtons.One, Key.LeftControl)
	map_button(n, WiimoteButtons.Two, Key.F2)
	map_button(n, WiimoteButtons.Plus, Key.Return)
	map_button(n, WiimoteButtons.Minus, Key.Z)
	map_button(n, WiimoteButtons.DPadUp, Key.Space)
	#map_button(n, WiimoteButtons.Home, Key.Escape)
	
def map_buttons_altZ(n):
	map_button(n, WiimoteButtons.A, Key.R)
	map_button(n, WiimoteButtons.One, Key.D5)
	map_button(n, WiimoteButtons.Two, Key.D6)
	map_button(n, WiimoteButtons.Plus, Key.G)
	map_button(n, WiimoteButtons.Minus, Key.Z)
	map_button(n, WiimoteButtons.Home, Key.Escape)
	
def map_nunchuck_buttons(n):
	mouse.rightButton = wiimote[n].nunchuck.buttons.button_down(NunchuckButtons.Z)
	diagnostics.watch(mouse.rightButton)
	diagnostics.watch(wiimote[n].nunchuck.buttons.button_down(NunchuckButtons.Z))
	if wiimote[n].nunchuck.buttons.button_down(NunchuckButtons.C):
		map_buttons_altC(n)
	#elif wiimote[n].nunchuck.buttons.button_down(NunchuckButtons.Z):
	#map_buttons_altZ(n)
	else:
		map_buttons(n)
	
def map_pov(n):
	mouse.leftButton = wiimote[n].buttons.button_down(WiimoteButtons.B)
	map_button(n, WiimoteButtons.DPadUp, Key.LeftAlt)
	map_button(n, WiimoteButtons.DPadRight, Key.Q)
	map_button(n, WiimoteButtons.DPadDown, Key.C)
	map_button(n, WiimoteButtons.DPadLeft, Key.LeftShift)
		
def updateWiimote1():
	#Wiimote 1
	#map_buttons(0)
	map_pov(0)
	
def updateNunchuck1():
	map_axis(0)
	map_nunchuck_buttons(0)
	
def updateMotionplus1():
	map_motionplus(0)
	
if starting:
	system.setThreadTiming(TimingTypes.HighresSystemTimer)
	system.threadExecutionInterval = 2
	wiimote[0].buttons.update += updateWiimote1
	wiimote[0].nunchuck.update += updateNunchuck1
	wiimote[0].motionplus.update += updateMotionplus1
	wiimote[0].enable(WiimoteCapabilities.Extension | WiimoteCapabilities.MotionPlus)
	x_offset = 0
	y_offset = 0
	mouse_sensitivity = 1.5
	# =============================================================================================
	# //////////////////////////////////////// SETTINGS ///////////////////////////////////////////
	# =============================================================================================
	# Mouse settings
	# =============================================================================================
	steering_sensitivity = 5
	sensitivity_center_reduction = 0.1
	# =============================================================================================
	# Steering settings
	# =============================================================================================
	int32_max = (2 ** 14) - 1
	int32_min = (( 2** 14) * -1) + 1
	#global steering, steering_max, steering_min, steering_center_reduction    
	# Init values, do not change
	steering_max = float(int32_max)
	steering_min = float(int32_min)
	
if(wiimote[0].buttons.button_down(WiimoteButtons.Home)):
	x_offset = wiimote[0].ahrs.yaw
	y_offset = wiimote[0].ahrs.pitch
I'm completely lost here. What's did I do wrong?
User avatar
zelmon64
Cross Eyed!
Posts: 134
Joined: Thu Apr 09, 2015 4:27 am

Re: Can't run WiiMote scripts with version 10.666

Post by zelmon64 »

Hi MrNatas,

Please try replacing Dolphiimote.dll with the one in this post.
MrNatas
One Eyed Hopeful
Posts: 4
Joined: Tue Jan 31, 2017 9:01 pm

Re: Can't run WiiMote scripts with version 10.666

Post by MrNatas »

zelmon64 wrote:Hi MrNatas,

Please try replacing Dolphiimote.dll with the one in this post.
YAY!

Thanks!
I remembered the trick and had an old version of this modified DLL already, I didn't realize there was an update.
Thanks a bunch!
Post Reply

Return to “FreePIE”