GP32 Gp32 Boutons Pad Cpu [mouse Driver]


ingeras

Certified Guru
Joined
Mar 4, 2004
Messages
388
Location
Europe
Website
www.gp32linux.com
hi
someone ask me some infos to try to make a mouse
driver for gp32linux
i saw somewhere but cant find where
how buttons are connected to the cpu

can someone post more infos ?
thanks
 
Code:
// This file is written/copyright 2004 Mirko Roller

#include "gp32.h"

void gp_ButtonInit() {
  rPBCON=0x0; // Init, all Input
  //rPECON=0x0;
}
      
u16 gp_ButtonResult() {
  u16 back=0;
  u32 pressedb = ((~rPBDAT >> 8) & 0xFF);
  u32 pressedc = ((~rPEDAT >> 6) & 0x3 );  // Bit 6&7  // 1=start 2=select
  
  back = (pressedc<<8)|(pressedb<<0);
   
  return back;
}


This is the button poll from Mr. Mirko's SDK, So it probably uses PORT B for most keys, and PORT E for the START and SELECT buttons. The I/O part of GP32.h is as follows: (The parts that matter anyhow)
Code:
#define rPBCON          (*(volatile unsigned *)0x15600008)
#define rPBDAT          (*(volatile unsigned *)0x1560000c)
#define rPBUP           (*(volatile unsigned *)0x15600010)
  
  #define BLEFT   1
  #define BDOWN   2
  #define BRIGHT  4
  #define BUP     8
  #define BL 16
  #define BB 32
  #define BA 64
  #define BR 128
  #define BSTART 256
  #define BSELECT 512

And the part that contains rPEDAT is just:

Code:
#define rPECON          (*(volatile unsigned *)0x1560002c)
#define rPEDAT          (*(volatile unsigned *)0x15600030)
#define rPEUP           (*(volatile unsigned *)0x15600034)
 
thanks Tristan
but can you explain this code by an example of using it

another question : this code use the interrupt?

and use it the stack?

thanks a lot ;)
 
It doesn't use the interrupt, as far as I know, the keys arn't wired up to any interrupts, I should check the datasheet though.

The code is used as follows:

Code:
void main(){
   ButtonInit();
   while (gp_ButtonResult()&BUP);
}

This way, it'll loop while the UP button is pressed. And what do you mean by stack, as in, buffer?

Edit:

Before I forget, I really appreciate you doing this, I'm a big fan of gp32Linux, and hope to see a nice desktop on my GP32 someday soon. Thanks!
 
thanks for the encouragments

again a question!
what is u16 and u32?

a struct?

a new type?

thanks a lot Tristan :D
 
u16 is unsigned short I think
and u32 is unsigned long.

Also, when I just thought about interrupts, I don't think it's very smart to use them, even if the buttons were wired up to interrupts (Which I think they arn't), what the CPU does when an interrupt is called, is drop everything, do whatever the interrupt tells it to, then go back. This'd mean that the mouse would have the highest priority, which is not a good thing.
 
ok
so i don't need to read a lot of pdf on the arm9 and the interrupt!!
:D
i didn't think at all it is unsigned short and long. good job guy
now i must build a module for the mouse or integrate the driver into the kernel directly

in your opinion what is the best solution?


ps : i'm sorry for my english
please don't kill me ... lol
 
I wanted to try to implement this too. Is anyone working on making a mouse driver, or even a pseudo keyboard driver for gp32linux so we could share the work? (eg: A button sends A, start sends ENTER, etc...)

Does anyone have an idea of how to implement a 'virtual keyboard' driver ?

EDIT: baallrog, do you have some code to share already?
 
not at this time!
t have only ideas to have implement this

but this evening or tommorrow i will have some code.

if you want i will bring you it

hum ... you want to develop a driver for the keyboard or for the mouse?

for the mouse i think that :
- A button is right clic
- B button is left clic
 
That's a bad move. Seeing as most of the linux is going to be in 240x320 rather then 320x240, you can better do this:

Right becomes DOWN
Left becomes UP
Up becomes RIGHT
Down becomes LEFT
Start is either left or right click
and L is either left or right click

This way, you keep the GP32 AB-button-side down, with your hands along the GP32, with your right hand thumb on the D-Pad, and your left hand thumb on the START button. Try it out
 
now i must build a module for the mouse or integrate the driver into the kernel directly

in your opinion what is the best solution?
I think, integrating it into the kernel is a good idea, seeing as everyone who's going to use GP32Linux is bound to have a gp32, everyone has the required hardware: The D-Pad.
 
Last edited by a moderator:
i succed in rotating the display for qte
by using a environment var
QWS_DISPLAY=Transformed:Rot270

but it has black borders right and left
have to investigate when i have time

so maybe depending on the application
we can chose if we rotate or not

so maybe it s nice to have a /etc/mouse.conf
or a kernel module so we can load/unload with != parameters
 
It doesn't use the interrupt, as far as I know, the keys arn't wired up to any interrupts, I should check the datasheet though.
PORTE (or whatever it was for SELECT & START keys) can generate an interrupt. They are not enabled by the BIOS so one has to fiddle a bit around.
 
Last edited by a moderator:
Back
Top