Mapping wiimote buttons to GPC buttons

GPC2 script programming for Titan Two. Code examples, questions, requests.

Mapping wiimote buttons to GPC buttons

Postby OFC-Giorgio » Sun Jul 16, 2017 4:03 pm

I am using a wiimote via a Titan One + BT dongle (slot 0) plugged into a Titan Two.

I want to map the wiimote buttons to GPC buttons in my script (so without an input translator)

Via GTuner I noticed the following output from the wiimote:

Code: Select all
WII RAW INPUT via BT+T1 in T2
 
Index GPC ID PS4 ID          WII ID
 
0  BUTTON_1  PS              WII_HOME
1  BUTTON_2  SHARE           WII_MINUS
2  BUTTON_3  Options         WII_PLUS
3  BUTTON_4  R1           
4  BUTTON_5  R2           
5  BUTTON_6  R3              WII_ONE
6  BUTTON_7  L1              WII_C                       
7  BUTTON_8  L2              WII_Z
8  BUTTON_9  L3              WII_TWO
9  BUTTON_10 Dpad Up         WII_UP       
10 BUTTON_11 Dpad Down       WII_DOWN     
11 BUTTON_12 Dpad Left       WII_LEFT   
12 BUTTON_13 Dpad Right      WII_RIGHT   
13 BUTTON_14 Triangle     
14 BUTTON_15 Circle          WII_B
15 BUTTON_16 Cross           WII_A       
16 BUTTON_17 Square                   
17 BUTTON_18 Touch Click     
18 BUTTON_19 Touch P1                                 
19 BUTTON_20 Touch P2
20 BUTTON_21
21 STICK1_X  Right Stick X   WII_IRX           
22 STICK1_Y  Right Stick Y   WII_IRY           
23 STICK2_X  Left Stick X    WII_NC_X
24 STICK2_Y  Left Stick Y    WII_NC_Y
25 POINT1_X  Touch P1 X
26 POINT1_Y  Touch P1 Y
27 POINT2_X  Touch P2 X
28 POINT2_Y  Touch P2 Y
29 ACCEL1_X  Accel X         WII_ACCX
30 ACCEL1_Y  Accel Y         WII_ACCY
31 ACCEL1_Z  Accel Z         WII_ACCZ
32 ACCEL2_X 
33 ACCEL2_Y 
34 ACCEL2_Z 
35 GYRO1_X   Gyro X          WII_ACCNX
36 GYRO1_Y   Gyro Y          WII_ACCNY
37 GYRO1_Z   Gyro Z          WII_ACCNZ
 

I noticed that the value of BUTTON_18 is always 100. I wonder why? :unsure:

Since the WII ID's do not exist (yet) I made an include file wiimote_bt_t1_t2.gph:

Code: Select all
#ifndef WIIMOTE_BT_T1_T2_GPH_
#define WIIMOTE_BT_T1_T2_GPH_
 
// INPUT WIIMOTE -> BlueTooth -> T1 (slot 0) -> T2:
 
#define WII_NX    STICK_2_X
#define WII_NY    STICK_2_Y
#define WII_LEFT  BUTTON_12
#define WII_RIGHT BUTTON_13
#define WII_UP    BUTTON_10
#define WII_DOWN  BUTTON_11
#define WII_ACCNX GYRO_1_X
#define WII_ACCNY GYRO_1_Y
#define WII_ACCNZ GYRO_1_Z
#define WII_ACCX  ACCEL_1_X
#define WII_ACCY  ACCEL_1_Y
#define WII_ACCZ  ACCEL_1_Z
#define WII_PLUS  BUTTON_3
#define WII_MINUS BUTTON_2
#define WII_HOME  BUTTON_1
#define WII_ONE   BUTTON_6
#define WII_TWO   BUTTON_9
#define WII_A     BUTTON_16
#define WII_B     BUTTON_15
#define WII_C     BUTTON_7
#define WII_Z     BUTTON_8
#define WII_IRX   STICK_1_X
#define WII_IRY   STICK_1_Y
 
/*
#define WII_RT    BUTTON_4
#define WII_ZR    BUTTON_5
#define WII_LT    WII_C
#define WII_ZL    WII_Z
#define WII_RX    STICK_1_X
#define WII_RY    STICK_1_Y
#define WII_LX    STICK_2_X
#define WII_LY    STICK_2_Y
#define WII_X     BUTTON_14
#define WII_X     BUTTON_17
*/

 
#endif /* WIIMOTE_BT_T1_T2_GPH_ */


