Gamepad to Mouse: Help needed

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

Re: Gamepad to Mouse: Help needed

Postby Scachi » Wed Jul 31, 2019 3:24 pm

SpecialEffect wrote:Brilliant. Love it! Seems spot on.

I tried on iOS13, and no luck getting a connection either through USB nor via Bluetooth PS4. Hopefully with a Bluetooth Multi HID device protocol update to the T2 this might work. I fear Apple have a block on even acknowledging the Titan though as it appears on an Android device, but not iOS. I've left them some feedback to say it would be fantastic to broaden the range of controllers that can attach to the iPad for simulated touch-mode and traditional gaming.

If you'd be up for it, I was wondering if you might consider a related script to accompany this it, giving some extra accessibility features for a standard gamepad? And then allow the users to swap between the two (gamepad/mouse protocol) if needed.

Huge thanks again. Really fantastic script.

You are welcome. Without the great code from J2kbr to start with it would have been a lot harder to get this thing to its current state. :smile0517:
I would be a nice addition to the Online Resource to upload your script to it with including your video into its description.
This way it would be easy to find/download/use for other users.
For including your video into the description you have to ask J2kbr via PM on how to do this.

Put in your Username and Password (both case sensitive) into GTuner iV ->Tools->Preferences->ConsoleTuner and you should be able to upload it to the Online Resource via GTuner IV->Tools->"Publish Wizard" when you have opened the script in the GPC IDE Editor.

.. For the other script, sure. Post your feature idea details in the forum as you have done with your first script and I am sure someone is willing to help. You did a great job describing the features you want and stuff that was not working right.

Send me a pm with a link to your post and I'll check to see if you still need help when I am back again :wink:
User avatar
Scachi
Brigadier General
Brigadier General
 
Posts: 3044
Joined: Wed May 11, 2016 6:25 am
Location: Germany

Re: Gamepad to Mouse: Help needed

Postby SpecialEffect » Wed Aug 14, 2019 10:46 am

Apologies for the delay. I've been looking into getting this working on Apple devices. Well, happily, it's working quite well on the iOS 13 Beta (latest release).

https://youtu.be/t3fp8bDMZOE - gives an early glimpse of it working. I've got further since. You can use the PS4 Dual shock wirelessly too with a suitable portable power pack.

I've recently learnt that getting the on-screen keyboard to work on iOS is best set-up via: Settings > Accessibility > Touch > Assistive Touch > Show Onscreen Keyboard (ON).


Three issues for this script remain I feel.

1. The Touch-pad click/View/Back button doesn't seem to work anymore. It should toggle between two or more speeds. Maybe I'm doing something wrong?

2. L2 = backspace (or optionally ENTER) would be nice.

3. Swapping slots. Using the default L1 (held) or R1(held) then tapping HOME is too difficult for some users. As an option (default = off), it would be great to give users the ability to use L1 = GOTO SLOT X and R1 = GOTO SLOT Y. Even if just as commented out code. Maybe also, tap R3 x number of times = GOTO SLOT Z... That could be useful for an attached switch connected to R3 (very easy to do).


Presently, it's not possible to swap between gamepad / mouse modes on iOS yet, as you can't connect a non-approved gamepad (including I believe PS4 and Xbox One 1st party controllers) via USB (aka the Titan Two connection). That's the next hope. Will ask Apple on this too.

Again, huge thanks to all helping on this.

Barrie
User avatar
SpecialEffect
Sergeant Major of the Army
Sergeant Major of the Army
 
Posts: 203
Joined: Mon Apr 07, 2014 3:26 pm

Re: Gamepad to Mouse: Help needed

Postby Scachi » Wed Aug 14, 2019 1:39 pm

Here a quick bugfix for the touchclick not changing sensitivity..
The other stuff will be done in the next few days...
different buttons to change slots has to be done for each script you are using, it can't be changed generally/directly in the T2 configuration. You can only enabled/disable RB/LB+Home in the T2 settings (Device Configuration).

Code: Select all
#pragma METAINFO("Gamepad 2 Mouse", 1, 06, "Scachi/J Koppe/G Law/B Ellis (SpecialEffect)")
// 29/7/2019
// Created for http://www.SpecialEffect.org.uk - PUBLIC DOMAIN
// viewtopic.php?f=26&t=13195
// Designed to convert a PS4/Xbox gamepad to Mouse use. Controls are...
 
