Gamepad to Mouse: Help needed

GPC script programming for Titan Two device. Code examples, how to, questions, requests.

Moderators: The_Rabid_Taco, pablosscripts, bonefisher

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: 2010
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
Command Sergeant Major
Command Sergeant Major
 
Posts: 165
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: 2010
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 2 times
User avatar
Scachi
Brigadier General
Brigadier General
 
Posts: 2010
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
Command Sergeant Major
Command Sergeant Major
 
Posts: 165
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: 2010
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) Not downloaded yet
User avatar
Scachi
Brigadier General
Brigadier General
 
Posts: 2010
Joined: Wed May 11, 2016 6:25 am
Location: Germany

Previous

Return to GPC Script Programming (Titan Two)

Who is online

Users browsing this forum: Bing [Bot], BrianRoby and 14 guests