The WII input layout I would like to have mapped like the layout below :

Code: Select all
#include <ps4.gph>
#include <wiimote_bt_t1_t2.gph>
 
#define NA  -1
 
const uint8 GPCLayout[38] = {
    BUTTON_1BUTTON_2BUTTON_3BUTTON_4BUTTON_5BUTTON_6BUTTON_7,
    BUTTON_8BUTTON_9BUTTON_10, BUTTON_11, BUTTON_12, BUTTON_13, BUTTON_14,
    BUTTON_15, BUTTON_16, BUTTON_17, BUTTON_18, BUTTON_19, BUTTON_20, BUTTON_21,
    STICK_1_X, STICK_1_Y, STICK_2_X, STICK_2_Y,
    POINT_1_X, POINT_1_Y, POINT_2_X, POINT_2_Y,
    ACCEL_1_X, ACCEL_1_Y, ACCEL_1_Z, ACCEL_2_X, ACCEL_2_Y, ACCEL_2_Z,
    GYRO_1_XGYRO_1_YGYRO_1_Z
};
 
const uint8 WiimoteLayout[38] = {
    WII_HOME,  NA,        WII_TWO,   WII_PLUS,  WII_B,     WII_DOWN, NA,
    WII_Z,     WII_A,     NA,        NA,        NA,        NA,       WII_RIGHT,
    WII_C,     WII_UP,    WII_MINUS, WII_ONE,   NA,        NA,       NA,
    WII_IRX,   WII_IRY,   WII_NX,    WII_NY,
    NA,        NA,        NA,        NA,
    WII_ACCX,  WII_ACCY,  WII_ACCZ,  NA,        NA,        NA,
    WII_ACCNX, WII_ACCNY, WII_ACCNZ
};
 
init
{
  remapper(WiimoteLayout);
}


So WII_HOME is mapped on BUTTON_1, BUTTON_2 is not used, WII_TWO is mapped to BUTTON3, etc.

The code above does not do that (Gtuner shows: WII_TWO is mapped to BUTTON_9 instead of BUTTON_3) .

Any advice or pointers are appreciated :oops:
Last edited by OFC-Giorgio on Mon Jul 17, 2017 4:13 pm, edited 1 time in total.
User avatar
OFC-Giorgio
Lieutenant
Lieutenant
 
Posts: 344
Joined: Mon Sep 15, 2014 4:26 pm

Re: Mapping wiimote buttons to GPC buttons

Postby J2Kbr » Mon Jul 17, 2017 4:03 pm

When making a controller mapping, the actual index of the map array is the what is mapped,

For example: changing the value of index 2 (BUTTON_3) to BUTTON_4 will make the input associated with the index 2 (BUTTON_3/start/options) to be mapped to R1.

I rewrote your code with comments that will make easy do the remappings. Please note the ones you indicated were already done. :smile0517:

Code: Select all
#define WII_HOME    BUTTON_1        // PS              
#define WII_MINUS   BUTTON_2        // SHARE           
#define WII_PLUS    BUTTON_3        // Options         
#define WII_NA_1    BUTTON_4        // R1           
#define WII_NA_2    BUTTON_5        // R2           
#define WII_ONE     BUTTON_6        // R3             
#define WII_C       BUTTON_7        // L1                                     
#define WII_Z       BUTTON_8        // L2             
#define WII_TWO     BUTTON_9        // L3             
#define WII_UP      BUTTON_10       // Dpad Up               
#define WII_DOWN    BUTTON_11       // Dpad Down           
#define WII_LEFT    BUTTON_12       // Dpad Left         
#define WII_RIGHT   BUTTON_13       // Dpad Right         
#define WII_NA_3    BUTTON_14       // Triangle     
#define WII_B       BUTTON_15       // Circle         
#define WII_A       BUTTON_16       // Cross                 
#define WII_NA_4    BUTTON_17       // Square                   
#define WII_NA_5    BUTTON_18       // Touch Click     
#define WII_NA_6    BUTTON_19       // Touch P1                                 
#define WII_NA_7    BUTTON_20       // Touch P2
#define WII_NA_8    BUTTON_21       //
#define WII_IRX     STICK_1_X       // Right Stick X             
#define WII_IRY     STICK_1_Y       // Right Stick Y             
#define WII_NC_X    STICK_2_X       // Left Stick X   
#define WII_NC_Y    STICK_2_Y       // Left Stick Y   
#define WII_NA_9    POINT_1_X       // Touch P1 X
#define WII_NA_10   POINT_1_Y       // Touch P1 Y
#define WII_NA_11   POINT_2_X       // Touch P2 X
#define WII_NA_12   POINT_2_Y       // Touch P2 Y
#define WII_ACCX    ACCEL_1_X       // Accel X         
#define WII_ACCY    ACCEL_1_Y       // Accel Y         
#define WII_ACCZ    ACCEL_1_Z       // Accel Z         
#define WII_NA_13   ACCEL_2_X       //
#define WII_NA_14   ACCEL_2_Y       //
#define WII_NA_15   ACCEL_2_Z       //
#define WII_ACCNX   GYRO_1_X        // Gyro X         
#define WII_ACCNY   GYRO_1_Y        // Gyro Y         
#define WII_ACCNZ   GYRO_1_Z        // Gyro Z         
 