// LEFT-STICK = MOUSE MOVEMENT , adjustable sensitivity with TOUCH/VIEW/BACK button
// RIGHT_STICK = MOUSE MOVEMENT , fixed sensitivity (index sensitivity_right_stick)
// CROSS/A = LEFT-CLICK
// CIRCLE/B = RIGHT-CLICK
// TRIANGLE/Y = DRAG ON/OFF
// SQUARE/X = AXIS LOCK (X-AXIS / Y-AXIS / FREE MOVEMENT)
// R2/RT = DOUBLE-LEFT-CLICK
// OPTION/START = tap->keyboard: ALT+F4 (pulse), hold->keyboard: ESCAPE (hold)
// DPAD = keyboard: cursor/arrow keys
 
// HOLD R2/RB + TAP HOME = CHANGE SLOT +1 (e.g. to Forced Xbox 360 Gamepad mode)
// HOLD L2/LB + TAP HOME = CHANGE SLOT -1
 
// I HAVE PUT THE INTERACTIVE CONFIGURATION DEFINITION AT THE END OF THE SCRIPT
// manual changes to the configuration in the code will have no effect now.
 
 
/*** CONFIGURATION SECTION START ***/
 
// LED brightness
fix32 brightness=60f;
// known colors, use first letter: 'B'lue, 'R'ed, 'G'reen, 'P'urple, 'C'yan, 'Y'ellow, 'W'hite;
uint8 color_default    ='B'// default color used
uint8 color_drag         ='R'// color for active drag
 
// MOUSE SPEED VARIABLE(0.02 slowest speed)
fix32 sensitivities[]             = {0.08,0.02, 0.00}; // always 3 values, set to 0.00 for not using one
// sensitivity_active uses first entry of sensitivities array as default, index 0 first value
uint8 sensitivity_active        =0;
// sensitivity index to use for right stick
fix32 sensitivity_right_stick;
 
// DEADZONE
fix32 deadzone = 20f;
 
// ALLOW USAGE OF DRAG
bool drag_allowed=TRUE;
 
// ALLOW LEFT_DOUBLE_CLICK
bool left_double_click_allowed=TRUE;
 
// ALLOW USAGE OF AXIS LOCKING
bool axis_lock_allowed=TRUE;
 
 
 
// ALOW DPAP TO CURSOR
bool dpad_to_cursor_allowed=TRUE;
 
// ALLOW USAGE OF Keyboard ALT+F4 & ESCAPE
bool altf4_escape_allowed=TRUE;
 
// OPTION/START time limit. In limit -> ALT+F4 , longer hold -> ESCAPE as long as button is hold
uint16 altf4_taplimit=250;
 
/*** CONFIGURATION SECTION END ***/
 
 
 
// Header file containing mouse related definitions
#include <mouse.gph>
 
// Header file containing keyboard related definitions
#include <keyboard.gph>
 
// Toogle variable for mouse left drag
bool drag_toggle;
 
// Toggle variable for axis lock. limit axis movement to: 0=x&y, 1=x, 2=y
uint8 axis_lock;
 
// flag if at least one valid sensitivity value was found
bool sensitivity_all_zero;
 
init {
    // FORCE HID (MOUSE) OUTPUT PROTOCOL.
    // N.B. Tick "Disable Joystick from Multi Interface HID output" in GTuner IV > Device Configuration > Device Options !!!!
    port_connect(PORT_USB_C, PROTOCOL_HID);
 
/* INTERACTIVE CONFIGURATION HANDLING / VALUE LOADING !!! START !!! */
        // load slots interactive configuration storage memory
        pmem_load();
 
        pmem_read(0, &brightness);
 
        // convert combox box value to char as the color function requires char:
        //        'B'lue, 'R'ed, 'G'reen, 'P'urple, 'C'yan, 'Y'ellow, 'W'hite;
        uint8 char_colors[] = { 'B','R','G','P','C','Y','W',};
        pmem_read(4, &color_default);
        color_default=char_colors[color_default]; // translate to char
        pmem_read(5, &color_drag);   
        color_drag=char_colors[color_drag]; // translate to char
 
        drag_allowed = (pmem_read(6) >> 0) & 0b1;
        left_double_click_allowed = (pmem_read(6) >> 1) & 0b1;
        axis_lock_allowed = (pmem_read(6) >> 2) & 0b1;
 
        pmem_read(16, &deadzone);
        pmem_read(20,&sensitivities[0]);
        pmem_read(24,&sensitivities[1]);
        pmem_read(28,&sensitivities[2]);
        /* check if at least one sensitivity is set */
        sensitivity_all_zero=TRUE;
        uint8 i=0;
        for (i=0; i<(sizeof(sensitivities)/4);i++)
        {
            if (sensitivities[i] > 0.0) sensitivity_all_zero=FALSE; // a valid value found
        }
 
        pmem_read(46,&sensitivity_right_stick);
 
 
        altf4_escape_allowed  = (pmem_read(50) >> 0) & 0b1;
        dpad_to_cursor_allowed= (pmem_read(50) >> 1) & 0b1;
        pmem_read(51, &altf4_taplimit);
/* INTERACTIVE CONFIGURATION HANDLING / VALUE LOADING !!! END !!! */
 
        // set default color
        ColorLED(color_default,brightness);
}
 
