Go Down

Topic: Help with mouse input and output? (Read 7768 times) previous topic - next topic

weird_dave

The pedal doesn't really get power as such, it's just a switch. The instructable says pin 7 was used for the switch, the other end of the switch connects to 0v (gnd). The pin is configured with an internal pullup resistance, when the switch is open, it sees a '1', when it is closed the pin is connected to 0v, so it sees a '0'.

Another option is a switch mounted on a glove such that you can easily activate it with your thumb, the options are endless, it comes down to whatever solution you feel comfortable using. You might find using your heel is easier to use on a foot switch than the font of the foot, the trick is to play around until you find something that works, even if it seems odd. If you can wiggle your ears you could attach a sensor to them :D

David1937

Okay but the foot petals seem like a good idea, so the foot petal isn't producing any power?


If I have this right: The Arduino Due (One of the pins) -------> Jumper Wire -------> Foot Pedal (If it is pressed it closes or opens the circuit.. idk but doesnt rlly matter) -----> Goes back to GRD. Send data to Arduio which would be connected to the computer via it's Programming Ports to send the mouseclick script?

Also I literally have none of the supplies:

What I have:   +The Due Board

                    + micro usb cable meant for phones but what I use for the Arduino

What I (think I need): + Foot Pedal Switch

                               + Jumper Cables: Which ones? Here's what I picked Tell me if its good
https://www.amazon.ca/Aukru-Female-Dupont-Arduino-Raspberry/dp/B019SX72CI/ref=sr_1_9?ie=UTF8&qid=1484799998&sr=8-9&keywords=arduino%2Bjumper%2Bwires&th=1

For the foot switch what I am looking for is something that is going to last, isn't very expensive and preferable has close shipping to me not really long shipping times. (I live in Canada and would like to order something in Canada maybe off Amazon.ca). Anyways since I have literally 0 knowledge on this type of stuff I don't really know what to order for this? Could you give me some help? I understand the whole concept of it I just don't know how the guy making that instructable knew that the inside would be basically empty and stuff. Thanks!

MorganS

#47
Jan 19, 2017, 06:29 am Last Edit: Jan 25, 2017, 07:19 am by MorganS
Assistance withdrawn.
"The problem is in the code you didn't post."

weird_dave

Okay but the foot petals seem like a good idea, so the foot petal isn't producing any power?
Yup. I rather like MorganS' reply.

If I have this right: The Arduino Due (One of the pins) -------> Jumper Wire -------> Foot Pedal (If it is pressed it closes or opens the circuit.. idk but doesnt rlly matter) -----> Goes back to GRD. Send data to Arduio which would be connected to the computer via it's Programming Ports to send the mouseclick script?
The Due has 2 USB ports, although you may program using either, to act as a USB mouse, you must use the 'Native' port, not the one labelled 'Programming'.

What I (think I need): + Foot Pedal Switch

                               + Jumper Cables: Which ones? Here's what I picked Tell me if its good
https://www.amazon.ca/Aukru-Female-Dupont-Arduino-Raspberry/dp/B019SX72CI/ref=sr_1_9?ie=UTF8&qid=1484799998&sr=8-9&keywords=arduino%2Bjumper%2Bwires&th=1
If the foot pedal has pins inside that will accept those jumpers then it will be easy, but you may not know until you get it unless there are decent pics or datasheet for it. Do you have a soldering iron, or a friend who does? I'd buy some twin core cable and some 0.1" pitch headers and make a lead that fits my own requirements. Those jumpers are short, it looks like you could daisy-chain them together but that's pretty ugly and a bit expensive way to make a cable (and more connections = less reliability).


For the foot switch what I am looking for is something that is going to last, isn't very expensive and preferable has close shipping to me not really long shipping times. (I live in Canada and would like to order something in Canada maybe off Amazon.ca). Anyways since I have literally 0 knowledge on this type of stuff I don't really know what to order for this? Could you give me some help? I understand the whole concept of it I just don't know how the guy making that instructable knew that the inside would be basically empty and stuff. Thanks!
This is a tougher question. I'd get the cheapest I can find and play with it for a bit, to make sure I didn't cripple myself in battle. long term I might try to find one with adjustable spring tension, or potentially make my own (I smell another reason to get a 3D printer...)

As for knowing the pedal would be mostly empty, you have to guess what it takes to make one, everything comes down to cost, so you guess that the inside has a spring and a switch, they don't need to be big, so there's probably a lot of empty space. Experience plays a part here.

David1937

Yup. I rather like MorganS' reply.

The Due has 2 USB ports, although you may program using either, to act as a USB mouse, you must use the 'Native' port, not the one labelled 'Programming'.
If the foot pedal has pins inside that will accept those jumpers then it will be easy, but you may not know until you get it unless there are decent pics or datasheet for it. Do you have a soldering iron, or a friend who does? I'd buy some twin core cable and some 0.1" pitch headers and make a lead that fits my own requirements. Those jumpers are short, it looks like you could daisy-chain them together but that's pretty ugly and a bit expensive way to make a cable (and more connections = less reliability).

