Teensyduino how to use Raw HID and Mouse simultaneously?

Status
Not open for further replies.

Boaas

Member
I want to use Raw HID and Mouse, but after selecting Raw HID from Tools → USB Type and clicking on Arduino's Verify, it prompts Compilation error: 'Mouse' not found Does your sketch include the line '# include<Mouse. h>'? I added # include<Mouse. h>, but it doesn't work either, so is there any way I can use Raw HID and Mouse?
1.png
 
You can only use the the USB mode you selected.
Raw HID for raw hid only
Keyboard+Mouse+Joistick for Keyboard and/or Mouse and/or Joystick
etc.
The different modes provide the needed USB description

BTW, do you really still have a Teensy 2.0 ???
 
Yes, I have a 2.0 sale here
You can only use the the USB mode you selected.
Raw HID for raw hid only
Keyboard+Mouse+Joistick for Keyboard and/or Mouse and/or Joystick
etc.
The different modes provide the needed USB description

BTW, do you really still have a Teensy 2.0 ???
Yes, I have a 2.0 version for sale here. I don't need a 4 or higher version, so I don't need that high performance
 
You can only use the the USB mode you selected.
Raw HID for raw hid only
Keyboard+Mouse+Joistick for Keyboard and/or Mouse and/or Joystick
etc.
The different modes provide the needed USB description

BTW, do you really still have a Teensy 2.0 ???
Can't I use Raw HID and Mouse together because I need to use C++applications on Windows to send messages to teensy2.0 for mouse operations through HID? Or can we only write code in C language and compile it into hex files for the Tensy Loader to burn?
 
You can use RAW HID and Mouse together, if you are using a RAW-HID + Mouse USB_mode. As this is not in the Teensyduino list, you can /must compose your own. Or, you encode Mouse operations into RAW-HId operations in PC and decode them in Teensy and vise versa
 
You can use RAW HID and Mouse together, if you are using a RAW-HID + Mouse USB_mode. As this is not in the Teensyduino list, you can /must compose your own. Or, you encode Mouse operations into RAW-HId operations in PC and decode them in Teensy and vise versa
you can / must compose your own

Can you tell me how to compose it? I only use RAW-HID+Mouse USB_mode, but I don't know how to compose it. If it's more complicated, I can only buy Arduino Leonardo hardware with my clients because they're not that complicated, but I still want to use Teensy more.
 
Can you tell me how to compose it?

On Teensy 2.0 creating custom USB types is quite difficult.

The USB code was completely redesigned in Teensy 3.0 (and all later Teensy) to make creating custom USB relatively easy by just editing usb_desc.h.

To accomplish this on Teensy 2.0, you'll need to study the USB code carefully. It is not easy. You might try to change one of the exiting combinations. But doing so requires editing the USB descriptor arrays and copying the necessary code. There is a reason it was completely redesigned in 2012...

I don't need a 4 or higher version, so I don't need that high performance

Even if your application doesn't need high performance, if your time is valuable and you're not planning to mass manufacture a product, just buying Teensy 4.0 is the simple path. You can save that old Teensy 2.0 for some other project which doesn't need a custom USB config.
 
