[HowTo] Usar Wiimote como gamepad no Windows // Tutorial & Scripts

Make.Love

Banido
Aproveito a thread para colocar os scripts que fiz/vou fazendo bem como aqueles que me forem pedidos. Se tiverem já feitos e desejarem divulga-los é só colocar na thread.

Programas necessários:

BlueSoleil 6 - Para usar com o receptor Bluetooth, tendo como objectivo procurar o Wiimote e conectar-se a este.
GlovePie 0.29 - Import/Export de scripts para o Wiimote
Informação Complementar: Wiimote no PC

Tutorial

blue.soleil.1.jpg

blue.soleil.2.jpg

blue.soleil.3.jpg

blue.soleil.4.jpg

blue.soleil.5.jpg

blue.soleil.6.jpg


GlovePie
glove.pie.1.jpg

glove.pie.2.jpg

Scripts

PES09 - Wiimote + Nunchuck
Código:
// PES09
// Make.Love

// Get Nunchuk axis locations. Range is -0.99 to 0.99 
// Multiply by 100 to get whole numbers. (-99 to 99) 
var.xNunchuk = Wiimote.Nunchuk.JoyX * 100 
var.yNunchuk = Wiimote.Nunchuk.JoyY * 100 

// X/Y offsets for Analog. If it's too sensative then make the numbers larger. 
var.xOff = 32
var.yOff = 32

// Analog Movements 
if var.xNunchuk > var.xOff and var.yNunchuk > var.yOff then 
   key.up = false
   key.left = false
   key.down = true
   key.right = true
   //debug = 'SE' 
else if var.xNunchuk > var.xOff and var.yNunchuk < -var.yOff then 
   key.up = true
   key.left = false
   key.down = false
   key.right = true
   //debug = 'NE' 
else if var.xNunchuk < -var.xOff and var.yNunchuk < -var.yOff then 
   key.up = true
   key.left = true
   key.down = false
   key.right = false
   //debug = 'NW' 
else if var.xNunchuk < -var.xOff and var.yNunchuk > var.yOff then 
   key.up = false
   key.left = true
   key.down = true
   key.right = false
   //debug = 'SW' 
else if var.xNunchuk > var.xOff then 
   key.up = false
   key.left = false
   key.down = false
   key.right = true
   //debug = 'Right' 
else if var.xNunchuk < -var.xOff then 
   key.up = false
   key.left = true
   key.down = false
   key.right = false
   //debug = 'Left' 
else if var.yNunchuk < -var.yOff then 
   key.up = true
   key.left = false
   key.down = false
   key.right = false
   //debug = 'Up' 
else if var.yNunchuk > var.yOff then 
   key.up = false
   key.left = false
   key.down = true
   key.right = false
   //debug = 'Down' 
else if var.xNunchuk > -var.xOff and < var.xOff and var.yNunchuk < var.yOff and > -var.yOff then 
   key.up = false
   key.left = false
   key.down = false
   key.right = false
   //debug = 'Khai sucks' 
else 
   key.up = false
   key.left = false
   key.down = false
   key.right = false
   //debug = 'Khai sucks' 
endif 

Wiimote.Led1 = 1
key.Enter = Wiimote.Plus
key.Escape = Wiimote.Home

// x360 pad: A Button
// Short Pass
// Pressure
key.x = Wiimote.A

// x360 pad: X Button
// Shot
// COM teammates pressure
key.a = Wiimote.B

// x360 pad: Y Button
// Through Pass
// Keeper runs towards ball
key.w = Wiimote.Down

// x360 pad: B Button
// Long Pass
// Sliding Tackle
key.d = Wiimote.Nunchuk.ZButton

// x360 pad: RB Button
// Trick
key.q = Wiimote.Plus

// x360 pad: LB Button
// Run
key.e = Wiimote.Nunchuk.CButton

// x360 pad: LT Button
// Choose Player
key.z = Wiimote.Up

GRID - Wiimote
Código:
// GRID
// Make.Love

Wiimote.Led1 = 1
key.Up = wiimote.Two           // Acceleration
key.down = Wiimote.One         // Brake & Reverse
Key.left = Wiimote.Up          // Left
Key.right = Wiimote.Down       // Right
Key.Space = Wiimote.B          // HandBrake
Key.Enter = Wiimote.A          // Enter
Key.C = Wiimote.Right          // Camera
Key.Escape = Wiimote.Home      // Menu & Escape
Key.V = Wiimote.Left           // Look Back
Key.F3 = Wiimote.Plus          // F3
Key.F2 = Wiimote.Minus         // F2
Key.F12 = Wiimote.Plus and Wiimote.Minus  // F12
Key.F1 = Wiimote.Left and Wiimote.Two     // F1
Key.F7 = Wiimote.Right and Wiimote.B      // F7


