[noob - vjoy] Scroll wheel smoothie

Official forum for open source FreePIE discussion and development.
Post Reply
Tux
One Eyed Hopeful
Posts: 3
Joined: Sat May 06, 2017 8:14 pm

[noob - vjoy] Scroll wheel smoothie

Post by Tux »

Hi,

I found a script in this forum but i need to do some improvement, but i'm too noob to do it :(

So, there is the script :

Code: Select all

#Title         :OMSI 2 Freepie Mouse (Edited Mjoy vJoy FreePIE python script)
#Version       :0.1 (2016-03-22)
#Author        :snp, NEMOROSUS
#Description   :FreePIE python script for OMSI 2 mouse controls such as acceleration, steering and clutch control that is more accurate that the built-in one.

import time
from System import Int16
from ctypes import windll, Structure, c_ulong, byref

class POINT(Structure):
   _fields_ = [("x", c_ulong), ("y", c_ulong)]

if starting:
   vJoy0_stat = 1
   vJoy[0].x = 0
   vJoy[0].y = 0
   vJoy[0].z = 0
   vJoy[0].rx = 0
   x = 0
   y = 0
   z = 0
   rx = 0
   mouse_x = 0
   mouse_y = 0
   mouse_z = 0
   mouse_x_locked = 0
   mouse_y_locked = 0
   x_m = 0
   y_m = 0
   z_m = 0
   axis_max = 16448
   screen_x = windll.user32.GetSystemMetrics(0)
   screen_y = windll.user32.GetSystemMetrics(1)
   pt = POINT()   
   sequence = 0
   system.setThreadTiming(TimingTypes.HighresSystemTimer)
   system.threadExecutionInterval = 1
   
z += mouse.wheel * 20 

if keyboard.getPressed(Key.Tab):
   rx = 1


# X/Y axis centering

if keyboard.getKeyDown(Key.Space):
   windll.user32.SetCursorPos((screen_x / 2),(screen_y / 2))

# Clutch for gears in speed


                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
# Turn script on/off

if keyboard.getPressed(Key.K):
   if sequence == 0:
      vJoy0_stat = 0   
   elif sequence == 1:
      vJoy0_stat = 1
      
   sequence = sequence + 1
   if sequence > 1:
      sequence = 0
   
if vJoy0_stat == 1:
   windll.user32.GetCursorPos(byref(pt))
   mouse_x = pt.x
   mouse_y = pt.y
   sensitivity = 32
   x_m = (mouse_x - (screen_x / 2)) * sensitivity
   y_m = (mouse_y - (screen_y / 2)) * sensitivity
   x_both = x_m + x
   y_both = y_m + y
   x_keyb_sensitivity = 350
   y_keyb_sensitivity = 350
   
   if x_m > axis_max:
      x_m = axis_max
   
   if x_m < - axis_max:
      x_m = - axis_max
      
   if y_m > axis_max:
      y_m = axis_max
   
   if y_m < - axis_max:
      y_m = - axis_max
   
   if x > axis_max:
      x = axis_max
   
   if x < - axis_max:
      x = - axis_max
      
   if y > axis_max:
      y = axis_max
   
   if y < - axis_max:
      y = - axis_max
      
   if z > axis_max:
      z = axis_max
   
   if z < - axis_max:
      z = - axis_max
      
   if rx > axis_max:
      rx = axis_max
   
   if rx < - axis_max:
      rx = - axis_max
      
   if x_both > axis_max:
      x_both = axis_max
   
   if x_both < - axis_max:
      x_both = - axis_max
      
   if y_both > axis_max:
      y_both = axis_max
   
   if y_both < - axis_max:
      y_both = - axis_max

   vJoy[0].x = x_m + x
   vJoy[0].y = y_m + y
   vJoy[0].z = z_m + z 
   vJoy[0].rx = z
   
# Diag

diagnostics.watch(screen_x)
diagnostics.watch(screen_y)
diagnostics.watch(mouse_x)
diagnostics.watch(mouse_y)
diagnostics.watch(mouse_x_locked)
diagnostics.watch(mouse_y_locked)
diagnostics.watch(vJoy[0].x)
diagnostics.watch(vJoy[0].y)
diagnostics.watch(vJoy[0].z)
diagnostics.watch(vJoy[0].rx)

Currently when i use the mouse wheel it's not smooth, i need to do the wheel smooth, how we can do this ?

in the forum i found this :

Code: Select all

You set "rx" but you never use it.
to make rx going "smooth" from 0 to axis_max repace "getPressed" with getKeyDown and increment rx slowly to axis_max (e.g. rx = rx + 0.1). As you limit rx later on to axis_max that should good enough
i tried to do this but nothing happened so i think i'm too noob to do this right, so i need your help.

Sorry for my poor english
thx
Tux
One Eyed Hopeful
Posts: 3
Joined: Sat May 06, 2017 8:14 pm

Re: [noob - vjoy] Scroll wheel smoothie

Post by Tux »

Nobody can help me ? :( please
Post Reply

Return to “FreePIE”