OSDev.org

The Place to Start for Operating System Developers
It is currently Mon Mar 27, 2017 6:44 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: One line keyboard handler.
PostPosted: Fri Jan 13, 2017 5:27 am 
Offline
Member
Member
User avatar

Joined: Tue Jan 10, 2017 3:19 pm
Posts: 84
Seriously.

Code:
void keyboard_handler(void) {unsigned char keyboard_byte[] = {0, 0, '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=', '\b', '\t', 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', '[', ']', '\n', 0, 'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', 0, '`', 0, 0, 'z', 'x', 'c', 'v', 'b', 'n', 'm', 0, ' ', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '-', 0, 0, 0, '+', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; unsigned char inb_kbr(uint16_t port) { uint8_t ret; __asm__ volatile ("inb %1, %0" : "=a"(ret) : "Nd"(port) ); return ret; }; unsigned char scancode = inb_kbr(0x60); unsigned char irqone = inb_kbr(0x20); if (irqone != 0x00) { if (scancode == 0x80) { } else { terminal_writechar(keyboard_byte[scancode], WHITE, BLACK, 0, 10); } }; }


(Customize some things to your liking. This will put whatever key you are pressing in 0, 10, assuming you have my terminal_writechar function, and only when it is run. Do an infinite loop for it to press anytime, but you cannot get out of this loop, beware.)

EDIT: The thing for some reason likes to print the correct letters then replace it with unexpected things (this applies for the letters w, e, r and p, along with 8 and 9, page up and enter.), i have no idea why. It is probably a problem with my writechar();.

_________________
(not so frequently updated) Code is at:

https://github.com/NunoLava1998/DixiumOS-1


Last edited by DixiumOS on Fri Jan 13, 2017 5:42 am, edited 7 times in total.

Top
 Profile  
 
 Post subject: Re: One line keyboard handler.
PostPosted: Fri Jan 13, 2017 5:31 am 
Offline
Member
Member

Joined: Sat Dec 27, 2014 9:11 am
Posts: 760
Location: Maadi, Cairo, Egypt
I guess it's then possible to make a one-line OS. :roll:
Seriously, do you have anything useful to post? [-X

_________________
Byte me; OS site, source code.
You know your OS is advanced when you stop using the Intel programming guide as a reference.


Top
 Profile  
 
 Post subject: Re: One line keyboard handler.
PostPosted: Fri Jan 13, 2017 5:44 am 
Offline
Member
Member
User avatar

Joined: Sun Dec 25, 2016 1:54 am
Posts: 181
#-o #-o #-o

";" is the statement separator in C... not "\n" carriage return. Presuming you know what a carriage is and where it returns to.

=D> =D> =D>

_________________
Plagiarize. Plagiarize. Let not one line escape thine eyes...


Top
 Profile  
 
 Post subject: Re: One line keyboard non-handler.
PostPosted: Fri Jan 13, 2017 5:47 am 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 2649
Location: Chichester, UK
A good example of how the reputation of this forum is suffering.


Last edited by iansjack on Fri Jan 13, 2017 7:37 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: One line keyboard handler.
PostPosted: Fri Jan 13, 2017 5:48 am 
Offline
Member
Member
User avatar

Joined: Tue Jan 10, 2017 3:19 pm
Posts: 84
dchapiesky wrote:
#-o #-o #-o

";" is the statement separator in C... not "\n" carriage return. Presuming you know what a carriage is and where it returns to.

=D> =D> =D>


what?
i never put it as that

_________________
(not so frequently updated) Code is at:

https://github.com/NunoLava1998/DixiumOS-1


Top
 Profile  
 
 Post subject: Re: One line keyboard handler.
PostPosted: Fri Jan 13, 2017 6:38 am 
Offline
Member
Member

Joined: Sat Mar 01, 2014 2:59 pm
Posts: 1061
iansjack wrote:
A good example of how the reputation of this forum is suffering.
This is the best part:
DixiumOS wrote:
EDIT: The thing for some reason likes to print the correct letters then replace it with unexpected things (this applies for the letters w, e, r and p, along with 8 and 9, page up and enter.), i have no idea why. It is probably a problem with my writechar();.
Also, interrupts exist for a reason:
DixiumOS wrote:
Do an infinite loop for it to press anytime, but you cannot get out of this loop, beware.

_________________
When you start writing an OS you do the minimum possible to get the x86 processor in a usable state, then you try to get as far away from it as possible.

Syntax checkup:
Wrong: OS's, IRQ's, zero'ing
Right: OSes, IRQs, zeroing


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Google [Bot] and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group