main {
 
     // TOUCH/VIEW/BACK button = SPEED adjustment
        if (!sensitivity_all_zero) {
            if(event_active(BUTTON_2)) {
                sensitivity_active = (sensitivity_active + 1) % (sizeof(sensitivities) / 4); // use next one
                while (sensitivities[sensitivity_active] == 0.0) // on sensitivity 0.0 try the next one until finding a valid
                {
                    sensitivity_active = (sensitivity_active + 1) % (sizeof(sensitivities) / 4);
                }
            }
        }
 
    // TRIANGLE/Y = DRAG ON/OFF
        if (drag_allowed) {
                if(event_active(BUTTON_14)) {
                        drag_toggle = !drag_toggle;
                        if (drag_toggle) ColorLED(color_drag,brightness);
                        else ColorLED(color_default,brightness);
                }
        }
 
    // R2/RT = DOUBLE-LEFT CLICK
        if (left_double_click_allowed) {
                if (event_active(BUTTON_5)) combo_run(DoubleLeftClick);
        }
 
    // SQUARE/X = AXIS LOCK (X-AXIS/Y-AXIS/FREE MOVEMENT)
        if (axis_lock_allowed) {
                if(event_active(BUTTON_17)) {
                        axis_lock = (axis_lock + 1) %3;
                }
        }
 
        // OPTIONS/START release, (TAP) = ALT+F4 (pulse) or ESCAPE (release)
        if (altf4_escape_allowed) {
            if (event_release(BUTTON_3)) {
                if (time_active(BUTTON_3) < altf4_taplimit) combo_run(AltF4); // short tap
                else combo_restart(Escape); // longer hold
            }
            // OPTIONS/START (HOLD) = Escape (hold as long button is hold)
            if (check_active(BUTTON_3,altf4_taplimit)) combo_run(Escape);
        }
 
        // Run the combo that converts DPAD to Cursor Keys
        if (dpad_to_cursor_allowed) {
            combo_run(DPad2Cursor);
        }
 
    // Run the combo that converts the gamepad input to mouse output. The combo
    // works as flow control to not overflow the host with mouse data packets.
    combo_run(Gamepad2Mouse);
}
 
 
combo AltF4 {
        // press
        key_set(KEY_LEFTALT,TRUE);
        key_set(KEY_F4,TRUE);
        wait(0); wait(25);
        // release
        key_set(KEY_LEFTALT,FALSE);
        key_set(KEY_F4,FALSE);
        wait(0);
}
 
 
combo Escape {
        // button active AND key not active -> set key pressed
        if ( is_active(BUTTON_3) && !key_get(KEY_ESCAPE)) key_set(KEY_ESCAPE,TRUE);
        // button not active AND key active -> set key released
        if (!is_active(BUTTON_3) &&  key_get(KEY_ESCAPE)) key_set(KEY_ESCAPE,FALSE);
 
        // Flow control timing
        wait(0);
        wait(6);
}
 
 
combo DPad2Cursor {   
      // UP : button active AND key not active -> set key pressed
        if ( get_actual(BUTTON_10) && !key_get(KEY_UPARROW        )) key_set(KEY_UPARROW    ,  TRUE);
        // UP : button not active AND key active -> set key released
        if (!get_actual(BUTTON_10) &&  key_get(KEY_UPARROW        )) key_set(KEY_UPARROW    ,  FALSE);
 
        // DOWN : button active AND key not active -> set key pressed
        if ( get_actual(BUTTON_11) && !key_get(KEY_DOWNARROW    )) key_set(KEY_DOWNARROW,  TRUE);
        // DOWN : button not active AND key active -> set key released
        if (!get_actual(BUTTON_11) &&  key_get(KEY_DOWNARROW    )) key_set(KEY_DOWNARROW,  FALSE);
 
        // LEFT : button active AND key not active -> set key pressed
        if ( get_actual(BUTTON_12) && !key_get(KEY_LEFTARROW    )) key_set(KEY_LEFTARROW,  TRUE);
        // DOWN : button not active AND key active -> set key released
        if (!get_actual(BUTTON_12) &&  key_get(KEY_LEFTARROW    )) key_set(KEY_LEFTARROW,  FALSE);
 
        // RIGHT : button active AND key not active -> set key pressed
        if (get_actual(BUTTON_13) && !key_get(KEY_RIGHTARROW    )) key_set(KEY_RIGHTARROW, TRUE);
        // RIGHT : button  not active AND key active -> set key released
        if (!get_actual(BUTTON_13) &&  key_get(KEY_RIGHTARROW    )) key_set(KEY_RIGHTARROW, FALSE);
 
        // Flow control timing
        wait(0);
        wait(6);
}
 
 
combo DoubleLeftClick {
        mouse_set(MBUTTON_1,  TRUE); wait(0); wait(6); // click
        mouse_set(MBUTTON_1, FALSE); wait(0); wait(6); // release
        mouse_set(MBUTTON_1,  TRUE); wait(0); wait(6); // click
        mouse_set(MBUTTON_1, FALSE); wait(0); // release
}
 
 
combo Gamepad2Mouse {
 
        // use left stick and sensitivity_active index by default
        uint8 STICK_X=STICK_2_X;
        uint8 STICK_Y=STICK_2_Y;
        fix32 sensitivity_x=sensitivities[sensitivity_active];
        fix32 sensitivity_y=sensitivities[sensitivity_active];
 
        // per axis: when right stick is > deadzone use it and its sensitivity index
        if (sensitivity_right_stick > 0.0) {
                if (abs(get_actual(STICK_1_X)) > deadzone ) {
                        STICK_X = STICK_1_X;
                        sensitivity_x=sensitivity_right_stick;
                }
                if (abs(get_actual(STICK_1_Y)) > deadzone ) {
                        STICK_Y = STICK_1_Y;
                        sensitivity_y=sensitivity_right_stick;
                }
        }
 
        // STICK X-AXIS TO MOUSE Y-AXIS
        if((axis_lock==0 || axis_lock==1) && abs(get_actual(STICK_X)) > deadzone) {
                mouse_set(MOUSE_X, (int16)(get_actual(STICK_X) * sensitivity_x));
        } else mouse_set(MOUSE_X, 0);
 
        // STICK Y-AXIS TO MOUSE Y-AXIS
    if((axis_lock==0 || axis_lock==2) && abs(get_actual(STICK_Y)) > deadzone) {
        mouse_set(MOUSE_Y, (int16)(get_actual(STICK_Y) * sensitivity_y));
    } else mouse_set(MOUSE_Y, 0);
 
 
    // CROSS/A = LEFT-CLICK
    // TRIANGLE/Y = DRAG ON/OFF
        if (drag_allowed) {
            mouse_set(MBUTTON_1, (drag_toggle || get_actual(BUTTON_16)) ? TRUE : FALSE);
        } else {
            mouse_set(MBUTTON_1, get_actual(BUTTON_16) ? TRUE : FALSE);
        }
 
 
    // CIRCLE/B = RIGHT-CLICK
    mouse_set(MBUTTON_2, get_actual(BUTTON_15) ? TRUE : FALSE);
 
    // Flow control timing
    wait(0); wait(6);
}
 
 
void ColorLED(uint8 color, fix32 brightness) {
        static uint8 last_color=255;
        static fix32 last_brightness=100f;
 
        if (color == last_color && brightness == last_brightness) return;
        last_color             = color;
        last_brightness = brightness;
 
        uint8 c1,c2,c3,c4;
        if             (color=='B') c1=1;
        else if (color=='R') c2=1;
        else if (color=='G') c3=1;
        else if (color=='P') c4=1;
        else if (color=='C') { c1=1; c3=1; }
        else if (color=='Y') { c2=1; c3=1; }
        else if (color=='W') { c1=1; c2=1, c3=1; c4=1; }
 
        led_reset();
 
        if (brightness==0.0) brightness=100f;
        if (c1) led_set(LED_1,brightness,0);
        if (c2) led_set(LED_2,brightness,0);
        if (c3) led_set(LED_3,brightness,0);
        if (c4) led_set(LED_4,brightness,0);
}
 
 
/* INTERACTIVE CONFIGURATION
 
<cfgdesc>
[Gamepad 2 Mouse Information]
collapsible=1
shortdesc     = <<<MULTILINE
29/7/2019 <b>Created for http://www.SpecialEffect.org.uk - PUBLIC DOMAIN</b><div align="right"><a href="viewtopic.php?f=26&t=13195">Forum Post</a></div>
<b>Designed to convert a PS4/Xbox gamepad to Mouse use.</b>
<table border="1" cellspacing="0" cellpadding="2"><tr bgcolor="#f2f3f4"><td><b>Control</b></td><td>Function</td></tr>
<tr><td><b>LEFT-STICK</b></td><td>MOUSE: MOVEMENT , adjustable sensitivity with TOUCH/VIEW/BACK button</td></tr>
<tr><td><b>RIGHT_STICK</b></td><td>MOUSE: MOVEMENT , fixed sensitivity (index sensitivity_right_stick)</td></tr>
<tr><td><b>CROSS/A</b></td><td>MOUSE: LEFT-CLICK</td></tr>
<tr><td><b>CIRCLE/B</b></td><td>MOUSE: RIGHT-CLICK</td></tr>
<tr><td><b>TRIANGLE/Y</b></td><td>MOUSE: DRAG ON/OFF (Left Mouse Button Hold)</td></tr>
<tr><td><b>SQUARE/X</b></td><td>MOUSE: AXIS LOCK (X-Axis / Y-Axis / Free Movement)</td></tr>
<tr><td><b>R2/RT</b></td><td>MOUSE: DOUBLE-LEFT-CLICK</td></tr>
<tr><td><b>OPTION/START</b></td><td>KEYBOARD: Tap->ALT+F4 (pulse), Hold->ESCAPE (hold)</td></tr>
<tr><td><b>DPAD</b></td><td>KEYBOARD: Cursor/Arrow keys</td></tr>
<tr><td><b>HOLD R2/RB + TAP HOME</b></td><td>CHANGE SLOT +1 (e.g. to Forced Xbox 360 Gamepad mode)</td></tr>
<tr><td><b>HOLD L2/LB + TAP HOME</b></td><td>CHANGE SLOT -1</td></tr>
</table>
MULTILINE
control   = info
 
[SPACE]
control        = space
default        = 15
 
[Configuration]
collapsible=0
shortdesc     = <<<MULTILINE
Customize the controls/settings
MULTILINE
control   = info
 
[Preconfigured Settings]
shortdesc     = <<<MULTILINE
<b>Click "SAVE and RUN" button after clicking one of the presets</b> to activate the new settings.
When you click "OK" to close the Interactive Configuration you have to manually reload the active slot for the changes to apply.
MULTILINE
control        = config
item      = Default (All Features enabled):00500000000107#10:001400000000147B0000051F00000000#2E:0000051F0300FA
item      = Basic (Enabled 'Movement,LeftCLick,RightClick,Speed Selection'):00500000020100#10:001400000000147B0000051F00000000#2E:0000051F0000FA
 
[LED Feedback]
collapsible=1
shortdesc     =
control   = info
 
[LED Brightness]
group            = true
shortdesc    = <<<MULTILINE
Brightness of LED
MULTILINE
byteoffset= 0
bitsize        = 32
control        = spinboxf
default        = 800
decimals    = 1
step            = 5
minimum        = 00
maximum        = 1000
 
[LED Default Color]
group            = true
shortdesc    = <<<MULTILINE
 
Default LED Color
MULTILINE
byteoffset= 4
bitsize        = 8
control   = combobox
default        = 0
item            = Blue
item            = Red
item            = Green
item            = Purple
item            = Cyan
item            = Yellow
item            = White
 
[LED DRAG Color]
group            = true
shortdesc    = <<<MULTILINE
 
LED Color when DRAG (left mouse button hold) is active
MULTILINE
byteoffset= 5
bitsize        = 8
control   = combobox
default        = 1
item            = Blue
item            = Red
item            = Green
item            = Purple
item            = Cyan
item            = Yellow
item            = White
 
[Mouse Settings]
collapsible=1
shortdesc     =
control   = info
 
[Mouse Button Features]
group            = true
shortdesc    = <<<MULTILINE
<b><u>Buttons</u></b>
MULTILINE
control   = info
 
[Mouse Drag]
group            = true
shortdesc    = <<<MULTILINE
 
<b>Mouse Drag</b> - Left Mouse Button Hold
Button <b>TRIANGLE/Y</b> will toggle Left Mouse Button Hold On/OFF when allowed.
MULTILINE
byteoffset= 6
bitsize        = 1
bitoffset = 0
control        = checkbox
default        = 1
item             = Allow Use of Mouse Drag
 
[Mouse Double Click]
group            = true
shortdesc    = <<<MULTILINE
 
<b>Mouse Double-Left-Click</b> - Left Mouse Button Double CLick
Button <b>R2/RT</b> will do a Double-Left-Click when allowed.
MULTILINE
byteoffset= 6
bitsize        = 1
bitoffset = 1
control        = checkbox
default        = 1
item             = Allow Use of Double-Left-Click
 
[Mouse Axis Lock]
group            = true
shortdesc    = <<<MULTILINE
 
<b>Mouse Axis Lock </b> - Toggle Lock of Mouse Movement Axis
Button <b>SQUARE/X</b> will cycle through Allowed : X-Axis , Y-Axis , Free
MULTILINE
byteoffset= 6
bitsize        = 1
bitoffset = 2
control        = checkbox
default        = 1
item             = Allow Use of Mouse Axis Lock
 
[Mouse Movement Features]
group            = true
shortdesc    = <<<MULTILINE
 
<b><u>Movement</u></b>
MULTILINE
control   = info
 
 
[Stick Deadzone]
group            = true
shortdesc    = <<<MULTILINE
 
<b>Stick Deadzone</b> value for mouse movement.
The deadzone defines the minimum required movement of the sticks to start moving the mouse.
Higher value -> more stick movement required
MULTILINE
byteoffset= 16
bitsize        = 32
control        = spinboxf
default        = 200
decimals    = 1
step            = 01
minimum        = 050
maximum        = 1000
 
[Left Stick Mouse Settings Information]
group            = true
shortdesc    = <<<MULTILINE
 
<b>The Left Stick Mouse speeds</b> can be cycled through with <b>TOUCH/VIEW/BACK button</b>.
Sensitivity values set to 0.00 will disable the setting.
Example: If you want to have use two different speed only set 3. to value 0.00
To disable the Left Sticks Mouse movement completely set all values to 0.00
MULTILINE
control   = info
 
[LEFT STICK Mouse Sensitivity 1]
group            = true
shortdesc    = <<<MULTILINE
 
<b>LEFT STICK 1. Sensitivity</b> (higher value->faster movement) To disable set this to 0.00
MULTILINE
byteoffset= 20
bitsize        = 32
control        = spinboxf
default        = 008
decimals    = 2
step            = 001
minimum        = 000
maximum        = 200
 
[LEFT STICK Mouse Sensitivity 2]
group            = true
shortdesc    = <<<MULTILINE
 
<b>LEFT STICK 2. Sensitivity</b> (higher->faster, lower->slower) To disable set this to 0.00
MULTILINE
byteoffset= 24
bitsize        = 32
control        = spinboxf
default        = 002
decimals    = 2
step            = 001
minimum        = 000
maximum        = 200
 
[LEFT STICK Mouse Sensitivity 3]
group            = true
shortdesc    = <<<MULTILINE
 
<b>LEFT STICK 3. Sensitivity</b> (higher->faster, lower->slower) To disable set this to 0.00
MULTILINE
byteoffset= 28
bitsize        = 32
control        = spinboxf
default        = 000
decimals    = 2
step            = 001
minimum        = 000
maximum        = 200
 
[Right Stick Mouse Settings Information]
group            = true
shortdesc    = <<<MULTILINE
 
<b><font color="DARKRED">The Right Stick</font> Mouse speed</b> has one speed only.
To disable the Right Sticks Mouse movement completely set the value to 0.00
MULTILINE
control   = info
 
 
[RIGHT STICK Mouse Sensitivity]
group            = true
shortdesc    = <<<MULTILINE
 
<b><font color="DARKRED">RIGHT</font> STICK Sensitivity</b> (higher->faster, lower->slower) To disable set this to 0.00
MULTILINE
byteoffset= 46
bitsize        = 32
control        = spinboxf
default        = 002
decimals    = 2
step            = 001
minimum        = 000
maximum        = 200
 
 
[Keyboard Settings]
collapsible=1
shortdesc     =
control   = info
 
[DPAD CURSOR]
group            = true
shortdesc    = <<<MULTILINE
 
<b>Keyboard Cursor/Arrow</b>
<b>DPAD DIRECTION</b> will press the corresponding Cursor/Arrow key
MULTILINE
byteoffset= 50
bitsize        = 1
bitoffset = 1
control        = checkbox
default        = 1
item             = Allow Use of DPAD to CURSOR keys
 
[Escape AltF4]
group            = true
shortdesc    = <<<MULTILINE
 
<b>Keyboard Escape and ALT+F4</b>
Button <b>OPTION/START</b>
A <b>short press</b> will send the keys <b>ALT+F4</b>
A <b>longer hold</b> will send the key <b>ESCAPE</b>
MULTILINE
byteoffset= 50
bitsize        = 1
bitoffset = 0
control        = checkbox
default        = 1
item             = Allow Use of ALT+4 and ESCAPE
 
[Escape AltF4 Tap Limit]
group            = true
shortdesc    = <<<MULTILINE
 
<b>Tap Time Limit in milliseconds </b>
Button hold time lower than value will send ALT+F4, longer will send ESCAPE
MULTILINE
byteoffset= 51
bitsize        = 16
control        = spinbox
default        = 250
step            = 1
minimum        = 150
maximum        = 1000
 
</cfgdesc>
*/

 
User avatar
Scachi
Brigadier General
Brigadier General
 