To explain just a bit more, on Teensy 1.0 & 2.0, the main core library code is in the "teensy" folder and USB portion of the core library code is located in 7 different directories. Each corresponds to 1 of the USB types you see in the Arduino Tools > USB Type menu (except the 2 disk types share the "usb_disk" folder.

1709521301160.png
 
Inside the main "teensy" folder, you'll see the files like usb.c are really just includes which reference 1 of those 7 folders.

Code:
#if defined(USB_SERIAL)
#include "../usb_serial/usb.c"
#elif defined(USB_HID)
#include "../usb_hid/usb.c"
#elif defined(USB_SERIAL_HID)
#include "../usb_serial_hid/usb.c"
#elif defined(USB_DISK) || defined(USB_DISK_SDFLASH)
#include "../usb_disk/usb.c"
#elif defined(USB_MIDI)
#include "../usb_midi/usb.c"
#elif defined(USB_RAWHID)
#include "../usb_rawhid/usb.c"
#elif defined(USB_FLIGHTSIM)
#include "../usb_flightsim/usb.c"
#endif

This structure grew out of the very early Teensy 1.0 code which initially supported just USB serial and USB hid (back then, only keyboard and mouse). This was around 2009, in the very early days of Arduino and about 3-4 years before Arduino mode their first native USB board, Arduino Leonardo. At the time, most USB code looked like Atmel's examples and LUFA, incredibly complicated using hundreds of files in dozens of folders (later LUFA added "class driver" code with simpler API and usage model).

Also at that time, Arduino wasn't widely used. Most people in the early days of Teensy used a Makefile and command line compile.

In 2009, when only 2 USB types existed and only a 3rd (MIDI) was on the horizon, simply making another copy of the USB code seemed like a good idea. For non-Arduino usage, each had been published as a separate project.

Of course, by the time Teensy 3.0 was in the design phase (mid-2011 to late-2012), making a new copy of the USB code for each usage case had become a limiting factor. With the far more powerful 32 bit hardware, more USB types would come. Teensy 3.0 also brought DMA-based hardware, rather than the simple polled shared buffer hardware of USB on AVR. Larger memory also gave the ability to do things quite differently. So the USB code was redesigned from the ground up.

Even though PJRC continued selling Teensy 2.0 for nearly 10 more years, the old USB code for Teensy 2.0 was never substantialy changed. It really could not have been made similar to Teensy 3.0's USB, since Teensy 2.0 has only tiny 2.5K memory and no DMA capability. That old core library code for Teensy 2.0 also had a *lot* of careful optimization and even assembly code, which still to this day makes Teensy 2.0 usually outperform other AVR-based Arduino boards, and even some of the ARM-based products running at 3 times higher clock speed and 32 bit data path.

Of course, now that PJRC has discontinued Teensy 2.0, that old code is in deep maintainance mode. As we've added features like CrashReport on Teensy 4.x, the older models have received updates to at least still compile with programs using the new features. But more substanial updates to that old code for discontinued product will never come. New development effort is going into the current products. The code in each new Teensyduino continues to support the features which existed on those old products at the time they were sold, but new features and changes like consolidating all the USB stuff into 1 set of code with an easy config like usb_desc.h will never be applied to the old Teensy 2.0 code.

So if you want to create a custom USB type on Teensy 2.0, you need to study the code in those 7 folders. Several of then share interfaces in common, so with some work you can probably see those patterns, maybe enough to try crafting an 8th folder, or to change 1 of those 7 to suit your needs.

But that is a lot of work and requires a pretty deep dive into the details of crafting USB devices. In Teensy 4.0 you still need some expertise, but it's meant to be much easier with editing 1 file, just usb_desc.h. Even if you don't need the more capable hardware, buying a new board might still be worthwhile because with 12 years newer hardware comes newer software that was built upon the learning experiences from those early products.
 
Inside the main "teensy" folder, you'll see the files like usb.c are really just includes which reference 1 of those 7 folders.

Code:
#if defined(USB_SERIAL)
#include "../usb_serial/usb.c"
#elif defined(USB_HID)
#include "../usb_hid/usb.c"
#elif defined(USB_SERIAL_HID)
#include "../usb_serial_hid/usb.c"
#elif defined(USB_DISK) || defined(USB_DISK_SDFLASH)
#include "../usb_disk/usb.c"
#elif defined(USB_MIDI)
#include "../usb_midi/usb.c"
#elif defined(USB_RAWHID)
#include "../usb_rawhid/usb.c"
#elif defined(USB_FLIGHTSIM)
#include "../usb_flightsim/usb.c"
#endif

This structure grew out of the very early Teensy 1.0 code which initially supported just USB serial and USB hid (back then, only keyboard and mouse). This was around 2009, in the very early days of Arduino and about 3-4 years before Arduino mode their first native USB board, Arduino Leonardo. At the time, most USB code looked like Atmel's examples and LUFA, incredibly complicated using hundreds of files in dozens of folders (later LUFA added "class driver" code with simpler API and usage model).

Also at that time, Arduino wasn't widely used. Most people in the early days of Teensy used a Makefile and command line compile.

In 2009, when only 2 USB types existed and only a 3rd (MIDI) was on the horizon, simply making another copy of the USB code seemed like a good idea. For non-Arduino usage, each had been published as a separate project.

Of course, by the time Teensy 3.0 was in the design phase (mid-2011 to late-2012), making a new copy of the USB code for each usage case had become a limiting factor. With the far more powerful 32 bit hardware, more USB types would come. Teensy 3.0 also brought DMA-based hardware, rather than the simple polled shared buffer hardware of USB on AVR. Larger memory also gave the ability to do things quite differently. So the USB code was redesigned from the ground up.

Even though PJRC continued selling Teensy 2.0 for nearly 10 more years, the old USB code for Teensy 2.0 was never substantialy changed. It really could not have been made similar to Teensy 3.0's USB, since Teensy 2.0 has only tiny 2.5K memory and no DMA capability. That old core library code for Teensy 2.0 also had a *lot* of careful optimization and even assembly code, which still to this day makes Teensy 2.0 usually outperform other AVR-based Arduino boards, and even some of the ARM-based products running at 3 times higher clock speed and 32 bit data path.

Of course, now that PJRC has discontinued Teensy 2.0, that old code is in deep maintainance mode. As we've added features like CrashReport on Teensy 4.x, the older models have received updates to at least still compile with programs using the new features. But more substanial updates to that old code for discontinued product will never come. New development effort is going into the current products. The code in each new Teensyduino continues to support the features which existed on those old products at the time they were sold, but new features and changes like consolidating all the USB stuff into 1 set of code with an easy config like usb_desc.h will never be applied to the old Teensy 2.0 code.

So if you want to create a custom USB type on Teensy 2.0, you need to study the code in those 7 folders. Several of then share interfaces in common, so with some work you can probably see those patterns, maybe enough to try crafting an 8th folder, or to change 1 of those 7 to suit your needs.

But that is a lot of work and requires a pretty deep dive into the details of crafting USB devices. In Teensy 4.0 you still need some expertise, but it's meant to be much easier with editing 1 file, just usb_desc.h. Even if you don't need the more capable hardware, buying a new board might still be worthwhile because with 12 years newer hardware comes newer software that was built upon the learning experiences from those early products.
Thank you, then I'll just buy Teeny 4.0 instead
 
On Teensy 2.0 creating custom USB types is quite difficult.

The USB code was completely redesigned in Teensy 3.0 (and all later Teensy) to make creating custom USB relatively easy by just editing usb_desc.h.

To accomplish this on Teensy 2.0, you'll need to study the USB code carefully. It is not easy. You might try to change one of the exiting combinations. But doing so requires editing the USB descriptor arrays and copying the necessary code. There is a reason it was completely redesigned in 2012...



Even if your application doesn't need high performance, if your time is valuable and you're not planning to mass manufacture a product, just buying Teensy 4.0 is the simple path. You can save that old Teensy 2.0 for some other project which doesn't need a custom USB config.
You and I still use teensy2.0, after all, it's cheap. Do you think it's okay for me to add the mouse code of usb_hid to usb_rawhid? This way, the mouse and RawHID can be used together.
 
Do you think it's okay for me to add the mouse code of usb_hid to usb_rawhid?

Answer depends on the meaning of the word "ok".

If ok means legal or ethical, yes, the code is open source. Legally, you have permission to change the code.

If ok means it is possible to do so, given enough effort and skill, yes. The result should be technically possible.

If ok means advisable or recommended to do so, then I would answer no. Very significant skill and work are required if using the old code. Unless you have that skill and you are dedicated to the substantial effort required (which is not apparent from the lack of technical detail in your questions), odds of success are virtually zero. I would recommend buying Teensy 4.0, which still requires effort to edit code, but the task is much easier if using the newer code.
 
Answer depends on the meaning of the word "ok".

If ok means legal or ethical, yes, the code is open source. Legally, you have permission to change the code.

If ok means it is possible to do so, given enough effort and skill, yes. The result should be technically possible.

If ok means advisable or recommended to do so, then I would answer no. Very significant skill and work are required if using the old code. Unless you have that skill and you are dedicated to the substantial effort required (which is not apparent from the lack of technical detail in your questions), odds of success are virtually zero. I would recommend buying Teensy 4.0, which still requires effort to edit code, but the task is much easier if using the newer code.
Thank you
 
Answer depends on the meaning of the word "ok".

If ok means legal or ethical, yes, the code is open source. Legally, you have permission to change the code.

If ok means it is possible to do so, given enough effort and skill, yes. The result should be technically possible.

If ok means advisable or recommended to do so, then I would answer no. Very significant skill and work are required if using the old code. Unless you have that skill and you are dedicated to the substantial effort required (which is not apparent from the lack of technical detail in your questions), odds of success are virtually zero. I would recommend buying Teensy 4.0, which still requires effort to edit code, but the task is much easier if using the newer code.
Mr. Stoffregen, could you please help me modify the teensy2.0 code and send it to me? All I need is mouse. move+mouse. click+Raw HID. I don't need any other keywords, joystick, serial, and Raw HID with Debug Messages, etc. Changing the code is indeed a bit difficult for me. If it's not done well, it will break down. For those of you who possess these skills, it's much simpler.
 
Teensy 2.0 is an old project which was discontinued long ago.

No, I will not write new code for Teensy 2.0. I have tried to explain this in several messages, but it seems you do not read my words? Let me say as clearly as possible, the answer is NO. Please do not continue asking the same question over and over.
 
Teensy 2.0 is an old project which was discontinued long ago.

No, I will not write new code for Teensy 2.0. I have tried to explain this in several messages, but it seems you do not read my words? Let me say as clearly as possible, the answer is NO. Please do not continue asking the same question over and over.
I know, because I really want to use 2.0. 4.0 is also possible. Can you help me write it? If you can help me write it, my client and I will buy 4.0 together
 
The answer is no. Please do not ask again.

I see on your other thread that your purpose is to cheat on video games, which have anti-cheating software to prevent artificial injection of mouse events. Such unethical behavior is bad for your karma!

This matter is closed. Do not continue asking.

I'm going to lock this thread. If you start new threads to re-ask this same Teensy 2.0 question, you may be permanently banned from this forum.
 
Status
Not open for further replies.
Back
Top