two cc values->up/down/left/right? mouse mickeys.

fanboi

2008-12-01 18:50:49

whatup. i read the thread about xy to mouse, and ive read the different encoder to left/right threads aswell. none of these can help me with whats im sure pretty simple to achieve (mainly because im thick and still doesnt understand the rules i guess heh), so i figured it was time to ask, because i just wont get it to work.

i have a stupid contorller that has a stupid joystick on it that sends out two messages, i need to convert this to a left-right-up-down mouse movement joystick.

it sends B0 39 pp on up/down, and it sends B0 38 pp on left/right.

all the different tries ive made using timers rules and whatnots have always ended up with it either moving just one mickey (as the outgoing mouse translator is supposed to do), or it is moving continously all the time after i move the joystick the first time since it triggers a timer with an infinite output of 1ms delay. in short: i cant get the rules to sense whether it sends out any cc number, or not.

i believe this is because of me lacking to understand the rules, but im trying. also i believe that i need more coffee, but nonetheless, if anyone could provide a quick and painless (or painful, which ever you prefer) solution to this problem i would very grateful to say the least.

with that said, i bid you farewell for now ;)

florian

2008-12-12 11:39:55

Hi Fanboi,

any luck with this so far? sorry for the late response.

Do you want to move from left screen to right screen when you move the joystick from far left to far right, and center the mouse cursor when it snaps to the middle? That way you'd have very little fine control... otherwise, you'd only be able to move the cursor a little to left or a little to the right from te current mouse cursor position.

A different idea is to use a timer: when holding the joystick to the right, the cursor moves to the right until you snap the joystick back to the middle, stopping the movement. Is that what you want to do?

(of course all that applies to up/down just the same)

Regards,
Florian

fanboi

2008-12-12 18:01:01

florian wrote:Hi Fanboi,

any luck with this so far? sorry for the late response.

Do you want to move from left screen to right screen when you move the joystick from far left to far right, and center the mouse cursor when it snaps to the middle? That way you'd have very little fine control... otherwise, you'd only be able to move the cursor a little to left or a little to the right from te current mouse cursor position.

A different idea is to use a timer: when holding the joystick to the right, the cursor moves to the right until you snap the joystick back to the middle, stopping the movement. Is that what you want to do?

(of course all that applies to up/down just the same)

Regards,
Florian
ah yes, i thought about using timers aswell. although im still too much of a noob to figure out a good way to stop the timer when i release /or rather, snap to the middle), but yes a timer would be my best bet aswell.

thing is that my hercules has a djmouse thing so i could in theory get this to work without bomes, although this would only work with my hercule, while this would be portable to any joystick, and this way i have total control over how fast/slow it will move, so this definetly seems like a better way to do it.


with that said, could you point me in the right direction of the timer thing?

florian

2009-01-05 09:03:01

Hi fanboi,

sorry for the late reply... 'lot to do here...

The basic idea for the described joystick control with timers is this:

1) when joystick is moved left/right, calculate the "strength" of left or right. For example, if the joystick centers at 64 (hex 40) and goes down to 0 when moving all the way to the left and going to 127 (hex 7F) when moving all the way to the right, the rules would look like this (given that left/right is sending modulation wheel controller 1):

Code: Select all

Translator "Start Left/Right Timer"
INCOMING: MIDI B0 01 pp
RULES:
  IF pp=64 THEN EXIT RULES, SKIP OUTGOING ACTION
  ga=pp-64
First, we check if pp is 64 (i.e. middle value). If yes, we don't do anything here (will get to that later).
Now ga is a global variable holding the strength: -64..-1 for moving to the left, and 1..63 for moving to the right. Now we want to start a timer that fires FASTER when the strength is greater, i.e. the millisecond delay gets smaller with higher strength. We could just use (65-ga) but that would get VERY fast towards the edges. So rather use a base delay of e.g. 10ms and then add half the strength to it. Also need to eliminate the negative sign when moving to the left. We calculate the delay in milliseconds in qq:

Code: Select all

qq=ga/2
IF qq<0 THEN qq=qq*-1
qq=33-qq
qq=qq+10
Last, fire up the timer:

Code: Select all

OUTGOING: TIMER "Left/Right Movement": periodic timer, initial delay qq milliseconds, repetition delay qq milliseconds
Now we need to respond to this timer. We need two translators, one for moving mouse to the left, and one for moving it to the right:

Code: Select all

Translator "Move mouse to left"
INCOMING: TIMER "Left/Right Movement"
RULES:
 IF ga>0 THEN exit rules, skip outgoing action
OUTGOING: MOUSE x=-5

Translator "Move mouse to right"
INCOMING: TIMER "Left/Right Movement"
RULES:
 IF ga<0 THEN exit rules, skip outgoing action
OUTGOING: MOUSE x=5
Finally, we need to care about boundary conditions: when we hit the center again, the timer needs to be stopped:

Code: Select all

Translator "Stop Left/Right Timer"
INCOMING: MIDI B0 01 pp
RULES:
  IF pp!=64 THEN EXIT RULES, SKIP OUTGOING ACTION
  ga=0
OUTGOING: Stop Timer "Left/Right Movement"
Let me know if that makes sense to you... The same translators will be used for up/down, except that you'll need to use a different global variable (e.g. gb) and a different timer name.

Florian

fanboi

2009-01-05 13:58:58

thanks alot. ill give it a try later on, got my joystick working with another solution at the moment, but ill give it a go. i just wasnt sure how to make it work with timers really. cheers mate.