Posts: 3044
Joined: Wed May 11, 2016 6:25 am
Location: Germany

Re: Gamepad to Mouse: Help needed

Postby Scachi » Mon Aug 19, 2019 3:53 pm

I have attached the latest code as it was too long to be post here directly.

L2LT / OPTIONSTART -> keyboard presses can be configured to press one of the kown keys list with different one for Tap and Hold of the button.
Default settings are the keys they had assigned in the previous version.

We are at ~39% bytecode size, plenty of space for more stuff :wink:
Attachments
Gamepad to Mouse_107.gpc
(66.66 KiB) Downloaded 176 times
User avatar
Scachi
Brigadier General
Brigadier General
 
Posts: 3044
Joined: Wed May 11, 2016 6:25 am
Location: Germany

Re: Gamepad to Mouse: Help needed

Postby SpecialEffect » Wed Aug 21, 2019 3:29 pm

Brilliant work. Thanks so much again. I'll update the public script.

A small improvement to the slot swapping would be to allow the user to adjust the time delay. Currently you have to press L3 or R3 very fast. Some won't be able to do that, so some allowance for slower uneven presses would be really good.

:)


After this, I've some thoughts for a complementary 2nd Joypad focussed script, that make use of the same mode swapping options, and have some extra things like latching, alternating, rapid-fire and so on. Output protocol swapping. Probably aimed at Xbox Adaptive Controller use and other similar devices. Then you could have two scripts that could do lots together on a PC/Android. Hopefully one day iOS too.
User avatar
SpecialEffect
Sergeant Major of the Army
Sergeant Major of the Army
 