This is a tougher question. I'd get the cheapest I can find and play with it for a bit, to make sure I didn't cripple myself in battle. long term I might try to find one with adjustable spring tension, or potentially make my own (I smell another reason to get a 3D printer...)

As for knowing the pedal would be mostly empty, you have to guess what it takes to make one, everything comes down to cost, so you guess that the inside has a spring and a switch, they don't need to be big, so there's probably a lot of empty space. Experience plays a part here.
Although untested, I think I found some code that will work in terms of having the mouse do rapid fire from
looking at a similar post on reddit.

In my theory, this looks like it would work but then again you are the experienced one here so I was wondering if you could tell me if it works or not? If not, what is it used for?

https://github.com/pontech/MouseHID



weird_dave

There's no real documentation, but a quick look at the code suggests it emulates a mouse using 9 input pins. I don't think it does autofire (I didn't dive too deep into the code). I don't even know for sure this will work on the Due, it will certainly require changes, the pin definitions are weird for a start :)
It was designed to run on this:
http://chipkit.net/wpcproduct/pontech-quick240/

David1937

There's no real documentation, but a quick look at the code suggests it emulates a mouse using 9 input pins. I don't think it does autofire (I didn't dive too deep into the code). I don't even know for sure this will work on the Due, it will certainly require changes, the pin definitions are weird for a start :)
It was designed to run on this:
http://chipkit.net/wpcproduct/pontech-quick240/

Okay thanks.

I made this code which I thought would work if I had a on the Go adaptor or a USB HOST SHIELD with my Due. In my logic it works, well I am at least pretty sure that at least the mouse button press and release works but idk about the move. If it doesn't work could you explain why because I don't understand what this class does otherwise.

// Require mouse control library
#include <MouseController.h>

// Initialize USB Controller
USBHost usb;

// Attach mouse controller to USB
MouseController mouse(usb);

// variables for mouse button states
boolean leftButton = false;
boolean middleButton = false;
boolean rightButton = false;
int MouseX;
int MouseY;
int MouseXD;
int MouseYD;

// This function intercepts mouse movements
void mouseMoved() {
 
  MouseX = mouse.getXChange();
 
  MouseY = mouse.getYChange();
Mouse.move(MouseX, MouseY, wheel);


}

// This function intercepts mouse movements while a button is pressed
void mouseDragged() {
 
   MouseXD = mouse.getXChange();
 
  MouseYD = mouse.getYChange();
Mouse.move(MouseXD, MouseYD, wheel);

}

// This function intercepts mouse button press
void mousePressed() {

  while (mouse.getButton(LEFT_BUTTON)){
    // autoclicker while loop
  }
  if (mouse.getButton(MIDDLE_BUTTON)){
    Mouse.press(MOUSE_MIDDLE)
    middleButton = true;
  }
  if (mouse.getButton(RIGHT_BUTTON)){
    Mouse.press(MOUSE_RIGHT)
    rightButton = true;
  }
}

// This function intercepts mouse button release
void mouseReleased() {
 
  if (!mouse.getButton(LEFT_BUTTON) && left==true) {
    Mouse.release(LEFT_BUTTON);
    leftButton = false;
  }
  if (!mouse.getButton(MIDDLE_BUTTON) && middle==true) {
   Mouse.release(MIDDLE_BUTTON);
    middleButton = false;
  }
  if (!mouse.getButton(RIGHT_BUTTON) && right==true) {
    Mouse.release(RIGHT_BUTTON);
    rightButton = false;
  }
 
}

void setup()
{
  Serial.begin(9600);
  Serial.println("Program started");
  delay(200);
}

void loop()
{
  // Process USB tasks
  usb.Task();
}

weird_dave

A host shield should work. An OTG adaptor would still require a USB shield (but wouldn't need to have host capability) because the Due doesn't have 2 true USB ports.
Calling them Mouse and mouse is very confusing...
There are a lot of coding errors so this simply won't compile as it is. This looks just like some code I spotted the other day which wouldn't compile, some of the errors are exactly the same...

"leftButton" isn't the same as "left"
What's LEFT_BUTTON, it certainly isn't listed here: https://www.arduino.cc/en/Reference/MousePress

Putting in an autoclicker while loop will block other code from running, so mouse movements won't happen, in fact, it will lock you out forever. What you need to do is set/clear a variable in the pressed/released functions then deal with the clicking in the main loop (without using any delays or dodgy while loops), the code in post 28 might do that (I've not actually tested it).

I think you modified this:
https://www.arduino.cc/en/Tutorial/MouseController

David1937

