Exemplo n.º 1
0
    def _findWiimotes(self):
        if os.name != 'nt': print('press 1&2')
        pygame_wiimote.init(4, 10)  # look for 1, wait 5 seconds
        n = pygame_wiimote.get_count()  # how many did we get?

        if n == 0:
            print('no wiimotes found')
            sys.exit(1)

        self._numberOfPlayers = pygame_wiimote.get_count()
        for i in range(0, self._numberOfPlayers):
            print('Setting wiimote ', i + 1)
            wm = pygame_wiimote.Wiimote(i)
            wm.enable_accels(1)
            wm.enable_ir(1, vres=(config.DISPLAY_WIDTH, config.DISPLAY_HEIGHT))
Exemplo n.º 2
0
I stole the graphing from wiiewer and then hacked it to work without Numeric

'''

import pygame
import wiiuse.pygame_wiimote as pygame_wiimote
import sys
import time
import os

pygame.init()

# initialze the wiimotes
if os.name != 'nt': print 'press 1&2'
pygame_wiimote.init(1, 5)  # look for 1, wait 5 seconds
n = pygame_wiimote.get_count()  # how many did we get?

if n == 0:
    print 'no wiimotes found'
    sys.exit(1)

w, h = size = (512, 512)

wm = pygame_wiimote.Wiimote(0)  # access the wiimote object
wm.enable_accels(1)  # turn on acceleration reporting
wm.enable_ir(1, vres=size)  # turn on ir reporting

screen = pygame.display.set_mode(size)

run = True
Exemplo n.º 3
0
import pygame
import wiiuse.pygame_wiimote as pygame_wiimote
import sys
import time
import os

if os.name != 'nt': print 'press 1&2'
pygame_wiimote.init(1, 5) # look for 1, wait 5 seconds
n = pygame_wiimote.get_count() # how many did we get?

if n == 0:
    print 'no wiimotes found'
    sys.exit(1)
Exemplo n.º 4
0
def main():
	#Initialize pygame
	pygame.init()
	running = True
	# initialze the wiimotes
	if os.name != 'nt': print 'press 1&2'
	pygame_wiimote.init(1, 5) # look for 1, wait 5 seconds
	n = pygame_wiimote.get_count() # how many did we get?

	if n == 0:
		print 'no wiimotes found'
		sys.exit(1)

	wm = pygame_wiimote.Wiimote(0) # access the wiimote object

	#Create objects
	Activities = ActivityList()
	screen = MainScreen(Activities)
#	VoiceRecord = AudioRecorder()
	VoiceOutput = VoiceDriver(Activities)

	#Infinite loop to run the program
	while running:
		for event in pygame.event.get():
			if event.type == pygame.QUIT:
				print 'quiting'
				running = False
				break
			elif event.type in [ pygame_wiimote.WIIMOTE_BUTTON_PRESS]:
				print event.button, 'pressed on', event.id
				#print type(event.button)
				if event.button=='Right' and not Activities.dayChosen:
					if Activities.activityChosen == False:
						screen.clearDay()
						Activities.dayIndex += 1
						screen.updateDay()
				if event.button=='Left' and not Activities.dayChosen:
					if Activities.activityChosen == False:
						screen.clearDay()
						Activities.dayIndex -= 1
						screen.updateDay()
				if event.button=='Up' and Activities.dayChosen:
					if Activities.activityChosen == False:
						screen.clearActivity()
						Activities.activityIndex -= 1
						screen.updateActivity()
					else:
						if screen.subjectSelected:
							screen.subjectSelected = False
							screen.updateSelection()
						else:
							screen.subjectSelected = True
							screen.updateSelection()

				if event.button=='Down' and  Activities.dayChosen:
					if Activities.activityChosen == False:
						screen.clearActivity()
						Activities.activityIndex += 1
						screen.updateActivity()
					else:
						if screen.subjectSelected:
							screen.subjectSelected = False
							screen.updateSelection()
						else:
							screen.subjectSelected = True
							screen.updateSelection()
				if event.button =='A':
					if not Activities.dayChosen:
						Activities.dayChosen = True
						screen.initActivities()
						screen.updateActivity()
					else:
						if Activities.activityChosen == False:
							Activities.activityChosen = True
							screen = ActivityScreen(Activities)
						else:
							if screen.subjectSelected:
								pass
							#	newSubject = VoiceRecord.recordAudio()
							#	Activities.setSubject(newSubject)
							#	screen.updateSelection()
							else:
								pass
							#	newActivity = VoiceRecord.recordAudio()
							#	Activities.setActivity(newActivity)
							#	screen.updateSelection()
				if event.button =='B':
					if Activities.activityChosen == False:
						screen.clearActivity()
						Activities.activityIndex = 0
						Activities.dayChosen = False
					else:
						screen = MainScreen(Activities)
	 					Activities.activityIndex = 0
	 					Activities.dayIndex = 0
						Activities.activityChosen = False
						Activities.dayChosen = False

			elif event.type in [ pygame_wiimote.WIIMOTE_BUTTON_RELEASE,pygame_wiimote.NUNCHUK_BUTTON_RELEASE ]:
				print event.button, 'released on', event.id

		'''event = pygame.event.poll()
		if event.type == pygame.QUIT:
			running = 0
        if event.type in [ pygame_wiimote.WIIMOTE_BUTTON_PRESS,pygame_wiimote.NUNCHUK_BUTTON_PRESS ]:
        	print event.button, 'pressed on', event.id

		if event.type == pygame.KEYDOWN:

			#Press escape to quit, change to HOME button on wiimote
			if event.key == pygame.K_ESCAPE:
				running = 0

			#Navigate the days with the left/right arrows keys, change to D-PAD left/right buttons on wiimote
			if event.key == pygame.K_RIGHT and not Activities.dayChosen:
				if Activities.activityChosen == False:
					screen.clearDay()
					Activities.dayIndex += 1
					screen.updateDay()

			if event.key == pygame.K_LEFT and not Activities.dayChosen:
				if Activities.activityChosen == False:
					screen.clearDay()
					Activities.dayIndex -= 1
					screen.updateDay()

			#Select the day with the enter key, change to A button on the wiimote
			if event.key == pygame.K_RETURN:
				if not Activities.dayChosen:
					Activities.dayChosen = True
					screen.initActivities()
					screen.updateActivity()
				else:
					if Activities.activityChosen == False:
						Activities.activityChosen = True
						screen = ActivityScreen(Activities)
					else:
						if screen.subjectSelected:
							pass
						#	newSubject = VoiceRecord.recordAudio()
						#	Activities.setSubject(newSubject)
						#	screen.updateSelection()
						else:
							pass
						#	newActivity = VoiceRecord.recordAudio()
						#	Activities.setActivity(newActivity)
						#	screen.updateSelection()

			#Navigate the day's activities with up/down arrow keys, change to D-PAD up/down buttons on wiimote
			if event.key == pygame.K_UP and Activities.dayChosen:
				if Activities.activityChosen == False:
					screen.clearActivity()
					Activities.activityIndex -= 1
					screen.updateActivity()
				else:
					if screen.subjectSelected:
						screen.subjectSelected = False
						screen.updateSelection()
					else:
						screen.subjectSelected = True
						screen.updateSelection()

			if event.key == pygame.K_DOWN and Activities.dayChosen:
				if Activities.activityChosen == False:
					screen.clearActivity()
					Activities.activityIndex += 1
					screen.updateActivity()
				else:
					if screen.subjectSelected:
						screen.subjectSelected = False
						screen.updateSelection()
					else:
						screen.subjectSelected = True
						screen.updateSelection()

			#Unselect activity and choose a new day
			if event.key == pygame.K_BACKSPACE and Activities.dayChosen:
				if Activities.activityChosen == False:
					screen.clearActivity()
					Activities.activityIndex = 0
					Activities.dayChosen = False
				else:
					screen = MainScreen(Activities)
 					Activities.activityIndex = 0
 					Activities.dayIndex = 0
					Activities.activityChosen = False
					Activities.dayChosen = False


		if event.type == pygame.KEYUP:
			if event.key == pygame.K_RIGHT or event.key == pygame.K_LEFT:
				pass'''
	pygame_wiimote.quit()
	pygame.quit()