Posts: 203
Joined: Mon Apr 07, 2014 3:26 pm

Re: Gamepad to Mouse: Help needed

Postby Scachi » Wed Aug 21, 2019 4:52 pm

SpecialEffect wrote:Brilliant work. Thanks so much again. I'll update the public script.

A small improvement to the slot swapping would be to allow the user to adjust the time delay. Currently you have to press L3 or R3 very fast. Some won't be able to do that, so some allowance for slower uneven presses would be really good.

:)
It is using the tap/hold timelimit at the moment for the L3/R3 taps, this isn't mentioned at all in the Interactive Configuration at the moment. I understand multiple taps can be more difficult than doing a short or longer holdd once.
It is no problem to add a separate time option for L3/R3 to it. I will add that.

After this, I've some thoughts for a complementary 2nd Joypad focussed script, that make use of the same mode swapping options, and have some extra things like latching, alternating, rapid-fire and so on. Output protocol swapping. Probably aimed at Xbox Adaptive Controller use and other similar devices. Then you could have two scripts that could do lots together on a PC/Android. Hopefully one day iOS too.

I'll split the one script file into multiple ones to make the reuse of functions of the current script for new ones easier.
Fixing a bug in one of the shared functions will then fix the bug in the other script using this too then.
Fix once and reupload all the script that make use of it is a lot easier than search through mutliple script for fixing the same bug.
User avatar
Scachi
Brigadier General
Brigadier General
 
