################################################################################
# This program is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or #
# (at your option) any later version. #
# This program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# You should have received a copy of the GNU General Public License #
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
################################################################################
from threading import Thread
wiimote_hwaddr = '' # Use your address to speed up the connection proccess
#wiimote_hwaddr = '00:19:1D:5D:5D:DC'
'''Wiimote callback managing method
Recieves a message list, each element is different, see the libcwiid docs'''
global btA, btB, last_point
#print "wiimote callback"
# if msg[0] == cwiid.MESG_IR:
# # msg is of the form (cwiid.MESG_IR, (((x, y), size) or None * 4))
# pos = p['pos'][0], p['pos'][1] # point is mirrored
# last_point = tuple(pos)
# #print "last_point",last_point
if msg[0] == cwiid.MESG_BTN:
# msg is of the form (cwiid.MESG_BTN, cwiid.BTN_*)
elif msg[0] == cwiid.MESG_NUNCHUK:
last_point = msg[1]['stick']
#ssx = msg[1]['stick'][0]
#ssy = msg[1]['stick'][1]
#elif msg[0] == cwiid.MESG_STATUS:
# # msg is of the form (cwiid.MESG_BTN, { 'status' : value, ... })
def Connect_Wiimote(frameobj):
print "Press 1+2 Now !!!!"
wm = cwiid.Wiimote(wiimote_hwaddr)
# each message will contain info about ir and buttons
wm.rpt_mode = cwiid.RPT_BTN | cwiid.RPT_EXT # | cwiid.RPT_STATUS | cwiid.RPT_IR |
# tell cwiid to use the callback interface and allways send button events
wm.enable(cwiid.FLAG_MESG_IFC)
#| cwiid.FLAG_REPEAT_BTN)
# specify wich function will manage messages AFTER the other settings
# quick check on the wiimote
frameobj.label_1.SetLabel("Got Wiimote !")
print str(e).ljust(8), ">", st[e]
print "Error with wiimote " + str(wiimote_hwaddr)
frameobj.label_1.SetLabel("Wiimote NOK")
def start_manu(self,evt):
self.label_1.SetLabel("press 1+2 now !!!")
wx.CallAfter(Connect_Wiimote, self)
HMIFrame.start_manu = start_manu
#wx.CallAfter(Connect_Wiimote)
#Thread(target=Connect_Wiimote).start()