const uint8 WiimoteLayout[38] = {
    /* WII_HOME  -> */  BUTTON_1,
    /* WII_MINUS -> */  BUTTON_17,
    /* WII_PLUS  -> */  BUTTON_4,
    /* WII_NA_1  -> */  BUTTON_10,
    /* WII_NA_2  -> */  BUTTON_7,
    /* WII_ONE   -> */  BUTTON_18,
    /* WII_C     -> */  BUTTON_15,
    /* WII_Z     -> */  BUTTON_8,
    /* WII_TWO   -> */  BUTTON_3,
    /* WII_UP    -> */  BUTTON_16,
    /* WII_DOWN  -> */  BUTTON_6,
    /* WII_LEFT  -> */  BUTTON_12,
    /* WII_RIGHT -> */  BUTTON_14,
    /* WII_NA_3  -> */  BUTTON_13,
    /* WII_B     -> */  BUTTON_5,
    /* WII_A     -> */  BUTTON_9,
    /* WII_NA_4  -> */  BUTTON_2,
    /* WII_NA_5  -> */  BUTTON_11,
    /* WII_NA_6  -> */  BUTTON_19,
    /* WII_NA_7  -> */  BUTTON_20,
    /* WII_NA_8  -> */  BUTTON_21,
    /* WII_IRX   -> */  STICK_1_X,
    /* WII_IRY   -> */  STICK_1_Y,
    /* WII_NC_X  -> */  STICK_2_X,
    /* WII_NC_Y  -> */  STICK_2_Y,
    /* WII_NA_9  -> */  POINT_1_X,
    /* WII_NA_10 -> */  POINT_1_Y,
    /* WII_NA_11 -> */  POINT_2_X,
    /* WII_NA_12 -> */  POINT_2_Y,
    /* WII_ACCX  -> */  ACCEL_1_X,
    /* WII_ACCY  -> */  ACCEL_1_Y,
    /* WII_ACCZ  -> */  ACCEL_1_Z,
    /* WII_NA_13 -> */  ACCEL_2_X,
    /* WII_NA_14 -> */  ACCEL_2_Y,
    /* WII_NA_15 -> */  ACCEL_2_Z,
    /* WII_ACCNX -> */  GYRO_1_X,
    /* WII_ACCNY -> */  GYRO_1_Y,
    /* WII_ACCNZ -> */  GYRO_1_Z
};
 
init {
  remapper(WiimoteLayout);
}
 
 
ConsoleTuner Support Team
User avatar
J2Kbr
General of the Army
General of the Army
 
Posts: 20323
Joined: Tue Mar 18, 2014 1:39 pm

Re: Mapping wiimote buttons to GPC buttons

Postby masterofwafflez » Thu Aug 24, 2017 12:49 am

What if your not using a titan 1 too connect the wiimote? I'm using a dolphin bar its a usb light bar with Bluetooth for the wii controller built in. it all works except the bindings aren't usable.
User avatar
masterofwafflez
Sergeant
Sergeant
 
Posts: 8
Joined: Sat Jun 24, 2017 1:11 pm


Return to GPC2 Script Programming

Who is online

Users browsing this forum: EvilGlenn and 138 guests