// The Wiimote will rumble as you press Hand Brake
Wiimote.Rumble = Wiimote.B

GRID - Wiimote + Nunchuk
Código:
// GRID
// Make.Love


Wiimote.Led1 = 1

var.xNunchuk = Wiimote.Nunchuk.JoyX * 100 
var.yNunchuk = Wiimote.Nunchuk.JoyY * 100 

// X/Y offsets for Analog. If it's too sensative then make the numbers larger. 
var.xOff = 32
var.yOff = 32
//default = 7

// Analog Movements 
if var.xNunchuk > var.xOff and var.yNunchuk > var.yOff then
   key.left = false
   key.right = true
   //debug = 'SE' 
else if var.xNunchuk > var.xOff and var.yNunchuk < -var.yOff then 
   key.left = false
   key.right = true
   //debug = 'NE' 
else if var.xNunchuk < -var.xOff and var.yNunchuk < -var.yOff then 
   key.left = true
   key.right = false
   //debug = 'NW' 
else if var.xNunchuk < -var.xOff and var.yNunchuk > var.yOff then
   key.left = true
   key.right = false
   //debug = 'SW' 
else if var.xNunchuk > var.xOff then 
   key.left = false
   key.right = true
   //debug = 'Right' 
else if var.xNunchuk < -var.xOff then 
   key.left = true
   key.right = false
   //debug = 'Left' 
else if var.yNunchuk < -var.yOff then 
   key.left = false
   key.right = false
   //debug = 'Up' 
else if var.yNunchuk > var.yOff then 
   key.left = false
   key.right = false
   //debug = 'Down' 
else if var.xNunchuk > -var.xOff and < var.xOff and var.yNunchuk < var.yOff and > -var.yOff then 
   key.left = false
   key.right = false
   //debug = 'Khai sucks' 
else 
   key.left = false
   key.right = false
   //debug = 'Khai sucks' 
endif 

key.Escape = Wiimote.Home
key.up = Wiimote.A
key.Space = Wiimote.Nunchuk.ZButton
key.F1 = Wiimote.Up
key.F2 = Wiimote.Left
key.F3 = Wiimote.Right
key.F7 = Wiimote.Down
key.F12 = Wiimote.Two
key.v = Wiimote.Nunchuk.CButton
key.C = Wiimote.One
key.Enter = Wiimote.Plus
key.down = Wiimote.B

// The Wiimote will rumble as you press HandBrake
Wiimote.Rumble = Nunchuk.ZButton


FlatOut Ultimate Carnage - Wiimote + Nunchuk
Código:
// FlatOut Ultimate Carnage
// Make.Love

Wiimote.Led1 = 1
key.Up = wiimote.Two           // Acceleration
key.down = Wiimote.One         // Brake & Reverse
Key.left = Wiimote.Up          // Left
Key.right = Wiimote.Down       // Right
Key.ctrl = Wiimote.B           // Nitro & Driver Launch
Key.Space = Wiimote.A          // HandBrake
Key.C = Wiimote.Right          // Camera
Key.R = Wiimote.Minus          // Reset
Key.Escape = Wiimote.Home      // Menu & Back
Key.PageDown = Wiimote.Left    // Look Back
Key.Enter = Wiimote.Plus       // Select & Start


// The Wiimote will rumble as you press Brake
Wiimote.Rumble = Wiimote.One

GTA4 PC - Wiimote + Nunchuk Imagem com o Mapeamento
Código:
// GTA4 PC
// Make.Love

// **** PLEASE READ THIS ****
// NEW KEY Assignments

// Foot
// Enter/Exit Cover --> C

// In Vehicle
// Horn --> M
// Accelerate --> Mouse Left Button
// Shoot --> U
// Turn Off Radio --> Left Ctrl
// **** END ****

// Get Nunchuk axis locations. Range is -0.99 to 0.99 
// Multiply by 100 to get whole numbers. (-99 to 99) 
var.xNunchuk = Wiimote.Nunchuk.JoyX * 100 
var.yNunchuk = Wiimote.Nunchuk.JoyY * 100 

// X/Y offsets for Analog. If it's too sensative then make the numbers larger. 
var.xOff = 32
var.yOff = 32

// Analog Movements 
if var.xNunchuk > var.xOff and var.yNunchuk > var.yOff then 
   key.w = false
   key.a = false
   key.s = true
   key.d = true
   //debug = 'SE' 
else if var.xNunchuk > var.xOff and var.yNunchuk < -var.yOff then 
   key.w = true
   key.a = false
   key.s = false
   key.d = true
   //debug = 'NE' 
else if var.xNunchuk < -var.xOff and var.yNunchuk < -var.yOff then 
   key.w = true
   key.a = true
   key.s = false
   key.d = false
   //debug = 'NW' 
