×
Namespaces

Variants
Actions
(Difference between revisions)

QWiimote - Nintendo Wiimote interactions for Qt / Symbian applications

From Nokia Developer Wiki
Jump to: navigation, search
galazzo (Talk | contribs)
(Galazzo - - QML)
hamishwillee (Talk | contribs)
m (Hamishwillee - Bot update - Fix metadata)
Line 7: Line 7:
 
|platform= Symbian^3 and later
 
|platform= Symbian^3 and later
 
|devicecompatability= <!-- Compatible devices e.g.: All* (must have internal GPS) -->
 
|devicecompatability= <!-- Compatible devices e.g.: All* (must have internal GPS) -->
|dependencies= <!-- Any other/external dependencies e.g.: Google Maps Api v1.0 -->  
+
|dependencies= <!-- Any other/external dependencies e.g.: Google Maps Api v1.0 -->
|signing=DevCert
+
|signing= DevCert
 
|capabilities= WriteDeviceData NetworkServices LocalServices
 
|capabilities= WriteDeviceData NetworkServices LocalServices
 
|keywords= Nintendo, Wiimote, Bluetooth, HID
 
|keywords= Nintendo, Wiimote, Bluetooth, HID
 
|language= <!-- Language category code for non-English topics - e.g. Lang-Chinese -->
 
|language= <!-- Language category code for non-English topics - e.g. Lang-Chinese -->
 
|translated-by= <!-- [[User:XXXX]] -->
 
|translated-by= <!-- [[User:XXXX]] -->
|translated-from-title= <!-- Title only -->  
+
|translated-from-title= <!-- Title only -->
 
|translated-from-id= <!-- Id of translated revision -->
 
|translated-from-id= <!-- Id of translated revision -->
|review-by=<!-- After re-review: [[User:username]] -->
+
|review-by= <!-- After re-review: [[User:username]] -->
 
|review-timestamp= <!-- After re-review: YYYYMMDD -->
 
|review-timestamp= <!-- After re-review: YYYYMMDD -->
 
|update-by= <!-- After significant update: [[User:username]]-->
 
|update-by= <!-- After significant update: [[User:username]]-->
Line 27: Line 27:
 
The Wii MotionPlus is an expansion device for the Wii Remote video game controller for the Wii that allows it to more accurately capture complex motion. According to Nintendo, the sensor in the device supplements the accelerometer and Sensor Bar capabilities of the Wii Remote to enable actions to be rendered identically on the screen in real time.<br />
 
The Wii MotionPlus is an expansion device for the Wii Remote video game controller for the Wii that allows it to more accurately capture complex motion. According to Nintendo, the sensor in the device supplements the accelerometer and Sensor Bar capabilities of the Wii Remote to enable actions to be rendered identically on the screen in real time.<br />
 
Since 2006, launch date for Nintendo Wii, have been developed projects and tools to connect the Wiimote to devices different form the mother console.  Anyway almost all are focused on Desktop application with very complex structurre and code interfaces.<br />
 
Since 2006, launch date for Nintendo Wii, have been developed projects and tools to connect the Wiimote to devices different form the mother console.  Anyway almost all are focused on Desktop application with very complex structurre and code interfaces.<br />
Last but not least there is a poor support for mobile platforms where there is more focues on to substitute the device event management with the controller one. {{Icode|QWiimote}} provide a QML bind and easy method to catch Nintendo's controller raw data and event.<br />
+
Last but not least there is a poor support for mobile platforms where there is more focues on to substitute the device event management with the controller one. {{Icode|QWiimote}} provide a QML bind and easy method to catch Nintendo's controller raw data and event.<br />
 
