~mixxxcontributors/mixxx/advanced_autodj

« back to all changes in this revision

Viewing changes to mixxx/res/controllers/Nintendo Wiimote.hid.js

  • Committer: Daniel Schürmann
  • Date: 2013-06-12 23:27:21 UTC
  • mfrom: (3184.1.101 mixxx-trunk)
  • Revision ID: daschuer@mixxx.org-20130612232721-ol6h11m9xbf72d2k
merge -r date:2012-06-26 lp:mixxx

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// 
 
2
// Nintendo Wii Remote controller HID packet declaration
 
3
// 
 
4
// This model does not register any of the packet fields directly to
 
5
// mixxx controls. Please register callbacks to fields named here in
 
6
// the script using WiimoteController() object and parse events
 
7
// yourself in callbacks.
 
8
// 
 
9
// Details for Wiimote HID packet data can be found in:
 
10
// http://wiibrew.org/wiki/Wiimote
 
11
//
 
12
// Note: until I figure out why my Wii does not accept output packets
 
13
// for LED and mode control, this mapping is for the basic mode only
 
14
// with buttons: no rumble, LED control or accelerometer data.
 
15
//
 
16
 
 
17
function WiimoteController() {
 
18
    this.controller = new HIDController();
 
19
 
 
20
    this.registerInputPackets = function() {
 
21
        // Example call for debugging: calling packet level 
 
22
        // callback ignores all field scalers and callbacks
 
23
        //packet = new HIDPacket('control',[],3,this.dump);
 
24
 
 
25
        // Basic button toggle input packet: packet is longer when
 
26
        // we figure out how to enable other data than buttons
 
27
        packet = new HIDPacket('control',[],3);
 
28
 
 
29
        packet.addControl('hid','arrow_left',1,'B',0x1);
 
30
        packet.addControl('hid','arrow_right',1,'B',0x2);
 
31
        packet.addControl('hid','arrow_down',1,'B',0x4);
 
32
        packet.addControl('hid','arrow_up',1,'B',0x8);
 
33
        packet.addControl('hid','button_plus',1,'B',0x10);
 
34
        packet.addControl('hid','button_1',2,'B',0x2);
 
35
        packet.addControl('hid','button_2',2,'B',0x1);
 
36
        packet.addControl('hid','button_bottom',2,'B',0x4);
 
37
        packet.addControl('hid','button_a',2,'B',0x8);
 
38
        packet.addControl('hid','button_minus',2,'B',0x10);
 
39
        packet.addControl('hid','button_home',2,'B',0x80);
 
40
 
 
41
        this.controller.registerInputPacket(packet);
 
42
    }
 
43
 
 
44
    // Wiimote has output controls, but I could not figure out how
 
45
    // to send the packets, I'm just getting a general error response.
 
46
    this.registerOutputPackets = function() { }
 
47
 
 
48
    // No default scalers: all controls done with callbacks anyway
 
49
    this.registerScalers = function() { }
 
50
 
 
51
    // Register your own callbacks in caller by overriding this
 
52
    this.registerCallbacks = function() { }
 
53
 
 
54
    // Default dummy callback for gyro events
 
55
    this.gyro = function(field) { return; }
 
56
 
 
57
    // Example of packet callback: 
 
58
    // dumps changes (delta) in all packet fields
 
59
    this.dump = function(packet,delta) {
 
60
        for (field_name in delta) {
 
61
            var field = delta[field_name];
 
62
            script.HIDDebug('Wiimote ' + field.id + ' VALUE ' + field.value);
 
63
        }   
 
64
    }
 
65
 
 
66
}
 
67