else if var.xNunchuk < -var.xOff and var.yNunchuk > var.yOff then 
   key.w = false
   key.a = true
   key.s = true
   key.d = false
   //debug = 'SW' 
else if var.xNunchuk > var.xOff then 
   key.w = false
   key.a = false
   key.s = false
   key.d = true
   //debug = 'Right' 
else if var.xNunchuk < -var.xOff then 
   key.w = false
   key.a = true
   key.s = false
   key.d = false
   //debug = 'Left' 
else if var.yNunchuk < -var.yOff then 
   key.w = true
   key.a = false
   key.s = false
   key.d = false
   //debug = 'Up' 
else if var.yNunchuk > var.yOff then 
   key.w = false
   key.a = false
   key.s = true
   key.d = false
   //debug = 'Down' 
else if var.xNunchuk > -var.xOff and < var.xOff and var.yNunchuk < var.yOff and > -var.yOff then 
   key.w = false
   key.a = false
   key.s = false
   key.d = false
   //debug = 'Khai sucks' 
else 
   key.w = false
   key.a = false
   key.s = false
   key.d = false
   //debug = 'Khai sucks' 
endif 

Wiimote.Led1 = 1
key.Escape = Wiimote.B and Wiimote.Down



// Wiimote
// On Foot & In Vehicle & Combat & General
key.F =Wiimote.Home // Enter & Exit Vehicle
key.C = Wiimote.One
key.V = Wiimote.Two // Change Camera
key.E = Wiimote.Minus // Action
key.LeftControl = Wiimote.Plus // Crouch & Turn Off Radio
key.Space = Wiimote.B // Jump & Hand Brake & Block (While Locked On)
key.R = Wiimote.Down // Reload & Headlight & Punch2
mouse.WheelUp = Wiimote.Right // Next Weapon & Next Radio Station & Sniper Zoom In
mouse.WheelDown = Wiimote.Left // Previous Weapon & Previous Radio Station & Sniper Zoom Out
key.Up = Wiimote.Up // Take Phone Out
mouse.LeftButton = Wiimote.A // Attack & Accelerate & Punch1
key.U = Wiimote.A and Wiimote.Nunchuk.ZButton // Shoot Inside Vehicle

// Nunchuk
key.LeftShift = Wiimote.Nunchuk.ZButton // Sprint & Lean Forward
mouse.RightButton = Wiimote.Nunchuk.CButton  // Free Aim & Melee Lock On
key.M = Wiimote.Nunchuk. CButton and Wiimote.Nunchuk.ZButton  // Horn



Post Original:

Viva,

tou a fazer um script e tou neste momento a programar a vibração do comando, consegui fazer em parte o que queria.

Quero meter o wiimote a vibrar quando carrego numa tecla (Home por exemplo) e desligar a vibraçao quando carrego também na mesma tecla.

O problema é que nao tou a conseguir faze-lo, porque nao entendi bem o funcionamento da linguagem e nao usa classes (penso eu de que.... lol), pelo que é mais complicado.


nesta situação ligo a vibraçao, mas depois nao desliga... nao entendo porquê! :/
Código:
//liga e desliga a vibracao pressionando o botao Home

variable.vibracao = false

if variable.vibracao = false and Wiimote.Home then
wiimote.Rumble = 1
variable.vibracao = true
endif

if variable.vibracao = true and Wiimote.Home then
wiimote.Rumble = 0
variable.vibracao = false
endif


Solução temporaria que fiz:

Código:
// liga a vibração enquanto o botao home é pressionado

wiimote.rumble = 0
if wiimote.home then
wiimote.rumble = 1
endif

alguma ideia? será que alguem aqui aventurou-se a programar scripts para o wiimote? :p
 
Última edição:
Nunca cheguei a fazer scrips que utilizassem vibração só mesmo os acelarometros, conseguia se associasses o on e off a teclas diferentes agora á mesma tecla. tenta algo assim

if wiimote.home then
var.vibr = true
wiimote.rumble = 1
endif

if var.vibr = true then
wiimote.home = wiimote.rumble = 0
endif
não faço ideia se funciona, ou ate se da mesmo para associar a função on\off rumble a mesma tecla
 
Última edição:
se calhar pode ser mesmo bug do programa pois não deve estar "programado" para associar a mesma tecla a funções diferentes

Há bug mas é do programador e do seu assistente :P


Se fosse comigo verificava se a rotina/função/método era executada sempre que se carrega num botão. Tipo colocando uns prints a sair para o ecrã.

É que estive a olhar para esse script e não percebi ao certo em que condições esse script é chamado.
 
theforbidden1, ve la se nao queres .... :004:

agora a serio, o glovepie permite ver os valores das variáveis a qualquer momento, e eu sei que este código está a receber e alterar os estados correctamente.