#53
Jan 24, 2017, 08:36 pm Last Edit: Jan 25, 2017, 05:09 am by David1937
A host shield should work. An OTG adaptor would still require a USB shield (but wouldn't need to have host capability) because the Due doesn't have 2 true USB ports.
Calling them Mouse and mouse is very confusing...
There are a lot of coding errors so this simply won't compile as it is. This looks just like some code I spotted the other day which wouldn't compile, some of the errors are exactly the same...

"leftButton" isn't the same as "left"
What's LEFT_BUTTON, it certainly isn't listed here: https://www.arduino.cc/en/Reference/MousePress

Putting in an autoclicker while loop will block other code from running, so mouse movements won't happen, in fact, it will lock you out forever. What you need to do is set/clear a variable in the pressed/released functions then deal with the clicking in the main loop (without using any delays or dodgy while loops), the code in post 28 might do that (I've not actually tested it).

I think you modified this:
https://www.arduino.cc/en/Tutorial/MouseController
Yeah I did modify that code lol.

So basically if I were to fix those stupid errors that I did the code would work? With a USB port adapter thing.

I can't wrap my head around on why the code, even in the class where I got it from doesn't work (From what I understand you saying). I understand that using Delay() or a while dodgy while loop would block it though. Basically I created a pretty complex algorithm to generate the random commands in the code. I don't want to bore you but basically I made it have a possibility of 5 clicking variation speeds each time it cycles. (30% for 100ms delay total, 30% for 90 delay total, 14% for 70ms delay total, etc.) After selecting the delay total it chooses the delay for the click sleep (how long click is pressed) and the interval sleep (delay between clicks) (randomizes which if it chooses click sleep first or interval sleep). After this there is only one remaining (either click sleep or click interval)  and that would be the one it didn't choose orginally where it  would just set that too the sum - the other delay. This is the code required to bypass the anticheat, but it is basically just if statements that could be placed anywhere. I need to create a autoclicking system with this code that doesn't use any weird blocks but I can't quite figure it out.

Would something like this work with my mouse/code/due if I got it to work?
https://www.amazon.ca/Shield-Module-Android-Arduino-Duemilanove/dp/B01KL4IO98/ref=sr_1_2?ie=UTF8&qid=1485286769&sr=8-2&keywords=usb+host+shield

David1937

A host shield should work. An OTG adaptor would still require a USB shield (but wouldn't need to have host capability) because the Due doesn't have 2 true USB ports.
Calling them Mouse and mouse is very confusing...
There are a lot of coding errors so this simply won't compile as it is. This looks just like some code I spotted the other day which wouldn't compile, some of the errors are exactly the same...

"leftButton" isn't the same as "left"
What's LEFT_BUTTON, it certainly isn't listed here: https://www.arduino.cc/en/Reference/MousePress

Putting in an autoclicker while loop will block other code from running, so mouse movements won't happen, in fact, it will lock you out forever. What you need to do is set/clear a variable in the pressed/released functions then deal with the clicking in the main loop (without using any delays or dodgy while loops), the code in post 28 might do that (I've not actually tested it).

I think you modified this:
https://www.arduino.cc/en/Tutorial/MouseController
I mean still overall I believe that Serial Commication would be easiest option. There are two problems with that though.

1) I don't understand how to make it.

2) I am afraid that the anti-cheat will scan it as a cheat if it is compiled, or even read the code and disallow it. (two things that the anti-cheat can easily do).

But there are things I like about it:

1) Only need a Due and the cord

There is a part of me wanting to do this but I know that I will get banned for it soon enough so there is also a part that doesn't want to do it. The E-Sports league I am in costs $8 a month and if you get banned I am pretty sure they IP ban.

MorganS

#55
Jan 25, 2017, 07:16 am Last Edit: Jan 25, 2017, 07:20 am by MorganS
Well there's where you just stepped over the line. If you had more experience with this forum you would know that the long term contributors will completely stop helping if they think your project is illegal, immoral or dangerous.

You could have left this as a practical excercise in mouse clicking but you have now given enough information that we can be sure that you are cheating.

Please don't give up on Arduino. It's lots of fun. I'm sure you'll have a science project within the next year that you can use your experience to look like some kind of genius to the rest of your team. I am willing to help with any project except this one.
"The problem is in the code you didn't post."

weird_dave