This article will cover just the API to interact with Wiimote. For who's interested on hack informations, please refer to dedicated project's section : [http://projects.developer.nokia.com/Wiimote/wiki/Wiimote_Hacking Wiimote Hacking]
 
This article will cover just the API to interact with Wiimote. For who's interested on hack informations, please refer to dedicated project's section : [http://projects.developer.nokia.com/Wiimote/wiki/Wiimote_Hacking Wiimote Hacking]
  
Line 246: Line 246:
 
Emitted when the controller is connected to your device
 
Emitted when the controller is connected to your device
 
* {{Icode|disconnected()}}<br />
 
* {{Icode|disconnected()}}<br />
Emitted when the controller disconnect from your device
+
Emitted when the controller disconnect from your device
 
* {{Icode|deviceSelected(QString address)}}<br />
 
* {{Icode|deviceSelected(QString address)}}<br />
 
Emitted when select the coontroller from the list of availables Bluetooth devices
 
Emitted when select the coontroller from the list of availables Bluetooth devices
Line 252: Line 252:
 
Emitted when the Bluetooth is powerd-on on your device
 
Emitted when the Bluetooth is powerd-on on your device
 
* {{Icode|extentionControllerPlugged()}}<br />
 
* {{Icode|extentionControllerPlugged()}}<br />
Emitted when an extention controller ( like Nunchuck ) is plugged to Wiimote
+
Emitted when an extention controller ( like Nunchuck ) is plugged to Wiimote
 
* {{Icode|buttonPressed(int button)}}<br />
 
* {{Icode|buttonPressed(int button)}}<br />
 
Emitted when a button is pressed. {{Icode|button}} provide the code of button pressed on controller.  
 
Emitted when a button is pressed. {{Icode|button}} provide the code of button pressed on controller.  
 
* {{Icode|buttonLeft()}}<br />
 
* {{Icode|buttonLeft()}}<br />
Emitted when the ''left'' button is pressed. Also a {{Icode|buttonPressed(int button)}} signal is emitted.
+
Emitted when the ''left'' button is pressed. Also a {{Icode|buttonPressed(int button)}} signal is emitted.
 
* {{Icode|buttonRight()}}<br />
 
* {{Icode|buttonRight()}}<br />
 
Emitted when the ''right'' button is pressed. Also a {{Icode|buttonPressed(int button)}} signal is emitted.
 
Emitted when the ''right'' button is pressed. Also a {{Icode|buttonPressed(int button)}} signal is emitted.
 
* {{Icode|buttonDown()}}<br />
 
* {{Icode|buttonDown()}}<br />
Emitted when the ''down'' button is pressed. Also a {{Icode|buttonPressed(int button)}} signal is emitted.
+
Emitted when the ''down'' button is pressed. Also a {{Icode|buttonPressed(int button)}} signal is emitted.
 
* {{Icode|buttonUp()}}<br />
 
* {{Icode|buttonUp()}}<br />
 
Emitted when the ''up'' button is pressed. Also a {{Icode|buttonPressed(int button)}} signal is emitted.
 
Emitted when the ''up'' button is pressed. Also a {{Icode|buttonPressed(int button)}} signal is emitted.
Line 272: Line 272:
 
Emitted when the ''B'' button is pressed. Also a {{Icode|buttonPressed(int button)}} signal is emitted.
 
Emitted when the ''B'' button is pressed. Also a {{Icode|buttonPressed(int button)}} signal is emitted.
 
* {{Icode|buttonA()}}<br />
 
* {{Icode|buttonA()}}<br />
Emitted when the ''A'' button is pressed. Also a {{Icode|buttonPressed(int button)}} signal is emitted.
+
Emitted when the ''A'' button is pressed. Also a {{Icode|buttonPressed(int button)}} signal is emitted.
 
* {{Icode|buttonMinus()}}<br />
 
* {{Icode|buttonMinus()}}<br />
 
Emitted when the ''-'' button is pressed. Also a {{Icode|buttonPressed(int button)}} signal is emitted.
 
Emitted when the ''-'' button is pressed. Also a {{Icode|buttonPressed(int button)}} signal is emitted.

Revision as of 07:11, 26 October 2012

Article Metadata
Tested with
Devices(s): Nokia C7-00, Nokia N8
Compatibility
Platform(s): Symbian^3 and later
Platform Security
Signing Required: DevCert
Capabilities: WriteDeviceData NetworkServices LocalServices
Article
Keywords: Nintendo, Wiimote, Bluetooth, HID
Created: galazzo (20 Oct 2012)
Last edited: hamishwillee (26 Oct 2012)

Contents

Introduction

Nintendo Wiimote
The Wii Remote, also known colloquially as the Wiimote, is the primary controller for Nintendo's Wii console. A main feature of the Wii Remote is its motion sensing capability, which allows the user to interact with and manipulate items on screen via gesture recognition and pointing through the use of accelerometer and optical sensor technology. Another feature is its expandability through the use of attachments. The attachment bundled with the Wii console is the Nunchuk, which complements the Wii Remote by providing functions similar to those in gamepad controllers.

The Wii MotionPlus is an expansion device for the Wii Remote video game controller for the Wii that allows it to more accurately capture complex motion. According to Nintendo, the sensor in the device supplements the accelerometer and Sensor Bar capabilities of the Wii Remote to enable actions to be rendered identically on the screen in real time.
Since 2006, launch date for Nintendo Wii, have been developed projects and tools to connect the Wiimote to devices different form the mother console. Anyway almost all are focused on Desktop application with very complex structurre and code interfaces.
Last but not least there is a poor support for mobile platforms where there is more focues on to substitute the device event management with the controller one. QWiimote provide a QML bind and easy method to catch Nintendo's controller raw data and event.
This article will cover just the API to interact with Wiimote. For who's interested on hack informations, please refer to dedicated project's section : Wiimote Hacking

QWiimote

  • Download the project from here

.pro

include(wiimote/wiimote.pri)

main.cpp

#include <QtGui/QApplication>
#include "qmlapplicationviewer.h"
 
#ifdef QWIIMOTE
#include <QtDeclarative>
#include "wiimote/qwiimote.h"
#endif
 
Q_DECL_EXPORT int main(int argc, char *argv[])
{
QScopedPointer<QApplication> app(createApplication(argc, argv));
 
#ifdef QWIIMOTE
qmlRegisterType<QWiimote>("Wiimote", 1, 0, "Wiimote");
#endif
 
QmlApplicationViewer viewer;
viewer.setMainQmlFile(QLatin1String("qml/WiimoteDemo/main.qml"));
viewer.showExpanded();
 
return app->exec();
}

QML

import QtQuick 1.1
import com.nokia.symbian 1.1
import Wiimote 1.0
 
Page {
id: mainPage
 
Column {
id: column1
width: 360
height: 640
spacing: 20
 
Button {
text: "Start!"
anchors.horizontalCenter: parent.horizontalCenter
onClicked: wiimote.start();
}
 
Button {
text: "Motion Plus"
anchors.horizontalCenter: parent.horizontalCenter
onClicked: wiimote.enableMotionPlus()
}
 
Button {
text: "Calibration"
anchors.horizontalCenter: parent.horizontalCenter
onClicked: wiimote.requestCalibrationData()
}
 
Button {
text: "Activate Buttons"
anchors.horizontalCenter: parent.horizontalCenter
onClicked: wiimote.enableCoreButtons()
}
 
Button {
text: "Activate Buttons and Accelerometer"
anchors.horizontalCenter: parent.horizontalCenter
onClicked: wiimote.enableCoreButtonsAndAccelerometer()
}
 
Button {
text: "Acceleration + Extension report"
anchors.horizontalCenter: parent.horizontalCenter
onClicked: wiimote.enableCoreButtonsAccelerometerExtention()
}
 
Row {
width: parent.width
height: 25
 
Text {
text: qsTr("X:")
height: parent.height
color: "#ffffff"
width: 60
font.pixelSize: 25
}
Text {
id: accelerometerX
height: parent.height
color: "#ffffff"
width: 60
font.pixelSize: 25
}
Text {
text: qsTr("Y:")
height: parent.height
color: "#ffffff"
width: 60
font.pixelSize: 25
}
Text {
id: accelerometerY
height: parent.height
color: "#ffffff"
width: 60
font.pixelSize: 25
}
Text {
text: qsTr("Z:")
height: parent.height
color: "#ffffff"
width: 60
font.pixelSize: 25
}
Text {
id: accelerometerZ
height: parent.height
color: "#ffffff"
width: 60
font.pixelSize: 25
}
}
}
 
Wiimote {
id: wiimote
 
onError : {
console.log("Error code:"+error)
}
 
onPowerOn : {
console.log("Bluetooth power error:"+error)
}
 
onDeviceSelected : {
console.log("Selected device :"+address)
}
 
onConnected : {
console.log("Connected to device")
wiimote.setLed(Wiimote.Led1)
}
 
onDisconnected : {
console.log("Disconnected from device")
Qt.quit();
}
 
onSendCompleted : {
console.log("Sent data to device")
}
 
onAccelerometerChanged: {
accelerometerX.text = accelerometer.x;
accelerometerY.text = accelerometer.y;
accelerometerZ.text = accelerometer.z;
}
 
onExtentionControllerPlugged: {
console.log("ExtentionControllerPlugged");
}
 
onButtonPressed : {
console.log("pressed button: "+ button);
if( button === (Wiimote.ButtonA|Wiimote.ButtonB))
console.log("A + B pressed")
}
 
onButtonLeft : {
console.log("pressed left button");
}
 
onButtonRight : {
console.log("pressed right button");
}
 
onButtonUp : {
console.log("pressed up button");
}
 
onButtonDown : {
console.log("pressed down button");
}
 
onButtonHome : {
console.log("pressed home button");
}
 
onButtonA : {
console.log("pressed A button");
}
 
onButtonMinus : {
console.log("pressed Minus button");
}
}
}

Signals

  • connected()

Emitted when the controller is connected to your device

  • disconnected()

Emitted when the controller disconnect from your device

  • deviceSelected(QString address)

Emitted when select the coontroller from the list of availables Bluetooth devices

  • powerOn(bool error)

Emitted when the Bluetooth is powerd-on on your device

  • extentionControllerPlugged()

Emitted when an extention controller ( like Nunchuck ) is plugged to Wiimote

  • buttonPressed(int button)

Emitted when a button is pressed. button provide the code of button pressed on controller.

  • buttonLeft()

Emitted when the left button is pressed. Also a buttonPressed(int button) signal is emitted.

  • buttonRight()

Emitted when the right button is pressed. Also a buttonPressed(int button) signal is emitted.

  • buttonDown()

Emitted when the down button is pressed. Also a buttonPressed(int button) signal is emitted.

  • buttonUp()

Emitted when the up button is pressed. Also a buttonPressed(int button) signal is emitted.

  • buttonPlus()

Emitted when the + button is pressed. Also a buttonPressed(int button) signal is emitted.

  • buttonTwo()

Emitted when the 2 button is pressed. Also a buttonPressed(int button) signal is emitted.

  • buttonOne()

Emitted when the 1 button is pressed. Also a buttonPressed(int button) signal is emitted.

  • buttonB()

Emitted when the B button is pressed. Also a buttonPressed(int button) signal is emitted.

  • buttonA()

Emitted when the A button is pressed. Also a buttonPressed(int button) signal is emitted.

  • buttonMinus()

Emitted when the - button is pressed. Also a buttonPressed(int button) signal is emitted.

  • buttonHome()

Emitted when the Home button is pressed. Also a buttonPressed(int button) signal is emitted.

  • error(int error)

Emitted when an error occurs.

Slots / Invokable Methods

  • setLed(WiimoteLed led)
  • enableCoreButtons()
  • enableCoreButtonsAndAccelerometer()
  • enableCoreButtonsAccelerometerExtention()
  • enableMotionPlus()
  • disableMotionPlus()
  • requestCalibrationData()

Further improvements

The project is still under development anyway features already available are almost freezed. More other function incoming soon. Accelerometer and Gyroscope ( Motion Plus ) raw data acquisition are already available but not yet for QML as for battery level notification.

Next days release:

  1. Accelerometer and Motion Plus bind to QML
  2. Accelerometer and Gyroscope smooth data
  3. IR-Camera support
267 page views in the last 30 days.
×