Posts: 3044
Joined: Wed May 11, 2016 6:25 am
Location: Germany

Re: Gamepad to Mouse: Help needed

Postby Scachi » Fri Aug 23, 2019 2:25 pm

Here is the script with a different time setting for the mutltiple tap slot control thing for L3/R3.
No further changes yet. To split the script in multiple files I'll wait until the next script so I can see which parts you are going to reuse for that script.
Attachments
Gamepad to Mouse_108.gpc
(67.43 KiB) Downloaded 160 times
User avatar
Scachi
Brigadier General
Brigadier General
 
Posts: 3044
Joined: Wed May 11, 2016 6:25 am
Location: Germany

Re: Gamepad to Mouse: Help needed

Postby SpecialEffect » Fri Sep 20, 2019 3:50 pm

Great update. It's brilliant that this sort of thing (and for PC/Mac) is now possible with T2: https://gameaccessblog.org.uk/apple-arcade-ios13-with-alternative-controllers/

From using this a fair bit, I'm thinking the following adjustment would much improve things for Gamepad 2 Mouse.

1: L3/LS = adjust sensitivity (instead of Touch as it is now - as all under one thumb then if you can click LS/L3)

2: TOUCH/VIEW = change slot (one tap = goto slot X, two-taps = goto slot Y, three-taps = goto slot Z - all user-redefinable destinations - maybe up to 9 --- (why? easy to press on a PS4 controller or via a XAC/C-SID switch interface - and works with some other gamepad scripts we use, e.g. Game Control Mixer stuff).




A separate gamepad script would go so well with this....

3: A separate gamepad focussed accessibility script to accompany this. The following would be brilliant.

3.1: Output protocol dropdown choice.

3.2: TOUCH/VIEW slot changer and SHIFT modifier momentary ON/latched ON/off (default off) with speed adjustment for slower users).
If SHIFT active - A/Cross, B/Circle or OPTIONS/Menu = Touch/View button.
If SHIFT active - Left-stick = D-pad.