I knew he was wanting to 'cheat' from the initial post. The thing is, I recall being able to buy joysticks with an autofire feature.
I have seen T's and C's which state that using any software or hardware that may give the player an advantage is not allowed, but where do you draw the line? Faster graphics and CPU clearly give an advantage, as do 4K monitors. Decent sound also falls into this category. OK, so autofire on a mouse isn't exactly normal, but maybe it should be, just like the old joysticks.
Since it is possible to click quite fast manually, I don't think an autofire function gives much advantage (I have seen anticheat reduce the click rate down to human levels if you over-egg it, either it was the anticheat or it wasn't polling the mouse events fast enough :) ), it may however reduce the risk of RSI. It may also waste ammo and reduce your hit rate stats.
There are plenty of mice and keyboards which come with macro functionality, it is easy to use these to do a whole bunch of stuff very quickly, obviously giving the player an advantage. The now defunct StarWars Galaxies MMORPG even had a built-in macro system which allowed the players to give themselves advantages.
I suspect that after an initial placebo effect, the perceived advantage will disappear as there is now less control. The user still has to control all the movement and aiming, but no longer has fine control over the amount of ammo used. It would certainly be interesting to find out if this project did have a benefit, if only to then decide if it should be allowed, as it stands it is borderline because we don't have enough information.

David1937

Well there's where you just stepped over the line. If you had more experience with this forum you would know that the long term contributors will completely stop helping if they think your project is illegal, immoral or dangerous.

You could have left this as a practical excercise in mouse clicking but you have now given enough information that we can be sure that you are cheating.

Please don't give up on Arduino. It's lots of fun. I'm sure you'll have a science project within the next year that you can use your experience to look like some kind of genius to the rest of your team. I am willing to help with any project except this one.
I knew he was wanting to 'cheat' from the initial post. The thing is, I recall being able to buy joysticks with an autofire feature.
I have seen T's and C's which state that using any software or hardware that may give the player an advantage is not allowed, but where do you draw the line? Faster graphics and CPU clearly give an advantage, as do 4K monitors. Decent sound also falls into this category. OK, so autofire on a mouse isn't exactly normal, but maybe it should be, just like the old joysticks.
Since it is possible to click quite fast manually, I don't think an autofire function gives much advantage (I have seen anticheat reduce the click rate down to human levels if you over-egg it, either it was the anticheat or it wasn't polling the mouse events fast enough :) ), it may however reduce the risk of RSI. It may also waste ammo and reduce your hit rate stats.
There are plenty of mice and keyboards which come with macro functionality, it is easy to use these to do a whole bunch of stuff very quickly, obviously giving the player an advantage. The now defunct StarWars Galaxies MMORPG even had a built-in macro system which allowed the players to give themselves advantages.
I suspect that after an initial placebo effect, the perceived advantage will disappear as there is now less control. The user still has to control all the movement and aiming, but no longer has fine control over the amount of ammo used. It would certainly be interesting to find out if this project did have a benefit, if only to then decide if it should be allowed, as it stands it is borderline because we don't have enough information.
I don't really understand what is wrong here or even what I said was wrong. Nothing I am doing with this has a conflict with the rules. If you think I am trying to cheat than like @weird_dave said, Why would I make such a low clicking speed where in fact it will bring me to a disadvantage when you bring in things such as recoil and stuff.
The reason why I am even needing to do this in the first place is I used to be able to click this fast normal clicking 10 clicks per second. However from clicking this fast and so much over time I have developed a problem in my hand (well I have all the symptoms) called Carpal Tunnel which you are probably aware of. I have also gone through many gaming mice in the past that are supposed to last 50 million clicks but since there is so much clicking they break within a month.

I honestly don't see this as cheating as @weird_dave is right I can literally normal click like 10 clicks a second which is as fast as I would need and would have more control then even the best Arduino code. I just don't want the problem in my hand to get worse. If I had real intentions of cheating I would have made my random code click a lot faster than 10-11 clicks a second, because the game likely wouldn't ban if I had it at 20 cps or something.

AkiraKurai

I don't really understand what is wrong here or even what I said was wrong. Nothing I am doing with this has a conflict with the rules. If you think I am trying to cheat than like @weird_dave said, Why would I make such a low clicking speed where in fact it will bring me to a disadvantage when you bring in things such as recoil and stuff.
The reason why I am even needing to do this in the first place is I used to be able to click this fast normal clicking 10 clicks per second. However from clicking this fast and so much over time I have developed a problem in my hand (well I have all the symptoms) called Carpal Tunnel which you are probably aware of. I have also gone through many gaming mice in the past that are supposed to last 50 million clicks but since there is so much clicking they break within a month.

I honestly don't see this as cheating as @weird_dave is right I can literally normal click like 10 clicks a second which is as fast as I would need and would have more control then even the best Arduino code. I just don't want the problem in my hand to get worse. If I had real intentions of cheating I would have made my random code click a lot faster than 10-11 clicks a second, because the game likely wouldn't ban if I had it at 20 cps or something.
So? you are using an illegal form of modification for that game regardless of if you can achieve the same speed without the mod. This is similar to how one person will automate a system that is flawless and then focus all their attention on another issue at hand. Also, I'll give you the hard truth. The company of whatever that game does not care of you get carpal tunnel you must follow the rules as they have stated in their own EULA.

Go Up