Nao sei se alguma vez tiveste uma disciplina de compiladores, mas quando tive que fazer uma linguagem de programação para a faculdade o processo de verificação de passagem ao longo do codigo é muito semelhante ao que o glovepie mostra.

Parece-me é que esta linguagem é muito simples mas com uns valentes bugs.

Por exemplo, neste código eu vejo a variável vibracao a mudar entre 1 e 0, no entanto o rumble não funciona.


Código:
//liga e desliga a vibracao pressionando o botao Home

variable.vibracao = o

if variable.vibracao = 0 and Wiimote.Home then
wiimote.Rumble = 1
variable.vibracao = 1
endif

if variable.vibracao = 1 and Wiimote.Home then
wiimote.Rumble = 0
variable.vibracao = o
endif
 
theforbidden1, ve la se nao queres .... :004:

agora a serio, o glovepie permite ver os valores das variáveis a qualquer momento, e eu sei que este código está a receber e alterar os estados correctamente.

Nao sei se alguma vez tiveste uma disciplina de compiladores, mas quando tive que fazer uma linguagem de programação para a faculdade o processo de verificação de passagem ao longo do codigo é muito semelhante ao que o glovepie mostra.

Parece-me é que esta linguagem é muito simples mas com uns valentes bugs.

Por exemplo, neste código eu vejo a variável vibracao a mudar entre 1 e 0, no entanto o rumble não funciona.


Código:
//liga e desliga a vibracao pressionando o botao Home

variable.vibracao = o

if variable.vibracao = 0 and Wiimote.Home then
wiimote.Rumble = 1
variable.vibracao = 1
endif

if variable.vibracao = 1 and Wiimote.Home then
wait 100ms
wiimote.Rumble = 0
variable.vibracao = o
endif

Tenta deixar um tempo entre o primires a segunda vez o" Home" e o rumble desligar-se
 
o rumble nao se desliga sozinho enquanto nao der ordem para tal.

aproveito pa dizer, que se fosse para desligar ao fim de x tempo seria assim:

Código:
// liga a vibração e desliga automaticamente passado 1sg

wiimote.rumble = 0
if wiimote.home then
wiimote.rumble = 1
[COLOR="Red"]wait 1000 ms[/COLOR]
[COLOR="Red"]wiimote.rumble = 0[/COLOR]
endif

edit: não reparei que tinhas alterado o codigo! xD vou experimentar, é preciso tentar tudo quando a coisa nao funciona!
 
Última edição:
o rumble nao se desliga sozinho enquanto nao der ordem para tal.

aproveito pa dizer, que se fosse para desligar ao fim de x tempo seria assim:

Código:
// liga a vibração e desliga automaticamente passado 1sg

wiimote.rumble = 0
if wiimote.home then
wiimote.rumble = 1
[COLOR=Red]wait 1000 ms[/COLOR]
[COLOR=Red]wiimote.rumble = 0[/COLOR]
endif
edit: não reparei que tinhas alterado o codigo! xD vou experimentar, é preciso tentar tudo quando a coisa nao funciona!

Se isso funcionar tens um problema de computação em tempo real, ou seja a ordem de ligar e desligar é dada em simultâneo ... e o wiimote deve estar a fazer "discard" á instrução inútil...

Depois tens um problema no teu codigo inicial que aquilo devia era lá ter um else...
 
com o else nem muda o valor da variavel da segunda passagem! :/ Já andei a turra com isto durante um bom tempinho e a ver exemplos mas nao cheguei a conclusões concretas. lol
 
com o else nem muda o valor da variavel da segunda passagem! :/ Já andei a turra com isto durante um bom tempinho e a ver exemplos mas nao cheguei a conclusões concretas. lol

Zipa o codigo e o instalador e as coisas que eu precisso que eu depois dou uma olhadela nisso.

Aquele teu codigo lá em cima nem devia fazer nada, porque aquilo ao ir ao optimizado devia ser eliminado... já que aqueles 2 ifs podem ser considerado código inútil
 
aproveito esta thread para anunciar que , se alguem desejar controlar algum jogo com o comando da Wii e nao souber fazer, basta dizer-me as teclas que deseja associar às do Wiimote, e será colocado aqui o respectivo Script.:D
 
Bem, sticky mesmo! Make.Love, tás lá ;)

Já agora, sei que não é muito relacionado, mas... vi isto hoje e fiquei espantado. Vejam bem a qualidade que o Wiimote nos proporciona num jogo como o Quake:

-> http://gonintendo.com/?p=65323

Isto foi feito pela comunidade homebrew! Bolas, será que developers não conseguem fazer melhor?

Make.Love, o GRID está tipo Mario Kart?
 
Back
Topo