3.3: L2/LT latch on/off/momentary normal use (with ability to change analogue value) (default momentary)
3.4: R2/RT as 3.3

3.5: L3/LS latch on/off/momentary/special* (default momentary)
3.6: R3/RS as 3.5

3.7: D-pad buttons: Allow each d-pad direction to be set as any left or right stick movement at any strength. Ideally any shape/ABXY button too (default = d-pad = d-pad).


*L3 / R3 special features for future expansion. I have in mind L3 = r-stick left/right (alternate between the two on each press).... l-stick UP latched on/off at any strength. Two switches enough to explore a FPS game..... A rapid fire option to mash the A/Cross button or RT/R2..... Some nice things for some of the most disabled users.


This is a big ask. No rush, and no expectation to do any of it. Hugely appreciate what you've done already. Have a fine weekend.
User avatar
SpecialEffect
Sergeant Major of the Army
Sergeant Major of the Army
 
Posts: 203
Joined: Mon Apr 07, 2014 3:26 pm

Re: Gamepad to Mouse: Help needed

Postby Scachi » Fri Sep 20, 2019 8:45 pm

The attached version 1.09 includes 1: & 2:

For the 3.x stuff I have a hard time understanding all that. No idea about the "latch" thing and "shift" modifier.
I 'll try again in the next days when my brain is working again :wink:
Attachments
Gamepad to Mouse_109.gpc
(73.9 KiB) Downloaded 165 times
User avatar
Scachi
Brigadier General
Brigadier General
 
