Disabled gamer in search of a mouse joystick script

Official forum for open source FreePIE discussion and development.
Post Reply
Platinum6151
One Eyed Hopeful
Posts: 2
Joined: Sat Feb 24, 2024 10:56 pm

Disabled gamer in search of a mouse joystick script

Post by Platinum6151 »

Hello! I have a disability that makes gaming difficult for me, and I've been trying to find the perfect way to emulate a joystick with my trackpad mouse.

I found a script intended for racing games that almost works (via vJoy), but it would be vastly more useful for my particular use case (playing classic Nintendo 64 games) if the joystick would center itself upon releasing my finger from the trackpad.

I know you can center the stick with a keystroke (this script uses Enter), but would it be theoretically possible to get a finger-up event to trigger the centering instead? For reference I'm using a Cirque Glidepoint trackpad which is certainly utilizing and storing these touch events somewhere in the system, right?

This is the script I found which does mostly what I want:

Code: Select all

	# =============================================================================================
	# /////////////////////////////// F1 2014 Mouse Steering Script ///////////////////////////////
	# =============================================================================================
	# This is a modified script, the original script was written by Skagen 
	# url: https://www.lfs.net/forum/post/1862759#post1862759
	# =============================================================================================
	# This script will use 2 axes 
	# 1. Steering (X-Axis)
	# 2. Throttle and Brake (Y-Axis)
	# =============================================================================================
	# Use vJoy Feeder to set the axes in game
	# This script allows full car control with just the mouse
	# Move the mouse up to control the throttle and down for brakes
	# =============================================================================================
if starting:    
    system.setThreadTiming(TimingTypes.HighresSystemTimer)
    system.threadExecutionInterval = 5
    def calculate_rate(max, time):
        if time > 0:
            return max / (time / system.threadExecutionInterval)
        else:
            return max

    int32_max = (2 ** 14) - 1
    int32_min = (( 2** 14) * -1) + 1
    
    v = vJoy[0]
    v.x, v.y, v.z, v.rx, v.ry, v.rz, v.slider, v.dial = (int32_min,) * 8
    # =============================================================================================
    # //////////////////////////////////////// SETTINGS ///////////////////////////////////////////
    # =============================================================================================
    # Mouse settings - Change the sensitivity here
    # =============================================================================================
    global mouse_sensitivity, mouse_throttle_sensitivity
    mouse_throttle_sensitivity = 30
    mouse_sensitivity = 30
    # Additional controls: Wheel Up = Reset Steering to Center @ Line 89
    # =============================================================================================
    # Throttle settings
    # Init values, do not change
    global throttle, throttle_max, throttle_min
    throttle_max = int32_max
    throttle_min = int32_min
    throttle = throttle_min 
    # =============================================================================================
    # Steering settings
    # =============================================================================================
    global steering, steering_max, steering_min, steering_center_reduction    
    # Init values, do not change
    steering = 0.0
    steering_max = float(int32_max)
    steering_min = float(int32_min)
    steering_center_reduction = 1.0
# =================================================================================================
# LOOP START
# =================================================================================================
# Steering logic
# =================================================================================================
if mouse.wheelUp:
	steering = 0.0
	throttle = 0
if keyboard.getKeyDown(Key.Return):
	steering = 0.0
	throttle = 0
steering = steering + (float(mouse.deltaX) * mouse_sensitivity)
if steering > steering_max:
    steering = steering_max
elif steering < steering_min:
    steering = steering_min
v.x = int(round(steering))
# =================================================================================================
# Throttle logic and Braking logic
# =================================================================================================
throttle = throttle + (float(-mouse.deltaY) * mouse_throttle_sensitivity)
if throttle > throttle_max:
    throttle = throttle_max
elif throttle < steering_min:
    throttle = throttle_min
v.y = int(round(throttle))
# =================================================================================================
# vJoy BUTTONS 
# F1 2014 allows keyboard controls mixed with other input devices, so we don't need to set any more
# =================================================================================================
v.setButton(0,int(mouse.leftButton))
v.setButton(1,int(mouse.rightButton))
v.setButton(2,int(mouse.middleButton))
# =================================================================================================
# PIE diagnostics logic
# =================================================================================================
diagnostics.watch(v.x)
diagnostics.watch(v.y)
Jabberwock
Cross Eyed!
Posts: 197
Joined: Mon Mar 02, 2015 3:58 pm

Re: Disabled gamer in search of a mouse joystick script

Post by Jabberwock »

Unfortunately, such operations are typically handled by proprietary/driver code, so it is not exposed to general Windows interface...

Maybe write to the manufacturer? Maybe they can provide a solution, given your situation (although it is not likely). If they offer something that reports the trackpad finger position (or lack of thereof), it would have the advantage of being much more effective: for now the trackpad software converts an absolute position (of finger on the pad) to relative movement of mouse cursor, which your script converts back to an absolute position.

Some alternative solutions: get a Steam Controller (hard to get now) and use Steam Input software to report it as a self-centering joystick (works only in Steam games).

If you know someone who works with Arduino etc., there is an inexpensive trackpad sensor (TM040040) from Cirque that could be used exactly that way - it would work natively as a joystick controller.
Platinum6151
One Eyed Hopeful
Posts: 2
Joined: Sat Feb 24, 2024 10:56 pm

Re: Disabled gamer in search of a mouse joystick script

Post by Platinum6151 »

Jabberwock wrote: Sun Feb 25, 2024 10:05 am Unfortunately, such operations are typically handled by proprietary/driver code, so it is not exposed to general Windows interface...

Maybe write to the manufacturer? Maybe they can provide a solution, given your situation (although it is not likely). If they offer something that reports the trackpad finger position (or lack of thereof), it would have the advantage of being much more effective: for now the trackpad software converts an absolute position (of finger on the pad) to relative movement of mouse cursor, which your script converts back to an absolute position.

Some alternative solutions: get a Steam Controller (hard to get now) and use Steam Input software to report it as a self-centering joystick (works only in Steam games).

If you know someone who works with Arduino etc., there is an inexpensive trackpad sensor (TM040040) from Cirque that could be used exactly that way - it would work natively as a joystick controller.
Thanks for the info--although slightly disappointing, you've given me some leads to follow, particularly the arduino thing, so thank you.
Jabberwock
Cross Eyed!
Posts: 197
Joined: Mon Mar 02, 2015 3:58 pm

Re: Disabled gamer in search of a mouse joystick script

Post by Jabberwock »

Note that Cirque offers development kits:

https://www.cirque.com/glidepoint-circle-trackpads

Given your situation, they might give you a reasonable offer. In that case all that is needed is creating the software, which should not be that difficult, as they have already some sample code:

https://github.com/cirque-corp/Cirque_P ... /README.md
MaClara
One Eyed Hopeful
Posts: 6
Joined: Mon Apr 22, 2024 2:51 am

jolibet

Post by MaClara »

Pretty nice post. I just stumbled upon your weblog and wanted to say that I have really enjoyed browsing your blog posts. After all I’ll be subscribing to your feed and I hope you write again soon!
jolibet login
Post Reply

Return to “FreePIE”