Posts: 3044
Joined: Wed May 11, 2016 6:25 am
Location: Germany

Re: Gamepad to Mouse: Help needed

Postby SpecialEffect » Fri Sep 27, 2019 8:16 am

Superb with 109, thank you. Works so much better with Left-stick mouse / LS to toggle speed. And VIEW/Touch-click for Slot change feels right too. I've published this to share in GTuner's resources.

Terrible English I used for the Gamepad companion script for a different slot. I'll try to word better below. :)

3: A separate gamepad focussed accessibility script to accompany this.

3.1: Output protocol dropdown choice. If not possible, Some code like this....

Code: Select all
#define PLATFORM_PS4            // USE XB360 / PS3 / PS4 / XB1 to set platform output protocol
 
 
//See https://www.consoletuner.com/wiki/index ... ort_status for latest platforms.
init {
#ifdef PLATFORM_XB360
     port_disconnect();
     port_connect(PORT_USB_C, PROTOCOL_XB360);
     printf("Xbox 360 mode ACTIVE");
#endif   
#ifdef PLATFORM_PS3
     port_disconnect();
     port_connect(PORT_USB_C, PROTOCOL_PS3);
     printf("PS3 mode ACTIVE");
#endif
#ifdef PLATFORM_PS4
     port_disconnect();
     port_connect(PORT_USB_C, PROTOCOL_PS4);
     printf("PS4 Mode ACTIVE");
#endif
#ifdef PLATFORM_XB1   
    port_disconnect();
    port_connect(PORT_USB_C, PROTOCOL_XB1);
    printf("Xbox One mode ACTIVE");
#endif
     }




3.2: SLOT CHANGER (default OFF)
TOUCH/VIEW = SLOT changer. As you have in Gamepad 2 Mouse. Tap TOUCH/VIEW 1-9 times to change slot.
ALSO - TOUCH/VIEW = pulse a button on/off (e.g. 2x tap = pulse LS.... 3x tap = pulse VIEW).


3.3: SHIFT (give buttons a secondary function if SHIFT held) (default OFF)
E.g. SHIFT + A = LB..... SHIFT + B = RB..... to help someone reach controls they can't otherwise.


3.4: R2/RT LATCH option (default OFF)
E.g. R2 = R2 on/off toggle. Allow users to alter strength from 20%-100%. For those unable to hold R2 for more than a few moments.


3.4: L3/LS = LEFT-RIGHT (LEFT-STICK OR RIGHT-STICK)
L3/LS = L-STICK LEFT / L-STICK RIGHT (allow user to define from 20%-100% strength for this and if left-stick or right-stick). Imagine you have only one-button (L3) and want to steer a car. Press it once to go left. Press it again to go right. In a FPS, the same thing for right-stick allows you to look left/right).

3.5 R3/RS = LEFT-STICK UP ON/OFF
Right stick alone can be used to look around and walk forward. Can also be used with 3.4 for two-switches/buttons being enough to explore a 3D world. Might be nice to expand this so instead of just LEFT-STICK UP other controls could be used instead if useful.


Hope that's clearer. Any of the above would be brilliant though.
User avatar
SpecialEffect
Sergeant Major of the Army
Sergeant Major of the Army
 
Posts: 203
Joined: Mon Apr 07, 2014 3:26 pm

PreviousNext

Return to GPC2 Script Programming

Who is online

Users browsing this forum: Majestic-12 [Bot] and 98 guests